Call processBeaconBlockRoot before processing txs(EIP-4788) (#1822)

This commit is contained in:
andri lim 2023-10-19 06:55:50 +07:00 committed by GitHub
parent 6199ddc1c9
commit b8e3fc5859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 34 deletions

View File

@ -16,12 +16,9 @@ newBlockchainTests
+ withdrawalsAddressBounds.json OK
+ withdrawalsAmountBounds.json OK
+ withdrawalsIndexBounds.json OK
+ withdrawalsRLPlessElements.json OK
+ withdrawalsRLPmoreElements.json OK
+ withdrawalsRLPnotAList.json OK
+ withdrawalsValidatorIndexBounds.json OK
```
OK: 18/18 Fail: 0/18 Skip: 0/18
OK: 15/15 Fail: 0/15 Skip: 0/15
## bcArrowGlacierToMerge
```diff
+ difficultyFormula.json OK
@ -103,21 +100,6 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
+ SuicideIssue.json OK
```
OK: 3/4 Fail: 0/4 Skip: 1/4
## bcForgedTest
```diff
+ bcBlockRLPAsList.json OK
+ bcBlockRLPPrefixed0000.json OK
+ bcBlockRLPRandomByte.json OK
+ bcBlockRLPTooLarge.json OK
+ bcBlockRLPZeroByte.json OK
+ bcForkBlockTest.json OK
+ bcInvalidRLPTest_BLOCK.json OK
+ bcInvalidRLPTest_TRANSACT.json OK
+ bcTransactRLPRandomByte.json OK
+ bcTransactRLPTooLarge.json OK
+ bcTransactRLPZeroByte.json OK
```
OK: 11/11 Fail: 0/11 Skip: 0/11
## bcForkStressTest
```diff
+ AmIOnEIP150.json OK
@ -3458,4 +3440,4 @@ OK: 11/11 Fail: 0/11 Skip: 0/11
OK: 1/1 Fail: 0/1 Skip: 0/1
---TOTAL---
OK: 2946/3052 Fail: 0/3052 Skip: 106/3052
OK: 2932/3038 Fail: 0/3038 Skip: 106/3038

View File

@ -682,6 +682,7 @@ OK: 13/13 Fail: 0/13 Skip: 0/13
## stEIP158Specific
```diff
+ CALL_OneVCallSuicide.json OK
+ CALL_OneVCallSuicide2.json OK
+ CALL_ZeroVCallSuicide.json OK
+ EXP_Empty.json OK
+ EXTCODESIZE_toEpmty.json OK
@ -689,7 +690,7 @@ OK: 13/13 Fail: 0/13 Skip: 0/13
+ callToEmptyThenCallError.json OK
+ vitalikTransactionTest.json OK
```
OK: 7/7 Fail: 0/7 Skip: 0/7
OK: 8/8 Fail: 0/8 Skip: 0/8
## stEIP2930
```diff
+ addressOpcodes.json OK
@ -765,9 +766,12 @@ OK: 12/12 Fail: 0/12 Skip: 0/12
+ extCodeHashDELEGATECALL.json OK
+ extCodeHashDeletedAccount.json OK
+ extCodeHashDeletedAccount1.json OK
+ extCodeHashDeletedAccount1Cancun.json OK
+ extCodeHashDeletedAccount2.json OK
+ extCodeHashDeletedAccount2Cancun.json OK
+ extCodeHashDeletedAccount3.json OK
+ extCodeHashDeletedAccount4.json OK
+ extCodeHashDeletedAccountCancun.json OK
+ extCodeHashDynamicArgument.json OK
+ extCodeHashInInitCode.json OK
+ extCodeHashMaxCodeSize.json OK
@ -779,9 +783,10 @@ OK: 12/12 Fail: 0/12 Skip: 0/12
+ extCodeHashSelfInInit.json OK
+ extCodeHashSubcallOOG.json OK
+ extCodeHashSubcallSuicide.json OK
+ extCodeHashSubcallSuicideCancun.json OK
+ extcodehashEmpty.json OK
```
OK: 32/32 Fail: 0/32 Skip: 0/32
OK: 36/36 Fail: 0/36 Skip: 0/36
## stHomesteadSpecific
```diff
+ contractCreationOOGdontLeaveEmptyContract.json OK
@ -1030,9 +1035,10 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
+ modexp.json OK
+ modexpTests.json OK
+ precompsEIP2929.json OK
+ precompsEIP2929Cancun.json OK
+ sec80.json OK
```
OK: 9/9 Fail: 0/9 Skip: 0/9
OK: 10/10 Fail: 0/10 Skip: 0/10
## stPreCompiledContracts2
```diff
+ CALLBlake2f.json OK
@ -2394,6 +2400,10 @@ OK: 12/14 Fail: 0/14 Skip: 2/14
+ InternalCallHittingGasLimitSuccess.json OK
+ InternlCallStoreClearsOOG.json OK
+ InternlCallStoreClearsSucces.json OK
+ NoSrcAccount.json OK
+ NoSrcAccount1559.json OK
+ NoSrcAccountCreate.json OK
+ NoSrcAccountCreate1559.json OK
+ Opcodes_TransactionInit.json OK
+ OverflowGasRequire2.json OK
+ PointAtInfinityECRecover.json OK
@ -2413,7 +2423,7 @@ OK: 12/14 Fail: 0/14 Skip: 2/14
+ TransactionToItself.json OK
+ ValueOverflow.json OK
```
OK: 31/31 Fail: 0/31 Skip: 0/31
OK: 35/35 Fail: 0/35 Skip: 0/35
## stTransitionTest
```diff
+ createNameRegistratorPerTxsAfter.json OK
@ -2879,4 +2889,4 @@ OK: 1/3 Fail: 0/3 Skip: 2/3
OK: 11/11 Fail: 0/11 Skip: 0/11
---TOTAL---
OK: 2514/2617 Fail: 0/2617 Skip: 103/2617
OK: 2524/2627 Fail: 0/2627 Skip: 103/2627

View File

@ -35,10 +35,6 @@ proc processTransactions*(vmState: BaseVMState;
vmState.receipts = newSeq[Receipt](transactions.len)
vmState.cumulativeGasUsed = 0
if header.parentBeaconBlockRoot.isSome:
vmState.processBeaconBlockRoot(header.parentBeaconBlockRoot.get).isOkOr:
return err(error)
for txIndex, tx in transactions:
var sender: EthAddress
if not tx.getSender(sender):
@ -70,6 +66,11 @@ proc procBlkPreamble(vmState: BaseVMState;
if header.parentBeaconBlockRoot.isSome:
raise ValidationError.newException("Pre-Cancun block header must not have parentBeaconBlockRoot")
if header.parentBeaconBlockRoot.isSome:
let r = vmState.processBeaconBlockRoot(header.parentBeaconBlockRoot.get)
if r.isErr:
error("error in processing beaconRoot", err=r.error)
if header.txRoot != EMPTY_ROOT_HASH:
if body.transactions.len == 0:
debug "No transactions in body",

View File

@ -76,6 +76,19 @@ proc dumpAccounts*(vmState: BaseVMState): JsonNode =
for ac in vmState.stateDB.addresses:
result[ac.toHex] = dumpAccount(vmState.stateDB, ac)
proc debugAccounts*(stateDB: AccountsCache, addresses: openArray[string]): string =
var
accounts = newJObject()
accountList = newSeq[EthAddress]()
for address in addresses:
accountList.add hexToByteArray[20](address)
for ac in accountList:
accounts[ac.toHex] = dumpAccount(stateDB, ac)
accounts.pretty
proc debugAccounts*(vmState: BaseVMState): string =
var
accounts = newJObject()
@ -145,15 +158,15 @@ proc debug*(tx: Transaction): string =
result.add "accessList : " & $tx.accessList & "\n"
result.add "maxFeePerBlobGas: " & $tx.maxFeePerBlobGas & "\n"
result.add "versionedHashes.len: " & $tx.versionedHashes.len & "\n"
if tx.networkPayload.isNil:
result.add "networkPaylod : nil\n"
result.add "networkPaylod : nil\n"
else:
result.add "networkPaylod : \n"
result.add " - blobs : " & $tx.networkPayload.blobs.len & "\n"
result.add " - commitments : " & $tx.networkPayload.commitments.len & "\n"
result.add " - proofs : " & $tx.networkPayload.proofs.len & "\n"
result.add "V : " & $tx.V & "\n"
result.add "R : " & $tx.R & "\n"
result.add "S : " & $tx.S & "\n"

View File

@ -139,6 +139,10 @@ proc parseBlocks(blocks: JsonNode): seq[TestBlock] =
doAssert(noError == false, "NOT A VALID TEST CASE")
of "withdrawals":
t.withdrawals = parseWithdrawals(value)
of "rlp_decoded":
# this field is intended for client who
# doesn't support rlp encoding(e.g. evmone)
discard
else:
doAssert("expectException" in key, key)
t.hasException = true
@ -387,9 +391,9 @@ proc testFixture(node: JsonNode, testStatusIMPL: var TestStatus, debugMode = fal
proc blockchainJsonMain*(debugMode = false) =
const
legacyFolder = "eth_tests/LegacyTests/Constantinople/BlockchainTests"
#newFolder = "eth_tests/BlockchainTests"
newFolder = "eth_tests/BlockchainTests"
#newFolder = "eth_tests/EIPTests/BlockchainTests"
newFolder = "eth_tests/EIPTests/Pyspecs/cancun"
#newFolder = "eth_tests/EIPTests/Pyspecs/cancun"
let res = loadKzgTrustedSetup()
if res.isErr: