Repository navigation
fix(specs): check chain id - #3000
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## forks/amsterdam #3000 +/- ##
===================================================
+ Coverage 92.80% 93.19% +0.38%
===================================================
Files 620 624 +4
Lines 36728 36926 +198
Branches 3345 3377 +32
===================================================
+ Hits 34087 34413 +326
+ Misses 1780 1716 -64
+ Partials 861 797 -64
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
LouisTsai-Csie
left a comment
There was a problem hiding this comment.
Leave one question, thank you
| if isinstance(tx, LegacyTransaction): | ||
| if tx.v == 27 or tx.v == 28: | ||
| return None | ||
| return U64((tx.v - U256(35)) >> U256(1)) | ||
| else: | ||
| return tx.chain_id |
There was a problem hiding this comment.
| if isinstance(tx, LegacyTransaction): | |
| if tx.v == 27 or tx.v == 28: | |
| return None | |
| return U64((tx.v - U256(35)) >> U256(1)) | |
| else: | |
| return tx.chain_id | |
| if isinstance(tx, LegacyTransaction): | |
| if tx.v == 27 or tx.v == 28: | |
| return None | |
| return U64((tx.v - U256(35)) >> U256(1)) | |
| return tx.chain_id |
Not very important suggestion.
| tx_chain_id = U64((v - U256(35)) >> U256(1)) | ||
| v = (v - U256(35)) & U256(1) | ||
| if v != 0 and v != 1: |
There was a problem hiding this comment.
Will this always be false? since v masks with U256(1), so it would always be either 0 or 1.
marioevz
left a comment
There was a problem hiding this comment.
Just one comment I think needs addressing. Thanks!
| if isinstance(tx, LegacyTransaction): | ||
| if tx.v == 27 or tx.v == 28: | ||
| return None | ||
| return U64((tx.v - U256(35)) >> U256(1)) |
There was a problem hiding this comment.
This test generates an overflow error in this line:
@pytest.mark.valid_from("Istanbul")
@pytest.mark.exception_test
def test_chainid_invalid_v(
state_test: StateTestFiller,
pre: Alloc,
chain_config: ChainConfig,
) -> None:
"""Test CHAINID opcode."""
chain_id = chain_config.chain_id
contract_address = pre.deploy_contract(Op.SSTORE(1, Op.CHAINID) + Op.STOP)
tx = Transaction(
ty=0,
chain_id=chain_id,
to=contract_address,
v=34,
r=1,
s=1,
sender=Address(0x0),
error=TransactionException.INVALID_SIGNATURE_VRS,
)
post = {
contract_address: Account(storage={1: chain_id}),
}
state_test(pre=pre, post=post, tx=tx)We still need to check that the v value is equal to 35 or greater. Same for the rest of the forks I believe.
e0a625f to
9d2a0b8
Compare
Co-authored-by: Mario Vega Zavala <mario.vegazavala@ethereum.org>
🗒️ Description
EELS didn't check incoming transaction's chain id
Cute Animal Picture