Skip to content

Conversation

@yihuang
Copy link
Contributor

@yihuang yihuang commented Jul 14, 2025

Closes: #280

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

Reviewers Checklist

All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.

I have...

  • added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • confirmed all author checklist items have been addressed
  • confirmed that this PR does not change production code
  • reviewed content
  • tested instructions (if applicable)
  • confirmed all CI checks have passed

@mmsqe
Copy link
Contributor

mmsqe commented Jul 14, 2025

seems there's chain id check in legacy tx

@yihuang
Copy link
Contributor Author

yihuang commented Jul 14, 2025

seems there's chain id check in legacy tx

treat 0 specially in get signer now, not ideal, but avoid changing too many code.

@yihuang
Copy link
Contributor Author

yihuang commented Jul 14, 2025

I think passing tx.ChainID to LatestSignerForChainID is not safe, we should pass the current network chainID to it.
WDYT @vladjdk @zsystm @cloudgray

@vladjdk
Copy link
Member

vladjdk commented Jul 14, 2025

@yihuang What makes you say it's not safe? Seems like LatestSignerForChainID handles nils, and if a chain doesn't allow unprotected transactions, then the ante will fail out anyways:

if !allowUnprotectedTxs {
if !ethTx.Protected() {
return errorsmod.Wrapf(
errortypes.ErrNotSupported,
"rejected unprotected ethereum transaction; please sign your transaction according to EIP-155 to protect it against replay-attacks")
}
if ethTx.ChainId().Uint64() != ethCfg.ChainID.Uint64() {
return errorsmod.Wrapf(
errortypes.ErrInvalidChainID,
"rejected ethereum transaction with incorrect chain-id; expected %d, got %d", ethCfg.ChainID, ethTx.ChainId())
}
}

@yihuang
Copy link
Contributor Author

yihuang commented Jul 14, 2025

@yihuang What makes you say it's not safe? Seems like LatestSignerForChainID handles nils, and if a chain doesn't allow unprotected transactions, then the ante will fail out anyways:

if !allowUnprotectedTxs {
if !ethTx.Protected() {
return errorsmod.Wrapf(
errortypes.ErrNotSupported,
"rejected unprotected ethereum transaction; please sign your transaction according to EIP-155 to protect it against replay-attacks")
}
if ethTx.ChainId().Uint64() != ethCfg.ChainID.Uint64() {
return errorsmod.Wrapf(
errortypes.ErrInvalidChainID,
"rejected ethereum transaction with incorrect chain-id; expected %d, got %d", ethCfg.ChainID, ethTx.ChainId())
}
}

I mean, normally the signer will recover sender from signature and check tx.chainId==network.chainId, assuing we pass network.chainId as parameter, but here we pass tx.chainId as parameter, so the second part of the verification is always true. it may not cause an immediate issue, but it's not how the API is expected to be called I think.

@vladjdk
Copy link
Member

vladjdk commented Jul 14, 2025

Ah, I think you're right. Feel free to add that change in this PR or open a new one if that makes more sense. I also don't think it'll cause any issues now, though.

@yihuang
Copy link
Contributor Author

yihuang commented Jul 15, 2025

Ah, I think you're right. Feel free to add that change in this PR or open a new one if that makes more sense. I also don't think it'll cause any issues now, though.

cyclic import if try to import "github.com/cosmos/evm/x/vm/types",
but to change the function signature, need to change cosmos-sdk,
so it's a little bit tricky here.

Copy link
Contributor

@zsystm zsystm left a comment

Choose a reason for hiding this comment

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

LGTM.

@vladjdk vladjdk merged commit 16ec2d0 into cosmos:main Jul 15, 2025
15 checks passed
yihuang added a commit to yihuang/evm that referenced this pull request Jul 31, 2025
* fix: non-eip-155 tx panic when get signer

Closes: cosmos#280

* treat zero chainID differently

* fix zero check

* fix comment

* fix conditon
mmsqe pushed a commit to mmsqe/evm that referenced this pull request Aug 2, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 6, 2025
* fix: non-eip-155 tx panic when get signer (#282)

* fix: non-eip-155 tx panic when get signer

Closes: #280

* treat zero chainID differently

* fix zero check

* fix comment

* fix conditon

* Update api/cosmos/evm/vm/v1/msg.go

Co-authored-by: mmsqe <tqd0800210105@gmail.com>

---------

Co-authored-by: mmsqe <tqd0800210105@gmail.com>
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
* fix: non-eip-155 tx panic when get signer

Closes: cosmos#280

* treat zero chainID differently

* fix zero check

* fix comment

* fix conditon
zsystm pushed a commit to zsystm/evm that referenced this pull request Nov 2, 2025
* fix: non-eip-155 tx panic when get signer (cosmos#282)

* fix: non-eip-155 tx panic when get signer

Closes: cosmos#280

* treat zero chainID differently

* fix zero check

* fix comment

* fix conditon

* Update api/cosmos/evm/vm/v1/msg.go

Co-authored-by: mmsqe <tqd0800210105@gmail.com>

---------

Co-authored-by: mmsqe <tqd0800210105@gmail.com>
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.

[Bug]: non-eip-155 tx panic when getting signer

4 participants