Skip to content

Commit

Permalink
Merge branch 'master' into portal-json-rpc-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeme authored Jan 14, 2025
2 parents ef2e258 + 288ee28 commit a7987f6
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 154 deletions.
23 changes: 11 additions & 12 deletions nimbus/beacon/beacon_engine.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Copyright (c) 2023-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand All @@ -16,7 +16,7 @@ import
./payload_conv,
./payload_queue,
./api_handler/api_utils,
../core/[tx_pool, casper, chain]
../core/[tx_pool, chain]

export
chain,
Expand Down Expand Up @@ -68,12 +68,12 @@ const
# Private helpers
# ------------------------------------------------------------------------------

func setWithdrawals(ctx: CasperRef, attrs: PayloadAttributes) =
func setWithdrawals(xp: TxPoolRef, attrs: PayloadAttributes) =
case attrs.version
of Version.V2, Version.V3:
ctx.withdrawals = ethWithdrawals attrs.withdrawals.get
xp.withdrawals = ethWithdrawals attrs.withdrawals.get
else:
ctx.withdrawals = @[]
xp.withdrawals = @[]

template wrapException(body: untyped): auto =
try:
Expand Down Expand Up @@ -146,19 +146,18 @@ proc generateExecutionBundle*(ben: BeaconEngineRef,
wrapException:
let
xp = ben.txPool
pos = xp.com.pos
headBlock = ben.chain.latestHeader

pos.prevRandao = attrs.prevRandao
pos.timestamp = ethTime attrs.timestamp
pos.feeRecipient = attrs.suggestedFeeRecipient
xp.prevRandao = attrs.prevRandao
xp.timestamp = ethTime attrs.timestamp
xp.feeRecipient = attrs.suggestedFeeRecipient

if attrs.parentBeaconBlockRoot.isSome:
pos.parentBeaconBlockRoot = attrs.parentBeaconBlockRoot.get
xp.parentBeaconBlockRoot = attrs.parentBeaconBlockRoot.get

pos.setWithdrawals(attrs)
xp.setWithdrawals(attrs)

if pos.timestamp <= headBlock.timestamp:
if xp.timestamp <= headBlock.timestamp:
return err "timestamp must be strictly later than parent"

# someBaseFee = true: make sure bundle.blk.header
Expand Down
13 changes: 1 addition & 12 deletions nimbus/common/common.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2022-2024 Status Research & Development GmbH
# Copyright (c) 2022-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE))
# * MIT license ([LICENSE-MIT](LICENSE-MIT))
Expand All @@ -11,7 +11,6 @@

import
chronicles,
../core/casper,
../db/[core_db, ledger, storage_types],
../utils/[utils],
".."/[constants, errors, version],
Expand Down Expand Up @@ -90,9 +89,6 @@ type
## installing a snapshot pivot. The default value for this field is
## `GENESIS_PARENT_HASH` to start at the very beginning.

pos: CasperRef
## Proof Of Stake descriptor

pruneHistory: bool
## Must not not set for a full node, might go away some time

Expand Down Expand Up @@ -181,7 +177,6 @@ proc init(com : CommonRef,
com.syncProgress= SyncProgress()
com.syncState = Waiting
com.pruneHistory= pruneHistory
com.pos = CasperRef.new
com.extraData = ShortClientId
com.taskpool = taskpool
com.gasLimit = DEFAULT_GAS_LIMIT
Expand All @@ -202,7 +197,6 @@ proc init(com : CommonRef,
toGenesisHeader(genesis, fork, com.db)

com.setForkId(com.genesisHeader)
com.pos.timestamp = genesis.timestamp

# By default, history begins at genesis.
com.startOfHistory = GENESIS_PARENT_HASH
Expand Down Expand Up @@ -276,7 +270,6 @@ func clone*(com: CommonRef, db: CoreDbRef): CommonRef =
genesisHeader: com.genesisHeader,
syncProgress : com.syncProgress,
networkId : com.networkId,
pos : com.pos,
pruneHistory : com.pruneHistory)

func clone*(com: CommonRef): CommonRef =
Expand Down Expand Up @@ -363,10 +356,6 @@ func startOfHistory*(com: CommonRef): Hash32 =
## Getter
com.startOfHistory

func pos*(com: CommonRef): CasperRef =
## Getter
com.pos

func db*(com: CommonRef): CoreDbRef =
com.db

Expand Down
56 changes: 0 additions & 56 deletions nimbus/core/casper.nim

This file was deleted.

43 changes: 38 additions & 5 deletions nimbus/core/tx_pool.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Copyright (c) 2018-2025 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
# http://www.apache.org/licenses/LICENSE-2.0)
Expand Down Expand Up @@ -42,8 +42,7 @@ import
./tx_pool/tx_item,
./tx_pool/tx_desc,
./tx_pool/tx_packer,
./chain/forked_chain,
./casper
./chain/forked_chain

from eth/common/eth_types_rlp import rlpHash

Expand Down Expand Up @@ -143,7 +142,7 @@ proc assembleBlock*(
return err(error)

var blk = EthBlock(
header: pst.assembleHeader
header: pst.assembleHeader(xp)
)
var blobsBundle: BlobsBundle
for item in pst.packedTxs:
Expand All @@ -160,7 +159,7 @@ proc assembleBlock*(

let com = xp.vmState.com
if com.isShanghaiOrLater(blk.header.timestamp):
blk.withdrawals = Opt.some(com.pos.withdrawals)
blk.withdrawals = Opt.some(xp.withdrawals)

if not com.isCancunOrLater(blk.header.timestamp) and blobsBundle.commitments.len > 0:
return err("PooledTransaction contains blobs prior to Cancun")
Expand All @@ -187,3 +186,37 @@ proc assembleBlock*(
blobsBundle: blobsBundleOpt,
blockValue: pst.blockValue,
executionRequests: executionRequestsOpt)

# ------------------------------------------------------------------------------
# PoS payload attributes getters
# ------------------------------------------------------------------------------

export
feeRecipient,
timestamp,
prevRandao,
withdrawals,
parentBeaconBlockRoot

# feeRecipient(xp: TxPoolRef): Address
# timestamp(xp: TxPoolRef): EthTime
# prevRandao(xp: TxPoolRef): Bytes32
# withdrawals(xp: TxPoolRef): seq[Withdrawal]
# parentBeaconBlockRoot(xp: TxPoolRef): Hash32

# ------------------------------------------------------------------------------
# PoS payload attributes setters
# ------------------------------------------------------------------------------

export
`feeRecipient=`,
`timestamp=`,
`prevRandao=`,
`withdrawals=`,
`parentBeaconBlockRoot=`

# `feeRecipient=`(xp: TxPoolRef, val: Address)
# `timestamp=`(xp: TxPoolRef, val: EthTime)
# `prevRandao=`(xp: TxPoolRef, val: Bytes32)
# `withdrawals=`(xp: TxPoolRef, val: sink seq[Withdrawal])
# `parentBeaconBlockRoot=`(xp: TxPoolRef, val: Hash32)
Loading

0 comments on commit a7987f6

Please sign in to comment.