-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[action] use correct signer for web3 action #3937
Conversation
SonarCloud Quality Gate failed. 0 Bugs No Coverage information Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Codecov Report
@@ Coverage Diff @@
## master #3937 +/- ##
==========================================
+ Coverage 75.38% 76.09% +0.71%
==========================================
Files 303 328 +25
Lines 25923 27968 +2045
==========================================
+ Hits 19541 21283 +1742
- Misses 5360 5588 +228
- Partials 1022 1097 +75
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
if useLondontSigner { | ||
signer = types.NewLondonSigner(big.NewInt(int64(chainID))) | ||
} else { | ||
signer = types.NewEIP155Signer(big.NewInt(int64(chainID))) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create a util function to generate signer
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer types.Signer
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer types.Signer
@@ -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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer types.Signer
signature []byte | ||
srcAddress address.Address | ||
hash hash.Hash256 | ||
useLondonSigner bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer
@@ -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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signer = nil
Description
as title.
Fixes #(issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Checklist: