fix Dencun fcU being always rejected as invalid; rm newPayload fork validation hack (#2253)
This commit is contained in:
parent
828fd63348
commit
01aeb3ad97
|
@ -36,7 +36,7 @@ template validateVersion(attr, com, apiVersion) =
|
||||||
if version < Version.V3:
|
if version < Version.V3:
|
||||||
raise unsupportedFork("forkChoiceUpdated" & $apiVersion &
|
raise unsupportedFork("forkChoiceUpdated" & $apiVersion &
|
||||||
" doesn't support payloadAttributes" & $version)
|
" doesn't support payloadAttributes" & $version)
|
||||||
if version >= Version.V3:
|
if version > Version.V3:
|
||||||
raise invalidAttr("forkChoiceUpdated" & $apiVersion &
|
raise invalidAttr("forkChoiceUpdated" & $apiVersion &
|
||||||
" doesn't support PayloadAttributes" & $version)
|
" doesn't support PayloadAttributes" & $version)
|
||||||
elif com.isShanghaiOrLater(timestamp):
|
elif com.isShanghaiOrLater(timestamp):
|
||||||
|
|
|
@ -59,10 +59,6 @@ template validateVersion(com, timestamp, version, apiVersion) =
|
||||||
"payload must be ExecutionPayloadV2, got ExecutionPayload" & $version)
|
"payload must be ExecutionPayloadV2, got ExecutionPayload" & $version)
|
||||||
|
|
||||||
elif version != Version.V1:
|
elif version != Version.V1:
|
||||||
if com.syncReqRelaxV2:
|
|
||||||
trace "Relaxed mode, treating payload as V1"
|
|
||||||
discard
|
|
||||||
else:
|
|
||||||
raise invalidParams("if timestamp is earlier than Shanghai, " &
|
raise invalidParams("if timestamp is earlier than Shanghai, " &
|
||||||
"payload must be ExecutionPayloadV1, got ExecutionPayload" & $version)
|
"payload must be ExecutionPayloadV1, got ExecutionPayload" & $version)
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,6 @@ type
|
||||||
## Call back function for the sync processor. This function stages
|
## Call back function for the sync processor. This function stages
|
||||||
## the arguent header to a private aerea for subsequent processing.
|
## the arguent header to a private aerea for subsequent processing.
|
||||||
|
|
||||||
syncReqRelaxV2: bool
|
|
||||||
## Allow processing of certain RPC/V2 messages type while syncing (i.e.
|
|
||||||
## `syncReqNewHead` is set.) although `shanghaiTime` is unavailable
|
|
||||||
## or has not reached, yet.
|
|
||||||
|
|
||||||
notifyBadBlock: NotifyBadBlockCB
|
notifyBadBlock: NotifyBadBlockCB
|
||||||
## Allow synchronizer to inform engine-API of bad encountered during sync
|
## Allow synchronizer to inform engine-API of bad encountered during sync
|
||||||
## progress
|
## progress
|
||||||
|
@ -101,7 +96,7 @@ type
|
||||||
# Forward declarations
|
# Forward declarations
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc hardForkTransition*(
|
func hardForkTransition*(
|
||||||
com: CommonRef, forkDeterminer: ForkDeterminationInfo)
|
com: CommonRef, forkDeterminer: ForkDeterminationInfo)
|
||||||
{.gcsafe, raises: [].}
|
{.gcsafe, raises: [].}
|
||||||
|
|
||||||
|
@ -109,7 +104,7 @@ proc hardForkTransition*(
|
||||||
# Private helper functions
|
# Private helper functions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc consensusTransition(com: CommonRef, fork: HardFork) =
|
func consensusTransition(com: CommonRef, fork: HardFork) =
|
||||||
if fork >= MergeFork:
|
if fork >= MergeFork:
|
||||||
com.consensusType = ConsensusType.POS
|
com.consensusType = ConsensusType.POS
|
||||||
else:
|
else:
|
||||||
|
@ -117,7 +112,7 @@ proc consensusTransition(com: CommonRef, fork: HardFork) =
|
||||||
# this could happen during reorg
|
# this could happen during reorg
|
||||||
com.consensusType = com.config.consensusType
|
com.consensusType = com.config.consensusType
|
||||||
|
|
||||||
proc setForkId(com: CommonRef, genesis: BlockHeader) =
|
func setForkId(com: CommonRef, genesis: BlockHeader) =
|
||||||
com.genesisHash = genesis.blockHash
|
com.genesisHash = genesis.blockHash
|
||||||
let genesisCRC = crc32(0, com.genesisHash.data)
|
let genesisCRC = crc32(0, com.genesisHash.data)
|
||||||
com.forkIdCalculator = initForkIdCalculator(
|
com.forkIdCalculator = initForkIdCalculator(
|
||||||
|
@ -125,7 +120,7 @@ proc setForkId(com: CommonRef, genesis: BlockHeader) =
|
||||||
genesisCRC,
|
genesisCRC,
|
||||||
genesis.timestamp.uint64)
|
genesis.timestamp.uint64)
|
||||||
|
|
||||||
proc daoCheck(conf: ChainConfig) =
|
func daoCheck(conf: ChainConfig) =
|
||||||
if not conf.daoForkSupport or conf.daoForkBlock.isNone:
|
if not conf.daoForkSupport or conf.daoForkBlock.isNone:
|
||||||
conf.daoForkBlock = conf.homesteadBlock
|
conf.daoForkBlock = conf.homesteadBlock
|
||||||
|
|
||||||
|
@ -194,7 +189,7 @@ proc getTd(com: CommonRef, blockHash: Hash256): Option[DifficultyInt] =
|
||||||
else:
|
else:
|
||||||
some(td)
|
some(td)
|
||||||
|
|
||||||
proc needTdForHardForkDetermination(com: CommonRef): bool =
|
func needTdForHardForkDetermination(com: CommonRef): bool =
|
||||||
let t = com.forkTransitionTable.mergeForkTransitionThreshold
|
let t = com.forkTransitionTable.mergeForkTransitionThreshold
|
||||||
t.ttdPassed.isNone and t.blockNumber.isNone and t.ttd.isSome
|
t.ttdPassed.isNone and t.blockNumber.isNone and t.ttd.isSome
|
||||||
|
|
||||||
|
@ -246,7 +241,7 @@ proc new*(
|
||||||
nil,
|
nil,
|
||||||
pruneHistory)
|
pruneHistory)
|
||||||
|
|
||||||
proc clone*(com: CommonRef, db: CoreDbRef): CommonRef =
|
func clone*(com: CommonRef, db: CoreDbRef): CommonRef =
|
||||||
## clone but replace the db
|
## clone but replace the db
|
||||||
## used in EVM tracer whose db is CaptureDB
|
## used in EVM tracer whose db is CaptureDB
|
||||||
CommonRef(
|
CommonRef(
|
||||||
|
@ -264,7 +259,7 @@ proc clone*(com: CommonRef, db: CoreDbRef): CommonRef =
|
||||||
pos : com.pos,
|
pos : com.pos,
|
||||||
pruneHistory : com.pruneHistory)
|
pruneHistory : com.pruneHistory)
|
||||||
|
|
||||||
proc clone*(com: CommonRef): CommonRef =
|
func clone*(com: CommonRef): CommonRef =
|
||||||
com.clone(com.db)
|
com.clone(com.db)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -275,7 +270,7 @@ func toHardFork*(
|
||||||
com: CommonRef, forkDeterminer: ForkDeterminationInfo): HardFork =
|
com: CommonRef, forkDeterminer: ForkDeterminationInfo): HardFork =
|
||||||
toHardFork(com.forkTransitionTable, forkDeterminer)
|
toHardFork(com.forkTransitionTable, forkDeterminer)
|
||||||
|
|
||||||
proc hardForkTransition(
|
func hardForkTransition(
|
||||||
com: CommonRef, forkDeterminer: ForkDeterminationInfo) =
|
com: CommonRef, forkDeterminer: ForkDeterminationInfo) =
|
||||||
## When consensus type already transitioned to POS,
|
## When consensus type already transitioned to POS,
|
||||||
## the storage can choose not to store TD anymore,
|
## the storage can choose not to store TD anymore,
|
||||||
|
@ -287,7 +282,7 @@ proc hardForkTransition(
|
||||||
com.currentFork = fork
|
com.currentFork = fork
|
||||||
com.consensusTransition(fork)
|
com.consensusTransition(fork)
|
||||||
|
|
||||||
proc hardForkTransition*(
|
func hardForkTransition*(
|
||||||
com: CommonRef,
|
com: CommonRef,
|
||||||
number: BlockNumber,
|
number: BlockNumber,
|
||||||
td: Option[DifficultyInt],
|
td: Option[DifficultyInt],
|
||||||
|
@ -469,55 +464,40 @@ func syncCurrent*(com: CommonRef): BlockNumber =
|
||||||
func syncHighest*(com: CommonRef): BlockNumber =
|
func syncHighest*(com: CommonRef): BlockNumber =
|
||||||
com.syncProgress.highest
|
com.syncProgress.highest
|
||||||
|
|
||||||
func syncReqRelaxV2*(com: CommonRef): bool =
|
|
||||||
com.syncReqRelaxV2
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Setters
|
# Setters
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc `syncStart=`*(com: CommonRef, number: BlockNumber) =
|
func `syncStart=`*(com: CommonRef, number: BlockNumber) =
|
||||||
com.syncProgress.start = number
|
com.syncProgress.start = number
|
||||||
|
|
||||||
proc `syncCurrent=`*(com: CommonRef, number: BlockNumber) =
|
func `syncCurrent=`*(com: CommonRef, number: BlockNumber) =
|
||||||
com.syncProgress.current = number
|
com.syncProgress.current = number
|
||||||
|
|
||||||
proc `syncHighest=`*(com: CommonRef, number: BlockNumber) =
|
func `syncHighest=`*(com: CommonRef, number: BlockNumber) =
|
||||||
com.syncProgress.highest = number
|
com.syncProgress.highest = number
|
||||||
|
|
||||||
proc `startOfHistory=`*(com: CommonRef, val: Hash256) =
|
func `startOfHistory=`*(com: CommonRef, val: Hash256) =
|
||||||
## Setter
|
## Setter
|
||||||
com.startOfHistory = val
|
com.startOfHistory = val
|
||||||
|
|
||||||
proc setTTD*(com: CommonRef, ttd: Option[DifficultyInt]) =
|
func setTTD*(com: CommonRef, ttd: Option[DifficultyInt]) =
|
||||||
## useful for testing
|
## useful for testing
|
||||||
com.config.terminalTotalDifficulty = ttd
|
com.config.terminalTotalDifficulty = ttd
|
||||||
# rebuild the MergeFork piece of the forkTransitionTable
|
# rebuild the MergeFork piece of the forkTransitionTable
|
||||||
com.forkTransitionTable.mergeForkTransitionThreshold = com.config.mergeForkTransitionThreshold
|
com.forkTransitionTable.mergeForkTransitionThreshold = com.config.mergeForkTransitionThreshold
|
||||||
|
|
||||||
proc setFork*(com: CommonRef, fork: HardFork): HardFork =
|
func setFork*(com: CommonRef, fork: HardFork): HardFork =
|
||||||
## useful for testing
|
## useful for testing
|
||||||
result = com.currentFork
|
result = com.currentFork
|
||||||
com.currentFork = fork
|
com.currentFork = fork
|
||||||
com.consensusTransition(fork)
|
com.consensusTransition(fork)
|
||||||
|
|
||||||
proc `syncReqNewHead=`*(com: CommonRef; cb: SyncReqNewHeadCB) =
|
func `syncReqNewHead=`*(com: CommonRef; cb: SyncReqNewHeadCB) =
|
||||||
## Activate or reset a call back handler for syncing. When resetting (by
|
## Activate or reset a call back handler for syncing.
|
||||||
## passing `cb` as `nil`), the `syncReqRelaxV2` value is also reset.
|
|
||||||
com.syncReqNewHead = cb
|
com.syncReqNewHead = cb
|
||||||
if cb.isNil:
|
|
||||||
com.syncReqRelaxV2 = false
|
|
||||||
|
|
||||||
proc `syncReqRelaxV2=`*(com: CommonRef; val: bool) =
|
func `notifyBadBlock=`*(com: CommonRef; cb: NotifyBadBlockCB) =
|
||||||
## Allow processing of certain RPC/V2 messages type while syncing (i.e.
|
|
||||||
## `syncReqNewHead` is set.) although `shanghaiTime` is unavailable
|
|
||||||
## or has not reached, yet.
|
|
||||||
##
|
|
||||||
## This setter is effective only while `syncReqNewHead` is activated.
|
|
||||||
if not com.syncReqNewHead.isNil:
|
|
||||||
com.syncReqRelaxV2 = val
|
|
||||||
|
|
||||||
proc `notifyBadBlock=`*(com: CommonRef; cb: NotifyBadBlockCB) =
|
|
||||||
## Activate or reset a call back handler for bad block notification.
|
## Activate or reset a call back handler for bad block notification.
|
||||||
com.notifyBadBlock = cb
|
com.notifyBadBlock = cb
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2023 Status Research & Development GmbH
|
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
@ -105,7 +105,7 @@ proc runMulti(buddy: BeaconBuddyRef) {.async.} =
|
||||||
# Private helpers
|
# Private helpers
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
proc updateBeaconHeaderCB(ctx: BeaconSyncRef): SyncReqNewHeadCB =
|
func updateBeaconHeaderCB(ctx: BeaconSyncRef): SyncReqNewHeadCB =
|
||||||
## Update beacon header. This function is intended as a call back function
|
## Update beacon header. This function is intended as a call back function
|
||||||
## for the RPC module.
|
## for the RPC module.
|
||||||
result = proc(h: BlockHeader) {.gcsafe, raises: [].} =
|
result = proc(h: BlockHeader) {.gcsafe, raises: [].} =
|
||||||
|
@ -119,8 +119,6 @@ proc enableRpcMagic(ctx: BeaconSyncRef) =
|
||||||
## Helper for `setup()`: Enable external pivot update via RPC
|
## Helper for `setup()`: Enable external pivot update via RPC
|
||||||
let com = ctx.ctx.chain.com
|
let com = ctx.ctx.chain.com
|
||||||
com.syncReqNewHead = ctx.updateBeaconHeaderCB
|
com.syncReqNewHead = ctx.updateBeaconHeaderCB
|
||||||
# We need engine_newPayload to be strict
|
|
||||||
com.syncReqRelaxV2 = false
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public functions
|
# Public functions
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
# according to those terms.
|
# according to those terms.
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[tables, os],
|
std/tables,
|
||||||
eth/[keys],
|
eth/[keys],
|
||||||
stew/byteutils, results, unittest2,
|
stew/byteutils, results, unittest2,
|
||||||
../nimbus/db/ledger,
|
../nimbus/db/ledger,
|
||||||
|
@ -17,10 +17,9 @@ import
|
||||||
../nimbus/[config, transaction, constants],
|
../nimbus/[config, transaction, constants],
|
||||||
../nimbus/core/tx_pool,
|
../nimbus/core/tx_pool,
|
||||||
../nimbus/core/casper,
|
../nimbus/core/casper,
|
||||||
../nimbus/core/executor,
|
|
||||||
../nimbus/common/common,
|
../nimbus/common/common,
|
||||||
../nimbus/utils/utils,
|
../nimbus/utils/utils,
|
||||||
../nimbus/[vm_state, vm_types],
|
../nimbus/vm_types,
|
||||||
./test_txpool/helpers,
|
./test_txpool/helpers,
|
||||||
./macro_assembler
|
./macro_assembler
|
||||||
|
|
||||||
|
@ -58,7 +57,9 @@ proc privKey(keyHex: string): PrivateKey =
|
||||||
|
|
||||||
kRes.get()
|
kRes.get()
|
||||||
|
|
||||||
proc makeTx(t: var TestEnv, recipient: EthAddress, amount: UInt256, payload: openArray[byte] = []): Transaction =
|
func makeTx(
|
||||||
|
t: var TestEnv, recipient: EthAddress, amount: UInt256,
|
||||||
|
payload: openArray[byte] = []): Transaction =
|
||||||
const
|
const
|
||||||
gasLimit = 75000.GasInt
|
gasLimit = 75000.GasInt
|
||||||
gasPrice = 30.gwei
|
gasPrice = 30.gwei
|
||||||
|
@ -77,7 +78,8 @@ proc makeTx(t: var TestEnv, recipient: EthAddress, amount: UInt256, payload: ope
|
||||||
inc t.nonce
|
inc t.nonce
|
||||||
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
||||||
|
|
||||||
proc signTxWithNonce(t: TestEnv, tx: Transaction, nonce: AccountNonce): Transaction =
|
func signTxWithNonce(
|
||||||
|
t: TestEnv, tx: Transaction, nonce: AccountNonce): Transaction =
|
||||||
var tx = tx
|
var tx = tx
|
||||||
tx.nonce = nonce
|
tx.nonce = nonce
|
||||||
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
||||||
|
|
Loading…
Reference in New Issue