Skip to content

Commit

Permalink
Remove CSPP server options.
Browse files Browse the repository at this point in the history
The CSPP server options have become redundant since the introduction of
peer-to-peer mixing, but in some places the value of csppserver was
still used to toggle mixing on/off. This behaviour is more properly
implemented using a boolean.

Breaking changes:
- Removed deprecated configs `--csppserver` and `--csppserver.ca`.
- `cspp_server` parameter replaced by `enable_mixing` in
  `purchasetickets` and `runticketbuyer` gRPCs.
- `cspp_server` parameter removed from `runaccountmixer` gRPC.
  • Loading branch information
jholdstock committed Sep 10, 2024
1 parent 5eff60a commit b49dccc
Show file tree
Hide file tree
Showing 7 changed files with 1,522 additions and 1,551 deletions.
10 changes: 0 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ type config struct {
IssueClientCert bool `long:"issueclientcert" description:"Notify a client cert and key over the TX pipe for RPC authentication"`

// CSPP
CSPPServer string `long:"csppserver" description:"(deprecated) Network address of CoinShuffle++ server"`
CSPPServerCA string `long:"csppserver.ca" description:"(deprecated) CoinShuffle++ TLS Certificate Authority"`
Mixing bool `long:"mixing" description:"Enable mixing support"`
CSPPSolver *cfgutil.ExplicitString `long:"csppsolver" description:"Path to CSPP solver executable (if not in PATH)"`
MixedAccount string `long:"mixedaccount" description:"Account/branch used to derive CoinShuffle++ mixed outputs and voting rewards"`
Expand Down Expand Up @@ -739,14 +737,6 @@ func loadConfig(ctx context.Context) (*config, []string, error) {
}
}

if cfg.CSPPServer != "" {
log.Warnf("--csppserver option is deprecated; set --mixing instead")
if !cfg.Mixing {
log.Warnf("Enabling --mixing option due to --csppserver being configured")
cfg.Mixing = true
}
}

var solverMustWork bool
if cfg.Mixing {
if cfg.CSPPSolver.ExplicitlySet() {
Expand Down
10 changes: 4 additions & 6 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -3314,7 +3314,6 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
dontSignTx = *cmd.DontSignTx
}

var mixing bool
var mixedAccount uint32
var mixedAccountBranch uint32
var mixedSplitAccount uint32
Expand All @@ -3323,11 +3322,10 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
var changeAccount = account

if s.cfg.Mixing {
mixing = true
mixedAccount, err = w.AccountNumber(ctx, s.cfg.MixAccount)
if err != nil {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
"CSPP Server set, but error on mixed account: %v", err)
"Mixing enabled, but error on mixed account: %v", err)
}
mixedAccountBranch = s.cfg.MixBranch
if mixedAccountBranch != 0 && mixedAccountBranch != 1 {
Expand All @@ -3337,12 +3335,12 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
mixedSplitAccount, err = w.AccountNumber(ctx, s.cfg.TicketSplitAccount)
if err != nil {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
"CSPP Server set, but error on mixedSplitAccount: %v", err)
"Mixing enabled, but error on mixedSplitAccount: %v", err)
}
changeAccount, err = w.AccountNumber(ctx, s.cfg.MixChangeAccount)
if err != nil {
return nil, rpcErrorf(dcrjson.ErrRPCInvalidParameter,
"CSPP Server set, but error on changeAccount: %v", err)
"Mixing enabled, but error on changeAccount: %v", err)
}
}

Expand Down Expand Up @@ -3375,7 +3373,7 @@ func (s *Server) purchaseTicket(ctx context.Context, icmd any) (any, error) {
DontSignTx: dontSignTx,

// CSPP
Mixing: mixing,
Mixing: s.cfg.Mixing,
MixedAccount: mixedAccount,
MixedAccountBranch: mixedAccountBranch,
MixedSplitAccount: mixedSplitAccount,
Expand Down
26 changes: 11 additions & 15 deletions internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1849,19 +1849,17 @@ func (s *walletServer) PurchaseTickets(ctx context.Context,

dontSignTx := req.DontSignTx

var csppServer string
var mixedAccount uint32
var mixedAccountBranch uint32
var mixedSplitAccount uint32
var changeAccount = req.ChangeAccount

if req.CsppServer != "" {
csppServer = req.CsppServer
if req.EnableMixing {
mixedAccount = req.MixedAccount
_, err = s.wallet.AccountName(ctx, mixedAccount)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on mixed account: %v", err)
"Mixing requested, but error on mixed account: %v", err)
}
mixedAccountBranch = req.MixedAccountBranch
if mixedAccountBranch != 0 && mixedAccountBranch != 1 {
Expand All @@ -1872,12 +1870,12 @@ func (s *walletServer) PurchaseTickets(ctx context.Context,
_, err = s.wallet.AccountName(ctx, mixedSplitAccount)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on mixedSplitAccount: %v", err)
"Mixing requested, but error on mixedSplitAccount: %v", err)
}
_, err = s.wallet.AccountName(ctx, changeAccount)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on changeAccount: %v", err)
"Mixing requested, but error on changeAccount: %v", err)
}
}

