Fix t8n regression: Legacy Tx should not validate chainId (#2858)

This commit is contained in:
andri lim 2024-11-21 21:57:22 +07:00 committed by GitHub
parent 453cb2f33e
commit a57a887269
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 11 deletions

View File

@ -13,7 +13,7 @@
import
eth/common,
results,
".."/[aristo_desc, aristo_get, aristo_utils, aristo_compute, aristo_serialise]
".."/[aristo_desc, aristo_get, aristo_utils, aristo_serialise]
const
ChainRlpNodesNoEntry* = {

View File

@ -264,7 +264,8 @@ proc parseTxJson(txo: TxObject, chainId: ChainId): Result[Transaction, string] =
optional(accessList)
required(authorizationList)
if tx.chainId != chainId:
# Ignore chainId if txType == TxLegacy
if tx.txType > TxLegacy and tx.chainId != chainId:
return err("invalid chain id: have " & $tx.chainId & " want " & $chainId)
let eip155 = txo.protected.get(true)
@ -285,10 +286,10 @@ proc readNestedTx(rlp: var Rlp, chainId: ChainId): Result[Transaction, string] =
else:
var rr = rlpFromBytes(rlp.read(seq[byte]))
rr.read(Transaction)
if tx.chainId == chainId:
ok(tx)
else:
err("invalid chain id: have " & $tx.chainId & " want " & $chainId)
# Ignore chainId if txType == TxLegacy
if tx.txType > TxLegacy and tx.chainId != chainId:
return err("invalid chain id: have " & $tx.chainId & " want " & $chainId)
ok(tx)
except RlpError as exc:
err(exc.msg)

View File

@ -169,7 +169,7 @@ proc runTest(appDir: string, spec: TestSpec): bool =
if spec.expOut.len > 0:
if spec.expOut.endsWith(".json"):
let path = base / spec.expOut
let path = base / spec.expOut
try:
let want = json.parseFile(path)
let have = json.parseJson(res)
@ -470,7 +470,7 @@ const
name : "Revert In Create In Init Create2",
base : "testdata/00-512",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
),
output: T8nOutput(alloc: true, result: true),
expOut: "exp.json",
@ -479,7 +479,7 @@ const
name : "Revert In Create In Init",
base : "testdata/00-513",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
),
output: T8nOutput(alloc: true, result: true),
expOut: "exp.json",
@ -488,7 +488,7 @@ const
name : "Init collision 3",
base : "testdata/00-514",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
"alloc.json", "txs.rlp", "env.json", "Berlin", "0"
),
output: T8nOutput(alloc: true, result: true),
expOut: "exp.json",
@ -506,7 +506,7 @@ const
name : "GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast_Frontier",
base : "testdata/00-516",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Frontier", "5000000000000000000", "0"
"alloc.json", "txs.rlp", "env.json", "Frontier", "5000000000000000000"
),
output: T8nOutput(alloc: true, result: true),
expOut: "exp.json",