Skip to content
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

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

islishude
Copy link
Contributor

@islishude islishude commented Jan 15, 2025

Use zero value check for the pragueSigner

This aligns with cancunSigner and londonSigner as well.

Copy link
Member

@lightclient lightclient left a 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.

@fjl
Copy link
Contributor

fjl commented Jan 15, 2025

I have checked this, and it's an API change for users. Block processing can never hit a tx with ChainID == nil because the decoding of transactions doesn't allow it (and SignatureValues isn't used as you say). It can only happen for transactions which are being signed by a user. There, we specifically allow ChainID == 0 to mean that you want the chain ID to be auto-set during signing. It's OK to also allow nil for this, but the intended behavior needs to remain in place.

The pragueSigner handles this incorrectly right now and we should change it to restore this behavior.

@islishude
Copy link
Contributor Author

I prefer to use nil check, because types.SignTx always set the chainId internally

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)
}

@islishude
Copy link
Contributor Author

islishude commented Jan 16, 2025

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

@islishude islishude changed the title core/types: update chainId check to handle nil values core/types: correct chainId check for pragueSigner Jan 16, 2025
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

@fjl fjl merged commit 17199da into ethereum:master Jan 20, 2025
1 of 2 checks passed
@islishude islishude deleted the fix-cancun-signer branch January 20, 2025 17:31
tnasu added a commit to tnasu/kaia that referenced this pull request Jan 29, 2025
tnasu added a commit to tnasu/kaia that referenced this pull request Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants