Skip to content

Berlinterop devnet 2 #3401

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 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
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
475600c
add eip-7883 changes
advaita-saha Jun 13, 2025
38fe506
Merge branch 'eip-7951' into berlinterop-devnet-2
advaita-saha Jun 13, 2025
08f856f
Merge branch 'CLZ' into berlinterop-devnet-2
advaita-saha 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
6c7f3da
Merge branch 'eip-7934' into berlinterop-devnet-2
advaita-saha Jun 13, 2025
81bf6fd
temp fix
advaita-saha Jun 13, 2025
58b1e1c
Merge branch 'modexp-new' into berlinterop-devnet-2
advaita-saha Jun 13, 2025
1446d18
another tmep fix
advaita-saha Jun 13, 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
5 changes: 3 additions & 2 deletions PrecompileTests.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ PrecompileTests
===
## PrecompileTests
```diff
+ P256Verify.json OK
+ blake2F.json OK
+ blsG1Add.json OK
+ blsG1MultiExp.json OK
Expand All @@ -24,7 +25,7 @@ PrecompileTests
+ ripemd160.json OK
+ sha256.json OK
```
OK: 21/21 Fail: 0/21 Skip: 0/21
OK: 22/22 Fail: 0/22 Skip: 0/22
## eest
```diff
+ add_G1_bls.json OK
Expand All @@ -49,4 +50,4 @@ OK: 21/21 Fail: 0/21 Skip: 0/21
OK: 18/18 Fail: 0/18 Skip: 0/18

---TOTAL---
OK: 39/39 Fail: 0/39 Skip: 0/39
OK: 40/40 Fail: 0/40 Skip: 0/40
4 changes: 4 additions & 0 deletions execution_chain/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,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: 2 additions & 0 deletions execution_chain/evm/interpreter/gas_costs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ template gasCosts(fork: EVMFork, prefix, ResultGasCostsName: untyped) =
Shl: fixed GasVeryLow,
Shr: fixed GasVeryLow,
Sar: fixed GasVeryLow,
Clz: fixed GasVeryLow,

# 20s: SHA3
Sha3: memExpansion `prefix gasSha3`,
Expand Down Expand Up @@ -858,3 +859,4 @@ const
Bls12381PairingPerPairGas* = GasInt 32600
Bls12381MapG1Gas* = GasInt 5500
Bls12381MapG2Gas* = GasInt 23800
GasP256VerifyGas* = GasInt 3450
5 changes: 3 additions & 2 deletions execution_chain/evm/interpreter/op_codes.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 @@ -58,8 +58,9 @@ type
Shl = 0x1B, ## Shift left
Shr = 0x1C, ## Logical shift right
Sar = 0x1D, ## Arithmetic shift right
Clz = 0x1E, ## Count leading zeros

Nop0x1E, Nop0x1F, ## ..
Nop0x1F, ## ..

# 20s: SHA3
Sha3 = 0x20, ## Compute Keccak-256 hash.
Expand Down
30 changes: 28 additions & 2 deletions execution_chain/evm/interpreter/op_handlers/oph_arithmetic.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 @@ -277,6 +277,26 @@ proc sarOp(cpt: VmCpt): EvmResultVoid =

cpt.stack.binaryWithTop(sar256)

proc clzOp(cpt: VmCpt): EvmResultVoid =
## 0x1e, Count Leading Zeros
template clz256(top, value, toStackElem) =
if value.isZero:
toStackElem(256.u256, top)
else:
var count = 0
for i in 0 ..< 32:
let b = (value shr ((31 - i) * 8)).truncate(byte)
if b != 0:
var mask = 0x80'u8
while (b and mask) == 0:
inc count
mask = mask shr 1
break
inc count, 8
toStackElem(count.u256, top)

cpt.stack.unaryWithTop(clz256)

# ------------------------------------------------------------------------------
# Public, op exec table entries
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -460,7 +480,13 @@ const
forks: VmOpConstantinopleAndLater,
name: "sarOp",
info: "Arithmetic shift right",
exec: sarOp)]
exec: sarOp),

(opCode: Clz, ## CLZ (Count Leading Zeros)
forks: VmOpOsakaAndLater, ## Or a newer fork gate, if appropriate
name: "clzOp",
info: "Count leading zero bits in a 256-bit word",
exec: clzOp)]

# ------------------------------------------------------------------------------
# End
Expand Down
6 changes: 6 additions & 0 deletions execution_chain/evm/interpreter/op_handlers/oph_defs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const
VmOpCancunAndLater* =
VmOpShanghaiAndLater - {FkShanghai}

VmOpPragueAndLater* =
VmOpCancunAndLater - {FkCancun}

VmOpOsakaAndLater* =
VmOpPragueAndLater - {FkPrague}

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