-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
core/types: correct chainId check for pragueSigner #31032
Conversation
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.
We should change this is all signers since 2930 if we want to make this change. It seems like the right thing to do -- @fjl added this line in dd2483c, maybe he can chime in if it's okay to switch over all other instances of this?
IIUC, this new check avoids derefing a nil chain id and disallows chain id 0. Since SignatureValues
is only used by WithSignature
, this shouldn't affect any aspects of consensus. But since chain id 0 txs are not allowed post EIP-155, it seems correct to make this update.
I have checked this, and it's an API change for users. Block processing can never hit a tx with The |
I prefer to use nil check, because signer := types.NewCancunSigner(chainId)
tx := types.NewTx(&types.BlobTx{
// whatever the chainId here is, nil or non-nil, it will be set by the signer
ChainID: uint256.MustFromBig(chainId),
})
signedTx, err := types.SignTx(tx, signer, privateKey) // it will set the chainId internally
if err != nil {
panic(err)
} |
using the zero value check is not a bad idea since it's not a breaking change. Just reverted the change, and updated the pragueSigner |
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.
SGTM
Use zero value check for the pragueSigner
This aligns with cancunSigner and londonSigner as well.