Skip to content

TESTING : Fusaka devnet 2 #3422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 64 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a5c5362
add the block validation check
advaita-saha Jun 10, 2025
08816a3
restrict block production to 10MB
advaita-saha Jun 11, 2025
bdf2591
temp fix
advaita-saha Jun 11, 2025
e171145
secp256r1 impl
advaita-saha Jun 12, 2025
0cae682
remove unwanted stuff
advaita-saha Jun 12, 2025
ab95690
fix double hashing
advaita-saha Jun 12, 2025
d481c60
remove commented code
advaita-saha Jun 12, 2025
b88979f
add complete test suite
advaita-saha Jun 12, 2025
bb1bfad
improve performance
advaita-saha Jun 12, 2025
cf05a0d
Merge branch 'master' into eip-7951
advaita-saha Jun 12, 2025
e4fd912
fix gas calculation
advaita-saha Jun 12, 2025
8a3970b
fix unwanted ECC Points
advaita-saha Jun 13, 2025
abee849
few more fixes
advaita-saha Jun 13, 2025
70e0955
fix weird EIP, no error but consume gas
advaita-saha Jun 13, 2025
6905019
initial impl of CLZ
advaita-saha Jun 13, 2025
d95bfb1
enum error fix
chirag-parmar Jun 13, 2025
41bbc80
update copyright year
chirag-parmar Jun 13, 2025
d4306e1
fix
chirag-parmar Jun 13, 2025
7b5efbe
add gas and Prague
advaita-saha Jun 13, 2025
2df3d67
execution_chain
advaita-saha Jun 13, 2025
58d4748
eip7907
chirag-parmar Jun 11, 2025
72a76c4
fix
chirag-parmar Jun 11, 2025
a7a4fc7
copyright year update
chirag-parmar Jun 11, 2025
01d939e
forked update
chirag-parmar Jun 12, 2025
9044fb6
add 7907 for ext code copy
chirag-parmar Jun 12, 2025
4521cb4
touch code
chirag-parmar Jun 13, 2025
2017994
Merge branch 'eip-7934' into CLZ
advaita-saha Jun 13, 2025
ca15b24
Revert "Merge branch 'eip-7934' into CLZ"
advaita-saha Jun 13, 2025
302e2ee
better if conditions
chirag-parmar Jun 13, 2025
6c962ce
Update execution_chain/core/tx_pool.nim
advaita-saha Jun 13, 2025
3794671
Merge branch 'master' into eip-7934
advaita-saha Jun 13, 2025
826e107
Increase rpc http server chunk size to 1 MBytes
jangko Jun 20, 2025
55c505f
Merge branch 'master' into eip-7934
advaita-saha Jun 23, 2025
2087bba
Merge branch 'master' into fusaka-devnet-2
advaita-saha Jun 23, 2025
79b1d07
Merge branch 'master' into eip-7907
advaita-saha Jun 23, 2025
a52e489
Merge branch 'eip-7907' into fusaka-devnet-2
advaita-saha Jun 23, 2025
a35122b
Merge branch 'chunk-size' into fusaka-devnet-2
advaita-saha Jun 23, 2025
8b72e69
Merge branch 'eip-7951' into fusaka-devnet-2
advaita-saha Jun 23, 2025
b03c5c5
Merge branch 'CLZ' into fusaka-devnet-2
advaita-saha Jun 23, 2025
95f665b
merge fixes
advaita-saha Jun 23, 2025
0243814
eth_sendRawTransaction return inner tx hash and not the pooled tx hash
jangko Jun 26, 2025
603a7bc
Merge branch 'fix-srt' into fusaka-devnet-2
advaita-saha Jun 26, 2025
2b15f20
increase blob tx limit
advaita-saha Jun 26, 2025
477f653
remove usage of results and log for more details on getPayloadBodies
advaita-saha Jun 27, 2025
3d8b46d
Transaction hashes broadcast handler: use inner tx hash + PooledTrans…
jangko Jun 28, 2025
258d0f8
Merge branch 'broadcast-hash' into fusaka-devnet-2
advaita-saha Jun 28, 2025
da0dbb2
Improves logging
jangko Jun 28, 2025
5ec361e
Fix
jangko Jun 28, 2025
ce240ee
Optimize getPayloadBodiesByHash/ByRange
jangko Jun 28, 2025
bb9fd5e
Merge branch 'broadcast-hash' into fusaka-devnet-2
advaita-saha Jun 28, 2025
2aa61ad
Add fallback to old withdrawals format
jangko Jun 28, 2025
30cc9f4
revert
advaita-saha Jun 28, 2025
a30bbe8
Merge branch 'optimize-payload-bodies' into fusaka-devnet-2
advaita-saha Jun 28, 2025
5e93ccf
feat: add admin_peers and admin ns (#3431)
barnabasbusa Jun 30, 2025
d33d111
Add export marker
jangko Jun 30, 2025
e7eea13
Fix tests
jangko Jul 1, 2025
30177a8
Restore invalid request exeception in admin_addPeer
jangko Jul 1, 2025
d84cfaf
Chicken and egg
jangko Jul 1, 2025
2129201
oops
jangko Jul 1, 2025
e528f5f
fix: string -> int for ports.discovery and listener (#3438)
barnabasbusa Jul 2, 2025
6bb84a6
Add export marker
jangko Jul 2, 2025
fa578e8
Add comments
jangko Jul 2, 2025
ba32896
Merge branch 'fix-imports' into fusaka-devnet-2
advaita-saha Jul 2, 2025
de58691
Merge branch 'master' into fusaka-devnet-2
advaita-saha Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ COPY ./ /nimbus-eth1

WORKDIR /nimbus-eth1

RUN mv vendor vendor.orig

RUN --mount=type=cache,target=/nimbus-eth1/build --mount=type=cache,target=/nimbus-eth1/vendor \
mv vendor.orig vendor && \
RUN --mount=type=cache,target=/nimbus-eth1/build \
make -j${NPROC} NIMFLAGS="${NIMFLAGS_COMMON} --parallelBuild:${NPROC}" V=1 update

RUN --mount=type=cache,target=/nimbus-eth1/build --mount=type=cache,target=/nimbus-eth1/vendor \
RUN --mount=type=cache,target=/nimbus-eth1/build \
make -j${NPROC} NIMFLAGS="${NIMFLAGS_COMMON} --parallelBuild:${NPROC}" nimbus_execution_client && \
mv build/nimbus_execution_client /usr/local/bin/nimbus_execution_client

Expand Down
11 changes: 10 additions & 1 deletion execution_chain/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,19 @@ const

## Fork specific constants

# See EIP-170 (https://eips.ethereum.org/EIPS/eip-170). Maximum code size
# See EIP-170 (https://eips.ethereum.org/EIPS/eip-170) Maximum code size
# that can be stored for a new contract. Init code when creating a new
# contract is not subject to this limit.
EIP170_MAX_CODE_SIZE* = 0x6000
# See See EIP-7907 (https://eips.ethereum.org/EIPS/eip-7907). Update to limits
CODE_SIZE_THRESHOLD* = 0x6000
EIP7907_MAX_CODE_SIZE* = 0x40000

# See EIP-3860 (https://eips.ethereum.org/EIPS/eip-3860). Maximum initcode
# size when creating a new contract.
EIP3860_MAX_INITCODE_SIZE* = 2 * EIP170_MAX_CODE_SIZE
# See EIP-7907 (https://eips.ethereum.org/EIPS/eip-7907).
EIP7907_MAX_INITCODE_SIZE* = 2 * EIP7907_MAX_CODE_SIZE

# EIP
MaxPrecompilesAddr* = 0xFFFF
Expand Down Expand Up @@ -107,4 +112,8 @@ const
HISTORY_STORAGE_ADDRESS* = address"0x0000F90827F1C53a10cb7A02335B175320002935"
WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS* = address"0x00000961Ef480Eb55e80D19ad83579A64c007002"
CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS* = address"0x0000BBdDc7CE488642fb579F8B00f3a590007251"

MAX_BLOCK_SIZE* = 10_485_760 # 10 MiB
SAFETY_MARGIN* = 2_097_152 # 2 MiB
MAX_RLP_BLOCK_SIZE* = MAX_BLOCK_SIZE - SAFETY_MARGIN
# End
4 changes: 4 additions & 0 deletions execution_chain/core/executor/process_block.nim
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ proc procBlkPreamble(
if blk.transactions.calcTxRoot != header.txRoot:
return err("Mismatched txRoot")

if com.isOsakaOrLater(header.timestamp):
if rlp.getEncodedLength(blk) > MAX_RLP_BLOCK_SIZE:
return err("Post-Osaka block exceeded MAX_RLP_BLOCK_SIZE")

if com.isPragueOrLater(header.timestamp):
if header.requestsHash.isNone:
return err("Post-Prague block header must have requestsHash")
Expand Down
4 changes: 4 additions & 0 deletions execution_chain/core/tx_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ proc assembleBlock*(
blobsBundle = BlobsBundle(
wrapperVersion: getWrapperVersion(com, blk.header.timestamp)
)
currentRlpSize = rlp.getEncodedLength(blk.header) + rlp.getEncodedLength(blk.withdrawals)

for item in pst.packedTxs:
let tx = item.pooledTx
if currentRlpSize > MAX_RLP_BLOCK_SIZE - 7:
break
currentRlpSize = currentRlpSize + rlp.getEncodedLength(tx.tx)
blk.txs.add tx.tx
if tx.blobsBundle != nil:
doAssert(tx.blobsBundle.wrapperVersion == blobsBundle.wrapperVersion)
Expand Down
2 changes: 1 addition & 1 deletion execution_chain/core/tx_pool/tx_desc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const
# the included blobs. Since blob transactions are pulled instead of pushed,
# and only a small metadata is kept in ram, there is no critical limit that
# should be enforced. Still, capping it to some sane limit can never hurt.
BLOB_TX_MAX_SIZE* = 1024 * 1024
BLOB_TX_MAX_SIZE* = 1024 * 1024 * 2

# ------------------------------------------------------------------------------
# Private functions
Expand Down
9 changes: 7 additions & 2 deletions execution_chain/core/validate.nim
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,13 @@ func validateTxBasic*(
if tx.txType == TxEip7702 and fork < FkPrague:
return err("invalid tx: Eip7702 Tx type detected before Prague")

if fork >= FkShanghai and tx.contractCreation and tx.payload.len > EIP3860_MAX_INITCODE_SIZE:
return err("invalid tx: initcode size exceeds maximum")
if tx.contractCreation:
if fork >= FkOsaka and tx.payload.len > EIP7907_MAX_INITCODE_SIZE:
return err("invalid tx: initcode size exceeds maximum")

if fork < FkOsaka and fork >= FkShanghai and tx.payload.len > EIP3860_MAX_INITCODE_SIZE:
return err("invalid tx: initcode size exceeds maximum")


# The total must be the larger of the two
if tx.maxFeePerGasNorm < tx.maxPriorityFeePerGasNorm:
Expand Down
19 changes: 18 additions & 1 deletion execution_chain/db/access_list.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) or
# http://www.apache.org/licenses/LICENSE-2.0)
Expand All @@ -21,6 +21,7 @@ type

AccessList* = object
slots: Table[Address, SlotSet]
codeAddrs: HashSet[Address]

# ------------------------------------------------------------------------------
# Private helpers
Expand All @@ -36,6 +37,7 @@ func toStorageKeys(slots: SlotSet): seq[Bytes32] =

proc init*(ac: var AccessList) =
ac.slots = Table[Address, SlotSet]()
ac.codeAddrs = HashSet[Address]()

proc init*(_: type AccessList): AccessList {.inline.} =
result.init()
Expand All @@ -47,6 +49,9 @@ proc init*(_: type AccessList): AccessList {.inline.} =
func contains*(ac: AccessList, address: Address): bool {.inline.} =
address in ac.slots

func containsCode*(ac: AccessList, codeAddr: Address): bool {.inline.} =
codeAddr in ac.codeAddrs

# returnValue: (addressPresent, slotPresent)
func contains*(ac: var AccessList, address: Address, slot: UInt256): bool =
ac.slots.withValue(address, val):
Expand All @@ -55,6 +60,7 @@ func contains*(ac: var AccessList, address: Address, slot: UInt256): bool =
proc mergeAndReset*(ac, other: var AccessList) =
# move values in `other` to `ac`
ac.slots.mergeAndReset(other.slots)
ac.codeAddrs.mergeAndReset(other.codeAddrs)

proc add*(ac: var AccessList, address: Address) =
if address notin ac.slots:
Expand All @@ -66,9 +72,16 @@ proc add*(ac: var AccessList, address: Address, slot: UInt256) =
do:
ac.slots[address] = toHashSet([slot])

proc addCode*(ac: var AccessList, codeAddr: Address) =
ac.codeAddrs.incl codeAddr

proc clear*(ac: var AccessList) {.inline.} =
ac.slots.clear()
ac.codeAddrs.clear()

# TODO: accesses code is still not a part of the transaction access list
# but when it does trickle down into the transaction we will have to add
# it here
func getAccessList*(ac: AccessList): transactions.AccessList =
for address, slots in ac.slots:
result.add transactions.AccessPair(
Expand All @@ -91,4 +104,8 @@ func equal*(ac: AccessList, other: var AccessList): bool =
do:
return false

for codeAddr in ac.codeAddrs:
if codeAddr notin other:
return false

true
11 changes: 11 additions & 0 deletions execution_chain/db/ledger.nim
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ proc accessList*(ac: LedgerRef, address: Address) =
proc accessList*(ac: LedgerRef, address: Address, slot: UInt256) =
ac.savePoint.accessList.add(address, slot)

proc codeAccessList*(ac: LedgerRef, codeAddr: Address) =
ac.savePoint.accessList.addCode(codeAddr)

func inAccessList*(ac: LedgerRef, address: Address): bool =
var sp = ac.savePoint
while sp != nil:
Expand All @@ -832,6 +835,14 @@ func inAccessList*(ac: LedgerRef, address: Address, slot: UInt256): bool =
return
sp = sp.parentSavepoint

func inCodeAccessList*(ac: LedgerRef, codeAddr: Address): bool =
var sp = ac.savePoint
while sp != nil:
result = sp.accessList.containsCode(codeAddr)
if result:
return
sp = sp.parentSavepoint

func getAccessList*(ac: LedgerRef): transactions.AccessList =
# make sure all savepoint already committed
doAssert(ac.savePoint.parentSavepoint.isNil)
Expand Down
11 changes: 9 additions & 2 deletions execution_chain/evm/computation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,15 @@ proc writeContract*(c: Computation) =
c.setError(StatusCode.ContractValidationFailure, true)
return

# EIP-170 constraint (https://eips.ethereum.org/EIPS/eip-3541).
if fork >= FkSpurious and len > EIP170_MAX_CODE_SIZE:
# EIP-7907 constraint (https://eips.ethereum.org/EIPS/eip-7907).
if fork >= FkOsaka and len > EIP7907_MAX_CODE_SIZE:
withExtra trace, "New contract code exceeds EIP-7907 limit",
codeSize=len, maxSize=EIP7907_MAX_CODE_SIZE
c.setError(StatusCode.OutOfGas, true)
return

# EIP-170 constraint (https://eips.ethereum.org/EIPS/eip-170).
if fork < FkOsaka and fork >= FkSpurious and len > EIP170_MAX_CODE_SIZE:
withExtra trace, "New contract code exceeds EIP-170 limit",
codeSize=len, maxSize=EIP170_MAX_CODE_SIZE
c.setError(StatusCode.OutOfGas, true)
Expand Down
6 changes: 5 additions & 1 deletion execution_chain/evm/interpreter/op_handlers/oph_call.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ proc updateStackAndParams(q: var LocalParams; c: Computation) =
q.memOffset = q.memOutPos
q.memLength = q.memOutLen

# EIP7907
if FkOsaka <= c.fork:
q.gasCallEIPs = gasCallEIP7907(c, q.codeAddress)

# EIP2929: This came before old gas calculator
# because it will affect `c.gasMeter.gasRemaining`
# and further `childGasLimit`
if FkBerlin <= c.fork:
q.gasCallEIPs = gasCallEIP2929(c, q.codeAddress)
q.gasCallEIPs += gasCallEIP2929(c, q.codeAddress)

if FkPrague <= c.fork:
let delegateTo = parseDelegationAddress(c.getCode(q.codeAddress))
Expand Down
25 changes: 21 additions & 4 deletions execution_chain/evm/interpreter/op_handlers/oph_create.nim
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ proc createOp(cpt: VmCpt): EvmResultVoid =
cpt.stack.lsShrink(2)
cpt.stack.lsTop(0)

# EIP-3860
if cpt.fork >= FkShanghai and memLen > EIP3860_MAX_INITCODE_SIZE:
# EIP-7907 and EIP-3860
if cpt.fork >= FkOsaka and memLen > EIP7907_MAX_INITCODE_SIZE:
trace "Initcode size exceeds maximum", initcodeSize = memLen
return err(opErr(InvalidInitCode))

if cpt.fork < FkOsaka and cpt.fork >= FkShanghai and memLen > EIP3860_MAX_INITCODE_SIZE:
trace "Initcode size exceeds maximum", initcodeSize = memLen
return err(opErr(InvalidInitCode))

Expand Down Expand Up @@ -114,6 +118,10 @@ proc createOp(cpt: VmCpt): EvmResultVoid =
createMsgGas -= createMsgGas div 64
? cpt.gasMeter.consumeGas(createMsgGas, reason = "CREATE msg gas")

if cpt.fork >= FkOsaka:
cpt.vmState.mutateLedger:
db.codeAccessList(cpt.msg.contractAddress)

var
childMsg = Message(
kind: CallKind.Create,
Expand Down Expand Up @@ -146,8 +154,12 @@ proc create2Op(cpt: VmCpt): EvmResultVoid =
cpt.stack.lsShrink(3)
cpt.stack.lsTop(0)

# EIP-3860
if cpt.fork >= FkShanghai and memLen > EIP3860_MAX_INITCODE_SIZE:
# EIP-7907 and EIP-3860
if cpt.fork >= FkOsaka and memLen > EIP7907_MAX_INITCODE_SIZE:
trace "Initcode size exceeds maximum", initcodeSize = memLen
return err(opErr(InvalidInitCode))

if cpt.fork < FkOsaka and cpt.fork >= FkShanghai and memLen > EIP3860_MAX_INITCODE_SIZE:
trace "Initcode size exceeds maximum", initcodeSize = memLen
return err(opErr(InvalidInitCode))

Expand Down Expand Up @@ -181,6 +193,11 @@ proc create2Op(cpt: VmCpt): EvmResultVoid =
balance = senderBalance
return ok()

if cpt.fork >= FkOsaka:
cpt.vmState.mutateLedger:
db.codeAccessList(cpt.msg.contractAddress)


var createMsgGas = cpt.gasMeter.gasRemaining
if cpt.fork >= FkTangerine:
createMsgGas -= createMsgGas div 64
Expand Down
27 changes: 26 additions & 1 deletion execution_chain/evm/interpreter/op_handlers/oph_envinfo.nim
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ proc extCodeCopyEIP2929Op(cpt: VmCpt): EvmResultVoid =
cpt.memory.writePadded(code.bytes(), memPos, codePos, len)
ok()

proc extCodeCopyEIP7907Op(cpt: VmCpt): EvmResultVoid =
## 0x3c, Copy an account's code to memory (EIP-2929).
? cpt.stack.lsCheck(4)
let
address = cpt.stack.lsPeekAddress(^1)
memPos = cpt.stack.lsPeekMemRef(^2)
codePos = cpt.stack.lsPeekMemRef(^3)
len = cpt.stack.lsPeekMemRef(^4)
gasCost = cpt.gasCosts[ExtCodeCopy].m_handler(cpt.memory.len, memPos, len) +
cpt.gasEip2929AccountCheck(address) + cpt.gasCallEIP7907(address)

cpt.stack.lsShrink(4)
? cpt.opcodeGasCost(ExtCodeCopy, gasCost, reason = "ExtCodeCopy EIP7907")

let code = cpt.getCode(address)
cpt.memory.writePadded(code.bytes(), memPos, codePos, len)
ok()

# -----------

func returnDataSizeOp(cpt: VmCpt): EvmResultVoid =
Expand Down Expand Up @@ -345,11 +363,18 @@ const


(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin through Cancun
forks: VmOpBerlinAndLater,
forks: VmOpBerlinAndLater - VmOpOsakaAndLater,
name: "extCodeCopyEIP2929",
info: "EIP2929: Copy an account's code to memory",
exec: extCodeCopyEIP2929Op),

(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin through Cancun
forks: VmOpOsakaAndLater,
name: "extCodeCopyEIP7907",
info: "EIP7907: Copy an account's code to memory",
exec: extCodeCopyEIP7907Op),



(opCode: ReturnDataSize, ## 0x3d, Previous call output data size
forks: VmOpByzantiumAndLater,
Expand Down
14 changes: 14 additions & 0 deletions execution_chain/evm/interpreter/op_handlers/oph_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
{.push raises: [].}

import
../../../constants,
../../evm_errors,
../../interpreter/utils/utils_numeric,
../../types,
../gas_costs,
eth/common/[addresses, base],
Expand Down Expand Up @@ -59,6 +61,18 @@ proc delegateResolutionCost*(c: Computation, address: Address): GasInt =
else:
return WarmStorageReadCost

proc gasCallEIP7907*(c: Computation, codeAddress: Address): GasInt =
c.vmState.mutateLedger:

if not db.inCodeAccessList(codeAddress):
db.codeAccessList(codeAddress)

let
code = db.getCode(codeAddress)
excessContractSize = max(0, code.len - CODE_SIZE_THRESHOLD)
largeContractCost = (ceil32(excessContractSize) * 2) div 32
return GasInt(largeContractCost)

# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------
Loading