Skip to content

Conversation

@pmikolajczyk41
Copy link
Member

@pmikolajczyk41 pmikolajczyk41 commented Nov 13, 2025

Native nitro

This PR doesn't change anything for natively compiled nitro.

Wasm nitro

For wasm target compilation any Keccak hash computation that was done with crypto.Keccak256() or crypto.Keccak256Hash() will be now realized by an external call - the resulting wasm binary/library expects an external arbkeccak module exposing keccak256 function (see OffchainLabs/go-ethereum#578).

Almost all keccaking is done with these two function. However, there are still some places where we unnecessarily use stateful keccak. This might be problematic, since as a result, our hash delegation will not be applied there. Specifically:

Running replay.wasm

with JIT

we inject a Rust binding to the tiny_keccak library, which is no-std friendly and we already did use it in arbutil:

"arbkeccak" => {
    "keccak256" => func!(arbkeccak::keccak256),
}

with arbitrator

we build a new wasm library arbkeccak providing expected functionality:

pub unsafe extern "C" fn arbkeccak__keccak256(in_buf_ptr: GuestPtr, in_buf_len: u32, out_buf_ptr: GuestPtr)

companion PR: OffchainLabs/go-ethereum#578
part of NIT-4075

@github-actions
Copy link

github-actions bot commented Nov 13, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
2216 3 2213 0
View the top 3 failed tests by shortest run time
TestVersion40
Stack Traces | 6.250s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
INFO [11-18|15:40:03.028] HTTP server stopped                      endpoint=127.0.0.1:44239
TRACE[11-18|15:40:03.028] P2P networking is spinning down
    precompile_inclusion_test.go:90: goroutine 455450 [running]:
        runtime/debug.Stack()
        	/opt/hostedtoolcache/go/1.25.4/x64/src/runtime/debug/stack.go:26 +0x5e
        github.com/offchainlabs/nitro/util/testhelpers.RequireImpl({0x40e0e30, 0xc095383dc0}, {0x409e680, 0xc2a0fcb380}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc095383dc0, {0x409e680, 0xc2a0fcb380}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1759 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc095383dc0, 0x28, {0xc11b077df8, 0x5, 0x39?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:90 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion40(0xc095383dc0?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:71 +0x64b
        testing.tRunner(0xc095383dc0, 0x3d251c8)
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1997 +0x465
        
    precompile_inclusion_test.go:90: �[31;1m [] execution aborted (timeout = 5s) �[0;0m
--- FAIL: TestVersion40 (6.25s)
TestVersion30
Stack Traces | 7.050s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
=== PAUSE TestVersion30
=== CONT  TestVersion30
    precompile_inclusion_test.go:90: goroutine 455449 [running]:
        runtime/debug.Stack()
        	/opt/hostedtoolcache/go/1.25.4/x64/src/runtime/debug/stack.go:26 +0x5e
        github.com/offchainlabs/nitro/util/testhelpers.RequireImpl({0x40e0e30, 0xc095383c00}, {0x409e680, 0xc2aeadfa40}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc095383c00, {0x409e680, 0xc2aeadfa40}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1759 +0x5d
        github.com/offchainlabs/nitro/system_tests.testPrecompiles(0xc095383c00, 0x1e, {0xc0c885fdb0, 0x6, 0x4f5de9?})
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:90 +0x371
        github.com/offchainlabs/nitro/system_tests.TestVersion30(0xc095383c00?)
        	/home/runner/work/nitro/nitro/system_tests/precompile_inclusion_test.go:67 +0x798
        testing.tRunner(0xc095383c00, 0x3d251c0)
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1997 +0x465
        
    precompile_inclusion_test.go:90: �[31;1m [] execution aborted (timeout = 5s) �[0;0m
--- FAIL: TestVersion30 (7.05s)
TestOutOfGasInStorageCacheFlush
Stack Traces | 7.140s run time
... [CONTENT TRUNCATED: Keeping last 20 lines]
�[34;1mChecking success (Rust => Solidity => Rust)�[0;0m
�[34;1mChecking call with value (Rust => EOA)�[0;0m
    program_test.go:2813: goroutine 685232 [running]:
        runtime/debug.Stack()
        	/opt/hostedtoolcache/go/1.25.4/x64/src/runtime/debug/stack.go:26 +0x5e
        github.com/offchainlabs/nitro/util/testhelpers.RequireImpl({0x40e0e30, 0xc0d6384fc0}, {0x409e200, 0xc15ac69560}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/util/testhelpers/testhelpers.go:29 +0x55
        github.com/offchainlabs/nitro/system_tests.Require(0xc0d6384fc0, {0x409e200, 0xc15ac69560}, {0x0, 0x0, 0x0})
        	/home/runner/work/nitro/nitro/system_tests/common_test.go:1759 +0x5d
        github.com/offchainlabs/nitro/system_tests.TestOutOfGasInStorageCacheFlush(0xc0d6384fc0)
        	/home/runner/work/nitro/nitro/system_tests/program_test.go:2813 +0xfe6
        testing.tRunner(0xc0d6384fc0, 0x3d24ce8)
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1934 +0xea
        created by testing.(*T).Run in goroutine 1
        	/opt/hostedtoolcache/go/1.25.4/x64/src/testing/testing.go:1997 +0x465
        
    program_test.go:2813: �[31;1m [] failed calculating position for validation: batch not found on L1 yet �[0;0m
INFO [11-18|15:39:41.418] HTTP server stopped                      endpoint=127.0.0.1:43583
TRACE[11-18|15:39:41.418] P2P networking is spinning down
--- FAIL: TestOutOfGasInStorageCacheFlush (7.14s)

📣 Thoughts on this report? Let Codecov know! | Powered by Codecov

@pmikolajczyk41 pmikolajczyk41 marked this pull request as ready for review November 18, 2025 13:25
Copy link
Contributor

@bragaigor bragaigor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In these set of PRs we introduce keccak for ZKVM precompile but only start using in some another PR, the ones mentioned in the description? Or am I missing something? And for my own sanity, the introduced keccak for replay.wasm uses the same implementation since wasm counterpart calls into arbkeccak::keccak256 as well?

@pmikolajczyk41
Copy link
Member Author

In these set of PRs we introduce keccak for ZKVM precompile but only start using in some another PR, the ones mentioned in the description? Or am I missing something?

This set of PRs introduce just one thing: whenever we compile nitro into wasm (e.g. cmd/replay/main.go), instead of using keccak implementation from a Golang lib sha3 (it was wrapped in the go-ethereum/crypto package), we will use expect that there will be also a wasm module called arbkeccak provided, with a method keccak256. For 2 specific cases, JIT replay and Arbitrator replay we provide this module either as a hacky injection (JIT case) or a standard wasm module (arbitrator case).

The other PRs mentioned in the description are just about ensuring that there are no other keccak hashing across the codebase that would still use the old way.

And for my own sanity, the introduced keccak for replay.wasm uses the same implementation since wasm counterpart calls into arbkeccak::keccak256 as well?

after this PR, the replay.wasm will start using the new implementation that comes from Rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants