Skip to content

Commit

Permalink
feat!: replace dash core quorum sign with quorum platformsign (#828)
Browse files Browse the repository at this point in the history
* feat: replace  dash core quorum sign with quorum platformsign

* chore: fix Docker legacy warning

* test(e2e): fix e2e quorum sign mock

* build(deps): update dashd-go to v0.25.0
  • Loading branch information
lklimek committed Jul 29, 2024
1 parent 5c0e30c commit b8c9b73
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DOCKER/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ LABEL maintainer="[email protected]"
# private validator file into /tenderdash/config.
#
# The /tenderdash/data dir is used by tenderdash to store state.
ENV TMHOME /tenderdash
ENV TMHOME=/tenderdash

# OS environment setup
# Set user right away for determinism, create directory for persistence and give our user ownership
Expand Down
12 changes: 10 additions & 2 deletions dash/core/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ func (rpcClient *RPCClient) QuorumSign(
if err := quorumType.Validate(); err != nil {
return nil, err
}
quorumSignResultWithBool, err := rpcClient.endpoint.QuorumSign(
quorumType,
quorumSignResultWithBool, err := rpcClient.endpoint.QuorumPlatformSign(
requestID.String(),
messageHash.String(),
quorumHash.String(),
false,
)

rpcClient.logger.Trace("core rpc call QuorumSign",
"quorumType", quorumType,
"requestID", requestID.String(),
Expand All @@ -192,7 +192,15 @@ func (rpcClient *RPCClient) QuorumSign(
if quorumSignResultWithBool == nil {
return nil, err
}

// as QuorumPlatformSign does not provide the quorum type, we need to check it manually
// to ensure we deliver what was requested by the caller
quorumSignResult := quorumSignResultWithBool.QuorumSignResult
if quorumType != btcjson.LLMQType(quorumSignResult.LLMQType) {
return nil, fmt.Errorf("possible misconfiguration: quorum platform sign uses unexpected quorum type %d, expected %d",
quorumSignResultWithBool.LLMQType, quorumType)
}

return &quorumSignResult, err
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/containerd/continuity v0.3.0 // indirect
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20230207105415-06df92693ac8
github.com/dashpay/dashd-go v0.24.1
github.com/dashpay/dashd-go v0.25.0
github.com/dashpay/dashd-go/btcec/v2 v2.1.0 // indirect
github.com/fortytw2/leaktest v1.3.0
github.com/fxamacker/cbor/v2 v2.4.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ github.com/daixiang0/gci v0.11.2 h1:Oji+oPsp3bQ6bNNgX30NBAVT18P4uBH4sRZnlOlTj7Y=
github.com/daixiang0/gci v0.11.2/go.mod h1:xtHP9N7AHdNvtRNfcx9gwTDfw7FRJx4bZUsiEfiNNAI=
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20230207105415-06df92693ac8 h1:v4K3CiDoFY1gjcWL/scRcwzyjBwh8TVG3ek8cWolK1g=
github.com/dashpay/bls-signatures/go-bindings v0.0.0-20230207105415-06df92693ac8/go.mod h1:auvGS60NBZ+a21aCCQh366PdsjDvHinsCvl28VrYPu4=
github.com/dashpay/dashd-go v0.24.1 h1:w+F5pDt+fqud4QQM/O9sAJihbQ3oswO8DKOmDS/pcNw=
github.com/dashpay/dashd-go v0.24.1/go.mod h1:4yuk/laGME2RnQRTdqTbw87PhT+42hE1anLCnpkgls8=
github.com/dashpay/dashd-go v0.25.0 h1:tswVRmM2fLHC/JhpuAZ5Oa0TpOO6L+tqiE+QLTCvIQc=
github.com/dashpay/dashd-go v0.25.0/go.mod h1:4yuk/laGME2RnQRTdqTbw87PhT+42hE1anLCnpkgls8=
github.com/dashpay/dashd-go/btcec/v2 v2.1.0 h1:fXwlLf5H+TtgHxjGMU74NesKzk6NisjKMPF04pBcygk=
github.com/dashpay/dashd-go/btcec/v2 v2.1.0/go.mod h1:1i8XtxdOmvK6mYEUCneVXTzFbrCUw3wq1u91j8gvsns=
github.com/dashpay/dashd-go/btcutil v1.2.0 h1:YMq7L0V0au5bbphIhpsBBc+nfOZqU+gJ4pkgRZB7Eiw=
Expand Down
4 changes: 0 additions & 4 deletions privval/signer_requestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ func DefaultValidationRequestHandler(

var proTxHash crypto.ProTxHash
proTxHash, err = privVal.GetProTxHash(context.Background())
if err != nil {
return res, err
}

if err != nil {
res = mustWrapMsg(&privvalproto.ProTxHashResponse{
ProTxHash: nil, Error: &privvalproto.RemoteSignerError{Code: 0, Description: err.Error()}})
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/node/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func setupCoreServer(cfg *Config) (*mockcoreserver.JRPCServer, error) {
srv = mockcoreserver.WithMethods(
srv,
mockcoreserver.WithQuorumInfoMethod(coreServer, mockcoreserver.Endless),
mockcoreserver.WithQuorumSignMethod(coreServer, mockcoreserver.Endless),
mockcoreserver.WithQuorumSignMethod(coreServer, mockcoreserver.Endless, coreServer.LLMQType),
mockcoreserver.WithQuorumVerifyMethod(coreServer, mockcoreserver.Endless),
mockcoreserver.WithMasternodeMethod(coreServer, mockcoreserver.Endless),
mockcoreserver.WithGetNetworkInfoMethod(coreServer, mockcoreserver.Endless),
Expand Down
12 changes: 7 additions & 5 deletions test/e2e/pkg/mockcoreserver/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,20 @@ func WithQuorumInfoMethod(cs CoreServer, times int) MethodFunc {
}

// WithQuorumSignMethod ...
func WithQuorumSignMethod(cs CoreServer, times int) MethodFunc {
func WithQuorumSignMethod(cs CoreServer, times int, quorumType btcjson.LLMQType) MethodFunc {
call := OnMethod(func(ctx context.Context, req btcjson.Request) (interface{}, error) {
cmd := btcjson.QuorumCmd{}
err := unmarshalCmd(req, &cmd.SubCmd, &cmd.LLMQType, &cmd.RequestID, &cmd.MessageHash, &cmd.QuorumHash, &cmd.Submit)
err := unmarshalCmd(req, &cmd.SubCmd, &cmd.RequestID, &cmd.MessageHash, &cmd.QuorumHash, &cmd.Submit)
if err != nil {
return nil, err
}
cmd.LLMQType = &quorumType

return cs.QuorumSign(ctx, cmd), nil
})
return func(srv *JRPCServer) {
srv.
On("quorum sign").
On("quorum platformsign").
Expect(And(Debug())).
Times(times).
Respond(call, JSONContentType())
Expand Down Expand Up @@ -100,7 +102,7 @@ func WithMasternodeMethod(cs CoreServer, times int) MethodFunc {

// WithGetNetworkInfoMethod ...
func WithGetNetworkInfoMethod(cs CoreServer, times int) MethodFunc {
call := OnMethod(func(ctx context.Context, req btcjson.Request) (interface{}, error) {
call := OnMethod(func(ctx context.Context, _req btcjson.Request) (interface{}, error) {
cmd := btcjson.GetNetworkInfoCmd{}
return cs.GetNetworkInfo(ctx, cmd), nil
})
Expand All @@ -115,7 +117,7 @@ func WithGetNetworkInfoMethod(cs CoreServer, times int) MethodFunc {

// WithPingMethod ...
func WithPingMethod(cs CoreServer, times int) MethodFunc {
call := OnMethod(func(ctx context.Context, req btcjson.Request) (interface{}, error) {
call := OnMethod(func(ctx context.Context, _req btcjson.Request) (interface{}, error) {
cmd := btcjson.PingCmd{}
return cs.Ping(ctx, cmd), nil
})
Expand Down

0 comments on commit b8c9b73

Please sign in to comment.