fixes EIP2929 CALL opCode
This commit is contained in:
parent
dbb336fa07
commit
f6c44ffcc0
|
@ -53,8 +53,6 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
|||
+ wrongDifficulty.json OK
|
||||
+ wrongGasLimit.json OK
|
||||
+ wrongGasUsed.json OK
|
||||
+ wrongMixHash.json OK
|
||||
+ wrongNonce.json OK
|
||||
+ wrongNumber.json OK
|
||||
+ wrongParentHash.json OK
|
||||
+ wrongParentHash2.json OK
|
||||
|
@ -64,7 +62,7 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
|||
+ wrongTransactionsTrie.json OK
|
||||
+ wrongUncleHash.json OK
|
||||
```
|
||||
OK: 23/23 Fail: 0/23 Skip: 0/23
|
||||
OK: 21/21 Fail: 0/21 Skip: 0/21
|
||||
## bcMultiChainTest
|
||||
```diff
|
||||
+ CallContractFromNotBestBlock.json OK
|
||||
|
@ -11169,4 +11167,4 @@ OK: 804/804 Fail: 0/804 Skip: 0/804
|
|||
OK: 519/519 Fail: 0/519 Skip: 0/519
|
||||
|
||||
---TOTAL---
|
||||
OK: 10904/10907 Fail: 0/10907 Skip: 3/10907
|
||||
OK: 10902/10905 Fail: 0/10905 Skip: 3/10905
|
||||
|
|
|
@ -2179,11 +2179,14 @@ OK: 56/66 Fail: 0/66 Skip: 10/66
|
|||
## stTimeConsuming
|
||||
```diff
|
||||
+ sstore_combinations_initial0.json OK
|
||||
+ sstore_combinations_initial0_2.json OK
|
||||
+ sstore_combinations_initial1.json OK
|
||||
+ sstore_combinations_initial1_2.json OK
|
||||
+ sstore_combinations_initial2.json OK
|
||||
+ sstore_combinations_initial2_1.json OK
|
||||
static_Call50000_sha256.json Skip
|
||||
```
|
||||
OK: 3/4 Fail: 0/4 Skip: 1/4
|
||||
OK: 6/7 Fail: 0/7 Skip: 1/7
|
||||
## stTransactionTest
|
||||
```diff
|
||||
+ ContractStoreClearsOOG.json OK
|
||||
|
@ -2593,4 +2596,4 @@ OK: 133/133 Fail: 0/133 Skip: 0/133
|
|||
OK: 130/130 Fail: 0/130 Skip: 0/130
|
||||
|
||||
---TOTAL---
|
||||
OK: 2289/2391 Fail: 0/2391 Skip: 102/2391
|
||||
OK: 2292/2394 Fail: 0/2394 Skip: 102/2394
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -715,11 +715,17 @@ func istanbulGasFees(previousFees: GasFeeSchedule): GasFeeSchedule =
|
|||
result[GasBalance] = 700
|
||||
result[GasTXDataNonZero]= 16
|
||||
|
||||
func berlinGasFees(previousFees: GasFeeSchedule): GasFeeSchedule =
|
||||
# https://eips.ethereum.org/EIPS/eip-2929
|
||||
result = previousFees
|
||||
result[GasCall] = WarmStorageReadCost
|
||||
|
||||
const
|
||||
HomesteadGasFees = BaseGasFees.homesteadGasFees
|
||||
TangerineGasFees = HomesteadGasFees.tangerineGasFees
|
||||
SpuriousGasFees = TangerineGasFees.spuriousGasFees
|
||||
IstanbulGasFees = SpuriousGasFees.istanbulGasFees
|
||||
BerlinGasFees = IstanbulGasFees.berlinGasFees
|
||||
|
||||
gasFees*: array[Fork, GasFeeSchedule] = [
|
||||
FkFrontier: BaseGasFees,
|
||||
|
@ -730,7 +736,7 @@ const
|
|||
FkConstantinople: SpuriousGasFees,
|
||||
FkPetersburg: SpuriousGasFees,
|
||||
FkIstanbul: IstanbulGasFees,
|
||||
FkBerlin: IstanbulGasFees
|
||||
FkBerlin: BerlinGasFees
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ proc gasEip2929AccountCheck(c: Computation, address: EthAddress, prevCost = 0.Ga
|
|||
ColdAccountAccessCost
|
||||
else:
|
||||
WarmStorageReadCost
|
||||
|
||||
c.gasMeter.consumeGas(gasCost - prevCost, reason = "gasEIP2929AccountCheck")
|
||||
|
||||
template push(x: typed) {.dirty.} =
|
||||
|
@ -771,6 +772,17 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
|||
else:
|
||||
(memOutPos, memOutLen)
|
||||
|
||||
# EIP2929
|
||||
# This came before old gas calculator
|
||||
# because it will affect `c.gasMeter.gasRemaining`
|
||||
# and further `childGasLimit`
|
||||
if c.fork >= FkBerlin:
|
||||
c.vmState.mutateStateDB:
|
||||
if not db.inAccessList(destination):
|
||||
db.accessList(destination)
|
||||
# The WarmStorageReadCostEIP2929 (100) is already deducted in the form of a constant cost
|
||||
c.gasMeter.consumeGas(ColdAccountAccessCost - WarmStorageReadCost, reason = "gasEIP2929Call")
|
||||
|
||||
let contractAddress = when opCode in {Call, StaticCall}: destination else: c.msg.contractAddress
|
||||
var (gasCost, childGasLimit) = c.gasCosts[opCode].c_handler(
|
||||
value,
|
||||
|
@ -790,10 +802,6 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
|||
# if c.fork >= FkBerlin and destination.toInt <= MaxPrecompilesAddr:
|
||||
# gasCost = gasCost - 660.GasInt
|
||||
|
||||
# EIP2929
|
||||
if c.fork >= FkBerlin:
|
||||
c.gasEip2929AccountCheck(destination, gasFees[c.fork][GasCall])
|
||||
|
||||
if gasCost >= 0:
|
||||
c.gasMeter.consumeGas(gasCost, reason = $opCode)
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 16fa567686a8cea578a500b0095c4d7f9f3bbe63
|
||||
Subproject commit dd23a3e4edd4619d99933fc135cc88b31ca3cafb
|
|
@ -96,6 +96,10 @@ func skipGSTTests*(folder: string, name: string): bool =
|
|||
return true
|
||||
|
||||
func skipNewGSTTests*(folder: string, name: string): bool =
|
||||
if folder == "stEIP2537":
|
||||
# a bug in ethereum test that later fixed, skip for now
|
||||
return true
|
||||
|
||||
# share the same slow and failing tests
|
||||
if skipGSTTests(folder, name):
|
||||
return true
|
||||
|
@ -119,7 +123,7 @@ func skipBCTests*(folder: string, name: string): bool =
|
|||
]
|
||||
|
||||
func skipNewBCTests*(folder: string, name: string): bool =
|
||||
if folder == "vmPerformance" or folder == "stStaticCall":
|
||||
if folder in ["vmPerformance", "stStaticCall"]:
|
||||
return true
|
||||
|
||||
# the new BC tests also contains these slow tests
|
||||
|
|
|
@ -364,7 +364,8 @@ proc processBlock(chainDB: BaseChainDB, vmState: BaseVMState, minedBlock: PlainB
|
|||
vmState.receipts[txIndex] = makeReceipt(vmState, fork)
|
||||
|
||||
if vmState.cumulativeGasUsed != minedBlock.header.gasUsed:
|
||||
raise newException(ValidationError, &"wrong gas used in header expected={minedBlock.header.gasUsed}, actual={vmState.cumulativeGasUsed}")
|
||||
let diff = vmState.cumulativeGasUsed - minedBlock.header.gasUsed
|
||||
raise newException(ValidationError, &"wrong gas used in header expected={minedBlock.header.gasUsed}, actual={vmState.cumulativeGasUsed}, diff={diff}")
|
||||
|
||||
assignBlockRewards(minedBlock, vmState, fork, vmState.chainDB)
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ proc verifyStateDB*(wantedState: JsonNode, stateDB: ReadOnlyStateDB) =
|
|||
actualNonce = stateDB.getNonce(account)
|
||||
|
||||
if wantedCode != actualCode:
|
||||
raise newException(ValidationError, &"{ac} codeDiff {wantedCode} != {actualCode}")
|
||||
raise newException(ValidationError, &"{ac} codeDiff {wantedCode.toHex} != {actualCode.toHex}")
|
||||
if wantedBalance != actualBalance:
|
||||
raise newException(ValidationError, &"{ac} balanceDiff {wantedBalance.toHex} != {actualBalance.toHex}")
|
||||
if wantedNonce != actualNonce:
|
||||
|
|
1461
witnessBuilderBC.md
1461
witnessBuilderBC.md
File diff suppressed because it is too large
Load Diff
1439
witnessBuilderGST.md
1439
witnessBuilderGST.md
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue