diff --git a/action/action.go b/action/action.go index 8899452f46..e3c3b26c68 100644 --- a/action/action.go +++ b/action/action.go @@ -38,12 +38,13 @@ type ( ) // Sign signs the action using sender's private key -func Sign(act Envelope, sk crypto.PrivateKey) (SealedEnvelope, error) { +func Sign(act Envelope, sk crypto.PrivateKey, useLondonSigner bool) (SealedEnvelope, error) { sealed := SealedEnvelope{ Envelope: act, srcPubkey: sk.PublicKey(), } + sealed.UseLondonSigner(useLondonSigner) h, err := sealed.envelopeHash() if err != nil { return sealed, errors.Wrap(err, "failed to generate envelope hash") diff --git a/action/action_test.go b/action/action_test.go index 0ada22a0d0..53f02ffee2 100644 --- a/action/action_test.go +++ b/action/action_test.go @@ -29,7 +29,7 @@ func TestActionProtoAndVerify(t *testing.T) { SetGasLimit(uint64(100000)). SetAction(v).Build() - selp, err := Sign(elp, identityset.PrivateKey(28)) + selp, err := Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) require.Equal(65, len(selp.SrcPubkey().Bytes())) require.NoError(selp.VerifySignature()) @@ -49,7 +49,7 @@ func TestActionProtoAndVerify(t *testing.T) { SetGasLimit(uint64(100000)). SetAction(v).Build() - selp, err := Sign(elp, identityset.PrivateKey(28)) + selp, err := Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) selp.srcPubkey = nil @@ -62,7 +62,7 @@ func TestActionProtoAndVerify(t *testing.T) { SetGasLimit(uint64(100000)). SetAction(v).Build() - selp, err := Sign(elp, identityset.PrivateKey(28)) + selp, err := Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) selp.signature = []byte("invalid signature") require.Equal(ErrInvalidSender, errors.Cause(selp.VerifySignature())) @@ -112,20 +112,20 @@ func TestIsSystemAction(t *testing.T) { cf := ClaimFromRewardingFundBuilder{} actClaimFromRewarding := cf.Build() act := builder.SetAction(&actClaimFromRewarding).Build() - sel, err := Sign(act, identityset.PrivateKey(1)) + sel, err := Sign(act, identityset.PrivateKey(1), false) require.NoError(err) require.False(IsSystemAction(sel)) gb := GrantRewardBuilder{} actGrantReward := gb.Build() act = builder.SetAction(&actGrantReward).Build() - sel, err = Sign(act, identityset.PrivateKey(1)) + sel, err = Sign(act, identityset.PrivateKey(1), false) require.NoError(err) require.True(IsSystemAction(sel)) actPollResult := NewPutPollResult(1, 1, nil) act = builder.SetAction(actPollResult).Build() - sel, err = Sign(act, identityset.PrivateKey(1)) + sel, err = Sign(act, identityset.PrivateKey(1), false) require.NoError(err) require.True(IsSystemAction(sel)) } diff --git a/action/candidateregister_test.go b/action/candidateregister_test.go index 661e33f9bd..843ec6db7f 100644 --- a/action/candidateregister_test.go +++ b/action/candidateregister_test.go @@ -123,7 +123,7 @@ func TestCandidateRegister(t *testing.T) { SetGasPrice(test.GasPrice). SetAction(cr).Build() // sign - selp, err := Sign(elp, test.SenderKey) + selp, err := Sign(elp, test.SenderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/candidateupdate_test.go b/action/candidateupdate_test.go index a72e43f1a6..386e6b770b 100644 --- a/action/candidateupdate_test.go +++ b/action/candidateupdate_test.go @@ -65,7 +65,7 @@ func TestCandidateUpdateSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(cu).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/execution_test.go b/action/execution_test.go index 01fa866ba2..aefb74d39a 100644 --- a/action/execution_test.go +++ b/action/execution_test.go @@ -44,7 +44,7 @@ func TestExecutionSignVerify(t *testing.T) { require.Equal(ex, ex2) // sign the Execution - selp, err := Sign(elp, executorKey) + selp, err := Sign(elp, executorKey, false) require.NoError(err) require.NotNil(selp) require.EqualValues(21, ex.BasicActionSize()) diff --git a/action/protocol/context.go b/action/protocol/context.go index 380f4883ac..0b9b4b47d0 100644 --- a/action/protocol/context.go +++ b/action/protocol/context.go @@ -113,6 +113,7 @@ type ( ValidateSystemAction bool AllowCorrectChainIDOnly bool AddContractStakingVotes bool + UseCorrectSigner bool SharedGasWithDapp bool } @@ -252,6 +253,7 @@ func WithFeatureCtx(ctx context.Context) context.Context { ValidateSystemAction: g.IsQuebec(height), AllowCorrectChainIDOnly: g.IsQuebec(height), AddContractStakingVotes: g.IsQuebec(height), + UseCorrectSigner: g.IsRedsea(height), SharedGasWithDapp: g.IsToBeEnabled(height), }, ) diff --git a/action/protocol/execution/protocol_test.go b/action/protocol/execution/protocol_test.go index fe5664d89a..f014b167f1 100644 --- a/action/protocol/execution/protocol_test.go +++ b/action/protocol/execution/protocol_test.go @@ -328,7 +328,7 @@ func runExecutions( SetGasLimit(ecfg.GasLimit()). SetGasPrice(ecfg.GasPrice()). Build() - selp, err := action.Sign(elp, ecfg.PrivateKey()) + selp, err := action.Sign(elp, ecfg.PrivateKey(), false) if err != nil { return nil, nil, err } @@ -691,7 +691,7 @@ func TestProtocol_Handle(t *testing.T) { elp := bd.SetAction(execution). SetNonce(1). SetGasLimit(100000).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(27)) + selp, err := action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) require.NoError(ap.Add(context.Background(), selp)) @@ -746,7 +746,7 @@ func TestProtocol_Handle(t *testing.T) { elp = bd.SetAction(execution). SetNonce(2). SetGasLimit(120000).Build() - selp, err = action.Sign(elp, identityset.PrivateKey(27)) + selp, err = action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) log.S().Infof("execution %+v", execution) @@ -782,7 +782,7 @@ func TestProtocol_Handle(t *testing.T) { elp = bd.SetAction(execution). SetNonce(3). SetGasLimit(120000).Build() - selp, err = action.Sign(elp, identityset.PrivateKey(27)) + selp, err = action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) log.S().Infof("execution %+v", execution) @@ -806,7 +806,7 @@ func TestProtocol_Handle(t *testing.T) { elp = bd.SetAction(execution1). SetNonce(4). SetGasLimit(100000).SetGasPrice(big.NewInt(10)).Build() - selp, err = action.Sign(elp, identityset.PrivateKey(27)) + selp, err = action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) require.NoError(ap.Add(context.Background(), selp)) diff --git a/action/protocol/generic_validator.go b/action/protocol/generic_validator.go index 8d67053468..a5469da7ef 100644 --- a/action/protocol/generic_validator.go +++ b/action/protocol/generic_validator.go @@ -45,6 +45,7 @@ func (v *GenericValidator) Validate(ctx context.Context, selp action.SealedEnvel } // Verify action using action sender's public key + selp.UseLondonSigner(MustGetFeatureCtx(ctx).UseCorrectSigner) if err := selp.VerifySignature(); err != nil { return err } diff --git a/action/protocol/generic_validator_test.go b/action/protocol/generic_validator_test.go index 9a66b9cd5b..639a18a890 100644 --- a/action/protocol/generic_validator_test.go +++ b/action/protocol/generic_validator_test.go @@ -91,7 +91,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { SetGasLimit(uint64(100000)). SetNonce(3). SetAction(v).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(28)) + selp, err := action.Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) nselp, err := (&action.Deserializer{}).SetEvmNetworkID(_evmNetworkID).ActionToSealedEnvelope(selp.Proto()) require.NoError(err) @@ -104,7 +104,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { elp := bd.SetGasPrice(big.NewInt(10)). SetGasLimit(uint64(10)). SetAction(v).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(28)) + selp, err := action.Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) nselp, err := (&action.Deserializer{}).SetEvmNetworkID(_evmNetworkID).ActionToSealedEnvelope(selp.Proto()) require.NoError(err) @@ -120,7 +120,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { SetGasLimit(uint64(100000)). SetNonce(1). SetAction(v).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(27)) + selp, err := action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) nselp, err := (&action.Deserializer{}).SetEvmNetworkID(_evmNetworkID).ActionToSealedEnvelope(selp.Proto()) require.NoError(err) @@ -136,7 +136,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { SetNonce(1). SetGasLimit(uint64(100000)). SetAction(&gr).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(28)) + selp, err := action.Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) nselp, err := (&action.Deserializer{}).SetEvmNetworkID(_evmNetworkID).ActionToSealedEnvelope(selp.Proto()) require.NoError(err) @@ -151,7 +151,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { SetNonce(1). SetGasLimit(uint64(100000)). SetAction(v).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(28)) + selp, err := action.Sign(elp, identityset.PrivateKey(28), false) require.NoError(err) nselp, err := (&action.Deserializer{}).SetEvmNetworkID(_evmNetworkID).ActionToSealedEnvelope(selp.Proto()) require.NoError(err) @@ -166,7 +166,7 @@ func TestActionProtoAndGenericValidator(t *testing.T) { elp := bd.SetAction(v).SetGasLimit(100000). SetGasPrice(big.NewInt(10)). SetNonce(1).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(27)) + selp, err := action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(err) require.Error(valid.Validate(ctx, selp)) }) diff --git a/action/protocol/poll/governance_protocol_test.go b/action/protocol/poll/governance_protocol_test.go index cb10abf247..04d334b67c 100644 --- a/action/protocol/poll/governance_protocol_test.go +++ b/action/protocol/poll/governance_protocol_test.go @@ -378,7 +378,7 @@ func TestHandle(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(tsf).Build() - selp, err := action.Sign(elp, senderKey) + selp, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp) receipt, err := p.Handle(ctx, selp.Action(), nil) @@ -398,7 +398,7 @@ func TestHandle(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act2).Build() - selp2, err := action.Sign(elp, senderKey) + selp2, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp2) caller := selp2.SenderAddress() @@ -445,7 +445,7 @@ func TestHandle(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act2).Build() - selp2, err := action.Sign(elp, senderKey) + selp2, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp2) caller := selp2.SenderAddress() @@ -480,7 +480,7 @@ func TestHandle(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act3).Build() - selp3, err := action.Sign(elp, senderKey) + selp3, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp3) caller := selp3.SenderAddress() @@ -514,7 +514,7 @@ func TestHandle(t *testing.T) { elp4 := bd4.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act4).Build() - selp4, err := action.Sign(elp4, senderKey) + selp4, err := action.Sign(elp4, senderKey, false) require.NoError(err) require.NotNil(selp4) caller := selp4.SenderAddress() @@ -548,7 +548,7 @@ func TestHandle(t *testing.T) { elp5 := bd5.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act5).Build() - selp5, err := action.Sign(elp5, senderKey) + selp5, err := action.Sign(elp5, senderKey, false) require.NoError(err) require.NotNil(selp5) caller := selp5.SenderAddress() diff --git a/action/protocol/poll/staking_committee_test.go b/action/protocol/poll/staking_committee_test.go index 5dc94c6d15..a8b20de452 100644 --- a/action/protocol/poll/staking_committee_test.go +++ b/action/protocol/poll/staking_committee_test.go @@ -214,7 +214,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(tsf).Build() - selp, err := action.Sign(elp, senderKey) + selp, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp) receipt, err := p.Handle(ctx, selp.Action(), nil) @@ -234,7 +234,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act2).Build() - selp2, err := action.Sign(elp, senderKey) + selp2, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp2) receipt, err := p.Handle(ctx2, selp2.Action(), sm2) @@ -264,7 +264,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act2).Build() - selp2, err := action.Sign(elp, senderKey) + selp2, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp2) caller := selp2.SenderAddress() @@ -301,7 +301,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act3).Build() - selp3, err := action.Sign(elp, senderKey) + selp3, err := action.Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp3) caller := selp3.SenderAddress() @@ -337,7 +337,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp4 := bd4.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act4).Build() - selp4, err := action.Sign(elp4, senderKey) + selp4, err := action.Sign(elp4, senderKey, false) require.NoError(err) require.NotNil(selp4) caller := selp4.SenderAddress() @@ -373,7 +373,7 @@ func TestHandle_StakingCommittee(t *testing.T) { elp5 := bd5.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act5).Build() - selp5, err := action.Sign(elp5, senderKey) + selp5, err := action.Sign(elp5, senderKey, false) require.NoError(err) require.NotNil(selp5) caller := selp5.SenderAddress() diff --git a/action/protocol/rewarding/protocol_test.go b/action/protocol/rewarding/protocol_test.go index 53610306c2..71aa8deac7 100644 --- a/action/protocol/rewarding/protocol_test.go +++ b/action/protocol/rewarding/protocol_test.go @@ -378,7 +378,7 @@ func TestProtocol_Handle(t *testing.T) { SetGasLimit(deposit.GasLimit()). SetAction(&deposit). Build() - se1, err := action.Sign(e1, identityset.PrivateKey(0)) + se1, err := action.Sign(e1, identityset.PrivateKey(0), false) require.NoError(t, err) _, err = p.Handle(ctx, se1.Action(), sm) @@ -390,7 +390,7 @@ func TestProtocol_Handle(t *testing.T) { // Grant // Test for createGrantRewardAction e2 := createGrantRewardAction(0, uint64(0)) - se2, err := action.Sign(e2, identityset.PrivateKey(0)) + se2, err := action.Sign(e2, identityset.PrivateKey(0), false) require.NoError(t, err) ctx = protocol.WithActionCtx( ctx, @@ -426,7 +426,7 @@ func TestProtocol_Handle(t *testing.T) { SetGasLimit(claim.GasLimit()). SetAction(&claim). Build() - se3, err := action.Sign(e3, identityset.PrivateKey(0)) + se3, err := action.Sign(e3, identityset.PrivateKey(0), false) require.NoError(t, err) ctx = protocol.WithActionCtx( ctx, diff --git a/action/rlp_tx.go b/action/rlp_tx.go index 0aaa3785b5..9f29219dab 100644 --- a/action/rlp_tx.go +++ b/action/rlp_tx.go @@ -13,13 +13,19 @@ import ( "golang.org/x/crypto/sha3" ) -func rlpRawHash(rawTx *types.Transaction, chainID uint32) (hash.Hash256, error) { - h := types.NewEIP155Signer(big.NewInt(int64(chainID))).Hash(rawTx) +func rlpRawHash(rawTx *types.Transaction, chainID uint32, useLondontSigner bool) (hash.Hash256, error) { + var signer types.Signer + if useLondontSigner { + signer = types.NewLondonSigner(big.NewInt(int64(chainID))) + } else { + signer = types.NewEIP155Signer(big.NewInt(int64(chainID))) + } + h := signer.Hash(rawTx) return hash.BytesToHash256(h[:]), nil } -func rlpSignedHash(tx *types.Transaction, chainID uint32, sig []byte) (hash.Hash256, error) { - signedTx, err := reconstructSignedRlpTxFromSig(tx, chainID, sig) +func rlpSignedHash(tx *types.Transaction, chainID uint32, sig []byte, useLondonSigner bool) (hash.Hash256, error) { + signedTx, err := reconstructSignedRlpTxFromSig(tx, chainID, sig, useLondonSigner) if err != nil { return hash.ZeroHash256, err } @@ -30,7 +36,7 @@ func rlpSignedHash(tx *types.Transaction, chainID uint32, sig []byte) (hash.Hash return hash.BytesToHash256(h.Sum(nil)), nil } -func reconstructSignedRlpTxFromSig(rawTx *types.Transaction, chainID uint32, sig []byte) (*types.Transaction, error) { +func reconstructSignedRlpTxFromSig(rawTx *types.Transaction, chainID uint32, sig []byte, useLondonSigner bool) (*types.Transaction, error) { if len(sig) != 65 { return nil, errors.Errorf("invalid signature length = %d, expecting 65", len(sig)) } @@ -40,7 +46,13 @@ func reconstructSignedRlpTxFromSig(rawTx *types.Transaction, chainID uint32, sig sc[64] -= 27 } - signedTx, err := rawTx.WithSignature(types.NewEIP155Signer(big.NewInt(int64(chainID))), sc) + var signer types.Signer + if useLondonSigner { + signer = types.NewLondonSigner(big.NewInt(int64(chainID))) + } else { + signer = types.NewEIP155Signer(big.NewInt(int64(chainID))) + } + signedTx, err := rawTx.WithSignature(signer, sc) if err != nil { return nil, err } diff --git a/action/rlp_tx_test.go b/action/rlp_tx_test.go index 22798b6c19..94d79e0d41 100644 --- a/action/rlp_tx_test.go +++ b/action/rlp_tx_test.go @@ -79,7 +79,7 @@ func TestGenerateRlp(t *testing.T) { require.Contains(err.Error(), v.err) continue } - h, err := rlpSignedHash(tx, _evmNetworkID, v.sig) + h, err := rlpSignedHash(tx, _evmNetworkID, v.sig, false) if err != nil { require.Contains(err.Error(), v.err) } @@ -354,6 +354,7 @@ func TestRlpDecodeVerify(t *testing.T) { require.NoError(err) require.True(bytes.Equal(rawHash[:], raw[:])) require.NotEqual(raw, h) + selp.UseLondonSigner(true) require.NoError(selp.VerifySignature()) } } diff --git a/action/sealedenvelope.go b/action/sealedenvelope.go index d2107e2ede..6c549daddc 100644 --- a/action/sealedenvelope.go +++ b/action/sealedenvelope.go @@ -18,12 +18,18 @@ import ( // SealedEnvelope is a signed action envelope. type SealedEnvelope struct { Envelope - encoding iotextypes.Encoding - evmNetworkID uint32 - srcPubkey crypto.PublicKey - signature []byte - srcAddress address.Address - hash hash.Hash256 + encoding iotextypes.Encoding + evmNetworkID uint32 + srcPubkey crypto.PublicKey + signature []byte + srcAddress address.Address + hash hash.Hash256 + useLondonSigner bool +} + +// UseLondonSigner sets to use London signer +func (sealed *SealedEnvelope) UseLondonSigner(use bool) { + sealed.useLondonSigner = use } // envelopeHash returns the raw hash of embedded Envelope (this is the hash to be signed) @@ -39,7 +45,7 @@ func (sealed *SealedEnvelope) envelopeHash() (hash.Hash256, error) { if err != nil { return hash.ZeroHash256, err } - return rlpRawHash(tx, sealed.evmNetworkID) + return rlpRawHash(tx, sealed.evmNetworkID, sealed.useLondonSigner) case iotextypes.Encoding_IOTEX_PROTOBUF: return hash.Hash256b(byteutil.Must(proto.Marshal(sealed.Envelope.Proto()))), nil default: @@ -71,7 +77,7 @@ func (sealed *SealedEnvelope) calcHash() (hash.Hash256, error) { if err != nil { return hash.ZeroHash256, err } - return rlpSignedHash(tx, sealed.evmNetworkID, sealed.Signature()) + return rlpSignedHash(tx, sealed.evmNetworkID, sealed.Signature(), sealed.useLondonSigner) case iotextypes.Encoding_IOTEX_PROTOBUF: return hash.Hash256b(byteutil.Must(proto.Marshal(sealed.Proto()))), nil default: @@ -146,7 +152,7 @@ func (sealed *SealedEnvelope) loadProto(pbAct *iotextypes.Action, evmID uint32) if err != nil { return err } - if _, err = rlpSignedHash(tx, evmID, pbAct.GetSignature()); err != nil { + if _, err = rlpSignedHash(tx, evmID, pbAct.GetSignature(), sealed.useLondonSigner); err != nil { return err } sealed.evmNetworkID = evmID diff --git a/action/signedaction.go b/action/signedaction.go index 639d9250a9..3b24155454 100644 --- a/action/signedaction.go +++ b/action/signedaction.go @@ -30,7 +30,7 @@ func SignedTransfer(recipientAddr string, senderPriKey crypto.PrivateKey, nonce SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(transfer).Build() - selp, err := Sign(elp, senderPriKey) + selp, err := Sign(elp, senderPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign transfer %v", elp) } @@ -48,7 +48,7 @@ func SignedExecution(contractAddr string, executorPriKey crypto.PrivateKey, nonc SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(execution).Build() - selp, err := Sign(elp, executorPriKey) + selp, err := Sign(elp, executorPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign execution %v", elp) } @@ -76,7 +76,7 @@ func SignedCandidateRegister( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(cr).Build() - selp, err := Sign(elp, registererPriKey) + selp, err := Sign(elp, registererPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign candidate register %v", elp) } @@ -100,7 +100,7 @@ func SignedCandidateUpdate( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(cu).Build() - selp, err := Sign(elp, registererPriKey) + selp, err := Sign(elp, registererPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign candidate update %v", elp) } @@ -127,7 +127,7 @@ func SignedCreateStake(nonce uint64, SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(cs).Build() - selp, err := Sign(elp, stakerPriKey) + selp, err := Sign(elp, stakerPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign create stake %v", elp) } @@ -163,7 +163,7 @@ func SignedReclaimStake( } elp = eb.SetAction(w).Build() } - selp, err := Sign(elp, reclaimerPriKey) + selp, err := Sign(elp, reclaimerPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign reclaim stake %v", elp) } @@ -189,7 +189,7 @@ func SignedChangeCandidate( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(cc).Build() - selp, err := Sign(elp, stakerPriKey) + selp, err := Sign(elp, stakerPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign change candidate %v", elp) } @@ -215,7 +215,7 @@ func SignedTransferStake( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(ts).Build() - selp, err := Sign(elp, stakerPriKey) + selp, err := Sign(elp, stakerPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign transfer stake %v", elp) } @@ -241,7 +241,7 @@ func SignedDepositToStake( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(ds).Build() - selp, err := Sign(elp, depositorPriKey) + selp, err := Sign(elp, depositorPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign deposit to stake %v", elp) } @@ -268,7 +268,7 @@ func SignedRestake( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(rs).Build() - selp, err := Sign(elp, restakerPriKey) + selp, err := Sign(elp, restakerPriKey, false) if err != nil { return SealedEnvelope{}, errors.Wrapf(err, "failed to sign restake %v", elp) } diff --git a/action/stake_changecandidate_test.go b/action/stake_changecandidate_test.go index 6e1fc1b74e..65fd429e76 100644 --- a/action/stake_changecandidate_test.go +++ b/action/stake_changecandidate_test.go @@ -64,7 +64,7 @@ func TestChangeCandidateSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(stake).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/stake_transferownership_test.go b/action/stake_transferownership_test.go index c3cda1a8b3..2b0752ea31 100644 --- a/action/stake_transferownership_test.go +++ b/action/stake_transferownership_test.go @@ -51,7 +51,7 @@ func TestStakingTransferSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(stake).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/stakeadddeposit_test.go b/action/stakeadddeposit_test.go index 27c0b282e6..a2688feeb1 100644 --- a/action/stakeadddeposit_test.go +++ b/action/stakeadddeposit_test.go @@ -100,7 +100,7 @@ func TestDeposit(t *testing.T) { SetGasPrice(test.GasPrice). SetAction(stake).Build() // sign - selp, err := Sign(elp, test.SenderKey) + selp, err := Sign(elp, test.SenderKey, false) require.NoError(err) require.NotNil(selp) ser, err = proto.Marshal(selp.Proto()) diff --git a/action/stakecreate_test.go b/action/stakecreate_test.go index 0de18ab556..c219e817c6 100644 --- a/action/stakecreate_test.go +++ b/action/stakecreate_test.go @@ -107,7 +107,7 @@ func TestCreateStake(t *testing.T) { SetGasPrice(test.GasPrice). SetAction(stake).Build() // sign - selp, err := Sign(elp, test.SenderKey) + selp, err := Sign(elp, test.SenderKey, false) require.NoError(err) require.NotNil(selp) ser, err = proto.Marshal(selp.Proto()) diff --git a/action/stakereclaim_test.go b/action/stakereclaim_test.go index d93a573683..1e54f2f1df 100644 --- a/action/stakereclaim_test.go +++ b/action/stakereclaim_test.go @@ -69,7 +69,7 @@ func TestUnstakeSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(stake).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) @@ -138,7 +138,7 @@ func TestWithdrawSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(stake).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/stakerestake_test.go b/action/stakerestake_test.go index 3ba92c45a7..cf40f5d61a 100644 --- a/action/stakerestake_test.go +++ b/action/stakerestake_test.go @@ -63,7 +63,7 @@ func TestRestakeSignVerify(t *testing.T) { SetGasPrice(_gasprice). SetAction(stake).Build() // sign - selp, err := Sign(elp, _senderKey) + selp, err := Sign(elp, _senderKey, false) require.NoError(err) require.NotNil(selp) ser, err := proto.Marshal(selp.Proto()) diff --git a/action/transfer_test.go b/action/transfer_test.go index 0ed465035b..bf1f2e9155 100644 --- a/action/transfer_test.go +++ b/action/transfer_test.go @@ -40,7 +40,7 @@ func TestTransferSignVerify(t *testing.T) { require.Equal(tsf, tsf2) // sign the transfer - selp, err := Sign(elp, senderKey) + selp, err := Sign(elp, senderKey, false) require.NoError(err) require.NotNil(selp) require.EqualValues(21, tsf.BasicActionSize()) diff --git a/actpool/actioniterator/actioniterator_test.go b/actpool/actioniterator/actioniterator_test.go index c52a20c784..45b9bc283f 100644 --- a/actpool/actioniterator/actioniterator_test.go +++ b/actpool/actioniterator/actioniterator_test.go @@ -33,7 +33,7 @@ func TestActionIterator(t *testing.T) { elp := bd.SetNonce(1). SetGasPrice(big.NewInt(13)). SetAction(tsf1).Build() - selp1, err := action.Sign(elp, priKeyA) + selp1, err := action.Sign(elp, priKeyA, false) require.NoError(err) tsf2, err := action.NewTransfer(uint64(2), big.NewInt(100), "2", nil, uint64(0), big.NewInt(30)) @@ -42,7 +42,7 @@ func TestActionIterator(t *testing.T) { elp = bd.SetNonce(2). SetGasPrice(big.NewInt(30)). SetAction(tsf2).Build() - selp2, err := action.Sign(elp, priKeyA) + selp2, err := action.Sign(elp, priKeyA, false) require.NoError(err) accMap[a.String()] = []action.SealedEnvelope{selp1, selp2} @@ -53,7 +53,7 @@ func TestActionIterator(t *testing.T) { elp = bd.SetNonce(1). SetGasPrice(big.NewInt(15)). SetAction(tsf3).Build() - selp3, err := action.Sign(elp, priKeyB) + selp3, err := action.Sign(elp, priKeyB, false) require.NoError(err) tsf4, err := action.NewTransfer(uint64(2), big.NewInt(100), "3", nil, uint64(0), big.NewInt(10)) @@ -62,7 +62,7 @@ func TestActionIterator(t *testing.T) { elp = bd.SetNonce(2). SetGasPrice(big.NewInt(10)). SetAction(tsf4).Build() - selp4, err := action.Sign(elp, priKeyB) + selp4, err := action.Sign(elp, priKeyB, false) require.NoError(err) tsf5, err := action.NewTransfer(uint64(3), big.NewInt(100), a.String(), nil, uint64(0), big.NewInt(2)) @@ -71,7 +71,7 @@ func TestActionIterator(t *testing.T) { elp = bd.SetNonce(3). SetGasPrice(big.NewInt(20)). SetAction(tsf5).Build() - selp5, err := action.Sign(elp, priKeyB) + selp5, err := action.Sign(elp, priKeyB, false) require.NoError(err) accMap[b.String()] = []action.SealedEnvelope{selp3, selp4, selp5} @@ -82,7 +82,7 @@ func TestActionIterator(t *testing.T) { elp = bd.SetNonce(1). SetGasPrice(big.NewInt(5)). SetAction(tsf6).Build() - selp6, err := action.Sign(elp, priKeyC) + selp6, err := action.Sign(elp, priKeyC, false) require.NoError(err) accMap[c.String()] = []action.SealedEnvelope{selp6} @@ -112,7 +112,7 @@ func BenchmarkLooping(b *testing.B) { elp := bd.SetNonce(1). SetGasPrice(big.NewInt(5)). SetAction(tsf).Build() - selp, err := action.Sign(elp, priKey) + selp, err := action.Sign(elp, priKey, false) require.NoError(b, err) accMap[addr.String()] = []action.SealedEnvelope{selp} } diff --git a/actpool/actpool_test.go b/actpool/actpool_test.go index a60e95ae8a..5a1cce8243 100644 --- a/actpool/actpool_test.go +++ b/actpool/actpool_test.go @@ -161,6 +161,9 @@ func TestActPool_AddActs(t *testing.T) { require.NoError(err) ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -244,7 +247,7 @@ func TestActPool_AddActs(t *testing.T) { elp := bd.SetNonce(4). SetAction(replaceTransfer). SetGasLimit(100000).Build() - selp, err := action.Sign(elp, _priKey1) + selp, err := action.Sign(elp, _priKey1, false) require.NoError(err) @@ -277,7 +280,7 @@ func TestActPool_AddActs(t *testing.T) { SetGasPrice(big.NewInt(10)). SetGasLimit(10). SetAction(creationExecution).Build() - selp, err = action.Sign(elp, _priKey1) + selp, err = action.Sign(elp, _priKey1, false) require.NoError(err) err = ap.Add(ctx, selp) @@ -297,6 +300,9 @@ func TestActPool_PickActs(t *testing.T) { require := require.New(t) sf := mock_chainmanager.NewMockStateReader(ctrl) ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) createActPool := func(cfg Config) (*actPool, []action.SealedEnvelope, []action.SealedEnvelope, []action.SealedEnvelope) { // Create actpool Ap, err := NewActPool(genesis.Default, sf, cfg) @@ -403,6 +409,9 @@ func TestActPool_removeConfirmedActs(t *testing.T) { }).Times(5) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -511,6 +520,9 @@ func TestActPool_Reset(t *testing.T) { require.NoError(err) ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap1.Add(ctx, tsf1)) require.NoError(ap1.Add(ctx, tsf2)) err = ap1.Add(ctx, tsf3) @@ -735,7 +747,7 @@ func TestActPool_Reset(t *testing.T) { elp := bd.SetNonce(3). SetGasLimit(20000). SetAction(tsf23).Build() - selp23, err := action.Sign(elp, _priKey4) + selp23, err := action.Sign(elp, _priKey4, false) require.NoError(err) tsf24, err := action.SignedTransfer(_addr5, _priKey5, uint64(1), big.NewInt(10), []byte{}, uint64(20000), big.NewInt(0)) @@ -749,7 +761,7 @@ func TestActPool_Reset(t *testing.T) { elp = bd.SetNonce(3). SetGasLimit(20000). SetAction(tsf26).Build() - selp26, err := action.Sign(elp, _priKey5) + selp26, err := action.Sign(elp, _priKey5, false) require.NoError(err) require.NoError(ap1.Add(ctx, tsf21)) @@ -820,6 +832,9 @@ func TestActPool_removeInvalidActs(t *testing.T) { }).Times(5) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -871,6 +886,9 @@ func TestActPool_GetPendingNonce(t *testing.T) { sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf3)) require.NoError(ap.Add(ctx, tsf4)) @@ -919,6 +937,9 @@ func TestActPool_GetUnconfirmedActs(t *testing.T) { }).Times(6) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf3)) require.NoError(ap.Add(ctx, tsf4)) @@ -1020,6 +1041,9 @@ func TestActPool_GetSize(t *testing.T) { }).Times(5) sf.EXPECT().Height().Return(uint64(1), nil).AnyTimes() ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) require.NoError(ap.Add(ctx, tsf3)) @@ -1097,6 +1121,9 @@ func TestActPool_SpeedUpAction(t *testing.T) { // A send action tsf1 with nonce 1, B send action tsf2 with nonce 1 ctx := genesis.WithGenesisContext(context.Background(), genesis.Default) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) require.NoError(ap.Add(ctx, tsf1)) require.NoError(ap.Add(ctx, tsf2)) diff --git a/api/coreservice.go b/api/coreservice.go index 32951b9d42..d29c463d6c 100644 --- a/api/coreservice.go +++ b/api/coreservice.go @@ -430,6 +430,9 @@ func (core *coreService) SendAction(ctx context.Context, in *iotextypes.Action) // Add to local actpool ctx = protocol.WithRegistry(ctx, core.registry) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, core.bc.Genesis()), protocol.BlockCtx{ + BlockHeight: core.bc.TipHeight() + 1, + })) hash, err := selp.Hash() if err != nil { return "", err diff --git a/api/coreservice_test.go b/api/coreservice_test.go index 6b1dd98384..37216ced8e 100644 --- a/api/coreservice_test.go +++ b/api/coreservice_test.go @@ -20,10 +20,12 @@ import ( "google.golang.org/protobuf/proto" "github.com/iotexproject/iotex-core/action" + "github.com/iotexproject/iotex-core/action/protocol" "github.com/iotexproject/iotex-core/actpool" "github.com/iotexproject/iotex-core/api/logfilter" "github.com/iotexproject/iotex-core/blockchain" "github.com/iotexproject/iotex-core/blockchain/blockdao" + "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/test/identityset" "github.com/iotexproject/iotex-core/test/mock/mock_blockindex" "github.com/iotexproject/iotex-core/testutil" @@ -210,6 +212,9 @@ func TestTraceTransaction(t *testing.T) { svr, bc, _, ap, cleanCallback := setupTestCoreService() defer cleanCallback() ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) tsf, err := action.SignedExecution(identityset.Address(29).String(), identityset.PrivateKey(29), 1, big.NewInt(0), testutil.TestGasLimit, big.NewInt(testutil.TestGasPriceInt64), []byte{}) @@ -243,6 +248,9 @@ func TestTraceCall(t *testing.T) { svr, bc, _, ap, cleanCallback := setupTestCoreService() defer cleanCallback() ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) tsf, err := action.SignedExecution(identityset.Address(29).String(), identityset.PrivateKey(29), 1, big.NewInt(0), testutil.TestGasLimit, big.NewInt(testutil.TestGasPriceInt64), []byte{}) diff --git a/api/grpcserver_integrity_test.go b/api/grpcserver_integrity_test.go index ae19e2f875..0ef66eb76f 100644 --- a/api/grpcserver_integrity_test.go +++ b/api/grpcserver_integrity_test.go @@ -1306,16 +1306,19 @@ func TestGrpcServer_SendActionIntegrity(t *testing.T) { } coreService.messageBatcher = nil + ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, cfg.genesis), protocol.BlockCtx{ + BlockHeight: 1, + })) for i, test := range _sendActionTests { request := &iotexapi.SendActionRequest{Action: test.actionPb} - res, err := grpcHandler.SendAction(context.Background(), request) + res, err := grpcHandler.SendAction(ctx, request) require.NoError(err) require.Equal(i+1, broadcastHandlerCount) require.Equal(test.actionHash, res.ActionHash) } // 3 failure cases - ctx := context.Background() tests := []struct { cfg func() testConfig action *iotextypes.Action @@ -2417,6 +2420,9 @@ func TestGrpcServer_GetActPoolActionsIntegrity(t *testing.T) { cfg := newConfig() cfg.api.GRPCPort = testutil.RandomPort() ctx := genesis.WithGenesisContext(context.Background(), cfg.genesis) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: 1, + })) svr, _, _, _, _, actPool, bfIndexFile, err := createServerV2(cfg, false) require.NoError(err) grpcHandler := newGRPCHandler(svr.core) @@ -2605,8 +2611,12 @@ func TestChainlinkErrIntegrity(t *testing.T) { testutil.CleanupPath(file) }() + ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, cfg.genesis), protocol.BlockCtx{ + BlockHeight: 1, + })) for _, action := range test.actions { - _, err = grpcHandler.SendAction(context.Background(), &iotexapi.SendActionRequest{Action: action}) + _, err = grpcHandler.SendAction(ctx, &iotexapi.SendActionRequest{Action: action}) if err != nil { break } @@ -2646,7 +2656,11 @@ func TestGrpcServer_TraceTransactionStructLogsIntegrity(t *testing.T) { data, _ := hex.DecodeString(contractCode) ex1, err := action.SignedExecution(action.EmptyAddress, identityset.PrivateKey(13), 1, big.NewInt(0), 500000, big.NewInt(testutil.TestGasPriceInt64), data) require.NoError(err) - actPool.Add(context.Background(), ex1) + ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, cfg.genesis), protocol.BlockCtx{ + BlockHeight: 1, + })) + actPool.Add(ctx, ex1) require.NoError(err) blk, err := bc.MintNewBlock(testutil.TimestampNow()) require.NoError(err) diff --git a/api/serverV2_integrity_test.go b/api/serverV2_integrity_test.go index ecb34ac756..bb3a357df3 100644 --- a/api/serverV2_integrity_test.go +++ b/api/serverV2_integrity_test.go @@ -72,6 +72,9 @@ var ( func addTestingBlocks(bc blockchain.Blockchain, ap actpool.ActPool) error { ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) addr0 := identityset.Address(27).String() addr1 := identityset.Address(28).String() addr2 := identityset.Address(29).String() @@ -225,7 +228,11 @@ func deployContractV2(bc blockchain.Blockchain, dao blockdao.BlockDAO, actPool a if err != nil { return "", err } - if err := actPool.Add(context.Background(), ex1); err != nil { + ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) + if err := actPool.Add(ctx, ex1); err != nil { return "", err } blk, err := bc.MintNewBlock(testutil.TimestampNow()) @@ -445,6 +452,9 @@ func createServerV2(cfg testConfig, needActPool bool) (*ServerV2, blockchain.Blo if needActPool { // Add actions to actpool ctx = protocol.WithRegistry(ctx, registry) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) if err := addActsToActPool(ctx, ap); err != nil { return nil, nil, nil, nil, nil, nil, "", err } diff --git a/api/web3server_marshal_test.go b/api/web3server_marshal_test.go index 562dc96719..559f603a71 100644 --- a/api/web3server_marshal_test.go +++ b/api/web3server_marshal_test.go @@ -94,7 +94,7 @@ func TestBlockObjectMarshal(t *testing.T) { SetNonce(2). SetVersion(1). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey(24)) + sevlp, err := action.Sign(evlp, identityset.PrivateKey(24), false) require.NoError(err) ra := (&block.RunnableActionsBuilder{}).AddActions([]action.SealedEnvelope{sevlp}...).Build() blk, err := block.NewBuilder(ra). diff --git a/blockchain/block/block_test.go b/blockchain/block/block_test.go index 721e4674ce..c9efb3d688 100644 --- a/blockchain/block/block_test.go +++ b/blockchain/block/block_test.go @@ -196,7 +196,7 @@ func makeBlock(tb testing.TB, n int) *Block { SetNonce(tsf.Nonce()). SetVersion(1). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size())) + sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size()), false) require.NoError(tb, err) sevlps = append(sevlps, sevlp) } diff --git a/blockchain/block/body_test.go b/blockchain/block/body_test.go index 7730436b0d..a1532e9996 100644 --- a/blockchain/block/body_test.go +++ b/blockchain/block/body_test.go @@ -111,7 +111,7 @@ func makeBody() (body Body, err error) { SetAction(v). SetAction(t).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(28)) + selp, err := action.Sign(elp, identityset.PrivateKey(28), false) if err != nil { return } diff --git a/blockchain/block/utils_test.go b/blockchain/block/utils_test.go index 4e828c998e..753266afaa 100644 --- a/blockchain/block/utils_test.go +++ b/blockchain/block/utils_test.go @@ -33,7 +33,7 @@ func TestBody_CalculateTxRoot(t *testing.T) { SetNonce(tsf.Nonce()). SetVersion(1). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size())) + sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size()), false) requireT.NoError(err) sevlps = append(sevlps, sevlp) } @@ -69,7 +69,7 @@ func TestBody_CalculateTransferAmount(t *testing.T) { SetNonce(tsf.Nonce()). SetVersion(1). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size())) + sevlp, err := action.Sign(evlp, identityset.PrivateKey((i+1)%identityset.Size()), false) requireT.NoError(err) transferAmount.Add(transferAmount, tsf.Amount()) sevlps = append(sevlps, sevlp) diff --git a/blockchain/block/validator_test.go b/blockchain/block/validator_test.go index 17b47640b8..ff2a7684e7 100644 --- a/blockchain/block/validator_test.go +++ b/blockchain/block/validator_test.go @@ -18,6 +18,7 @@ import ( "github.com/iotexproject/iotex-core/action" "github.com/iotexproject/iotex-core/action/protocol" + "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/state" "github.com/iotexproject/iotex-core/test/identityset" "github.com/iotexproject/iotex-core/testutil" @@ -27,6 +28,9 @@ func TestValidator(t *testing.T) { require := require.New(t) ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, genesis.Default), protocol.BlockCtx{ + BlockHeight: 1, + })) blk := &Block{} v := NewValidator(nil) diff --git a/blockchain/blockchain.go b/blockchain/blockchain.go index f117983c8b..f82d4394e6 100644 --- a/blockchain/blockchain.go +++ b/blockchain/blockchain.go @@ -384,7 +384,7 @@ func (bc *blockchain) MintNewBlock(timestamp time.Time) (*block.Block, error) { blockBuilder, err := bc.bbf.NewBlockBuilder( ctx, func(elp action.Envelope) (action.SealedEnvelope, error) { - return action.Sign(elp, minterPrivateKey) + return action.Sign(elp, minterPrivateKey, protocol.MustGetFeatureCtx(ctx).UseCorrectSigner) }, ) if err != nil { diff --git a/blockchain/integrity/integrity_test.go b/blockchain/integrity/integrity_test.go index dfb00c96e8..05cd966262 100644 --- a/blockchain/integrity/integrity_test.go +++ b/blockchain/integrity/integrity_test.go @@ -737,7 +737,7 @@ func TestBlockchain_MintNewBlock(t *testing.T) { SetNonce(1). SetGasLimit(100000). SetGasPrice(big.NewInt(10)).Build() - selp1, err := action.Sign(elp1, identityset.PrivateKey(0)) + selp1, err := action.Sign(elp1, identityset.PrivateKey(0), false) require.NoError(t, err) require.NoError(t, ap.Add(ctx, selp1)) // This execution should not be included in block because block is out of gas @@ -745,7 +745,7 @@ func TestBlockchain_MintNewBlock(t *testing.T) { SetNonce(2). SetGasLimit(100000). SetGasPrice(big.NewInt(10)).Build() - selp2, err := action.Sign(elp2, identityset.PrivateKey(0)) + selp2, err := action.Sign(elp2, identityset.PrivateKey(0), false) require.NoError(t, err) require.NoError(t, ap.Add(ctx, selp2)) @@ -1875,7 +1875,7 @@ func deployXrc20(bc blockchain.Blockchain, dao blockdao.BlockDAO, ap actpool.Act SetNonce(3). SetGasLimit(1000000). SetGasPrice(big.NewInt(testutil.TestGasPriceInt64)).Build() - selp, err := action.Sign(elp, genesisPriKey) + selp, err := action.Sign(elp, genesisPriKey, false) require.NoError(err) require.NoError(ap.Add(context.Background(), selp)) @@ -2022,7 +2022,7 @@ func makeTransfer(contract string, bc blockchain.Blockchain, ap actpool.ActPool, SetNonce(4). SetGasLimit(1000000). SetGasPrice(big.NewInt(testutil.TestGasPriceInt64)).Build() - selp, err := action.Sign(elp, genesisPriKey) + selp, err := action.Sign(elp, genesisPriKey, false) require.NoError(err) require.NoError(ap.Add(context.Background(), selp)) blk, err := bc.MintNewBlock(testutil.TimestampNow()) diff --git a/chainservice/chainservice.go b/chainservice/chainservice.go index 941ea043c2..203dac9733 100644 --- a/chainservice/chainservice.go +++ b/chainservice/chainservice.go @@ -28,6 +28,7 @@ import ( "github.com/iotexproject/iotex-core/blockchain" "github.com/iotexproject/iotex-core/blockchain/block" "github.com/iotexproject/iotex-core/blockchain/blockdao" + "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/blockindex" "github.com/iotexproject/iotex-core/blockindex/contractstaking" "github.com/iotexproject/iotex-core/blocksync" @@ -115,6 +116,9 @@ func (cs *ChainService) HandleAction(ctx context.Context, actPb *iotextypes.Acti return err } ctx = protocol.WithRegistry(ctx, cs.registry) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, cs.chain.Genesis()), protocol.BlockCtx{ + BlockHeight: cs.chain.TipHeight() + 1, + })) err = cs.actpool.Add(ctx, act) if err != nil { log.L().Debug(err.Error()) diff --git a/e2etest/bigint_test.go b/e2etest/bigint_test.go index ead36d90a4..69fb98e12e 100644 --- a/e2etest/bigint_test.go +++ b/e2etest/bigint_test.go @@ -145,9 +145,13 @@ func prepareAction(bc blockchain.Blockchain, sf factory.Factory, ap actpool.ActP func prepare(bc blockchain.Blockchain, sf factory.Factory, ap actpool.ActPool, elp action.Envelope, r *require.Assertions) (*block.Block, error) { priKey, err := crypto.HexStringToPrivateKey(_executorPriKey) r.NoError(err) - selp, err := action.Sign(elp, priKey) + selp, err := action.Sign(elp, priKey, false) r.NoError(err) - r.Error(ap.Add(context.Background(), selp)) + ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: 1, + })) + r.Error(ap.Add(ctx, selp)) blk, err := bc.MintNewBlock(testutil.TimestampNow()) r.NoError(err) // when validate/commit a blk, the workingset and receipts of blk should be nil diff --git a/e2etest/contract_staking_test.go b/e2etest/contract_staking_test.go index 9d4b20ec70..e0259658a1 100644 --- a/e2etest/contract_staking_test.go +++ b/e2etest/contract_staking_test.go @@ -1989,7 +1989,7 @@ func deployContracts( SetGasLimit(gasLimit). SetGasPrice(gasPrice). Build() - selp, err := action.Sign(elp, sk) + selp, err := action.Sign(elp, sk, false) r.NoError(err) err = ap.Add(context.Background(), selp) r.NoError(err) @@ -2053,7 +2053,7 @@ func writeContract(bc blockchain.Blockchain, SetGasLimit(gasLimit). SetGasPrice(gasPrice). Build() - selp, err := action.Sign(elp, sk) + selp, err := action.Sign(elp, sk, false) r.NoError(err) err = ap.Add(context.Background(), selp) r.NoError(err) diff --git a/e2etest/local_transfer_test.go b/e2etest/local_transfer_test.go index dee9273f9c..97de742b3d 100644 --- a/e2etest/local_transfer_test.go +++ b/e2etest/local_transfer_test.go @@ -698,7 +698,7 @@ func TestEnforceChainID(t *testing.T) { SetNonce(c.nonce). SetGasLimit(100000). SetGasPrice(big.NewInt(1).Mul(big.NewInt(int64(i)+10), big.NewInt(unit.Qev))).Build() - selp, err := action.Sign(elp1, identityset.PrivateKey(0)) + selp, err := action.Sign(elp1, identityset.PrivateKey(0), false) require.NoError(err) // simulate API receives tx diff --git a/e2etest/native_staking_test.go b/e2etest/native_staking_test.go index fdb359c6b8..3e7fb074bf 100644 --- a/e2etest/native_staking_test.go +++ b/e2etest/native_staking_test.go @@ -91,6 +91,9 @@ func TestNativeStaking(t *testing.T) { ap := svr.ChainService(chainID).ActionPool() dao := svr.ChainService(chainID).BlockDAO() require.NotNil(bc) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, cfg.Genesis), protocol.BlockCtx{ + BlockHeight: bc.TipHeight(), + })) require.True(cfg.Genesis.IsFbkMigration(1)) @@ -151,7 +154,7 @@ func TestNativeStaking(t *testing.T) { cs1, err := action.SignedCreateStake(1, candidate1Name, vote.String(), 1, false, nil, gasLimit, gasPrice, voter1PriKey) require.NoError(err) - require.NoError(ap.Add(context.Background(), cs1)) + require.NoError(ap.Add(ctx, cs1)) cs2, err := addOneTx(action.SignedCreateStake(1, candidate1Name, vote.String(), 1, false, nil, gasLimit, gasPrice, voter2PriKey)) require.NoError(err) diff --git a/e2etest/rewarding_test.go b/e2etest/rewarding_test.go index db99c9771a..f47c3edc10 100644 --- a/e2etest/rewarding_test.go +++ b/e2etest/rewarding_test.go @@ -519,7 +519,7 @@ func injectClaim( SetGasLimit(100000). SetAction(&act).Build() - selp, err := action.Sign(elp, beneficiaryPri) + selp, err := action.Sign(elp, beneficiaryPri, false) require.NoError(t, err) bo := backoff.WithMaxRetries(backoff.NewConstantBackOff(time.Duration(retryInterval)*time.Second), uint64(retryNum)) diff --git a/e2etest/sgd_registry_test.go b/e2etest/sgd_registry_test.go index efa2c05ebd..8d687155f8 100644 --- a/e2etest/sgd_registry_test.go +++ b/e2etest/sgd_registry_test.go @@ -82,6 +82,9 @@ func TestSGDRegistry(t *testing.T) { r.NoError(ep.Register(registry)) r.NoError(bc.Start(ctx)) ctx = genesis.WithGenesisContext(ctx, cfg.Genesis) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(ctx, protocol.BlockCtx{ + BlockHeight: bc.TipHeight(), + })) r.NoError(sf.Start(ctx)) defer r.NoError(bc.Stop(ctx)) @@ -93,7 +96,7 @@ func TestSGDRegistry(t *testing.T) { r.NoError(err) deployHash, err := exec.Hash() r.NoError(err) - r.NoError(ap.Add(context.Background(), exec)) + r.NoError(ap.Add(ctx, exec)) blk, err := bc.MintNewBlock(fixedTime) r.NoError(err) r.NoError(bc.CommitBlock(blk)) @@ -237,7 +240,7 @@ func TestSGDRegistry(t *testing.T) { r.NoError(err) exec, err = action.SignedExecution(contractAddress, _execPriKey, atomic.AddUint64(&nonce, 1), big.NewInt(0), 10000000, big.NewInt(9000000000000), data) r.NoError(err) - r.NoError(ap.Add(context.Background(), exec)) + r.NoError(ap.Add(ctx, exec)) blk, err = bc.MintNewBlock(fixedTime) r.NoError(err) r.NoError(bc.CommitBlock(blk)) diff --git a/e2etest/staking_test.go b/e2etest/staking_test.go index 316aeeac8a..c2072e5c01 100644 --- a/e2etest/staking_test.go +++ b/e2etest/staking_test.go @@ -55,6 +55,9 @@ func TestStakingContract(t *testing.T) { registry := svr.ChainService(chainID).Registry() require.NotNil(bc) require.NotNil(registry) + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: bc.TipHeight(), + })) admin := identityset.PrivateKey(26) state0 := hash.BytesToHash160(identityset.Address(26).Bytes()) s := &state.Account{} @@ -70,7 +73,7 @@ func TestStakingContract(t *testing.T) { deployHash, err := ex.Hash() require.NoError(err) - require.NoError(ap.Add(context.Background(), ex)) + require.NoError(ap.Add(ctx, ex)) blk, err := bc.MintNewBlock(fixedTime) require.NoError(err) require.NoError(bc.CommitBlock(blk)) @@ -93,7 +96,7 @@ func TestStakingContract(t *testing.T) { require.True(len(data) > 0) ex, err := action.SignedExecution(r.ContractAddress, sk, nonce+1, fixedAmount, 1000000, big.NewInt(testutil.TestGasPriceInt64), data) require.NoError(err) - require.NoError(ap.Add(context.Background(), ex)) + require.NoError(ap.Add(ctx, ex)) } blk, err = bc.MintNewBlock(fixedTime) require.NoError(err) diff --git a/e2etest/util.go b/e2etest/util.go index 3cea1fa4dc..64448cb001 100644 --- a/e2etest/util.go +++ b/e2etest/util.go @@ -16,8 +16,10 @@ import ( "github.com/pkg/errors" "github.com/iotexproject/iotex-core/action" + "github.com/iotexproject/iotex-core/action/protocol" "github.com/iotexproject/iotex-core/actpool" "github.com/iotexproject/iotex-core/blockchain" + "github.com/iotexproject/iotex-core/blockchain/genesis" "github.com/iotexproject/iotex-core/pkg/unit" "github.com/iotexproject/iotex-core/test/identityset" "github.com/iotexproject/iotex-core/testutil" @@ -25,6 +27,9 @@ import ( func addTestingTsfBlocks(bc blockchain.Blockchain, ap actpool.ActPool) error { ctx := context.Background() + ctx = protocol.WithFeatureCtx(protocol.WithBlockCtx(genesis.WithGenesisContext(ctx, bc.Genesis()), protocol.BlockCtx{ + BlockHeight: bc.TipHeight() + 1, + })) addOneTx := func(tx action.SealedEnvelope, err error) error { if err != nil { return err diff --git a/gasstation/gasstattion_test.go b/gasstation/gasstattion_test.go index e89bc99194..f709a427b1 100644 --- a/gasstation/gasstattion_test.go +++ b/gasstation/gasstattion_test.go @@ -105,7 +105,7 @@ func TestSuggestGasPriceForUserAction(t *testing.T) { SetNonce(uint64(i) + 1). SetGasLimit(100000). SetGasPrice(big.NewInt(1).Mul(big.NewInt(int64(i)+10), big.NewInt(unit.Qev))).Build() - selp1, err := action.Sign(elp1, identityset.PrivateKey(0)) + selp1, err := action.Sign(elp1, identityset.PrivateKey(0), false) require.NoError(t, err) require.NoError(t, ap.Add(context.Background(), selp1)) diff --git a/ioctl/cmd/action/action.go b/ioctl/cmd/action/action.go index bb502b0d5f..69a60ff43a 100644 --- a/ioctl/cmd/action/action.go +++ b/ioctl/cmd/action/action.go @@ -273,7 +273,7 @@ func SendAction(elp action.Envelope, signer string) error { elp.SetNonce(nonce) } - sealed, err := action.Sign(elp, prvKey) + sealed, err := action.Sign(elp, prvKey, false) prvKey.Zero() if err != nil { return output.NewError(output.CryptoError, "failed to sign action", err) diff --git a/ioctl/newcmd/action/action.go b/ioctl/newcmd/action/action.go index 430d984ee3..ed2f4cc3b6 100644 --- a/ioctl/newcmd/action/action.go +++ b/ioctl/newcmd/action/action.go @@ -355,7 +355,7 @@ func SendAction(client ioctl.Client, elp.SetNonce(nonce) } - sealed, err := action.Sign(elp, sk) + sealed, err := action.Sign(elp, sk, false) if err != nil { return errors.Wrap(err, "failed to sign action") } diff --git a/state/factory/factory_test.go b/state/factory/factory_test.go index 8b229e422b..52947e0860 100644 --- a/state/factory/factory_test.go +++ b/state/factory/factory_test.go @@ -259,7 +259,7 @@ func testCandidates(sf Factory, t *testing.T) { elp := bd.SetGasLimit(uint64(100000)). SetGasPrice(big.NewInt(10)). SetAction(act).Build() - selp, err := action.Sign(elp, identityset.PrivateKey(27)) + selp, err := action.Sign(elp, identityset.PrivateKey(27), false) require.NoError(t, err) require.NotNil(t, selp) @@ -472,7 +472,7 @@ func testState(sf Factory, t *testing.T) { require.NoError(t, err) bd := &action.EnvelopeBuilder{} elp := bd.SetAction(tsf).SetGasLimit(20000).SetNonce(1).Build() - selp, err := action.Sign(elp, priKeyA) + selp, err := action.Sign(elp, priKeyA, false) require.NoError(t, err) ctx = protocol.WithBlockCtx( ctx, @@ -536,7 +536,7 @@ func testHistoryState(sf Factory, t *testing.T, statetx, archive bool) { require.NoError(t, err) bd := &action.EnvelopeBuilder{} elp := bd.SetAction(tsf).SetGasLimit(20000).SetNonce(1).Build() - selp, err := action.Sign(elp, priKeyA) + selp, err := action.Sign(elp, priKeyA, false) require.NoError(t, err) ctx = protocol.WithBlockCtx( ctx, @@ -620,7 +620,7 @@ func testFactoryStates(sf Factory, t *testing.T) { require.NoError(t, err) bd := &action.EnvelopeBuilder{} elp := bd.SetAction(tsf).SetGasLimit(20000).SetNonce(1).Build() - selp, err := action.Sign(elp, priKeyA) + selp, err := action.Sign(elp, priKeyA, false) require.NoError(t, err) ctx = protocol.WithBlockCtx( ctx, @@ -789,7 +789,7 @@ func testNonce(ctx context.Context, sf Factory, t *testing.T) { require.NoError(t, err) bd := &action.EnvelopeBuilder{} elp := bd.SetAction(tx).SetNonce(0).SetGasLimit(20000).Build() - selp, err := action.Sign(elp, priKeyA) + selp, err := action.Sign(elp, priKeyA, false) require.NoError(t, err) ctx = protocol.WithBlockCtx(ctx, @@ -825,7 +825,7 @@ func testNonce(ctx context.Context, sf Factory, t *testing.T) { require.NoError(t, err) bd = &action.EnvelopeBuilder{} elp = bd.SetAction(tx).SetNonce(1).SetGasLimit(20000).Build() - selp, err = action.Sign(elp, priKeyA) + selp, err = action.Sign(elp, priKeyA, false) require.NoError(t, err) blk, err := block.NewTestingBuilder(). @@ -1000,14 +1000,14 @@ func testCommit(factory Factory, t *testing.T) { require.NoError(err) bd := &action.EnvelopeBuilder{} elp := bd.SetNonce(1).SetAction(tx1).Build() - selp1, err := action.Sign(elp, priKeyA) + selp1, err := action.Sign(elp, priKeyA, false) require.NoError(err) tx2, err := action.NewTransfer(uint64(1), big.NewInt(20), a, nil, uint64(100000), big.NewInt(0)) require.NoError(err) bd = &action.EnvelopeBuilder{} elp = bd.SetNonce(1).SetAction(tx2).Build() - selp2, err := action.Sign(elp, priKeyB) + selp2, err := action.Sign(elp, priKeyB, false) require.NoError(err) blkHash, err := selp1.Hash() @@ -1112,7 +1112,7 @@ func testNewBlockBuilder(factory Factory, t *testing.T) { require.NoError(err) bd := &action.EnvelopeBuilder{} elp := bd.SetNonce(1).SetAction(tx1).Build() - selp1, err := action.Sign(elp, priKeyA) + selp1, err := action.Sign(elp, priKeyA, false) require.NoError(err) accMap[identityset.Address(28).String()] = []action.SealedEnvelope{selp1} @@ -1125,7 +1125,7 @@ func testNewBlockBuilder(factory Factory, t *testing.T) { require.NoError(err) bd = &action.EnvelopeBuilder{} elp = bd.SetNonce(1).SetAction(tx2).Build() - selp2, err := action.Sign(elp, priKeyB) + selp2, err := action.Sign(elp, priKeyB, false) require.NoError(err) accMap[identityset.Address(29).String()] = []action.SealedEnvelope{selp2} ctrl := gomock.NewController(t) diff --git a/state/factory/workingset_test.go b/state/factory/workingset_test.go index 887120a764..7b821dd1d9 100644 --- a/state/factory/workingset_test.go +++ b/state/factory/workingset_test.go @@ -367,7 +367,7 @@ func makeTransferAction(t *testing.T, nonce uint64) action.SealedEnvelope { SetChainID(1). SetVersion(1). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey(28)) + sevlp, err := action.Sign(evlp, identityset.PrivateKey(28), false) require.NoError(t, err) return sevlp } @@ -381,7 +381,7 @@ func makeRewardAction(t *testing.T) action.SealedEnvelope { SetGasLimit(grant.GasLimit()). SetAction(&grant). Build() - sevlp, err := action.Sign(evlp, identityset.PrivateKey(28)) + sevlp, err := action.Sign(evlp, identityset.PrivateKey(28), false) require.NoError(t, err) return sevlp } diff --git a/tools/actioninjector.v2/internal/client/client_test.go b/tools/actioninjector.v2/internal/client/client_test.go index 575b3937d3..1a70811fc3 100644 --- a/tools/actioninjector.v2/internal/client/client_test.go +++ b/tools/actioninjector.v2/internal/client/client_test.go @@ -48,7 +48,7 @@ func TestClient(t *testing.T) { require.NoError(err) bd := &action.EnvelopeBuilder{} elp := bd.SetNonce(1).SetAction(tx).Build() - selp, err := action.Sign(elp, priKeyA) + selp, err := action.Sign(elp, priKeyA, false) require.NoError(err) bc := mock_blockchain.NewMockBlockchain(mockCtrl) diff --git a/tools/bot/server/bot/execution.go b/tools/bot/server/bot/execution.go index a6f26f88d6..9a38cad7de 100644 --- a/tools/bot/server/bot/execution.go +++ b/tools/bot/server/bot/execution.go @@ -169,7 +169,7 @@ func (s *Execution) exec(pri crypto.PrivateKey) (txhash string, err error) { SetGasLimit(tx.GasLimit()). SetGasPrice(gasprice). SetAction(tx).Build() - selp, err := action.Sign(elp, pri) + selp, err := action.Sign(elp, pri, false) if err != nil { return } diff --git a/tools/bot/server/bot/xrc20.go b/tools/bot/server/bot/xrc20.go index 66727c0351..a0c7d97180 100644 --- a/tools/bot/server/bot/xrc20.go +++ b/tools/bot/server/bot/xrc20.go @@ -138,7 +138,7 @@ func (s *Xrc20) transfer(pri crypto.PrivateKey) (txhash string, err error) { SetGasLimit(tx.GasLimit()). SetGasPrice(gasprice). SetAction(tx).Build() - selp, err := action.Sign(elp, pri) + selp, err := action.Sign(elp, pri, false) if err != nil { return } diff --git a/tools/executiontester/blockchain/contract.go b/tools/executiontester/blockchain/contract.go index b08d349a1d..e68a7c1b49 100644 --- a/tools/executiontester/blockchain/contract.go +++ b/tools/executiontester/blockchain/contract.go @@ -230,7 +230,7 @@ func (c *contract) Transact(data []byte, readOnly bool) (string, error) { return "", crypto.ErrInvalidKey } defer prvKey.Zero() - selp, err := action.Sign(elp, prvKey) + selp, err := action.Sign(elp, prvKey, false) prvKey.Zero() if err != nil { return "", err diff --git a/tools/util/injectorutil.go b/tools/util/injectorutil.go index 391f173012..38114b1589 100644 --- a/tools/util/injectorutil.go +++ b/tools/util/injectorutil.go @@ -573,7 +573,7 @@ func createSignedTransfer( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(transfer).Build() - selp, err := action.Sign(elp, sender.PriKey) + selp, err := action.Sign(elp, sender.PriKey, false) if err != nil { return action.SealedEnvelope{}, nil, errors.Wrapf(err, "failed to sign transfer %v", elp) } @@ -603,7 +603,7 @@ func createSignedExecution( SetGasPrice(gasPrice). SetGasLimit(gasLimit). SetAction(execution).Build() - selp, err := action.Sign(elp, executor.PriKey) + selp, err := action.Sign(elp, executor.PriKey, false) if err != nil { return action.SealedEnvelope{}, nil, errors.Wrapf(err, "failed to sign execution %v", elp) } @@ -631,7 +631,7 @@ func createSignedStake( SetGasLimit(gasLimit). SetAction(createStake). Build() - selp, err := action.Sign(elp, executor.PriKey) + selp, err := action.Sign(elp, executor.PriKey, false) if err != nil { return action.SealedEnvelope{}, nil, err }