Expand All @@ -1891,7 +1889,7 @@ func (s *walletServer) PurchaseTickets(ctx context.Context,
VotingAccount: req.VotingAccount,

// CSPP
Mixing: csppServer != "",
Mixing: req.EnableMixing,
MixedAccount: mixedAccount,
MixedAccountBranch: mixedAccountBranch,
MixedSplitAccount: mixedSplitAccount,
Expand Down Expand Up @@ -2562,7 +2560,7 @@ func (t *accountMixerServer) RunAccountMixer(req *pb.RunAccountMixerRequest, svr
}

tb := ticketbuyer.New(wallet, ticketbuyer.Config{
Mixing: req.CsppServer != "",
Mixing: true,
MixedAccountBranch: req.MixedAccountBranch,
MixedAccount: req.MixedAccount,
ChangeAccount: req.ChangeAccount,
Expand Down Expand Up @@ -2652,21 +2650,19 @@ func (t *ticketbuyerServer) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr pb
return status.Errorf(codes.InvalidArgument, "Negative balance to maintain given")
}

var csppServer string
var mixedAccount uint32
var mixedAccountBranch uint32
var mixedSplitAccount uint32
var changeAccount = req.ChangeAccount
var mixedChange = false

if req.CsppServer != "" {
if req.EnableMixing {
mixedChange = true
csppServer = req.CsppServer
mixedAccount = req.MixedAccount
_, err = wallet.AccountName(ctx, mixedAccount)
if err != nil {
return status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on mixed account: %v", err)
"Mixing requested, but error on mixed account: %v", err)
}
mixedAccountBranch = req.MixedAccountBranch
if mixedAccountBranch != 0 && mixedAccountBranch != 1 {
Expand All @@ -2677,12 +2673,12 @@ func (t *ticketbuyerServer) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr pb
_, err = wallet.AccountName(ctx, mixedSplitAccount)
if err != nil {
return status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on mixedSplitAccount: %v", err)
"Mixing requested, but error on mixedSplitAccount: %v", err)
}
_, err = wallet.AccountName(ctx, changeAccount)
if err != nil {
return status.Errorf(codes.InvalidArgument,
"CSPP Server set, but error on changeAccount: %v", err)
"Mixing requested, but error on changeAccount: %v", err)
}
}

Expand All @@ -2696,7 +2692,7 @@ func (t *ticketbuyerServer) RunTicketBuyer(req *pb.RunTicketBuyerRequest, svr pb
VotingAccount: req.VotingAccount,
Maintain: dcrutil.Amount(req.BalanceToMaintain),
VSP: vspClient,
Mixing: csppServer != "",
Mixing: req.EnableMixing,
MixedAccount: mixedAccount,
MixChange: mixedChange,
ChangeAccount: changeAccount,
Expand Down
5 changes: 2 additions & 3 deletions rpc/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ message PurchaseTicketsRequest {
int64 tx_fee = 7;
int64 ticket_fee = 8;
bool dont_sign_tx = 9;
string cspp_server = 10;
bool enable_mixing = 10;
uint32 mixed_account = 11;
uint32 mixed_account_branch = 12;
uint32 mixed_split_account = 13;
Expand Down Expand Up @@ -897,7 +897,7 @@ message RunTicketBuyerRequest {
string vsp_host = 5;
string vsp_pubkey = 6;
int32 limit = 7;
string cspp_server = 8;
bool enable_mixing = 8;
uint32 mixed_account = 9;
uint32 mixed_account_branch = 10;
uint32 mixed_split_account = 11;
Expand All @@ -911,7 +911,6 @@ message RunAccountMixerRequest {
uint32 mixed_account = 2;
uint32 mixed_account_branch = 3;
uint32 change_account = 4;
string cspp_server = 5;
}

message RunAccountMixerResponse {}
Expand Down
4 changes: 1 addition & 3 deletions rpc/documentation/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ expiry, tx_fee, ticket_fee.

- `bool dont_sign_tx`: If the tickets tx should be signed or not.

- `string cspp_server`: The cspp server to use.
- `bool mixing_enabled`: Enable mixed ticket purchasing.

- `uint32 mixed_account`: The mixed account.

Expand Down Expand Up @@ -2837,8 +2837,6 @@ The `RunAccountMixer` starts a new account mixer for the specified account (and

- `uint32 change_account`: The account that will be used for any unmixed change that is waiting to be mixed.

- `string cspp_server`: The CSPP mixing server URL and port.

**Response:** `stream RunAccountMixerResponse`

**Expected errors:**
Expand Down
Loading

0 comments on commit b49dccc

Please sign in to comment.