From 03c24842e089c9cf5937745627c4b3d3f88e3300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 12:10:50 +0100 Subject: [PATCH 01/21] Create arbkeccak dummy package --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 5980b42518..cda5f1337a 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 5980b4251863bd54b6b2e2b681cb8880bd57bc10 +Subproject commit cda5f1337a43daf630d059b97a5f1864134e47be From 879e77e41fd911dec0968b0638c3b0828d710b2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 12:16:13 +0100 Subject: [PATCH 02/21] Remove Keccak512 (not used, avoid future collision) --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index cda5f1337a..7bd1d709e4 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit cda5f1337a43daf630d059b97a5f1864134e47be +Subproject commit 7bd1d709e4fb79121fa1b83d221e55cdaa570bc4 From 45a870752775439f48d4f3f7c5605656f98406b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 12:24:44 +0100 Subject: [PATCH 03/21] Move crypto.Keccak* to arbkeccak --- arbnode/delay_buffer.go | 5 +- arbnode/delayed.go | 10 ++-- .../mel/extraction/delayed_message_lookup.go | 5 +- .../extraction/delayed_message_lookup_test.go | 8 +-- .../extraction/message_extraction_function.go | 5 +- .../message_extraction_function_test.go | 5 +- arbnode/mel/messages.go | 15 +++--- arbos/addressTable/addressTable_test.go | 9 ++-- arbos/arbostypes/incomingmessage.go | 4 +- arbos/arbostypes/messagewithmeta.go | 4 +- arbos/blockhash/blockhash_test.go | 6 +-- arbos/l1pricing/l1pricing.go | 14 +++--- arbos/merkleAccumulator/merkleAccumulator.go | 9 ++-- arbos/parse_l2.go | 8 +-- arbos/retryables/retryable.go | 5 +- arbos/storage/storage.go | 8 +-- arbos/storage/storage_test.go | 5 +- arbutil/hash.go | 4 +- blsSignatures/blsSignatures.go | 4 +- bold/chain-abstraction/execution_state.go | 5 +- bold/chain-abstraction/interfaces.go | 4 +- .../edge_challenge_manager.go | 4 +- .../history/history_commitment.go | 7 ++- .../history/history_commitment_test.go | 49 +++++++++---------- .../inclusion-proofs/inclusion_proofs.go | 17 +++---- .../prefix-proofs/merkle_expansions_test.go | 17 +++---- .../prefix-proofs/prefix_proofs.go | 12 ++--- .../prefix-proofs/prefix_proofs_test.go | 7 +-- bold/testing/integration/prefixproofs_test.go | 5 +- .../layer2_state_provider_test.go | 9 ++-- cmd/el-proxy/main.go | 4 +- cmd/mel-replay/delayed_message_db_test.go | 6 +-- cmd/mel-replay/receipt_fetcher_test.go | 4 +- daprovider/das/dastree/dastree.go | 9 ++-- daprovider/das/dastree/dastree_test.go | 9 ++-- daprovider/das/dasutil/dasutil.go | 6 +-- .../das/extra_signature_checker_test.go | 5 +- daprovider/data_streaming/signing.go | 9 ++-- daprovider/referenceda/reference_reader.go | 4 +- execution/gethexec/classicMessage.go | 4 +- .../gethexec/express_lane_service_test.go | 3 +- execution/nodeInterface/NodeInterface.go | 14 +++--- go-ethereum | 2 +- precompiles/ArbAddressTable_test.go | 8 +-- precompiles/ArbAggregator_test.go | 9 ++-- precompiles/ArbGasInfo_test.go | 6 +-- precompiles/ArbOwner_test.go | 16 +++--- precompiles/constraints_test.go | 5 +- precompiles/precompile.go | 4 +- precompiles/precompile_test.go | 4 +- staker/bold/bold_state_provider.go | 4 +- staker/legacy/assertion.go | 5 +- staker/legacy/block_challenge_backend.go | 7 ++- staker/legacy/l1_validator.go | 4 +- staker/legacy/rollup_watcher.go | 4 +- system_tests/conditionaltx_test.go | 4 +- system_tests/infra_fee_test.go | 5 +- system_tests/multigas_stylus_program_test.go | 4 +- system_tests/outbox_test.go | 8 +-- system_tests/precompile_doesnt_revert_test.go | 11 ++--- system_tests/precompile_test.go | 12 ++--- system_tests/program_ink_test.go | 4 +- system_tests/program_test.go | 11 +++-- system_tests/seqfeed_test.go | 4 +- system_tests/staker_test.go | 4 +- system_tests/stylus_trace_test.go | 7 +-- system_tests/test_info.go | 3 +- system_tests/timeboost_test.go | 4 +- system_tests/validation_mock_test.go | 4 +- timeboost/types.go | 7 +-- util/merkletree/merkleAccumulator_test.go | 19 ++++--- util/merkletree/merkleEventProof_test.go | 7 ++- util/merkletree/merkleTree.go | 11 ++--- util/signature/sign_verify.go | 7 ++- util/signature/simple_hmac.go | 8 +-- util/signature/verifier.go | 3 +- util/signature/verifier_test.go | 5 +- validator/execution_state.go | 11 ++--- .../proofenhancement/proof_enhancer_test.go | 15 +++--- .../readpreimage_proof_enhancer.go | 5 +- .../validatecertificate_proof_enhancer.go | 5 +- wavmio/stub.go | 4 +- 82 files changed, 297 insertions(+), 319 deletions(-) diff --git a/arbnode/delay_buffer.go b/arbnode/delay_buffer.go index 89b7b71318..41a71c05bc 100644 --- a/arbnode/delay_buffer.go +++ b/arbnode/delay_buffer.go @@ -12,9 +12,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/headerreader" @@ -94,7 +93,7 @@ func GenDelayProof(ctx context.Context, message *arbostypes.MessageWithMetadata, Timestamp: message.Message.Header.Timestamp, InboxSeqNum: new(big.Int).SetUint64(seqNum), BaseFeeL1: message.Message.Header.L1BaseFee, - MessageDataHash: crypto.Keccak256Hash(message.Message.L2msg), + MessageDataHash: arbkeccak.Keccak256Hash(message.Message.L2msg), } delayProof := &bridgegen.DelayProof{ BeforeDelayedAcc: beforeDelayedAcc, diff --git a/arbnode/delayed.go b/arbnode/delayed.go index e76f674644..98ca56e423 100644 --- a/arbnode/delayed.go +++ b/arbnode/delayed.go @@ -15,10 +15,10 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -143,16 +143,16 @@ type DelayedInboxMessage struct { } func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash { - hash := crypto.Keccak256( + hash := arbkeccak.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - crypto.Keccak256(m.Message.L2msg), + arbkeccak.Keccak256(m.Message.L2msg), ) - return crypto.Keccak256Hash(m.BeforeInboxAcc[:], hash) + return arbkeccak.Keccak256Hash(m.BeforeInboxAcc[:], hash) } func (b *DelayedBridge) LookupMessagesInRange(ctx context.Context, from, to *big.Int, batchFetcher arbostypes.FallibleBatchFetcher) ([]*DelayedInboxMessage, error) { @@ -224,7 +224,7 @@ func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []type if !ok { return nil, fmt.Errorf("message %v data not found", parsedLog.MessageIndex) } - if crypto.Keccak256Hash(data) != parsedLog.MessageDataHash { + if arbkeccak.Keccak256Hash(data) != parsedLog.MessageDataHash { return nil, fmt.Errorf("found message %v data with mismatched hash", parsedLog.MessageIndex) } diff --git a/arbnode/mel/extraction/delayed_message_lookup.go b/arbnode/mel/extraction/delayed_message_lookup.go index 5385fc2121..63d1d6bbf8 100644 --- a/arbnode/mel/extraction/delayed_message_lookup.go +++ b/arbnode/mel/extraction/delayed_message_lookup.go @@ -9,10 +9,9 @@ import ( "sort" "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" @@ -118,7 +117,7 @@ func parseDelayedMessagesFromBlock( if !ok { return nil, fmt.Errorf("message %v data not found", parsedLog.MessageIndex) } - if crypto.Keccak256Hash(data) != parsedLog.MessageDataHash { + if arbkeccak.Keccak256Hash(data) != parsedLog.MessageDataHash { return nil, fmt.Errorf("found message %v data with mismatched hash", parsedLog.MessageIndex) } // Fill in the message data for the delayed message scaffolds. diff --git a/arbnode/mel/extraction/delayed_message_lookup_test.go b/arbnode/mel/extraction/delayed_message_lookup_test.go index 19c9f21dc4..a3ee349d23 100644 --- a/arbnode/mel/extraction/delayed_message_lookup_test.go +++ b/arbnode/mel/extraction/delayed_message_lookup_test.go @@ -6,11 +6,11 @@ import ( "sort" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/trie" "github.com/offchainlabs/nitro/arbnode/mel" @@ -257,7 +257,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: crypto.Keccak256Hash(msgData), + MessageDataHash: arbkeccak.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } @@ -359,7 +359,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: crypto.Keccak256Hash(msgData), + MessageDataHash: arbkeccak.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } @@ -451,7 +451,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: crypto.Keccak256Hash(msgData), + MessageDataHash: arbkeccak.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } diff --git a/arbnode/mel/extraction/message_extraction_function.go b/arbnode/mel/extraction/message_extraction_function.go index 4f8fc57cd3..fdfe5e490b 100644 --- a/arbnode/mel/extraction/message_extraction_function.go +++ b/arbnode/mel/extraction/message_extraction_function.go @@ -6,10 +6,9 @@ import ( "errors" "fmt" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate" @@ -178,7 +177,7 @@ func extractMessagesImpl( if err != nil { return nil, nil, nil, fmt.Errorf("failed to parse batch posting report: %w", err) } - gotHash := crypto.Keccak256Hash(serialized) + gotHash := arbkeccak.Keccak256Hash(serialized) if gotHash != batchHash { return nil, nil, nil, fmt.Errorf( "batch data hash incorrect %v (wanted %v for batch %v)", diff --git a/arbnode/mel/extraction/message_extraction_function_test.go b/arbnode/mel/extraction/message_extraction_function_test.go index 8bc60ab2e1..8badabe7fa 100644 --- a/arbnode/mel/extraction/message_extraction_function_test.go +++ b/arbnode/mel/extraction/message_extraction_function_test.go @@ -7,12 +7,11 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate" @@ -299,7 +298,7 @@ func failingSerializer(ctx context.Context, func successfulParseReport( rd io.Reader, ) (*big.Int, common.Address, common.Hash, uint64, *big.Int, uint64, error) { - return nil, common.Address{}, crypto.Keccak256Hash([]byte("foobar")), 0, nil, 0, nil + return nil, common.Address{}, arbkeccak.Keccak256Hash([]byte("foobar")), 0, nil, 0, nil } func emptyParseReport( diff --git a/arbnode/mel/messages.go b/arbnode/mel/messages.go index 3bab5d214d..f3afbba90a 100644 --- a/arbnode/mel/messages.go +++ b/arbnode/mel/messages.go @@ -1,10 +1,9 @@ package mel import ( + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/bridgegen" @@ -43,30 +42,30 @@ type DelayedInboxMessage struct { } func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash { - hash := crypto.Keccak256( + hash := arbkeccak.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - crypto.Keccak256(m.Message.L2msg), + arbkeccak.Keccak256(m.Message.L2msg), ) - return crypto.Keccak256Hash(m.BeforeInboxAcc[:], hash) + return arbkeccak.Keccak256Hash(m.BeforeInboxAcc[:], hash) } // Hash will replace AfterInboxAcc func (m *DelayedInboxMessage) Hash() common.Hash { - hash := crypto.Keccak256( + hash := arbkeccak.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - crypto.Keccak256(m.Message.L2msg), + arbkeccak.Keccak256(m.Message.L2msg), ) - return crypto.Keccak256Hash(hash) + return arbkeccak.Keccak256Hash(hash) } type BatchMetadata struct { diff --git a/arbos/addressTable/addressTable_test.go b/arbos/addressTable/addressTable_test.go index b368f82881..9002f4065a 100644 --- a/arbos/addressTable/addressTable_test.go +++ b/arbos/addressTable/addressTable_test.go @@ -7,9 +7,8 @@ import ( "bytes" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" @@ -39,7 +38,7 @@ func TestAddressTable1(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) _, err := atab.Register(addr) Require(t, err) if size(t, atab) != 1 { @@ -85,7 +84,7 @@ func TestAddressTableCompressNotInTable(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) res, err := atab.Compress(addr) Require(t, err) @@ -112,7 +111,7 @@ func TestAddressTableCompressInTable(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) _, err := atab.Register(addr) Require(t, err) diff --git a/arbos/arbostypes/incomingmessage.go b/arbos/arbostypes/incomingmessage.go index e3e17068ee..0057334204 100644 --- a/arbos/arbostypes/incomingmessage.go +++ b/arbos/arbostypes/incomingmessage.go @@ -11,8 +11,8 @@ import ( "io" "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/util" @@ -191,7 +191,7 @@ func (msg *L1IncomingMessage) FillInBatchGasFields(batchFetcher FallibleBatchFet if err != nil { return fmt.Errorf("failed to fetch batch mentioned by batch posting report: %w", err) } - gotHash := crypto.Keccak256Hash(batchData) + gotHash := arbkeccak.Keccak256Hash(batchData) if gotHash != batchHash { return fmt.Errorf("batch fetcher returned incorrect data hash %v (wanted %v for batch %v)", gotHash, batchHash, batchNum) } diff --git a/arbos/arbostypes/messagewithmeta.go b/arbos/arbostypes/messagewithmeta.go index 36ca90d728..4458e2bf57 100644 --- a/arbos/arbostypes/messagewithmeta.go +++ b/arbos/arbostypes/messagewithmeta.go @@ -5,8 +5,8 @@ import ( "encoding/binary" "fmt" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" "github.com/offchainlabs/nitro/arbutil" @@ -46,7 +46,7 @@ func (m *MessageWithMetadata) Hash(sequenceNumber arbutil.MessageIndex, chainId return common.Hash{}, fmt.Errorf("unable to serialize message %v: %w", sequenceNumber, err) } - return crypto.Keccak256Hash(uniquifyingPrefix, serializedExtraData, serializedMessage), nil + return arbkeccak.Keccak256Hash(uniquifyingPrefix, serializedExtraData, serializedMessage), nil } type InboxMultiplexer interface { diff --git a/arbos/blockhash/blockhash_test.go b/arbos/blockhash/blockhash_test.go index dba21bac06..aa4b905fc9 100644 --- a/arbos/blockhash/blockhash_test.go +++ b/arbos/blockhash/blockhash_test.go @@ -6,8 +6,8 @@ package blockhash import ( "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/burn" @@ -36,7 +36,7 @@ func TestBlockhash(t *testing.T) { Fail(t, "should have generated error on Blockhash(4242) in new Blockhashes") } - hash0 := common.BytesToHash(crypto.Keccak256([]byte{0})) + hash0 := common.BytesToHash(arbkeccak.Keccak256([]byte{0})) err = bh.RecordNewL1Block(0, hash0, arbosVersion) Require(t, err) bnum, err = bh.L1BlockNumber() @@ -50,7 +50,7 @@ func TestBlockhash(t *testing.T) { Fail(t, "incorrect hash return for initial Blockhash(0)") } - hash4242 := common.BytesToHash(crypto.Keccak256([]byte{42, 42})) + hash4242 := common.BytesToHash(arbkeccak.Keccak256([]byte{42, 42})) err = bh.RecordNewL1Block(4242, hash4242, arbosVersion) Require(t, err) bnum, err = bh.L1BlockNumber() diff --git a/arbos/l1pricing/l1pricing.go b/arbos/l1pricing/l1pricing.go index 793250be26..2c94162768 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -9,12 +9,12 @@ import ( "fmt" "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbcompress" @@ -558,13 +558,13 @@ var estimationPaddingUnits uint64 = 16 * params.TxDataNonZeroGasEIP2028 const estimationPaddingBasisPoints = 100 -var randomNonce = binary.BigEndian.Uint64(crypto.Keccak256([]byte("Nonce"))[:8]) -var randomGasTipCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasTipCap"))[:4]) -var randomGasFeeCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasFeeCap"))[:4]) -var RandomGas = uint64(binary.BigEndian.Uint32(crypto.Keccak256([]byte("Gas"))[:4])) +var randomNonce = binary.BigEndian.Uint64(arbkeccak.Keccak256([]byte("Nonce"))[:8]) +var randomGasTipCap = new(big.Int).SetBytes(arbkeccak.Keccak256([]byte("GasTipCap"))[:4]) +var randomGasFeeCap = new(big.Int).SetBytes(arbkeccak.Keccak256([]byte("GasFeeCap"))[:4]) +var RandomGas = uint64(binary.BigEndian.Uint32(arbkeccak.Keccak256([]byte("Gas"))[:4])) var randV = arbmath.BigMulByUint(chaininfo.ArbitrumOneChainConfig().ChainID, 3) -var randR = crypto.Keccak256Hash([]byte("R")).Big() -var randS = crypto.Keccak256Hash([]byte("S")).Big() +var randR = arbkeccak.Keccak256Hash([]byte("R")).Big() +var randS = arbkeccak.Keccak256Hash([]byte("S")).Big() // The returned tx will be invalid, likely for a number of reasons such as an invalid signature. // It's only used to check how large it is after brotli level 0 compression. diff --git a/arbos/merkleAccumulator/merkleAccumulator.go b/arbos/merkleAccumulator/merkleAccumulator.go index eb34cad23f..6650e1ac02 100644 --- a/arbos/merkleAccumulator/merkleAccumulator.go +++ b/arbos/merkleAccumulator/merkleAccumulator.go @@ -4,9 +4,8 @@ package merkleAccumulator import ( + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" ) @@ -69,14 +68,14 @@ func (acc *MerkleAccumulator) Keccak(data ...[]byte) ([]byte, error) { if acc.backingStorage != nil { return acc.backingStorage.Keccak(data...) } - return crypto.Keccak256(data...), nil + return arbkeccak.Keccak256(data...), nil } func (acc *MerkleAccumulator) KeccakHash(data ...[]byte) (common.Hash, error) { if acc.backingStorage != nil { return acc.backingStorage.KeccakHash(data...) } - return crypto.Keccak256Hash(data...), nil + return arbkeccak.Keccak256Hash(data...), nil } func (acc *MerkleAccumulator) getPartial(level uint64) (*common.Hash, error) { @@ -131,7 +130,7 @@ func (acc *MerkleAccumulator) Append(itemHash common.Hash) ([]MerkleTreeNodeEven events := []MerkleTreeNodeEvent{} level := uint64(0) - soFar := crypto.Keccak256(itemHash.Bytes()) + soFar := arbkeccak.Keccak256(itemHash.Bytes()) for { if level == CalcNumPartials(size-1) { // -1 to counteract the acc.size++ at top of this function h := common.BytesToHash(soFar) diff --git a/arbos/parse_l2.go b/arbos/parse_l2.go index 776068eb16..09394099e1 100644 --- a/arbos/parse_l2.go +++ b/arbos/parse_l2.go @@ -8,9 +8,9 @@ import ( "math/big" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" @@ -40,8 +40,8 @@ func ParseL2Transactions(msg *arbostypes.L1IncomingMessage, chainId *big.Int, la return nil, errors.New("cannot issue L2 funded by L1 tx without L1 request id") } kind := msg.L2msg[0] - depositRequestId := crypto.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big0)) - unsignedRequestId := crypto.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big1)) + depositRequestId := arbkeccak.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big0)) + unsignedRequestId := arbkeccak.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big1)) tx, err := parseUnsignedTx(bytes.NewReader(msg.L2msg[1:]), msg.Header.Poster, &unsignedRequestId, chainId, kind) if err != nil { return nil, err @@ -146,7 +146,7 @@ func parseL2Message(rd io.Reader, poster common.Address, timestamp uint64, reque var nextRequestId *common.Hash if requestId != nil { - subRequestId := crypto.Keccak256Hash(requestId[:], arbmath.U256Bytes(index)) + subRequestId := arbkeccak.Keccak256Hash(requestId[:], arbmath.U256Bytes(index)) nextRequestId = &subRequestId } nestedSegments, err := parseL2Message(bytes.NewReader(nextMsg), poster, timestamp, nextRequestId, chainId, depth+1) diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index 43e344f96f..046084672b 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -9,12 +9,11 @@ import ( "math/big" "github.com/ethereum/go-ethereum/arbitrum/multigas" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" @@ -366,7 +365,7 @@ func (retryable *Retryable) MakeTx(chainId *big.Int, nonce uint64, gasFeeCap *bi } func RetryableEscrowAddress(ticketId common.Hash) common.Address { - return common.BytesToAddress(crypto.Keccak256([]byte("retryable escrow"), ticketId.Bytes())) + return common.BytesToAddress(arbkeccak.Keccak256([]byte("retryable escrow"), ticketId.Bytes())) } func RetryableSubmissionFee(calldataLengthInBytes int, l1BaseFee *big.Int) *big.Int { diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index d06453b2d1..6cea1184c9 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -11,13 +11,13 @@ import ( "sync/atomic" "github.com/ethereum/go-ethereum/arbitrum/multigas" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/triedb" @@ -333,7 +333,7 @@ func (s *Storage) Keccak(data ...[]byte) ([]byte, error) { if err := s.burner.Burn(multigas.ResourceKindComputation, cost); err != nil { return nil, err } - return crypto.Keccak256(data...), nil + return arbkeccak.Keccak256(data...), nil } func (s *Storage) KeccakHash(data ...[]byte) (common.Hash, error) { @@ -348,13 +348,13 @@ func (s *Storage) KeccakHash(data ...[]byte) (common.Hash, error) { // note: returned slice is not thread-safe func (s *Storage) cachedKeccak(data ...[]byte) []byte { if s.hashCache == nil { - return crypto.Keccak256(data...) + return arbkeccak.Keccak256(data...) } keyString := string(bytes.Join(data, []byte{})) if hash, wasCached := s.hashCache.Get(keyString); wasCached { return hash } - hash := crypto.Keccak256(data...) + hash := arbkeccak.Keccak256(data...) evicted := s.hashCache.Add(keyString, hash) if evicted && cacheFullLogged.CompareAndSwap(false, true) { log.Warn("Hash cache full, we didn't expect that. Some non-static storage keys may fill up the cache.") diff --git a/arbos/storage/storage_test.go b/arbos/storage/storage_test.go index 750f257d48..35bf8e49b8 100644 --- a/arbos/storage/storage_test.go +++ b/arbos/storage/storage_test.go @@ -8,10 +8,9 @@ import ( "sync" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/util/arbmath" ) @@ -106,7 +105,7 @@ func TestOpenCachedSubStorage(t *testing.T) { } var expectedKeys [][]byte for _, subSpaceID := range subSpaceIDs { - expectedKeys = append(expectedKeys, crypto.Keccak256(s.storageKey, subSpaceID)) + expectedKeys = append(expectedKeys, arbkeccak.Keccak256(s.storageKey, subSpaceID)) } n := len(subSpaceIDs) * 50 start := make(chan struct{}) diff --git a/arbutil/hash.go b/arbutil/hash.go index c6e91c8ebf..26bacb78b0 100644 --- a/arbutil/hash.go +++ b/arbutil/hash.go @@ -3,8 +3,8 @@ package arbutil import ( "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" ) // PaddedKeccak256 pads each argument to 32 bytes, concatenates and returns @@ -14,7 +14,7 @@ func PaddedKeccak256(args ...[]byte) []byte { for _, arg := range args { data = append(data, common.BytesToHash(arg).Bytes()...) } - return crypto.Keccak256(data) + return arbkeccak.Keccak256(data) } // SumBytes sums two byte slices and returns the result. diff --git a/blsSignatures/blsSignatures.go b/blsSignatures/blsSignatures.go index eba084584f..3b42c7752c 100644 --- a/blsSignatures/blsSignatures.go +++ b/blsSignatures/blsSignatures.go @@ -9,7 +9,7 @@ import ( "errors" "math/big" - "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/crypto/bls12381" ) @@ -181,7 +181,7 @@ func VerifyAggregatedSignatureDifferentMessages(sig Signature, messages [][]byte // so that the result will not collide with a result generated in an ordinary signature. func hashToG1Curve(message []byte, keyValidationMode bool) (*bls12381.PointG1, error) { var padding [16]byte - h := crypto.Keccak256(message) + h := arbkeccak.Keccak256(message) if keyValidationMode { // modify padding, for domain separation padding[0] = 1 diff --git a/bold/chain-abstraction/execution_state.go b/bold/chain-abstraction/execution_state.go index 07d4c57d25..30768aa250 100644 --- a/bold/chain-abstraction/execution_state.go +++ b/bold/chain-abstraction/execution_state.go @@ -10,9 +10,8 @@ import ( "encoding/binary" "math" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/solgen/go/challengeV2gen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" ) @@ -51,7 +50,7 @@ func (s GoGlobalState) Hash() common.Hash { data = append(data, s.SendRoot.Bytes()...) data = append(data, u64ToBe(s.Batch)...) data = append(data, u64ToBe(s.PosInBatch)...) - return crypto.Keccak256Hash(data) + return arbkeccak.Keccak256Hash(data) } func (s GoGlobalState) AsSolidityStruct() challengeV2gen.GlobalState { diff --git a/bold/chain-abstraction/interfaces.go b/bold/chain-abstraction/interfaces.go index 3d06adf724..886338aa7d 100644 --- a/bold/chain-abstraction/interfaces.go +++ b/bold/chain-abstraction/interfaces.go @@ -12,12 +12,12 @@ import ( "strconv" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/bold/containers/option" @@ -134,7 +134,7 @@ type AssertionCreatedInfo struct { func (i AssertionCreatedInfo) ExecutionHash() common.Hash { afterGlobalStateHash := GoGlobalStateFromSolidity(i.AfterState.GlobalState).Hash() - return crypto.Keccak256Hash(append([]byte{i.AfterState.MachineStatus}, afterGlobalStateHash.Bytes()...)) + return arbkeccak.Keccak256Hash(append([]byte{i.AfterState.MachineStatus}, afterGlobalStateHash.Bytes()...)) } // AssertionChain can manage assertions in the protocol and retrieve diff --git a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go index 487d02bae2..6b6fc3eda1 100644 --- a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go +++ b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go @@ -11,13 +11,13 @@ import ( "strings" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/metrics" "github.com/offchainlabs/nitro/bold/chain-abstraction" @@ -535,7 +535,7 @@ func calculateMutualId(level uint8, originId [32]byte, startHeight *big.Int, sta return common.Hash{}, err } // Pack stores level(uint8) as 32 bytes, so we need to slice off the first 31 bytes - return crypto.Keccak256Hash(mutualIdByte[31:]), nil + return arbkeccak.Keccak256Hash(mutualIdByte[31:]), nil } // GetEdge gets an edge by its hash. diff --git a/bold/state-commitments/history/history_commitment.go b/bold/state-commitments/history/history_commitment.go index 305d6585ec..240c856792 100644 --- a/bold/state-commitments/history/history_commitment.go +++ b/bold/state-commitments/history/history_commitment.go @@ -44,10 +44,9 @@ import ( "fmt" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/bold/math" ) @@ -75,7 +74,7 @@ type treePosition struct { type historyCommitter struct { fillers []common.Hash - keccak crypto.KeccakState + keccak arbkeccak.KeccakState cursor treePosition lastLeafProver *lastLeafProver } @@ -83,7 +82,7 @@ type historyCommitter struct { func newCommitter() *historyCommitter { return &historyCommitter{ fillers: make([]common.Hash, 0), - keccak: crypto.NewKeccakState(), + keccak: arbkeccak.NewKeccakState(), } } diff --git a/bold/state-commitments/history/history_commitment_test.go b/bold/state-commitments/history/history_commitment_test.go index af03b94c7d..fceaaa8043 100644 --- a/bold/state-commitments/history/history_commitment_test.go +++ b/bold/state-commitments/history/history_commitment_test.go @@ -8,18 +8,17 @@ import ( "fmt" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/bold/state-commitments/legacy" "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" "github.com/offchainlabs/nitro/bold/testing/casttest" ) func FuzzHistoryCommitter(f *testing.F) { - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) f.Fuzz(func(t *testing.T, numReal uint64, virtual uint64, limit uint64) { // Set some bounds. numReal = numReal % (1 << 10) @@ -42,7 +41,7 @@ func FuzzHistoryCommitter(f *testing.F) { func BenchmarkPrefixProofGeneration_Legacy(b *testing.B) { for i := 0; i < b.N; i++ { prefixIndex := 13384 - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) hashes := make([]common.Hash, 1<<14) for i := 0; i < len(hashes); i++ { hashes[i] = simpleHash @@ -64,8 +63,8 @@ func BenchmarkPrefixProofGeneration_Legacy(b *testing.B) { func BenchmarkPrefixProofGeneration_Optimized(b *testing.B) { b.StopTimer() - simpleHash := crypto.Keccak256Hash([]byte("foo")) - hashes := []common.Hash{crypto.Keccak256Hash(simpleHash[:])} + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + hashes := []common.Hash{arbkeccak.Keccak256Hash(simpleHash[:])} prefixIndex := uint64(13384) virtual := uint64(1 << 14) committer := newCommitter() @@ -80,20 +79,20 @@ func TestSimpleHistoryCommitment(t *testing.T) { aLeaf := common.HexToHash("0xA") bLeaf := common.HexToHash("0xB") // Level 0 - aHash := crypto.Keccak256Hash(aLeaf[:]) - bHash := crypto.Keccak256Hash(bLeaf[:]) + aHash := arbkeccak.Keccak256Hash(aLeaf[:]) + bHash := arbkeccak.Keccak256Hash(bLeaf[:]) // Level 1 - abHash := crypto.Keccak256Hash(append(aHash[:], bHash[:]...)) - bzHash := crypto.Keccak256Hash(append(bHash[:], emptyHash[:]...)) - bbHash := crypto.Keccak256Hash(append(bHash[:], bHash[:]...)) + abHash := arbkeccak.Keccak256Hash(append(aHash[:], bHash[:]...)) + bzHash := arbkeccak.Keccak256Hash(append(bHash[:], emptyHash[:]...)) + bbHash := arbkeccak.Keccak256Hash(append(bHash[:], bHash[:]...)) // Level 2 - abbzHash := crypto.Keccak256Hash(append(abHash[:], bzHash[:]...)) - abbbHash := crypto.Keccak256Hash(append(abHash[:], bbHash[:]...)) - ababHash := crypto.Keccak256Hash(append(abHash[:], abHash[:]...)) - bbbbHash := crypto.Keccak256Hash(append(bbHash[:], bbHash[:]...)) + abbzHash := arbkeccak.Keccak256Hash(append(abHash[:], bzHash[:]...)) + abbbHash := arbkeccak.Keccak256Hash(append(abHash[:], bbHash[:]...)) + ababHash := arbkeccak.Keccak256Hash(append(abHash[:], abHash[:]...)) + bbbbHash := arbkeccak.Keccak256Hash(append(bbHash[:], bbHash[:]...)) // Level 3 - ababbbbbHash := crypto.Keccak256Hash(append(ababHash[:], bbbbHash[:]...)) - abababbbHash := crypto.Keccak256Hash(append(ababHash[:], abbbHash[:]...)) + ababbbbbHash := arbkeccak.Keccak256Hash(append(ababHash[:], bbbbHash[:]...)) + abababbbHash := arbkeccak.Keccak256Hash(append(ababHash[:], abbbHash[:]...)) tests := []struct { name string @@ -167,7 +166,7 @@ func TestSimpleHistoryCommitment(t *testing.T) { func TestLegacyVsOptimized(t *testing.T) { t.Parallel() end := uint64(1 << 6) - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) for i := uint64(1); i < end; i++ { limit := nextPowerOf2(i) for j := i; j < limit; j++ { @@ -192,7 +191,7 @@ func TestLegacyVsOptimized(t *testing.T) { func TestLegacyVsOptimizedEdgeCases(t *testing.T) { t.Parallel() - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) tests := []struct { realLength int @@ -233,7 +232,7 @@ func TestLegacyVsOptimizedEdgeCases(t *testing.T) { func TestVirtualSparse(t *testing.T) { t.Parallel() - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) makeLeaves := func(n int) []common.Hash { leaves := make([]common.Hash, n) for i := range leaves { @@ -298,7 +297,7 @@ func TestVirtualSparse(t *testing.T) { func TestMaximumDepthHistoryCommitment(t *testing.T) { t.Parallel() - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) hashedLeaves := []common.Hash{ simpleHash, } @@ -308,7 +307,7 @@ func TestMaximumDepthHistoryCommitment(t *testing.T) { func BenchmarkMaximumDepthHistoryCommitment(b *testing.B) { b.StopTimer() - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) hashedLeaves := []common.Hash{ simpleHash, } @@ -320,7 +319,7 @@ func BenchmarkMaximumDepthHistoryCommitment(b *testing.B) { } func TestInclusionProofEquivalence(t *testing.T) { - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) leaves := []common.Hash{ simpleHash, simpleHash, @@ -335,7 +334,7 @@ func TestInclusionProofEquivalence(t *testing.T) { } func TestHashInto(t *testing.T) { - simpleHash := crypto.Keccak256Hash([]byte("foo")) + simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) leaves := []common.Hash{ simpleHash, simpleHash, @@ -343,7 +342,7 @@ func TestHashInto(t *testing.T) { simpleHash, } comm := newCommitter() - want := crypto.Keccak256Hash(simpleHash[:], simpleHash[:], simpleHash[:], simpleHash[:]) + want := arbkeccak.Keccak256Hash(simpleHash[:], simpleHash[:], simpleHash[:], simpleHash[:]) var got common.Hash comm.hashInto(&got, &leaves[0], &leaves[1], &leaves[2], &leaves[3]) if got != want { diff --git a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go index 8864966838..74b888ca79 100644 --- a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go +++ b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go @@ -10,11 +10,10 @@ import ( "runtime" "sync" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" ) @@ -47,9 +46,9 @@ func FullTree(leaves []common.Hash) ([][]common.Hash, error) { nextLayer := make([]common.Hash, (len(prevLayer)+1)/2) for i := 0; i < len(nextLayer); i++ { if 2*i+1 < len(prevLayer) { - nextLayer[i] = crypto.Keccak256Hash(prevLayer[2*i].Bytes(), prevLayer[2*i+1].Bytes()) + nextLayer[i] = arbkeccak.Keccak256Hash(prevLayer[2*i].Bytes(), prevLayer[2*i+1].Bytes()) } else { - nextLayer[i] = crypto.Keccak256Hash(prevLayer[2*i].Bytes(), (common.Hash{}).Bytes()) + nextLayer[i] = arbkeccak.Keccak256Hash(prevLayer[2*i].Bytes(), (common.Hash{}).Bytes()) } } layers[l] = nextLayer @@ -81,7 +80,7 @@ func GenerateInclusionProof(leaves []common.Hash, idx uint64) ([]common.Hash, er go func() { defer waitGroup.Done() for j := start; j < start+batchSize; j++ { - rehashed[j] = crypto.Keccak256Hash(leaves[j].Bytes()) + rehashed[j] = arbkeccak.Keccak256Hash(leaves[j].Bytes()) } }() } @@ -89,7 +88,7 @@ func GenerateInclusionProof(leaves []common.Hash, idx uint64) ([]common.Hash, er go func() { defer waitGroup.Done() for j := start; j < start+batchSize+batchRemainder; j++ { - rehashed[j] = crypto.Keccak256Hash(leaves[j].Bytes()) + rehashed[j] = arbkeccak.Keccak256Hash(leaves[j].Bytes()) } }() waitGroup.Wait() @@ -123,13 +122,13 @@ func CalculateRootFromProof(proof []common.Hash, index uint64, leaf common.Hash) if len(proof) > 256 { return common.Hash{}, ErrProofTooLong } - h := crypto.Keccak256Hash(leaf[:]) + h := arbkeccak.Keccak256Hash(leaf[:]) for i := 0; i < len(proof); i++ { node := proof[i] if index&(1< 0 { kind := preimage[0] - return kind != NodeByte && kind != LeafByte && hash == crypto.Keccak256Hash(preimage) + return kind != NodeByte && kind != LeafByte && hash == arbkeccak.Keccak256Hash(preimage) } return false } diff --git a/daprovider/das/dastree/dastree_test.go b/daprovider/das/dastree/dastree_test.go index 5eed2091e6..29e1f3265b 100644 --- a/daprovider/das/dastree/dastree_test.go +++ b/daprovider/das/dastree/dastree_test.go @@ -8,8 +8,7 @@ import ( "math/rand" "testing" - "github.com/ethereum/go-ethereum/crypto" - + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" @@ -19,7 +18,7 @@ import ( func TestDASTree(t *testing.T) { store := make(map[bytes32][]byte) tests := [][]byte{ - {}, {0x32}, crypto.Keccak256(), + {}, {0x32}, arbkeccak.Keccak256(), make([]byte, BinSize), make([]byte, BinSize+1), make([]byte, 4*BinSize), } for i := 0; i < 64; i++ { @@ -30,7 +29,7 @@ func TestDASTree(t *testing.T) { record := func(key bytes32, value []byte, ty arbutil.PreimageType) { colors.PrintGrey("storing ", key, " ", pretty.PrettyBytes(value)) store[key] = value - if crypto.Keccak256Hash(value) != key { + if arbkeccak.Keccak256Hash(value) != key { Fail(t, "key not the hash of value") } } @@ -39,7 +38,7 @@ func TestDASTree(t *testing.T) { if !ok { Fail(t, "no preimage for key", key) } - if crypto.Keccak256Hash(preimage) != key { + if arbkeccak.Keccak256Hash(preimage) != key { Fail(t, "key not the hash of preimage") } colors.PrintBlue("loading ", key, " ", pretty.PrettyBytes(preimage)) diff --git a/daprovider/das/dasutil/dasutil.go b/daprovider/das/dasutil/dasutil.go index b2c73853c1..8675e71dd5 100644 --- a/daprovider/das/dasutil/dasutil.go +++ b/daprovider/das/dasutil/dasutil.go @@ -11,8 +11,8 @@ import ( "fmt" "io" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbos/util" @@ -194,7 +194,7 @@ func recoverPayloadFromDasBatchInternal( } switch { - case version == 0 && crypto.Keccak256Hash(preimage) != hash: + case version == 0 && arbkeccak.Keccak256Hash(preimage) != hash: fallthrough case version == 1 && dastree.Hash(preimage) != hash: log.Error( @@ -246,7 +246,7 @@ func recoverPayloadFromDasBatchInternal( if version == 0 { treeLeaf := dastree.FlatHashToTreeLeaf(dataHash) preimageRecorder(dataHash, payload, arbutil.Keccak256PreimageType) - preimageRecorder(crypto.Keccak256Hash(treeLeaf), treeLeaf, arbutil.Keccak256PreimageType) + preimageRecorder(arbkeccak.Keccak256Hash(treeLeaf), treeLeaf, arbutil.Keccak256PreimageType) } else { dastree.RecordHash(preimageRecorder, payload) } diff --git a/daprovider/das/extra_signature_checker_test.go b/daprovider/das/extra_signature_checker_test.go index 15ebbf081e..d481048397 100644 --- a/daprovider/das/extra_signature_checker_test.go +++ b/daprovider/das/extra_signature_checker_test.go @@ -10,6 +10,7 @@ import ( "io/ioutil" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/daprovider/das/dasutil" @@ -58,7 +59,7 @@ func TestSimpleSignatureCheck(t *testing.T) { Require(t, err) data := []byte("Hello World") - dataHash := crypto.Keccak256(data) + dataHash := arbkeccak.Keccak256(data) sig, err := crypto.Sign(dataHash, privateKey) Require(t, err) @@ -79,7 +80,7 @@ func TestEvenSimplerSignatureCheck(t *testing.T) { Require(t, err) data := []byte("Hello World") - dataHash := crypto.Keccak256(data) + dataHash := arbkeccak.Keccak256(data) sig, err := crypto.Sign(dataHash, privateKey) Require(t, err) diff --git a/daprovider/data_streaming/signing.go b/daprovider/data_streaming/signing.go index e67320a6fe..d1ea378865 100644 --- a/daprovider/data_streaming/signing.go +++ b/daprovider/data_streaming/signing.go @@ -6,8 +6,7 @@ import ( "encoding/binary" "errors" - "github.com/ethereum/go-ethereum/crypto" - + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/signature" ) @@ -19,7 +18,7 @@ type PayloadSigner struct { func DefaultPayloadSigner(signer signature.DataSignerFunc) *PayloadSigner { return CustomPayloadSigner(func(bytes []byte, extras ...uint64) ([]byte, error) { - return signer(crypto.Keccak256(flattenDataForSigning(bytes, extras...))) + return signer(arbkeccak.Keccak256(flattenDataForSigning(bytes, extras...))) }) } @@ -31,7 +30,7 @@ func CustomPayloadSigner(signingFunc func([]byte, ...uint64) ([]byte, error)) *P func PayloadCommiter() *PayloadSigner { return CustomPayloadSigner(func(bytes []byte, extras ...uint64) ([]byte, error) { - return crypto.Keccak256(flattenDataForSigning(bytes, extras...)), nil + return arbkeccak.Keccak256(flattenDataForSigning(bytes, extras...)), nil }) } @@ -55,7 +54,7 @@ func CustomPayloadVerifier(verifyingFunc func(ctx context.Context, signature []b func PayloadCommitmentVerifier() *PayloadVerifier { return CustomPayloadVerifier(func(ctx context.Context, signature []byte, data []byte, extras ...uint64) error { - expectedCommitment := crypto.Keccak256(flattenDataForSigning(data, extras...)) + expectedCommitment := arbkeccak.Keccak256(flattenDataForSigning(data, extras...)) if bytes.Equal(signature, expectedCommitment) { return nil } else { diff --git a/daprovider/referenceda/reference_reader.go b/daprovider/referenceda/reference_reader.go index 51170634fb..7e09edeeeb 100644 --- a/daprovider/referenceda/reference_reader.go +++ b/daprovider/referenceda/reference_reader.go @@ -9,8 +9,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" @@ -103,7 +103,7 @@ func (r *Reader) recoverInternal( // Record the mapping from certificate hash to actual payload data // This is what the replay binary expects: keccak256(certificate) -> payload - certHash := crypto.Keccak256Hash(certBytes) + certHash := arbkeccak.Keccak256Hash(certBytes) preimageRecorder(certHash, payload, arbutil.DACertificatePreimageType) } diff --git a/execution/gethexec/classicMessage.go b/execution/gethexec/classicMessage.go index 581f874111..6eab3317a1 100644 --- a/execution/gethexec/classicMessage.go +++ b/execution/gethexec/classicMessage.go @@ -10,8 +10,8 @@ import ( "math/big" "math/bits" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" ) @@ -32,7 +32,7 @@ type ClassicOutboxMsg struct { } func msgBatchKey(batchNum *big.Int) []byte { - return crypto.Keccak256(append([]byte("msgBatch"), batchNum.Bytes()...)) + return arbkeccak.Keccak256(append([]byte("msgBatch"), batchNum.Bytes()...)) } func (m *ClassicOutboxRetriever) GetMsg(batchNum *big.Int, index uint64) (*ClassicOutboxMsg, error) { diff --git a/execution/gethexec/express_lane_service_test.go b/execution/gethexec/express_lane_service_test.go index 6aa8941bd3..121da97f75 100644 --- a/execution/gethexec/express_lane_service_test.go +++ b/execution/gethexec/express_lane_service_test.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum_types" @@ -967,7 +968,7 @@ func Benchmark_expressLaneService_validateExpressLaneTx(b *testing.B) { } func buildSignature(privateKey *ecdsa.PrivateKey, data []byte) ([]byte, error) { - prefixedData := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(data))), data...)) + prefixedData := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(data))), data...)) signature, err := crypto.Sign(prefixedData, privateKey) if err != nil { return nil, err diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 3169cd9a07..ba460ed8e2 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -13,12 +13,12 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" @@ -386,7 +386,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) } if level == 0 { - hash = crypto.Keccak256Hash(hash.Bytes()) + hash = arbkeccak.Keccak256Hash(hash.Bytes()) } place := merkletree.NewLevelAndLeaf(level, leafAdded) @@ -444,7 +444,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) // move to the parent step.Level += 1 step.Leaf |= 1 << (step.Level - 1) - known[step] = crypto.Keccak256Hash(left.Bytes(), right.Bytes()) + known[step] = arbkeccak.Keccak256Hash(left.Bytes(), right.Bytes()) } } @@ -458,13 +458,13 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) } // recover the root and check correctness - recovery := crypto.Keccak256Hash(send.Bytes()) + recovery := arbkeccak.Keccak256Hash(send.Bytes()) recoveryStep := leaf for _, hash := range hashes { if recoveryStep&1 == 0 { - recovery = crypto.Keccak256Hash(recovery.Bytes(), hash.Bytes()) + recovery = arbkeccak.Keccak256Hash(recovery.Bytes(), hash.Bytes()) } else { - recovery = crypto.Keccak256Hash(hash.Bytes(), recovery.Bytes()) + recovery = arbkeccak.Keccak256Hash(hash.Bytes(), recovery.Bytes()) } recoveryStep >>= 1 } @@ -472,7 +472,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) proof := merkletree.MerkleProof{ RootHash: root, // now resolved - LeafHash: crypto.Keccak256Hash(send.Bytes()), + LeafHash: arbkeccak.Keccak256Hash(send.Bytes()), LeafIndex: leaf, Proof: hashes, } diff --git a/go-ethereum b/go-ethereum index 7bd1d709e4..064a6fced6 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 7bd1d709e4fb79121fa1b83d221e55cdaa570bc4 +Subproject commit 064a6fced657b642fe13c726201bb5b2eb4132ed diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index 772e293d8b..e24d092217 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -8,10 +8,10 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" @@ -47,7 +47,7 @@ func TestAddressTable1(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) exists, err := atab.AddressExists(context, evm, addr) Require(t, err) @@ -107,7 +107,7 @@ func TestAddressTableCompressNotInTable(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) // verify that compressing addr produces the 21-byte format res, err := atab.Compress(context, evm, addr) @@ -135,7 +135,7 @@ func TestAddressTableCompressInTable(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) // Register addr if _, err := atab.Register(context, evm, addr); err != nil { diff --git a/precompiles/ArbAggregator_test.go b/precompiles/ArbAggregator_test.go index dd6a104cd4..1a8ba4b0ae 100644 --- a/precompiles/ArbAggregator_test.go +++ b/precompiles/ArbAggregator_test.go @@ -7,9 +7,8 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/l1pricing" ) @@ -18,8 +17,8 @@ func TestFeeCollector(t *testing.T) { agg := ArbAggregator{} aggAddr := l1pricing.BatchPosterAddress - collectorAddr := common.BytesToAddress(crypto.Keccak256([]byte{1})[:20]) - impostorAddr := common.BytesToAddress(crypto.Keccak256([]byte{2})[:20]) + collectorAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{1})[:20]) + impostorAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{2})[:20]) aggCtx := testContext(aggAddr, evm) callerCtx := testContext(common.Address{}, evm) @@ -57,7 +56,7 @@ func TestTxBaseFee(t *testing.T) { evm := newMockEVMForTesting() agg := ArbAggregator{} - aggAddr := common.BytesToAddress(crypto.Keccak256([]byte{0})[:20]) + aggAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{0})[:20]) targetFee := big.NewInt(973) aggCtx := testContext(aggAddr, evm) diff --git a/precompiles/ArbGasInfo_test.go b/precompiles/ArbGasInfo_test.go index 52d1d8e60d..721896295b 100644 --- a/precompiles/ArbGasInfo_test.go +++ b/precompiles/ArbGasInfo_test.go @@ -7,10 +7,10 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbosState" @@ -29,7 +29,7 @@ func setupArbGasInfo( *ArbGasInfo, ) { evm := newMockEVMForTesting() - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) @@ -119,7 +119,7 @@ func TestGetPricesInArbGas(t *testing.T) { t.Parallel() evm := newMockEVMForTesting() - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) arbGasInfo := &ArbGasInfo{} callCtx := testContext(caller, evm) diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index c978988a0e..4e9cd4af8f 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,13 +9,13 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/holiman/uint256" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbosState" @@ -28,15 +28,15 @@ import ( func TestArbOwner(t *testing.T) { evm := newMockEVMForTesting() - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) Require(t, state.ChainOwners().Add(caller)) - addr1 := common.BytesToAddress(crypto.Keccak256([]byte{1})[:20]) - addr2 := common.BytesToAddress(crypto.Keccak256([]byte{2})[:20]) - addr3 := common.BytesToAddress(crypto.Keccak256([]byte{3})[:20]) + addr1 := common.BytesToAddress(arbkeccak.Keccak256([]byte{1})[:20]) + addr2 := common.BytesToAddress(arbkeccak.Keccak256([]byte{2})[:20]) + addr3 := common.BytesToAddress(arbkeccak.Keccak256([]byte{3})[:20]) prec := &ArbOwner{} gasInfo := &ArbGasInfo{} @@ -210,7 +210,7 @@ func TestArbOwner(t *testing.T) { func TestArbOwnerSetChainConfig(t *testing.T) { evm := newMockEVMForTestingWithVersionAndRunMode(nil, core.NewMessageGasEstimationContext()) - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) @@ -245,8 +245,8 @@ func TestArbOwnerSetChainConfig(t *testing.T) { func TestArbInfraFeeAccount(t *testing.T) { version0 := uint64(0) evm := newMockEVMForTestingWithVersion(&version0) - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) - newAddr := common.BytesToAddress(crypto.Keccak256([]byte{0})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + newAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{0})[:20]) callCtx := testContext(caller, evm) prec := &ArbOwner{} _, err := prec.GetInfraFeeAccount(callCtx, evm) diff --git a/precompiles/constraints_test.go b/precompiles/constraints_test.go index b4ffa83dd3..1580fcc223 100644 --- a/precompiles/constraints_test.go +++ b/precompiles/constraints_test.go @@ -6,13 +6,12 @@ package precompiles import ( "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" @@ -31,7 +30,7 @@ func setupResourceConstraintHandles( t.Helper() evm := newMockEVMForTesting() - caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) require.NoError(t, err) diff --git a/precompiles/precompile.go b/precompiles/precompile.go index 73315a4f15..f968365c46 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -17,10 +17,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum/multigas" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" @@ -413,7 +413,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr var topic [32]byte if len(bytes) > 32 { - topic = *(*[32]byte)(crypto.Keccak256(bytes)) + topic = *(*[32]byte)(arbkeccak.Keccak256(bytes)) } else { offset := 32 - len(bytes) copy(topic[offset:], bytes) diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index 61398d4ff1..f3deea9295 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -8,9 +8,9 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/storage" @@ -35,7 +35,7 @@ func TestEvents(t *testing.T) { } } - zeroHash := crypto.Keccak256Hash([]byte{0x00}) + zeroHash := arbkeccak.Keccak256Hash([]byte{0x00}) falseHash := common.Hash{} var data []byte diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 677599a557..e692a7850c 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -10,9 +10,9 @@ import ( "strings" "sync" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" @@ -255,7 +255,7 @@ func (s *BOLDStateProvider) StatesInBatchRange( } func machineHash(gs validator.GoGlobalState) common.Hash { - return crypto.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) + return arbkeccak.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) } func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbutil.MessageIndex, batchIndex l2stateprovider.Batch) (validator.GoGlobalState, error) { diff --git a/staker/legacy/assertion.go b/staker/legacy/assertion.go index 4253102079..6cac5a9db4 100644 --- a/staker/legacy/assertion.go +++ b/staker/legacy/assertion.go @@ -6,9 +6,8 @@ package legacystaker import ( "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/validator" @@ -39,7 +38,7 @@ func HashChallengeState( for _, h := range hashes { hashesBytes = append(hashesBytes, h[:]...) } - return crypto.Keccak256Hash( + return arbkeccak.Keccak256Hash( arbmath.Uint64ToU256Bytes(segmentStart), arbmath.Uint64ToU256Bytes(segmentLength), hashesBytes, diff --git a/staker/legacy/block_challenge_backend.go b/staker/legacy/block_challenge_backend.go index d4b2f6f3da..644a76a9f1 100644 --- a/staker/legacy/block_challenge_backend.go +++ b/staker/legacy/block_challenge_backend.go @@ -10,10 +10,9 @@ import ( "math" "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/solgen/go/challenge_legacy_gen" @@ -184,9 +183,9 @@ func (b *BlockChallengeBackend) GetHashAtStep(_ context.Context, position uint64 if status == StatusFinished { data := []byte("Block state:") data = append(data, gs.Hash().Bytes()...) - return crypto.Keccak256Hash(data), nil + return arbkeccak.Keccak256Hash(data), nil } else if status == StatusTooFar { - return crypto.Keccak256Hash([]byte("Block state, too far:")), nil + return arbkeccak.Keccak256Hash([]byte("Block state, too far:")), nil } else { panic(fmt.Sprintf("Unknown block status: %v", status)) } diff --git a/staker/legacy/l1_validator.go b/staker/legacy/l1_validator.go index 176edce94f..74725f4af5 100644 --- a/staker/legacy/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -11,9 +11,9 @@ import ( "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" @@ -530,7 +530,7 @@ func (v *L1Validator) createNewNodeAction( } executionHash := assertion.ExecutionHash() - newNodeHash := crypto.Keccak256Hash(hasSiblingByte[:], lastHash[:], executionHash[:], validatedBatchAcc[:], wasmModuleRoot[:]) + newNodeHash := arbkeccak.Keccak256Hash(hasSiblingByte[:], lastHash[:], executionHash[:], validatedBatchAcc[:], wasmModuleRoot[:]) action := createNodeAction{ assertion: assertion, diff --git a/staker/legacy/rollup_watcher.go b/staker/legacy/rollup_watcher.go index e09f7e9e43..2710d1218b 100644 --- a/staker/legacy/rollup_watcher.go +++ b/staker/legacy/rollup_watcher.go @@ -15,9 +15,9 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" @@ -259,7 +259,7 @@ func (r *RollupWatcher) LookupNodeChildren(ctx context.Context, nodeNum uint64, if i > 0 { lastHashIsSibling[0] = 1 } - lastHash = crypto.Keccak256Hash(lastHashIsSibling[:], lastHash[:], parsedLog.ExecutionHash[:], parsedLog.AfterInboxBatchAcc[:], parsedLog.WasmModuleRoot[:]) + lastHash = arbkeccak.Keccak256Hash(lastHashIsSibling[:], lastHash[:], parsedLog.ExecutionHash[:], parsedLog.AfterInboxBatchAcc[:], parsedLog.WasmModuleRoot[:]) l1BlockProposed, err := arbutil.CorrespondingL1BlockNumber(ctx, r.client, ethLog.BlockNumber) if err != nil { return nil, err diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 823ec3a11a..9f69568f69 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -15,11 +15,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/arbitrum_types" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/execution/gethexec" @@ -188,7 +188,7 @@ func dedupOptions(t *testing.T, options []*arbitrum_types.ConditionalOptions) [] for _, opt := range options { data, err := json.Marshal(opt) Require(t, err) - dataHash := crypto.Keccak256Hash(data) + dataHash := arbkeccak.Keccak256Hash(data) _, seen := seenBefore[dataHash] if !seen { result = append(result, opt) diff --git a/system_tests/infra_fee_test.go b/system_tests/infra_fee_test.go index bd52566ca4..9fdf95ddae 100644 --- a/system_tests/infra_fee_test.go +++ b/system_tests/infra_fee_test.go @@ -10,9 +10,8 @@ import ( "context" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" @@ -38,7 +37,7 @@ func TestInfraFee(t *testing.T) { Require(t, err) networkFeeAddr, err := arbownerPublic.GetNetworkFeeAccount(ownerCallOpts) Require(t, err) - infraFeeAddr := common.BytesToAddress(crypto.Keccak256([]byte{3, 2, 6})) + infraFeeAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{3, 2, 6})) tx, err := arbowner.SetInfraFeeAccount(&ownerTxOpts, infraFeeAddr) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) diff --git a/system_tests/multigas_stylus_program_test.go b/system_tests/multigas_stylus_program_test.go index f6e400f05e..0d86cbf314 100644 --- a/system_tests/multigas_stylus_program_test.go +++ b/system_tests/multigas_stylus_program_test.go @@ -8,12 +8,12 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum/multigas" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/cmd/chaininfo" @@ -95,7 +95,7 @@ func TestMultigasStylus_AccountAccessHostIOs(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - selector := crypto.Keccak256([]byte(tc.selectorSignature))[:4] + selector := arbkeccak.Keccak256([]byte(tc.selectorSignature))[:4] callData := append([]byte{}, selector...) callData = append(callData, common.LeftPadBytes(target.Bytes(), 32)...) diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 31495c5b04..8ff5f0c1ad 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -13,10 +13,10 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/gethhook" @@ -247,7 +247,7 @@ func TestOutboxProofs(t *testing.T) { leaf := new(big.Int).SetBytes(position[8:]).Uint64() if level == 0 { - hash = crypto.Keccak256Hash(hash.Bytes()) + hash = arbkeccak.Keccak256Hash(hash.Bytes()) } place := merkletree.LevelAndLeaf{ @@ -321,7 +321,7 @@ func TestOutboxProofs(t *testing.T) { // move to the parent step.Level += 1 step.Leaf |= 1 << (step.Level - 1) - known[step] = crypto.Keccak256Hash(left.Bytes(), right.Bytes()) + known[step] = arbkeccak.Keccak256Hash(left.Bytes(), right.Bytes()) } if known[step] != rootHash { @@ -348,7 +348,7 @@ func TestOutboxProofs(t *testing.T) { proof := merkletree.MerkleProof{ RootHash: rootHash, - LeafHash: crypto.Keccak256Hash(provable.hash.Bytes()), + LeafHash: arbkeccak.Keccak256Hash(provable.hash.Bytes()), LeafIndex: provable.leaf, Proof: hashes, } diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index 391b8690c7..7d053b527c 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -10,10 +10,9 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" @@ -37,7 +36,7 @@ func TestArbAddressTableDoesntRevert(t *testing.T) { arbAddressTable, err := precompilesgen.NewArbAddressTable(types.ArbAddressTableAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) exists, err := arbAddressTable.AddressExists(callOpts, addr) Require(t, err) @@ -128,8 +127,8 @@ func TestArbSysDoesntRevert(t *testing.T) { arbSys, err := precompilesgen.NewArbSys(types.ArbSysAddress, builder.L2.Client) Require(t, err) - addr1 := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) - addr2 := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr1 := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr2 := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) _, err = arbSys.MapL1SenderContractAddressToL2Alias(callOpts, addr1, addr2) Require(t, err) } @@ -181,7 +180,7 @@ func TestArbGasInfoDoesntRevert(t *testing.T) { defer cleanup() callOpts := &bind.CallOpts{Context: ctx} - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) arbGasInfo, err := precompilesgen.NewArbGasInfo(types.ArbGasInfoAddress, builder.L2.Client) Require(t, err) diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 35443d7768..4970d33461 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -13,12 +13,12 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/google/go-cmp/cmp" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" @@ -334,7 +334,7 @@ func TestL1PricingRewardRecipient(t *testing.T) { defer cleanup() ctx := builder.ctx - rewardRecipient := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + rewardRecipient := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) tx, err := arbOwner.SetL1PricingRewardRecipient(&auth, rewardRecipient) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) @@ -1077,7 +1077,7 @@ func TestArbFunctionTable(t *testing.T) { arbFunctionTable, err := precompilesgen.NewArbFunctionTable(types.ArbFunctionTableAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) // should be a noop tx, err := arbFunctionTable.Upload(&auth, []byte{0, 0, 0, 0}) @@ -1253,7 +1253,7 @@ func TestArbAggregatorBatchPosters(t *testing.T) { arbDebug, err := precompilesgen.NewArbDebug(types.ArbDebugAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) // initially should have one batch poster bps, err := arbAggregator.GetBatchPosters(callOpts) @@ -1296,7 +1296,7 @@ func TestArbAggregatorGetPreferredAggregator(t *testing.T) { arbAggregator, err := precompilesgen.NewArbAggregator(types.ArbAggregatorAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) prefAgg, isDefault, err := arbAggregator.GetPreferredAggregator(callOpts, addr) Require(t, err) @@ -1332,7 +1332,7 @@ func TestArbDebugOverwriteContractCode(t *testing.T) { Require(t, err) // create EOA to test against - addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) // test that code is empty code, err := builder.L2.Client.CodeAt(ctx, addr, nil) diff --git a/system_tests/program_ink_test.go b/system_tests/program_ink_test.go index 5b70e3f518..ad4e208d9a 100644 --- a/system_tests/program_ink_test.go +++ b/system_tests/program_ink_test.go @@ -9,10 +9,10 @@ import ( "strings" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbos/util" @@ -623,7 +623,7 @@ func encodeHostioTestCalldata(t *testing.T, solFunc string, args []any) []byte { // For the functions that are not in the Hostio interface, we encoded them manually func encodeHostioFromSignature(t *testing.T, signature string, args []uint64) []byte { - data := crypto.Keccak256([]byte(signature))[:4] + data := arbkeccak.Keccak256([]byte(signature))[:4] for _, arg := range args { data = append(data, make([]byte, 24)...) // padding data = binary.BigEndian.AppendUint64(data, arg) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 06cfbb4fd7..59427036cf 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -18,6 +18,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/rawdb" @@ -117,7 +118,7 @@ func keccakTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) { } preimage := []byte("°º¤ø,¸,ø¤°º¤ø,¸,ø¤°º¤ø,¸ nyan nyan ~=[,,_,,]:3 nyan nyan") - correct := crypto.Keccak256Hash(preimage) + correct := arbkeccak.Keccak256Hash(preimage) args := []byte{0x01} // keccak the preimage once args = append(args, preimage...) @@ -985,7 +986,7 @@ func testCreate(t *testing.T, jit bool) { create2Args = append(create2Args, deployCode...) create1Addr := crypto.CreateAddress(createAddr, 1) - create2Addr := crypto.CreateAddress2(createAddr, salt, crypto.Keccak256(deployCode)) + create2Addr := crypto.CreateAddress2(createAddr, salt, arbkeccak.Keccak256(deployCode)) create(create1Args, create1Addr) create(create2Args, create2Addr) @@ -1411,7 +1412,7 @@ func TestStylusPrecompileMethodsSimple(t *testing.T) { _, err = arbWasm.PageRamp(nil) Require(t, err) - codehash := crypto.Keccak256Hash(wasm) + codehash := arbkeccak.Keccak256Hash(wasm) cas, err := arbWasm.CodehashAsmSize(nil, codehash) Require(t, err) if cas == 0 { @@ -1457,7 +1458,7 @@ func TestProgramActivationLogs(t *testing.T) { if log.Program != programAddress { Fatal(t, "unexpected program in activation log: ", log.Program) } - if crypto.Keccak256Hash(wasm) != log.Codehash { + if arbkeccak.Keccak256Hash(wasm) != log.Codehash { Fatal(t, "unexpected codehash in activation log: ", log.Codehash) } } @@ -1552,7 +1553,7 @@ func TestProgramCacheManager(t *testing.T) { // deploy without activating a wasm wasm, _ := readWasmFile(t, rustFile("keccak")) program := deployContract(t, ctx, userAuth, l2client, wasm) - codehash := crypto.Keccak256Hash(wasm) + codehash := arbkeccak.Keccak256Hash(wasm) // try to manage the cache without authorization manager, tx, mock, err := localgen.DeploySimpleCacheManager(&ownerAuth, l2client) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index bf303e54e1..d4a1a25ddd 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -11,9 +11,9 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" @@ -520,7 +520,7 @@ func TestRegressionInPopulateFeedBacklog(t *testing.T) { // sub in correct batch hash batchData, _, err := builder.L2.ConsensusNode.InboxReader.GetSequencerMessageBytes(ctx, 0) Require(t, err) - expectedBatchHash := crypto.Keccak256Hash(batchData) + expectedBatchHash := arbkeccak.Keccak256Hash(batchData) copy(data[52:52+32], expectedBatchHash[:]) dummyMessage := arbostypes.MessageWithMetadata{ diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index 768d9ac71a..c4ca556520 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -17,10 +17,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" @@ -384,7 +384,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) managerAddr, err := stakerA.Rollup().ChallengeManager(&bind.CallOpts{Context: ctx}) Require(t, err) // 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103 - proxyAdminSlot := common.BigToHash(arbmath.BigSub(crypto.Keccak256Hash([]byte("eip1967.proxy.admin")).Big(), common.Big1)) + proxyAdminSlot := common.BigToHash(arbmath.BigSub(arbkeccak.Keccak256Hash([]byte("eip1967.proxy.admin")).Big(), common.Big1)) proxyAdminBytes, err := builder.L1.Client.StorageAt(ctx, managerAddr, proxyAdminSlot, nil) Require(t, err) proxyAdminAddr := common.BytesToAddress(proxyAdminBytes) diff --git a/system_tests/stylus_trace_test.go b/system_tests/stylus_trace_test.go index da05678f55..abaa89ce2d 100644 --- a/system_tests/stylus_trace_test.go +++ b/system_tests/stylus_trace_test.go @@ -11,6 +11,7 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/holiman/uint256" "github.com/ethereum/go-ethereum/common" @@ -138,7 +139,7 @@ func TestStylusOpcodeTraceNativeKeccak(t *testing.T) { args := binary.LittleEndian.AppendUint32(nil, 1) // rounds args = append(args, testhelpers.RandomSlice(123)...) - hash := crypto.Keccak256Hash(args) // the keccak.wat program computes the hash of the whole args + hash := arbkeccak.Keccak256Hash(args) // the keccak.wat program computes the hash of the whole args // native_keccak256 result := sendAndTraceTransaction(t, builder, program, nil, args) @@ -244,7 +245,7 @@ func TestStylusOpcodeTraceEvmData(t *testing.T) { Require(t, err) programCode, err := l2client.CodeAt(ctx, program, nil) Require(t, err) - programCodehash := crypto.Keccak256(programCode) + programCodehash := arbkeccak.Keccak256(programCode) owner := l2info.GetAddress("Owner") // read_args @@ -411,7 +412,7 @@ func TestStylusOpcodeTraceCreate(t *testing.T) { startValue := testhelpers.RandomCallValue(1e5) salt := testhelpers.RandomHash() create1Addr := crypto.CreateAddress(program, 1) - create2Addr := crypto.CreateAddress2(program, salt, crypto.Keccak256(deployCode)) + create2Addr := crypto.CreateAddress2(program, salt, arbkeccak.Keccak256(deployCode)) // create1 create1Args := []byte{0x01} diff --git a/system_tests/test_info.go b/system_tests/test_info.go index a600c9bac5..a471217bbe 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -12,6 +12,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -82,7 +83,7 @@ func NewL1TestInfo(t *testing.T) *BlockchainTestInfo { } func GetTestKeyForAccountName(t *testing.T, name string) *ecdsa.PrivateKey { - keyBytes := crypto.Keccak256([]byte(name)) + keyBytes := arbkeccak.Keccak256([]byte(name)) keyBytes[0] = 0 privateKey, err := crypto.ToECDSA(keyBytes) if err != nil { diff --git a/system_tests/timeboost_test.go b/system_tests/timeboost_test.go index 00d13aeade..c30a74c020 100644 --- a/system_tests/timeboost_test.go +++ b/system_tests/timeboost_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -22,7 +23,6 @@ import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" @@ -1995,7 +1995,7 @@ func (elc *expressLaneClient) sendExpressLaneRPC(msg *timeboost.JsonExpressLaneS } func signSubmission(message []byte, key *ecdsa.PrivateKey) ([]byte, error) { - prefixed := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(message))), message...)) + prefixed := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(message))), message...)) sig, err := secp256k1.Sign(prefixed, math.PaddedBigBytes(key.D, 32)) if err != nil { return nil, err diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index 91c1cd39fc..e50886e892 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" @@ -117,7 +117,7 @@ func (r *mockExecRun) GetStepAt(position uint64) containers.PromiseInterface[*va resState = r.endState } return containers.NewReadyPromise[*validator.MachineStepResult](&validator.MachineStepResult{ - Hash: crypto.Keccak256Hash(new(big.Int).SetUint64(position).Bytes()), + Hash: arbkeccak.Keccak256Hash(new(big.Int).SetUint64(position).Bytes()), Position: position, Status: status, GlobalState: resState, diff --git a/timeboost/types.go b/timeboost/types.go index cabdf94467..ec2a30c0e1 100644 --- a/timeboost/types.go +++ b/timeboost/types.go @@ -6,6 +6,7 @@ import ( "fmt" "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/arbitrum_types" @@ -64,7 +65,7 @@ func (b *Bid) ToEIP712Hash(domainSeparator [32]byte) (common.Hash, error) { return common.Hash{}, err } - bidHash := crypto.Keccak256Hash( + bidHash := arbkeccak.Keccak256Hash( []byte("\x19\x01"), domainSeparator[:], messageHash, @@ -112,7 +113,7 @@ func (v *ValidatedBid) BigIntHash(domainSeparator [32]byte) *big.Int { bidHash, _ := bid.ToEIP712Hash(domainSeparator) bidder := v.Bidder.Bytes() - return new(big.Int).SetBytes(crypto.Keccak256Hash(bidder, bidHash.Bytes()).Bytes()) + return new(big.Int).SetBytes(arbkeccak.Keccak256Hash(bidder, bidHash.Bytes()).Bytes()) } func (v *ValidatedBid) ToJson() *JsonValidatedBid { @@ -235,7 +236,7 @@ func (els *ExpressLaneSubmission) Sender() (common.Address, error) { return common.Address{}, errors.Wrap(ErrMalformedData, "signature length is not 65") } // Recover the public key. - prefixed := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(signingMessage))), signingMessage...)) + prefixed := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(signingMessage))), signingMessage...)) sigItem := make([]byte, len(els.Signature)) copy(sigItem, els.Signature) // Signature verification expects the last byte of the signature to have 27 subtracted, diff --git a/util/merkletree/merkleAccumulator_test.go b/util/merkletree/merkleAccumulator_test.go index 041317c488..8bf0087009 100644 --- a/util/merkletree/merkleAccumulator_test.go +++ b/util/merkletree/merkleAccumulator_test.go @@ -8,9 +8,8 @@ import ( "encoding/binary" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) @@ -43,7 +42,7 @@ func TestAccumulator1(t *testing.T) { if mt.Size() != 1 { t.Fatal(mt.Size()) } - if root(t, acc) != crypto.Keccak256Hash(itemHash.Bytes()) { + if root(t, acc) != arbkeccak.Keccak256Hash(itemHash.Bytes()) { Fail(t) } if root(t, acc) != mt.Hash() { @@ -78,9 +77,9 @@ func TestAccumulator3(t *testing.T) { Fail(t) } - expectedHash := crypto.Keccak256( - crypto.Keccak256(crypto.Keccak256(itemHash0.Bytes()), crypto.Keccak256(itemHash1.Bytes())), - crypto.Keccak256(crypto.Keccak256(itemHash2.Bytes()), make([]byte, 32)), + expectedHash := arbkeccak.Keccak256( + arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash0.Bytes()), arbkeccak.Keccak256(itemHash1.Bytes())), + arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash2.Bytes()), make([]byte, 32)), ) if root(t, acc) != common.BytesToHash(expectedHash) { Fail(t) @@ -120,9 +119,9 @@ func TestAccumulator4(t *testing.T) { Fail(t) } - expectedHash := crypto.Keccak256( - crypto.Keccak256(crypto.Keccak256(itemHash0.Bytes()), crypto.Keccak256(itemHash1.Bytes())), - crypto.Keccak256(crypto.Keccak256(itemHash2.Bytes()), crypto.Keccak256(itemHash3.Bytes())), + expectedHash := arbkeccak.Keccak256( + arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash0.Bytes()), arbkeccak.Keccak256(itemHash1.Bytes())), + arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash2.Bytes()), arbkeccak.Keccak256(itemHash3.Bytes())), ) if root(t, acc) != common.BytesToHash(expectedHash) { Fail(t) @@ -168,7 +167,7 @@ func testSerDe(tree MerkleTree, t *testing.T) { func pseudorandomForTesting(x uint64) common.Hash { var buf [8]byte binary.BigEndian.PutUint64(buf[:], x) - return crypto.Keccak256Hash(buf[:]) + return arbkeccak.Keccak256Hash(buf[:]) } func accAppend(t *testing.T, acc *merkleAccumulator.MerkleAccumulator, itemHash common.Hash) { diff --git a/util/merkletree/merkleEventProof_test.go b/util/merkletree/merkleEventProof_test.go index fdcfec6fce..e08d49ad49 100644 --- a/util/merkletree/merkleEventProof_test.go +++ b/util/merkletree/merkleEventProof_test.go @@ -6,9 +6,8 @@ package merkletree import ( "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" "github.com/offchainlabs/nitro/arbos/storage" @@ -34,7 +33,7 @@ func TestProofForNext(t *testing.T) { if proof == nil { Fail(t, i) } - if proof.LeafHash != crypto.Keccak256Hash(leaf.Bytes()) { + if proof.LeafHash != arbkeccak.Keccak256Hash(leaf.Bytes()) { Fail(t, i) } if !proof.IsCorrect() { @@ -75,7 +74,7 @@ func ProofFromAccumulator(acc *merkleAccumulator.MerkleAccumulator, nextHash com return &MerkleProof{ RootHash: root, - LeafHash: crypto.Keccak256Hash(nextHash.Bytes()), + LeafHash: arbkeccak.Keccak256Hash(nextHash.Bytes()), LeafIndex: size, Proof: partials, }, nil diff --git a/util/merkletree/merkleTree.go b/util/merkletree/merkleTree.go index d0ad45840b..2dc39f7d7b 100644 --- a/util/merkletree/merkleTree.go +++ b/util/merkletree/merkleTree.go @@ -8,9 +8,8 @@ import ( "io" "math/big" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbos/util" ) @@ -67,7 +66,7 @@ func newMerkleLeafFromReader(rd io.Reader) (MerkleTree, error) { } func (leaf *merkleTreeLeaf) Hash() common.Hash { - return crypto.Keccak256Hash(leaf.hash.Bytes()) + return arbkeccak.Keccak256Hash(leaf.hash.Bytes()) } func (leaf *merkleTreeLeaf) Size() uint64 { @@ -149,7 +148,7 @@ type merkleInternal struct { func NewMerkleInternal(left, right MerkleTree) MerkleTree { return &merkleInternal{ - crypto.Keccak256Hash(left.Hash().Bytes(), right.Hash().Bytes()), + arbkeccak.Keccak256Hash(left.Hash().Bytes(), right.Hash().Bytes()), left.Size() + right.Size(), left.Capacity() + right.Capacity(), left, @@ -308,9 +307,9 @@ func (proof *MerkleProof) IsCorrect() bool { for _, hashFromProof := range proof.Proof { if index&1 == 0 { - hash = crypto.Keccak256Hash(hash.Bytes(), hashFromProof.Bytes()) + hash = arbkeccak.Keccak256Hash(hash.Bytes(), hashFromProof.Bytes()) } else { - hash = crypto.Keccak256Hash(hashFromProof.Bytes(), hash.Bytes()) + hash = arbkeccak.Keccak256Hash(hashFromProof.Bytes(), hash.Bytes()) } index = index / 2 } diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 81eaf6a57d..1541150e95 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,10 +4,9 @@ import ( "context" "errors" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/util/contracts" ) @@ -69,7 +68,7 @@ func NewSignVerify(config *SignVerifyConfig, signerFunc DataSignerFunc, bpValida } func (v *SignVerify) VerifySignature(ctx context.Context, signature []byte, data ...[]byte) error { - ecdsaErr := v.verifier.verifyClosure(ctx, signature, crypto.Keccak256Hash(data...)) + ecdsaErr := v.verifier.verifyClosure(ctx, signature, arbkeccak.Keccak256Hash(data...)) if ecdsaErr == nil { return nil } @@ -89,5 +88,5 @@ func (v *SignVerify) SignMessage(data ...[]byte) ([]byte, error) { } return nil, errors.New("no private key. cannot sign messages") } - return v.signerFunc(crypto.Keccak256Hash(data...).Bytes()) + return v.signerFunc(arbkeccak.Keccak256Hash(data...).Bytes()) } diff --git a/util/signature/simple_hmac.go b/util/signature/simple_hmac.go index 44ec9b6baf..e98eeb81d2 100644 --- a/util/signature/simple_hmac.go +++ b/util/signature/simple_hmac.go @@ -8,10 +8,10 @@ import ( "regexp" "strings" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" ) type SimpleHmac struct { @@ -118,13 +118,13 @@ func (h *SimpleHmac) VerifySignature(sig []byte, data ...[]byte) error { return fmt.Errorf("%w: signature must be exactly 32 bytes", ErrSignatureNotVerified) } - expectHmac := crypto.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) + expectHmac := arbkeccak.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) if subtle.ConstantTimeCompare(expectHmac[:], sig) == 1 { return nil } if h.fallbackVerificationKey != nil { - expectHmac = crypto.Keccak256Hash(prependBytes(h.fallbackVerificationKey[:], data...)...) + expectHmac = arbkeccak.Keccak256Hash(prependBytes(h.fallbackVerificationKey[:], data...)...) if subtle.ConstantTimeCompare(expectHmac[:], sig) == 1 { return nil } @@ -136,7 +136,7 @@ func (h *SimpleHmac) VerifySignature(sig []byte, data ...[]byte) error { func (h *SimpleHmac) SignMessage(data ...[]byte) ([]byte, error) { var hmac [32]byte if h.signingKey != nil { - hmac = crypto.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) + hmac = arbkeccak.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) } return hmac[:], nil } diff --git a/util/signature/verifier.go b/util/signature/verifier.go index 9e8a7c96eb..074200e574 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" @@ -83,7 +84,7 @@ func (v *Verifier) VerifyHash(ctx context.Context, signature []byte, hash common } func (v *Verifier) VerifyData(ctx context.Context, signature []byte, data ...[]byte) error { - return v.verifyClosure(ctx, signature, crypto.Keccak256Hash(data...)) + return v.verifyClosure(ctx, signature, arbkeccak.Keccak256Hash(data...)) } func (v *Verifier) verifyClosure(ctx context.Context, sig []byte, hash common.Hash) error { diff --git a/util/signature/verifier_test.go b/util/signature/verifier_test.go index d40d27ed9e..70818e89cd 100644 --- a/util/signature/verifier_test.go +++ b/util/signature/verifier_test.go @@ -8,6 +8,7 @@ import ( "errors" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/util/contracts" @@ -29,7 +30,7 @@ func TestVerifier(t *testing.T) { Require(t, err) data := []byte{0, 1, 2, 3, 4, 5, 6, 7} - hash := crypto.Keccak256Hash(data) + hash := arbkeccak.Keccak256Hash(data) signature, err := dataSigner(hash.Bytes()) Require(t, err, "error signing data") @@ -89,7 +90,7 @@ func TestVerifierBatchPoster(t *testing.T) { Require(t, err) data := []byte{0, 1, 2, 3, 4, 5, 6, 7} - hash := crypto.Keccak256Hash(data) + hash := arbkeccak.Keccak256Hash(data) signature, err := dataSigner(hash.Bytes()) Require(t, err, "error signing data") diff --git a/validator/execution_state.go b/validator/execution_state.go index 0bd94f4d7d..a670e2fda1 100644 --- a/validator/execution_state.go +++ b/validator/execution_state.go @@ -5,9 +5,8 @@ import ( "fmt" "math" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/solgen/go/challenge_legacy_gen" "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" ) @@ -52,7 +51,7 @@ func (s GoGlobalState) Hash() common.Hash { data = append(data, s.SendRoot.Bytes()...) data = append(data, u64ToBe(s.Batch)...) data = append(data, u64ToBe(s.PosInBatch)...) - return crypto.Keccak256Hash(data) + return arbkeccak.Keccak256Hash(data) } func (s GoGlobalState) AsLegacySolidityStruct() rollup_legacy_gen.GlobalState { @@ -96,11 +95,11 @@ func (s *ExecutionState) AsLegacySolidityStruct() rollup_legacy_gen.ExecutionSta func (s *ExecutionState) BlockStateHash() common.Hash { if s.MachineStatus == MachineStatusFinished { - return crypto.Keccak256Hash([]byte("Block state:"), s.GlobalState.Hash().Bytes()) + return arbkeccak.Keccak256Hash([]byte("Block state:"), s.GlobalState.Hash().Bytes()) } else if s.MachineStatus == MachineStatusErrored { - return crypto.Keccak256Hash([]byte("Block state, errored:"), s.GlobalState.Hash().Bytes()) + return arbkeccak.Keccak256Hash([]byte("Block state, errored:"), s.GlobalState.Hash().Bytes()) } else if s.MachineStatus == MachineStatusTooFar { - return crypto.Keccak256Hash([]byte("Block state, too far:")) + return arbkeccak.Keccak256Hash([]byte("Block state, too far:")) } else { panic(fmt.Sprintf("invalid machine status %v", s.MachineStatus)) } diff --git a/validator/proofenhancement/proof_enhancer_test.go b/validator/proofenhancement/proof_enhancer_test.go index 6a55d5a9cd..9156434173 100644 --- a/validator/proofenhancement/proof_enhancer_test.go +++ b/validator/proofenhancement/proof_enhancer_test.go @@ -6,9 +6,8 @@ import ( "strings" "testing" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" @@ -84,7 +83,7 @@ func createTestCertificate(t *testing.T, data []byte) []byte { cert[0] = daprovider.DACertificateMessageHeaderFlag // Use Keccak256 for data hash - dataHash := crypto.Keccak256(data) + dataHash := arbkeccak.Keccak256(data) copy(cert[1:33], dataHash) // Mock signature values (v, r, s) @@ -100,7 +99,7 @@ func TestCustomDAProofEnhancement(t *testing.T) { // Test data testData := []byte("test custom DA preimage data") testCertificate := createTestCertificate(t, testData) - certHash := crypto.Keccak256Hash(testCertificate) + certHash := arbkeccak.Keccak256Hash(testCertificate) testOffset := uint64(10) // Create sequencer message with 40-byte header + certificate @@ -230,7 +229,7 @@ func TestValidateCertificateProofEnhancement(t *testing.T) { // Test data testData := []byte("test data for certificate validation") testCertificate := createTestCertificate(t, testData) - certHash := crypto.Keccak256Hash(testCertificate) + certHash := arbkeccak.Keccak256Hash(testCertificate) // Create sequencer message with 40-byte header + certificate sequencerMessage := make([]byte, 40+len(testCertificate)) @@ -328,7 +327,7 @@ func TestNewCustomDAProofEnhancer(t *testing.T) { // Test data testData := []byte("test custom DA data") testCertificate := createTestCertificate(t, testData) - certHash := crypto.Keccak256Hash(testCertificate) + certHash := arbkeccak.Keccak256Hash(testCertificate) testOffset := uint64(10) // Create sequencer message @@ -439,7 +438,7 @@ func TestProofEnhancerErrorCases(t *testing.T) { t.Run("CertificateHashMismatch", func(t *testing.T) { testCertificate := createTestCertificate(t, []byte("test data")) - wrongHash := crypto.Keccak256Hash([]byte("wrong data")) + wrongHash := arbkeccak.Keccak256Hash([]byte("wrong data")) sequencerMessage := make([]byte, 40+len(testCertificate)) copy(sequencerMessage[40:], testCertificate) @@ -487,7 +486,7 @@ func TestProofEnhancerErrorCases(t *testing.T) { enhancer := NewReadPreimageProofEnhancer(validator, inboxTracker, inboxReader) enhancerManager.RegisterEnhancer(MarkerCustomDAReadPreimage, enhancer) - certHash := crypto.Keccak256Hash([]byte("test")) + certHash := arbkeccak.Keccak256Hash([]byte("test")) mockProof := make([]byte, 100+32+8+1) mockProof[0] = ProofEnhancementFlag copy(mockProof[100:132], certHash[:]) diff --git a/validator/proofenhancement/readpreimage_proof_enhancer.go b/validator/proofenhancement/readpreimage_proof_enhancer.go index e8c0020b75..18be4c41fb 100644 --- a/validator/proofenhancement/readpreimage_proof_enhancer.go +++ b/validator/proofenhancement/readpreimage_proof_enhancer.go @@ -8,9 +8,8 @@ import ( "encoding/binary" "fmt" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" @@ -93,7 +92,7 @@ func (e *ReadPreimageProofEnhancer) EnhanceProof(ctx context.Context, messageNum offset := binary.BigEndian.Uint64(proof[offsetPos:markerPos]) // Verify the certificate hash matches what's in the proof - certHash := crypto.Keccak256Hash(certificate) + certHash := arbkeccak.Keccak256Hash(certificate) if !bytes.Equal(certHash[:], certKeccak256[:]) { return nil, fmt.Errorf("certificate hash mismatch: expected %x, got %x", certKeccak256, certHash) } diff --git a/validator/proofenhancement/validatecertificate_proof_enhancer.go b/validator/proofenhancement/validatecertificate_proof_enhancer.go index 0b58edf687..36be6203b6 100644 --- a/validator/proofenhancement/validatecertificate_proof_enhancer.go +++ b/validator/proofenhancement/validatecertificate_proof_enhancer.go @@ -7,9 +7,8 @@ import ( "encoding/binary" "fmt" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" @@ -75,7 +74,7 @@ func (e *ValidateCertificateProofEnhancer) EnhanceProof(ctx context.Context, mes certificate := sequencerMessage[SequencerMessageHeaderSize:] // Verify the certificate hash matches what's requested - actualHash := crypto.Keccak256Hash(certificate) + actualHash := arbkeccak.Keccak256Hash(certificate) if actualHash != common.BytesToHash(certHash[:]) { return nil, fmt.Errorf("certificate hash mismatch: expected %x, got %x", certHash, actualHash) } diff --git a/wavmio/stub.go b/wavmio/stub.go index a53bb96b99..b0a321de2b 100644 --- a/wavmio/stub.go +++ b/wavmio/stub.go @@ -13,8 +13,8 @@ import ( "io" "os" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" @@ -70,7 +70,7 @@ func parsePreimageBytes(path string) { if uint64(read) != fieldSize { panic("missing bytes reading data") } - hash := crypto.Keccak256Hash(dataBuf) + hash := arbkeccak.Keccak256Hash(dataBuf) preimages[hash] = dataBuf } } From b432bba787ebe36e0ebd521313aa0db0370922be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 12:43:05 +0100 Subject: [PATCH 04/21] Copy the implementation for the wasm world (temporarily) --- arbnode/delay_buffer.go | 1 + arbnode/mel/extraction/delayed_message_lookup.go | 1 + arbnode/mel/extraction/delayed_message_lookup_test.go | 2 +- arbnode/mel/extraction/message_extraction_function.go | 1 + arbnode/mel/extraction/message_extraction_function_test.go | 3 ++- arbnode/mel/messages.go | 1 + arbos/addressTable/addressTable_test.go | 1 + arbos/merkleAccumulator/merkleAccumulator.go | 1 + arbos/retryables/retryable.go | 1 + arbos/storage/storage_test.go | 1 + bold/chain-abstraction/execution_state.go | 1 + bold/chain-abstraction/interfaces.go | 2 +- .../sol-implementation/edge_challenge_manager.go | 2 +- bold/state-commitments/history/history_commitment.go | 3 ++- bold/state-commitments/history/history_commitment_test.go | 3 ++- bold/state-commitments/inclusion-proofs/inclusion_proofs.go | 3 ++- bold/state-commitments/prefix-proofs/merkle_expansions_test.go | 3 ++- bold/state-commitments/prefix-proofs/prefix_proofs.go | 2 +- bold/state-commitments/prefix-proofs/prefix_proofs_test.go | 2 +- bold/testing/integration/prefixproofs_test.go | 2 +- .../testing/mocks/state-provider/layer2_state_provider_test.go | 3 ++- cmd/el-proxy/main.go | 2 +- cmd/mel-replay/delayed_message_db_test.go | 2 +- cmd/mel-replay/receipt_fetcher_test.go | 2 +- daprovider/das/dastree/dastree.go | 1 + daprovider/das/dastree/dastree_test.go | 1 + daprovider/data_streaming/signing.go | 1 + execution/gethexec/express_lane_service_test.go | 2 +- go-ethereum | 2 +- precompiles/ArbAggregator_test.go | 1 + precompiles/ArbOwner_test.go | 2 +- precompiles/constraints_test.go | 3 ++- staker/legacy/assertion.go | 1 + staker/legacy/block_challenge_backend.go | 1 + system_tests/infra_fee_test.go | 1 + system_tests/multigas_stylus_program_test.go | 2 +- system_tests/precompile_doesnt_revert_test.go | 1 + system_tests/precompile_test.go | 2 +- system_tests/stylus_trace_test.go | 2 +- system_tests/timeboost_test.go | 2 +- timeboost/types.go | 2 +- util/merkletree/merkleAccumulator_test.go | 1 + util/merkletree/merkleEventProof_test.go | 1 + util/merkletree/merkleTree.go | 1 + util/signature/sign_verify.go | 3 ++- util/signature/simple_hmac.go | 2 +- util/signature/verifier.go | 2 +- validator/execution_state.go | 1 + validator/proofenhancement/proof_enhancer_test.go | 1 + validator/proofenhancement/readpreimage_proof_enhancer.go | 1 + .../proofenhancement/validatecertificate_proof_enhancer.go | 1 + 51 files changed, 59 insertions(+), 27 deletions(-) diff --git a/arbnode/delay_buffer.go b/arbnode/delay_buffer.go index 41a71c05bc..c347da555b 100644 --- a/arbnode/delay_buffer.go +++ b/arbnode/delay_buffer.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" "github.com/offchainlabs/nitro/util/headerreader" diff --git a/arbnode/mel/extraction/delayed_message_lookup.go b/arbnode/mel/extraction/delayed_message_lookup.go index 63d1d6bbf8..2a62995d4c 100644 --- a/arbnode/mel/extraction/delayed_message_lookup.go +++ b/arbnode/mel/extraction/delayed_message_lookup.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" diff --git a/arbnode/mel/extraction/delayed_message_lookup_test.go b/arbnode/mel/extraction/delayed_message_lookup_test.go index a3ee349d23..89fc73f7d5 100644 --- a/arbnode/mel/extraction/delayed_message_lookup_test.go +++ b/arbnode/mel/extraction/delayed_message_lookup_test.go @@ -6,9 +6,9 @@ import ( "sort" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" diff --git a/arbnode/mel/extraction/message_extraction_function.go b/arbnode/mel/extraction/message_extraction_function.go index fdfe5e490b..fb1936a692 100644 --- a/arbnode/mel/extraction/message_extraction_function.go +++ b/arbnode/mel/extraction/message_extraction_function.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate" diff --git a/arbnode/mel/extraction/message_extraction_function_test.go b/arbnode/mel/extraction/message_extraction_function_test.go index 8badabe7fa..2b06d52273 100644 --- a/arbnode/mel/extraction/message_extraction_function_test.go +++ b/arbnode/mel/extraction/message_extraction_function_test.go @@ -7,11 +7,12 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbstate" diff --git a/arbnode/mel/messages.go b/arbnode/mel/messages.go index f3afbba90a..e6fc410588 100644 --- a/arbnode/mel/messages.go +++ b/arbnode/mel/messages.go @@ -4,6 +4,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/solgen/go/bridgegen" diff --git a/arbos/addressTable/addressTable_test.go b/arbos/addressTable/addressTable_test.go index 9002f4065a..02642d617f 100644 --- a/arbos/addressTable/addressTable_test.go +++ b/arbos/addressTable/addressTable_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/testhelpers" diff --git a/arbos/merkleAccumulator/merkleAccumulator.go b/arbos/merkleAccumulator/merkleAccumulator.go index 6650e1ac02..f76a370c78 100644 --- a/arbos/merkleAccumulator/merkleAccumulator.go +++ b/arbos/merkleAccumulator/merkleAccumulator.go @@ -6,6 +6,7 @@ package merkleAccumulator import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index 046084672b..f33bb7978b 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/arbos/storage/storage_test.go b/arbos/storage/storage_test.go index 35bf8e49b8..78dff5585d 100644 --- a/arbos/storage/storage_test.go +++ b/arbos/storage/storage_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/bold/chain-abstraction/execution_state.go b/bold/chain-abstraction/execution_state.go index 30768aa250..54bb742b1b 100644 --- a/bold/chain-abstraction/execution_state.go +++ b/bold/chain-abstraction/execution_state.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/challengeV2gen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" ) diff --git a/bold/chain-abstraction/interfaces.go b/bold/chain-abstraction/interfaces.go index 886338aa7d..032ba5d316 100644 --- a/bold/chain-abstraction/interfaces.go +++ b/bold/chain-abstraction/interfaces.go @@ -12,10 +12,10 @@ import ( "strconv" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" diff --git a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go index 6b6fc3eda1..7e1f99b9db 100644 --- a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go +++ b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go @@ -11,11 +11,11 @@ import ( "strings" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/metrics" diff --git a/bold/state-commitments/history/history_commitment.go b/bold/state-commitments/history/history_commitment.go index 240c856792..88229c3c31 100644 --- a/bold/state-commitments/history/history_commitment.go +++ b/bold/state-commitments/history/history_commitment.go @@ -44,9 +44,10 @@ import ( "fmt" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/bold/math" ) diff --git a/bold/state-commitments/history/history_commitment_test.go b/bold/state-commitments/history/history_commitment_test.go index fceaaa8043..64e878dfd0 100644 --- a/bold/state-commitments/history/history_commitment_test.go +++ b/bold/state-commitments/history/history_commitment_test.go @@ -8,10 +8,11 @@ import ( "fmt" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/bold/state-commitments/legacy" "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" "github.com/offchainlabs/nitro/bold/testing/casttest" diff --git a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go index 74b888ca79..11e6f948f8 100644 --- a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go +++ b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go @@ -10,10 +10,11 @@ import ( "runtime" "sync" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" ) diff --git a/bold/state-commitments/prefix-proofs/merkle_expansions_test.go b/bold/state-commitments/prefix-proofs/merkle_expansions_test.go index efd17a9aab..9f32fa63a6 100644 --- a/bold/state-commitments/prefix-proofs/merkle_expansions_test.go +++ b/bold/state-commitments/prefix-proofs/merkle_expansions_test.go @@ -7,8 +7,9 @@ package prefixproofs import ( "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/arbkeccak" ) func TestMerkleExpansion(t *testing.T) { diff --git a/bold/state-commitments/prefix-proofs/prefix_proofs.go b/bold/state-commitments/prefix-proofs/prefix_proofs.go index 24825bb6b3..f1a265a9b0 100644 --- a/bold/state-commitments/prefix-proofs/prefix_proofs.go +++ b/bold/state-commitments/prefix-proofs/prefix_proofs.go @@ -108,9 +108,9 @@ import ( "math/bits" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" ) diff --git a/bold/state-commitments/prefix-proofs/prefix_proofs_test.go b/bold/state-commitments/prefix-proofs/prefix_proofs_test.go index f16c37a8c2..55b4243dda 100644 --- a/bold/state-commitments/prefix-proofs/prefix_proofs_test.go +++ b/bold/state-commitments/prefix-proofs/prefix_proofs_test.go @@ -11,10 +11,10 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/bold/testing/integration/prefixproofs_test.go b/bold/testing/integration/prefixproofs_test.go index 6405de5bb2..8733926986 100644 --- a/bold/testing/integration/prefixproofs_test.go +++ b/bold/testing/integration/prefixproofs_test.go @@ -11,10 +11,10 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" diff --git a/bold/testing/mocks/state-provider/layer2_state_provider_test.go b/bold/testing/mocks/state-provider/layer2_state_provider_test.go index 118a0ea4de..9326f4ffce 100644 --- a/bold/testing/mocks/state-provider/layer2_state_provider_test.go +++ b/bold/testing/mocks/state-provider/layer2_state_provider_test.go @@ -12,10 +12,11 @@ import ( "math" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/bold/chain-abstraction" "github.com/offchainlabs/nitro/bold/layer2-state-provider" "github.com/offchainlabs/nitro/bold/testing" diff --git a/cmd/el-proxy/main.go b/cmd/el-proxy/main.go index 81031e9b9b..b4f62a8ff7 100644 --- a/cmd/el-proxy/main.go +++ b/cmd/el-proxy/main.go @@ -25,9 +25,9 @@ import ( "syscall" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/cmd/mel-replay/delayed_message_db_test.go b/cmd/mel-replay/delayed_message_db_test.go index f28ae7ed64..b97b43db6f 100644 --- a/cmd/mel-replay/delayed_message_db_test.go +++ b/cmd/mel-replay/delayed_message_db_test.go @@ -4,9 +4,9 @@ import ( "context" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" diff --git a/cmd/mel-replay/receipt_fetcher_test.go b/cmd/mel-replay/receipt_fetcher_test.go index 4360047d05..46489a7c92 100644 --- a/cmd/mel-replay/receipt_fetcher_test.go +++ b/cmd/mel-replay/receipt_fetcher_test.go @@ -9,9 +9,9 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" diff --git a/daprovider/das/dastree/dastree.go b/daprovider/das/dastree/dastree.go index 5cec3968e5..3f73697cc3 100644 --- a/daprovider/das/dastree/dastree.go +++ b/daprovider/das/dastree/dastree.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/arbmath" ) diff --git a/daprovider/das/dastree/dastree_test.go b/daprovider/das/dastree/dastree_test.go index 29e1f3265b..42ce537691 100644 --- a/daprovider/das/dastree/dastree_test.go +++ b/daprovider/das/dastree/dastree_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" diff --git a/daprovider/data_streaming/signing.go b/daprovider/data_streaming/signing.go index d1ea378865..07404f736d 100644 --- a/daprovider/data_streaming/signing.go +++ b/daprovider/data_streaming/signing.go @@ -7,6 +7,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/signature" ) diff --git a/execution/gethexec/express_lane_service_test.go b/execution/gethexec/express_lane_service_test.go index 121da97f75..6b03730c0f 100644 --- a/execution/gethexec/express_lane_service_test.go +++ b/execution/gethexec/express_lane_service_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum_types" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" diff --git a/go-ethereum b/go-ethereum index 064a6fced6..8623b9933a 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 064a6fced657b642fe13c726201bb5b2eb4132ed +Subproject commit 8623b9933a8361e21b699fade2aaf69577d0a60a diff --git a/precompiles/ArbAggregator_test.go b/precompiles/ArbAggregator_test.go index 1a8ba4b0ae..527ca9ece6 100644 --- a/precompiles/ArbAggregator_test.go +++ b/precompiles/ArbAggregator_test.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/l1pricing" ) diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index 4e9cd4af8f..3ce796d85e 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,9 +9,9 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" diff --git a/precompiles/constraints_test.go b/precompiles/constraints_test.go index 1580fcc223..c3c489ddd3 100644 --- a/precompiles/constraints_test.go +++ b/precompiles/constraints_test.go @@ -6,12 +6,13 @@ package precompiles import ( "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/util" diff --git a/staker/legacy/assertion.go b/staker/legacy/assertion.go index 6cac5a9db4..670f778b44 100644 --- a/staker/legacy/assertion.go +++ b/staker/legacy/assertion.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/validator" diff --git a/staker/legacy/block_challenge_backend.go b/staker/legacy/block_challenge_backend.go index 644a76a9f1..c651fe5252 100644 --- a/staker/legacy/block_challenge_backend.go +++ b/staker/legacy/block_challenge_backend.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" "github.com/offchainlabs/nitro/solgen/go/challenge_legacy_gen" diff --git a/system_tests/infra_fee_test.go b/system_tests/infra_fee_test.go index 9fdf95ddae..dd3169b4e5 100644 --- a/system_tests/infra_fee_test.go +++ b/system_tests/infra_fee_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" "github.com/offchainlabs/nitro/util/arbmath" diff --git a/system_tests/multigas_stylus_program_test.go b/system_tests/multigas_stylus_program_test.go index 0d86cbf314..a6598046e8 100644 --- a/system_tests/multigas_stylus_program_test.go +++ b/system_tests/multigas_stylus_program_test.go @@ -8,10 +8,10 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum/multigas" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index 7d053b527c..e3d3736ee0 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/cmd/chaininfo" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 4970d33461..ca2e6fc704 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -13,10 +13,10 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/google/go-cmp/cmp" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" diff --git a/system_tests/stylus_trace_test.go b/system_tests/stylus_trace_test.go index abaa89ce2d..99badb310a 100644 --- a/system_tests/stylus_trace_test.go +++ b/system_tests/stylus_trace_test.go @@ -11,9 +11,9 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" diff --git a/system_tests/timeboost_test.go b/system_tests/timeboost_test.go index c30a74c020..52a9c9679d 100644 --- a/system_tests/timeboost_test.go +++ b/system_tests/timeboost_test.go @@ -15,10 +15,10 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" diff --git a/timeboost/types.go b/timeboost/types.go index ec2a30c0e1..6f3e097888 100644 --- a/timeboost/types.go +++ b/timeboost/types.go @@ -6,10 +6,10 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/arbitrum_types" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/util/merkletree/merkleAccumulator_test.go b/util/merkletree/merkleAccumulator_test.go index 8bf0087009..069b5383db 100644 --- a/util/merkletree/merkleAccumulator_test.go +++ b/util/merkletree/merkleAccumulator_test.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) diff --git a/util/merkletree/merkleEventProof_test.go b/util/merkletree/merkleEventProof_test.go index e08d49ad49..e37c54a8b2 100644 --- a/util/merkletree/merkleEventProof_test.go +++ b/util/merkletree/merkleEventProof_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" "github.com/offchainlabs/nitro/arbos/storage" diff --git a/util/merkletree/merkleTree.go b/util/merkletree/merkleTree.go index 2dc39f7d7b..89b1dee81b 100644 --- a/util/merkletree/merkleTree.go +++ b/util/merkletree/merkleTree.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbos/util" ) diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 1541150e95..6aec515eb2 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,9 +4,10 @@ import ( "context" "errors" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/offchainlabs/nitro/util/contracts" ) diff --git a/util/signature/simple_hmac.go b/util/signature/simple_hmac.go index e98eeb81d2..7472d35570 100644 --- a/util/signature/simple_hmac.go +++ b/util/signature/simple_hmac.go @@ -8,9 +8,9 @@ import ( "regexp" "strings" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" ) diff --git a/util/signature/verifier.go b/util/signature/verifier.go index 074200e574..793926adf5 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -8,9 +8,9 @@ import ( "errors" "fmt" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" diff --git a/validator/execution_state.go b/validator/execution_state.go index a670e2fda1..17ae59e089 100644 --- a/validator/execution_state.go +++ b/validator/execution_state.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/challenge_legacy_gen" "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" ) diff --git a/validator/proofenhancement/proof_enhancer_test.go b/validator/proofenhancement/proof_enhancer_test.go index 9156434173..09b44aecac 100644 --- a/validator/proofenhancement/proof_enhancer_test.go +++ b/validator/proofenhancement/proof_enhancer_test.go @@ -8,6 +8,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" diff --git a/validator/proofenhancement/readpreimage_proof_enhancer.go b/validator/proofenhancement/readpreimage_proof_enhancer.go index 18be4c41fb..e3bf2ddffb 100644 --- a/validator/proofenhancement/readpreimage_proof_enhancer.go +++ b/validator/proofenhancement/readpreimage_proof_enhancer.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" diff --git a/validator/proofenhancement/validatecertificate_proof_enhancer.go b/validator/proofenhancement/validatecertificate_proof_enhancer.go index 36be6203b6..715f7a8707 100644 --- a/validator/proofenhancement/validatecertificate_proof_enhancer.go +++ b/validator/proofenhancement/validatecertificate_proof_enhancer.go @@ -9,6 +9,7 @@ import ( "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" "github.com/offchainlabs/nitro/staker" From 0e3a918d8113b90efb8a19402ba604164df9a06a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:00:24 +0100 Subject: [PATCH 05/21] Do refactor --- arbitrator/jit/src/machine.rs | 3 +++ go-ethereum | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arbitrator/jit/src/machine.rs b/arbitrator/jit/src/machine.rs index 8b53a380c6..744d3b5e9c 100644 --- a/arbitrator/jit/src/machine.rs +++ b/arbitrator/jit/src/machine.rs @@ -69,6 +69,9 @@ pub fn create(opts: &Opts, env: WasmEnv) -> (Instance, FunctionEnv, Sto "brotli_compress" => func!(arbcompress::brotli_compress), "brotli_decompress" => func!(arbcompress::brotli_decompress), }, + "arbkeccak" => { + "keccak256" => func!(), + }, "wavmio" => { "getGlobalStateBytes32" => func!(wavmio::get_global_state_bytes32), "setGlobalStateBytes32" => func!(wavmio::set_global_state_bytes32), diff --git a/go-ethereum b/go-ethereum index 8623b9933a..d284a5e2b5 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 8623b9933a8361e21b699fade2aaf69577d0a60a +Subproject commit d284a5e2b56758423b8ce7c54c56c8f3168a3594 From 24ff16263b7743a42d0d6ee89c1ede69a374f6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:36:17 +0100 Subject: [PATCH 06/21] JIT working! --- arbitrator/Cargo.lock | 1 + arbitrator/caller-env/Cargo.toml | 1 + arbitrator/caller-env/src/arbkeccak.rs | 23 +++++++++++++++++++++++ arbitrator/caller-env/src/lib.rs | 2 ++ arbitrator/jit/src/arbkeccak.rs | 21 +++++++++++++++++++++ arbitrator/jit/src/lib.rs | 1 + arbitrator/jit/src/machine.rs | 7 ++----- arbitrator/wasm-libraries/Cargo.lock | 3 ++- go-ethereum | 2 +- 9 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 arbitrator/caller-env/src/arbkeccak.rs create mode 100644 arbitrator/jit/src/arbkeccak.rs diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index d850235d2b..37d90a0b0e 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -370,6 +370,7 @@ dependencies = [ "num_enum", "rand", "rand_pcg", + "tiny-keccak", "wasmer", ] diff --git a/arbitrator/caller-env/Cargo.toml b/arbitrator/caller-env/Cargo.toml index ad4d07ccad..aa1ab91199 100644 --- a/arbitrator/caller-env/Cargo.toml +++ b/arbitrator/caller-env/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition.workspace = true [dependencies] +tiny-keccak = { version = "2.0.2", features = ["keccak"] } brotli = { path = "../brotli/", optional = true } num_enum.workspace = true rand_pcg = { version = "0.3.1", default-features = false } diff --git a/arbitrator/caller-env/src/arbkeccak.rs b/arbitrator/caller-env/src/arbkeccak.rs new file mode 100644 index 0000000000..642dda59e9 --- /dev/null +++ b/arbitrator/caller-env/src/arbkeccak.rs @@ -0,0 +1,23 @@ +use core::mem::MaybeUninit; +use tiny_keccak::{Hasher, Keccak}; +use crate::{ExecEnv, GuestPtr, MemAccess}; + +pub fn keccak256( + mem: &mut M, + _env: &mut E, + in_buf_ptr: GuestPtr, + in_buf_len: u32, + out_buf_ptr: GuestPtr, +) { + let input = mem.read_slice(in_buf_ptr, in_buf_len as usize); + + let mut output = MaybeUninit::<[u8; 32]>::uninit(); + let mut hasher = Keccak::v256(); + hasher.update(input.as_ref()); + + // SAFETY: finalize() writes 32 bytes + unsafe { + hasher.finalize(&mut *output.as_mut_ptr()); + mem.write_slice(out_buf_ptr, output.assume_init().as_slice()); + } +} diff --git a/arbitrator/caller-env/src/lib.rs b/arbitrator/caller-env/src/lib.rs index e61f7ef2e8..b0f043b2ea 100644 --- a/arbitrator/caller-env/src/lib.rs +++ b/arbitrator/caller-env/src/lib.rs @@ -20,6 +20,8 @@ pub mod wasmer_traits; #[cfg(feature = "brotli")] pub mod brotli; +pub mod arbkeccak; + mod guest_ptr; pub mod wasip1_stub; diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs new file mode 100644 index 0000000000..7bd8d9ed99 --- /dev/null +++ b/arbitrator/jit/src/arbkeccak.rs @@ -0,0 +1,21 @@ +use caller_env::GuestPtr; +use crate::caller_env::{JitEnv, JitExecEnv}; +use crate::machine::{MaybeEscape, WasmEnvMut}; + +#[allow(clippy::too_many_arguments)] +pub fn keccak256( + mut src: WasmEnvMut, + in_buf_ptr: GuestPtr, + in_buf_len: u32, + out_buf_ptr: GuestPtr, +) -> MaybeEscape { + let (mut mem, wenv) = src.jit_env(); + + Ok(caller_env::arbkeccak::keccak256( + &mut mem, + &mut JitExecEnv { wenv }, + in_buf_ptr, + in_buf_len, + out_buf_ptr, + )) +} diff --git a/arbitrator/jit/src/lib.rs b/arbitrator/jit/src/lib.rs index 49d969ca3e..f06215a4f7 100644 --- a/arbitrator/jit/src/lib.rs +++ b/arbitrator/jit/src/lib.rs @@ -5,6 +5,7 @@ use std::path::PathBuf; use structopt::StructOpt; mod arbcompress; +mod arbkeccak; mod caller_env; pub mod machine; mod prepare; diff --git a/arbitrator/jit/src/machine.rs b/arbitrator/jit/src/machine.rs index 744d3b5e9c..3d29d99d12 100644 --- a/arbitrator/jit/src/machine.rs +++ b/arbitrator/jit/src/machine.rs @@ -1,10 +1,7 @@ // Copyright 2022-2024, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md -use crate::{ - arbcompress, caller_env::GoRuntimeState, prepare::prepare_env, program, socket, - stylus_backend::CothreadHandler, wasip1_stub, wavmio, Opts, -}; +use crate::{arbcompress, arbkeccak, caller_env::GoRuntimeState, prepare::prepare_env, program, socket, stylus_backend::CothreadHandler, wasip1_stub, wavmio, Opts}; use arbutil::{Bytes32, Color, PreimageType}; use eyre::{bail, ErrReport, Result, WrapErr}; use sha3::{Digest, Keccak256}; @@ -70,7 +67,7 @@ pub fn create(opts: &Opts, env: WasmEnv) -> (Instance, FunctionEnv, Sto "brotli_decompress" => func!(arbcompress::brotli_decompress), }, "arbkeccak" => { - "keccak256" => func!(), + "keccak256" => func!(arbkeccak::keccak256), }, "wavmio" => { "getGlobalStateBytes32" => func!(wavmio::get_global_state_bytes32), diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index a5a066e5c9..0a20d2aefa 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "ahash" @@ -222,6 +222,7 @@ dependencies = [ "num_enum", "rand", "rand_pcg", + "tiny-keccak", ] [[package]] diff --git a/go-ethereum b/go-ethereum index d284a5e2b5..c9162cbab3 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit d284a5e2b56758423b8ce7c54c56c8f3168a3594 +Subproject commit c9162cbab31f27461df3827a4e17afc96d846533 From d3b64726534fc4de4ddf230d059569ea35cab458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:44:42 +0100 Subject: [PATCH 07/21] Keep keccak implementation in jit --- arbitrator/Cargo.lock | 2 +- arbitrator/caller-env/Cargo.toml | 1 - arbitrator/caller-env/src/arbkeccak.rs | 23 ----------------------- arbitrator/caller-env/src/lib.rs | 2 -- arbitrator/jit/Cargo.toml | 1 + arbitrator/jit/src/arbkeccak.rs | 24 +++++++++++++++--------- arbitrator/wasm-libraries/Cargo.lock | 1 - 7 files changed, 17 insertions(+), 37 deletions(-) delete mode 100644 arbitrator/caller-env/src/arbkeccak.rs diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index 37d90a0b0e..b95aebb3dd 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -370,7 +370,6 @@ dependencies = [ "num_enum", "rand", "rand_pcg", - "tiny-keccak", "wasmer", ] @@ -1216,6 +1215,7 @@ dependencies = [ "structopt", "stylus", "thiserror", + "tiny-keccak", "wasmer", "wasmer-compiler-cranelift", "wasmer-compiler-llvm", diff --git a/arbitrator/caller-env/Cargo.toml b/arbitrator/caller-env/Cargo.toml index aa1ab91199..ad4d07ccad 100644 --- a/arbitrator/caller-env/Cargo.toml +++ b/arbitrator/caller-env/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition.workspace = true [dependencies] -tiny-keccak = { version = "2.0.2", features = ["keccak"] } brotli = { path = "../brotli/", optional = true } num_enum.workspace = true rand_pcg = { version = "0.3.1", default-features = false } diff --git a/arbitrator/caller-env/src/arbkeccak.rs b/arbitrator/caller-env/src/arbkeccak.rs deleted file mode 100644 index 642dda59e9..0000000000 --- a/arbitrator/caller-env/src/arbkeccak.rs +++ /dev/null @@ -1,23 +0,0 @@ -use core::mem::MaybeUninit; -use tiny_keccak::{Hasher, Keccak}; -use crate::{ExecEnv, GuestPtr, MemAccess}; - -pub fn keccak256( - mem: &mut M, - _env: &mut E, - in_buf_ptr: GuestPtr, - in_buf_len: u32, - out_buf_ptr: GuestPtr, -) { - let input = mem.read_slice(in_buf_ptr, in_buf_len as usize); - - let mut output = MaybeUninit::<[u8; 32]>::uninit(); - let mut hasher = Keccak::v256(); - hasher.update(input.as_ref()); - - // SAFETY: finalize() writes 32 bytes - unsafe { - hasher.finalize(&mut *output.as_mut_ptr()); - mem.write_slice(out_buf_ptr, output.assume_init().as_slice()); - } -} diff --git a/arbitrator/caller-env/src/lib.rs b/arbitrator/caller-env/src/lib.rs index b0f043b2ea..e61f7ef2e8 100644 --- a/arbitrator/caller-env/src/lib.rs +++ b/arbitrator/caller-env/src/lib.rs @@ -20,8 +20,6 @@ pub mod wasmer_traits; #[cfg(feature = "brotli")] pub mod brotli; -pub mod arbkeccak; - mod guest_ptr; pub mod wasip1_stub; diff --git a/arbitrator/jit/Cargo.toml b/arbitrator/jit/Cargo.toml index fb49b871b3..6f362574ab 100644 --- a/arbitrator/jit/Cargo.toml +++ b/arbitrator/jit/Cargo.toml @@ -17,6 +17,7 @@ parking_lot = "0.12.1" rand = { version = "0.8.4", default-features = false } rand_pcg = { version = "0.3.1", default-features = false } thiserror = "1.0.33" +tiny-keccak = { version = "2.0.2", features = ["keccak"] } hex = "0.4.3" structopt = "0.3.26" sha3 = "0.9.1" diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index 7bd8d9ed99..53534305fb 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -1,6 +1,8 @@ -use caller_env::GuestPtr; -use crate::caller_env::{JitEnv, JitExecEnv}; +use crate::caller_env::JitEnv; use crate::machine::{MaybeEscape, WasmEnvMut}; +use caller_env::{GuestPtr, MemAccess}; +use core::mem::MaybeUninit; +use tiny_keccak::{Hasher, Keccak}; #[allow(clippy::too_many_arguments)] pub fn keccak256( @@ -10,12 +12,16 @@ pub fn keccak256( out_buf_ptr: GuestPtr, ) -> MaybeEscape { let (mut mem, wenv) = src.jit_env(); + let input = mem.read_slice(in_buf_ptr, in_buf_len as usize); - Ok(caller_env::arbkeccak::keccak256( - &mut mem, - &mut JitExecEnv { wenv }, - in_buf_ptr, - in_buf_len, - out_buf_ptr, - )) + let mut output = MaybeUninit::<[u8; 32]>::uninit(); + let mut hasher = Keccak::v256(); + hasher.update(input.as_ref()); + + // SAFETY: finalize() writes 32 bytes + unsafe { + hasher.finalize(&mut *output.as_mut_ptr()); + mem.write_slice(out_buf_ptr, output.assume_init().as_slice()); + } + Ok(()) } diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index 0a20d2aefa..51d8822ab2 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -222,7 +222,6 @@ dependencies = [ "num_enum", "rand", "rand_pcg", - "tiny-keccak", ] [[package]] From f4871f4dbaccdbcafa77c3839778571156796a59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:53:30 +0100 Subject: [PATCH 08/21] Add new wasm library (wip) --- arbitrator/wasm-libraries/Cargo.lock | 7 +++++++ arbitrator/wasm-libraries/Cargo.toml | 1 + arbitrator/wasm-libraries/arbkeccak/Cargo.toml | 11 +++++++++++ arbitrator/wasm-libraries/arbkeccak/build.rs | 8 ++++++++ arbitrator/wasm-libraries/arbkeccak/src/lib.rs | 16 ++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 arbitrator/wasm-libraries/arbkeccak/Cargo.toml create mode 100644 arbitrator/wasm-libraries/arbkeccak/build.rs create mode 100644 arbitrator/wasm-libraries/arbkeccak/src/lib.rs diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index 51d8822ab2..5dc2786dc8 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -64,6 +64,13 @@ dependencies = [ "paste", ] +[[package]] +name = "arbkeccak" +version = "0.1.0" +dependencies = [ + "caller-env", +] + [[package]] name = "arbutil" version = "0.1.0" diff --git a/arbitrator/wasm-libraries/Cargo.toml b/arbitrator/wasm-libraries/Cargo.toml index 837df8f4da..0cc80cb78a 100644 --- a/arbitrator/wasm-libraries/Cargo.toml +++ b/arbitrator/wasm-libraries/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "arbcompress", + "arbkeccak", "wasi-stub", "host-io", "user-host", diff --git a/arbitrator/wasm-libraries/arbkeccak/Cargo.toml b/arbitrator/wasm-libraries/arbkeccak/Cargo.toml new file mode 100644 index 0000000000..d8ea559030 --- /dev/null +++ b/arbitrator/wasm-libraries/arbkeccak/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "arbkeccak" +version = "0.1.0" +edition = "2021" +publish = false + +[lib] +crate-type = ["cdylib"] + +[dependencies] +caller-env = { path = "../../caller-env/", features = ["static_caller"] } diff --git a/arbitrator/wasm-libraries/arbkeccak/build.rs b/arbitrator/wasm-libraries/arbkeccak/build.rs new file mode 100644 index 0000000000..5316e1f233 --- /dev/null +++ b/arbitrator/wasm-libraries/arbkeccak/build.rs @@ -0,0 +1,8 @@ +// Copyright 2025, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md + +fn main() { + // Tell Cargo that if the given file changes, to rerun this build script. + println!("cargo:rustc-link-search=../../target/lib-wasm/"); + println!("cargo:rustc-link-search=../target/lib/"); +} diff --git a/arbitrator/wasm-libraries/arbkeccak/src/lib.rs b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs new file mode 100644 index 0000000000..ad3ffa08b5 --- /dev/null +++ b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs @@ -0,0 +1,16 @@ +// Copyright 2025, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md + +#![allow(clippy::missing_safety_doc)] + +use caller_env::{self, GuestPtr}; + +#[no_mangle] +pub unsafe extern "C" fn arbkeccak__keccak256(in_buf_ptr: GuestPtr, in_buf_len: u32, out_buf_ptr: GuestPtr) +{ + caller_env::brotli::brotli_compress( + &mut caller_env::static_caller::STATIC_MEM, + &mut caller_env::static_caller::STATIC_ENV, + in_buf_ptr, in_buf_len, out_buf_ptr, out_len_ptr, level, window_size, + ) +} From b2faa32a770800ab1b2ee03b07b7e4ed86ff618d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:53:56 +0100 Subject: [PATCH 09/21] Revert "Keep keccak implementation in jit" This reverts commit d3b64726534fc4de4ddf230d059569ea35cab458. --- arbitrator/Cargo.lock | 2 +- arbitrator/caller-env/Cargo.toml | 1 + arbitrator/caller-env/src/arbkeccak.rs | 23 +++++++++++++++++++++++ arbitrator/caller-env/src/lib.rs | 2 ++ arbitrator/jit/Cargo.toml | 1 - arbitrator/jit/src/arbkeccak.rs | 24 +++++++++--------------- arbitrator/wasm-libraries/Cargo.lock | 1 + 7 files changed, 37 insertions(+), 17 deletions(-) create mode 100644 arbitrator/caller-env/src/arbkeccak.rs diff --git a/arbitrator/Cargo.lock b/arbitrator/Cargo.lock index b95aebb3dd..37d90a0b0e 100644 --- a/arbitrator/Cargo.lock +++ b/arbitrator/Cargo.lock @@ -370,6 +370,7 @@ dependencies = [ "num_enum", "rand", "rand_pcg", + "tiny-keccak", "wasmer", ] @@ -1215,7 +1216,6 @@ dependencies = [ "structopt", "stylus", "thiserror", - "tiny-keccak", "wasmer", "wasmer-compiler-cranelift", "wasmer-compiler-llvm", diff --git a/arbitrator/caller-env/Cargo.toml b/arbitrator/caller-env/Cargo.toml index ad4d07ccad..aa1ab91199 100644 --- a/arbitrator/caller-env/Cargo.toml +++ b/arbitrator/caller-env/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition.workspace = true [dependencies] +tiny-keccak = { version = "2.0.2", features = ["keccak"] } brotli = { path = "../brotli/", optional = true } num_enum.workspace = true rand_pcg = { version = "0.3.1", default-features = false } diff --git a/arbitrator/caller-env/src/arbkeccak.rs b/arbitrator/caller-env/src/arbkeccak.rs new file mode 100644 index 0000000000..642dda59e9 --- /dev/null +++ b/arbitrator/caller-env/src/arbkeccak.rs @@ -0,0 +1,23 @@ +use core::mem::MaybeUninit; +use tiny_keccak::{Hasher, Keccak}; +use crate::{ExecEnv, GuestPtr, MemAccess}; + +pub fn keccak256( + mem: &mut M, + _env: &mut E, + in_buf_ptr: GuestPtr, + in_buf_len: u32, + out_buf_ptr: GuestPtr, +) { + let input = mem.read_slice(in_buf_ptr, in_buf_len as usize); + + let mut output = MaybeUninit::<[u8; 32]>::uninit(); + let mut hasher = Keccak::v256(); + hasher.update(input.as_ref()); + + // SAFETY: finalize() writes 32 bytes + unsafe { + hasher.finalize(&mut *output.as_mut_ptr()); + mem.write_slice(out_buf_ptr, output.assume_init().as_slice()); + } +} diff --git a/arbitrator/caller-env/src/lib.rs b/arbitrator/caller-env/src/lib.rs index e61f7ef2e8..b0f043b2ea 100644 --- a/arbitrator/caller-env/src/lib.rs +++ b/arbitrator/caller-env/src/lib.rs @@ -20,6 +20,8 @@ pub mod wasmer_traits; #[cfg(feature = "brotli")] pub mod brotli; +pub mod arbkeccak; + mod guest_ptr; pub mod wasip1_stub; diff --git a/arbitrator/jit/Cargo.toml b/arbitrator/jit/Cargo.toml index 6f362574ab..fb49b871b3 100644 --- a/arbitrator/jit/Cargo.toml +++ b/arbitrator/jit/Cargo.toml @@ -17,7 +17,6 @@ parking_lot = "0.12.1" rand = { version = "0.8.4", default-features = false } rand_pcg = { version = "0.3.1", default-features = false } thiserror = "1.0.33" -tiny-keccak = { version = "2.0.2", features = ["keccak"] } hex = "0.4.3" structopt = "0.3.26" sha3 = "0.9.1" diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index 53534305fb..7bd8d9ed99 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -1,8 +1,6 @@ -use crate::caller_env::JitEnv; +use caller_env::GuestPtr; +use crate::caller_env::{JitEnv, JitExecEnv}; use crate::machine::{MaybeEscape, WasmEnvMut}; -use caller_env::{GuestPtr, MemAccess}; -use core::mem::MaybeUninit; -use tiny_keccak::{Hasher, Keccak}; #[allow(clippy::too_many_arguments)] pub fn keccak256( @@ -12,16 +10,12 @@ pub fn keccak256( out_buf_ptr: GuestPtr, ) -> MaybeEscape { let (mut mem, wenv) = src.jit_env(); - let input = mem.read_slice(in_buf_ptr, in_buf_len as usize); - let mut output = MaybeUninit::<[u8; 32]>::uninit(); - let mut hasher = Keccak::v256(); - hasher.update(input.as_ref()); - - // SAFETY: finalize() writes 32 bytes - unsafe { - hasher.finalize(&mut *output.as_mut_ptr()); - mem.write_slice(out_buf_ptr, output.assume_init().as_slice()); - } - Ok(()) + Ok(caller_env::arbkeccak::keccak256( + &mut mem, + &mut JitExecEnv { wenv }, + in_buf_ptr, + in_buf_len, + out_buf_ptr, + )) } diff --git a/arbitrator/wasm-libraries/Cargo.lock b/arbitrator/wasm-libraries/Cargo.lock index 5dc2786dc8..0dbec4d3ae 100644 --- a/arbitrator/wasm-libraries/Cargo.lock +++ b/arbitrator/wasm-libraries/Cargo.lock @@ -229,6 +229,7 @@ dependencies = [ "num_enum", "rand", "rand_pcg", + "tiny-keccak", ] [[package]] From 39786cc5c91f91fb651fd9bb535f145c67511319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 13:55:01 +0100 Subject: [PATCH 10/21] Wasm library refer to caller-env --- arbitrator/wasm-libraries/arbkeccak/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arbitrator/wasm-libraries/arbkeccak/src/lib.rs b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs index ad3ffa08b5..d521ced49a 100644 --- a/arbitrator/wasm-libraries/arbkeccak/src/lib.rs +++ b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs @@ -8,9 +8,9 @@ use caller_env::{self, GuestPtr}; #[no_mangle] pub unsafe extern "C" fn arbkeccak__keccak256(in_buf_ptr: GuestPtr, in_buf_len: u32, out_buf_ptr: GuestPtr) { - caller_env::brotli::brotli_compress( + caller_env::arbkeccak::keccak256( &mut caller_env::static_caller::STATIC_MEM, &mut caller_env::static_caller::STATIC_ENV, - in_buf_ptr, in_buf_len, out_buf_ptr, out_len_ptr, level, window_size, + in_buf_ptr, in_buf_len, out_buf_ptr ) } From 200d42346dc7ff2985f279358f427f27a6e7ce5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 14:00:43 +0100 Subject: [PATCH 11/21] Makefile --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3b26d0b122..a073e2a70a 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ replay_wasm=$(output_latest)/replay.wasm arb_brotli_files = $(wildcard arbitrator/brotli/src/*.* arbitrator/brotli/src/*/*.* arbitrator/brotli/*.toml arbitrator/brotli/*.rs) .make/cbrotli-lib .make/cbrotli-wasm arbitrator_generated_header=$(output_root)/include/arbitrator.h -arbitrator_wasm_libs=$(patsubst %, $(output_root)/machines/latest/%.wasm, forward wasi_stub host_io soft-float arbcompress user_host program_exec) +arbitrator_wasm_libs=$(patsubst %, $(output_root)/machines/latest/%.wasm, forward wasi_stub host_io soft-float arbcompress arbkeccak user_host program_exec) arbitrator_stylus_lib=$(output_root)/lib/libstylus.a prover_bin=$(output_root)/bin/prover arbitrator_jit=$(output_root)/bin/jit @@ -453,6 +453,11 @@ $(output_latest)/arbcompress.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps,brotli) install arbitrator/wasm-libraries/$(wasm32_wasi)/arbcompress.wasm $@ ./scripts/remove_reference_types.sh $@ +$(output_latest)/arbkeccak.wasm: $(DEP_PREDICATE) $(call wasm_lib_deps) $(wasm_lib_go_abi) + cargo build --manifest-path arbitrator/wasm-libraries/Cargo.toml --release --target wasm32-wasip1 --config $(wasm_lib_cargo) --package arbkeccak + install arbitrator/wasm-libraries/$(wasm32_wasi)/arbkeccak.wasm $@ + ./scripts/remove_reference_types.sh $@ + $(output_latest)/forward.wasm: $(DEP_PREDICATE) $(wasm_lib_forward) .make/machines cargo run --manifest-path $(forward_dir)/Cargo.toml -- --path $(forward_dir)/forward.wat wat2wasm $(wasm_lib)/forward/forward.wat -o $@ @@ -463,7 +468,7 @@ $(output_latest)/forward_stub.wasm: $(DEP_PREDICATE) $(wasm_lib_forward) .make/m $(output_latest)/machine.wavm.br: $(DEP_PREDICATE) $(prover_bin) $(arbitrator_wasm_libs) $(replay_wasm) $(prover_bin) $(replay_wasm) --generate-binaries $(output_latest) \ - $(patsubst %,-l $(output_latest)/%.wasm, forward soft-float wasi_stub host_io user_host arbcompress program_exec) + $(patsubst %,-l $(output_latest)/%.wasm, forward soft-float wasi_stub host_io user_host arbcompress arbkeccak program_exec) $(arbitrator_cases)/%.wasm: $(arbitrator_cases)/%.wat wat2wasm $< -o $@ From 0eb3642d81c21f070982483906cca27025686685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 14:59:49 +0100 Subject: [PATCH 12/21] Merge --- arbitrator/jit/src/arbkeccak.rs | 2 ++ go-ethereum | 2 +- go.mod | 3 ++- go.sum | 6 ++++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index 7bd8d9ed99..6af68e8aca 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -11,6 +11,8 @@ pub fn keccak256( ) -> MaybeEscape { let (mut mem, wenv) = src.jit_env(); + eprintln!("HELLO"); + Ok(caller_env::arbkeccak::keccak256( &mut mem, &mut JitExecEnv { wenv }, diff --git a/go-ethereum b/go-ethereum index c9162cbab3..ae4b9b65f5 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit c9162cbab31f27461df3827a4e17afc96d846533 +Subproject commit ae4b9b65f5848a6e9f75d3e7df136628d139dddb diff --git a/go.mod b/go.mod index c6929c56f3..8355b0557e 100644 --- a/go.mod +++ b/go.mod @@ -62,11 +62,12 @@ require ( cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect cloud.google.com/go/compute/metadata v0.3.0 // indirect cloud.google.com/go/iam v1.1.8 // indirect + github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 // indirect github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect github.com/crate-crypto/go-eth-kzg v1.4.0 // indirect github.com/dchest/siphash v1.2.3 // indirect github.com/emicklei/dot v1.6.2 // indirect - github.com/ethereum/c-kzg-4844/v2 v2.1.3 // indirect + github.com/ethereum/c-kzg-4844/v2 v2.1.5 // indirect github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab // indirect github.com/ethereum/go-verkle v0.2.2 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect diff --git a/go.sum b/go.sum index 7c9a4e344e..b88e1d5571 100644 --- a/go.sum +++ b/go.sum @@ -24,6 +24,8 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1 github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6 h1:1zYrtlhrZ6/b6SAjLSfKzWtdgqK0U+HtH/VcBWh1BaU= +github.com/ProjectZKM/Ziren/crates/go-runtime/zkvm_runtime v0.0.0-20251001021608-1fe7b43fc4d6/go.mod h1:ioLG6R+5bUSO1oeGSDxOV3FADARuMoytZCSX6MEMQkI= github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VictoriaMetrics/fastcache v1.13.0 h1:AW4mheMR5Vd9FkAPUv+NH6Nhw+fmbTMGMsNAoA/+4G0= @@ -170,8 +172,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/ethereum/c-kzg-4844/v2 v2.1.3 h1:DQ21UU0VSsuGy8+pcMJHDS0CV1bKmJmxsJYK8l3MiLU= -github.com/ethereum/c-kzg-4844/v2 v2.1.3/go.mod h1:fyNcYI/yAuLWJxf4uzVtS8VDKeoAaRM8G/+ADz/pRdA= +github.com/ethereum/c-kzg-4844/v2 v2.1.5 h1:aVtoLK5xwJ6c5RiqO8g8ptJ5KU+2Hdquf6G3aXiHh5s= +github.com/ethereum/c-kzg-4844/v2 v2.1.5/go.mod h1:u59hRTTah4Co6i9fDWtiCjTrblJv0UwsqZKCc0GfgUs= github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab h1:rvv6MJhy07IMfEKuARQ9TKojGqLVNxQajaXEp/BoqSk= github.com/ethereum/go-bigmodexpfix v0.0.0-20250911101455-f9e208c548ab/go.mod h1:IuLm4IsPipXKF7CW5Lzf68PIbZ5yl7FFd74l/E0o9A8= github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8= From 0022541456e770911ef508ca39eb9a48b95f3a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 15:04:36 +0100 Subject: [PATCH 13/21] fix --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index ae4b9b65f5..903fb81e0e 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit ae4b9b65f5848a6e9f75d3e7df136628d139dddb +Subproject commit 903fb81e0e688906cee208edd124b56c3142ad82 From 4c045945800bd2fa6160db5141ee92f6b25b16e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 15:17:11 +0100 Subject: [PATCH 14/21] Add keccak_wasm.go --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 903fb81e0e..3d6ff7c861 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 903fb81e0e688906cee208edd124b56c3142ad82 +Subproject commit 3d6ff7c8616be578273c7acf5fdd11068e852526 From 636279cc686aea18173b37b3c3add7887bff62ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 15:19:12 +0100 Subject: [PATCH 15/21] Revert import --- arbnode/delay_buffer.go | 5 +- arbnode/delayed.go | 11 +++-- .../mel/extraction/delayed_message_lookup.go | 5 +- .../extraction/delayed_message_lookup_test.go | 8 ++-- .../extraction/message_extraction_function.go | 4 +- .../message_extraction_function_test.go | 4 +- arbnode/mel/messages.go | 14 +++--- arbos/addressTable/addressTable_test.go | 8 ++-- arbos/arbostypes/incomingmessage.go | 4 +- arbos/arbostypes/messagewithmeta.go | 4 +- arbos/blockhash/blockhash_test.go | 6 +-- arbos/l1pricing/l1pricing.go | 14 +++--- arbos/merkleAccumulator/merkleAccumulator.go | 8 ++-- arbos/parse_l2.go | 8 ++-- arbos/retryables/retryable.go | 5 +- arbos/storage/storage.go | 9 ++-- arbos/storage/storage_test.go | 4 +- arbutil/hash.go | 4 +- blsSignatures/blsSignatures.go | 4 +- bold/chain-abstraction/execution_state.go | 4 +- bold/chain-abstraction/interfaces.go | 5 +- .../edge_challenge_manager.go | 5 +- .../history/history_commitment.go | 6 +-- .../history/history_commitment_test.go | 48 +++++++++---------- .../inclusion-proofs/inclusion_proofs.go | 16 +++---- .../prefix-proofs/merkle_expansions_test.go | 17 ++++--- .../prefix-proofs/prefix_proofs.go | 12 ++--- .../prefix-proofs/prefix_proofs_test.go | 8 ++-- bold/testing/integration/prefixproofs_test.go | 6 +-- .../layer2_state_provider_test.go | 8 ++-- cmd/el-proxy/main.go | 4 +- cmd/mel-replay/delayed_message_db_test.go | 6 +-- cmd/mel-replay/receipt_fetcher_test.go | 4 +- daprovider/das/dastree/dastree.go | 8 ++-- daprovider/das/dastree/dastree_test.go | 9 ++-- daprovider/das/dasutil/dasutil.go | 6 +-- .../das/extra_signature_checker_test.go | 5 +- daprovider/data_streaming/signing.go | 9 ++-- daprovider/referenceda/reference_reader.go | 5 +- execution/gethexec/classicMessage.go | 4 +- .../gethexec/express_lane_service_test.go | 4 +- execution/nodeInterface/NodeInterface.go | 15 +++--- precompiles/ArbAddressTable_test.go | 8 ++-- precompiles/ArbAggregator_test.go | 8 ++-- precompiles/ArbGasInfo_test.go | 6 +-- precompiles/ArbOwner_test.go | 16 +++---- precompiles/constraints_test.go | 4 +- precompiles/precompile.go | 5 +- precompiles/precompile_test.go | 4 +- staker/bold/bold_state_provider.go | 4 +- staker/legacy/assertion.go | 4 +- staker/legacy/block_challenge_backend.go | 6 +-- staker/legacy/l1_validator.go | 5 +- staker/legacy/rollup_watcher.go | 5 +- system_tests/conditionaltx_test.go | 5 +- system_tests/infra_fee_test.go | 4 +- system_tests/multigas_stylus_program_test.go | 5 +- system_tests/outbox_test.go | 9 ++-- system_tests/precompile_doesnt_revert_test.go | 11 +++-- system_tests/precompile_test.go | 13 ++--- system_tests/program_ink_test.go | 4 +- system_tests/program_test.go | 12 ++--- system_tests/seqfeed_test.go | 4 +- system_tests/staker_test.go | 5 +- system_tests/stylus_trace_test.go | 7 ++- system_tests/test_info.go | 4 +- system_tests/timeboost_test.go | 5 +- system_tests/validation_mock_test.go | 4 +- timeboost/types.go | 8 ++-- util/merkletree/merkleAccumulator_test.go | 18 +++---- util/merkletree/merkleEventProof_test.go | 6 +-- util/merkletree/merkleTree.go | 10 ++-- util/signature/sign_verify.go | 7 ++- util/signature/simple_hmac.go | 8 ++-- util/signature/verifier.go | 3 +- util/signature/verifier_test.go | 5 +- validator/execution_state.go | 10 ++-- .../proofenhancement/proof_enhancer_test.go | 14 +++--- .../readpreimage_proof_enhancer.go | 4 +- .../validatecertificate_proof_enhancer.go | 4 +- wavmio/stub.go | 4 +- 81 files changed, 311 insertions(+), 300 deletions(-) diff --git a/arbnode/delay_buffer.go b/arbnode/delay_buffer.go index c347da555b..e2e00eeb67 100644 --- a/arbnode/delay_buffer.go +++ b/arbnode/delay_buffer.go @@ -12,7 +12,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -94,7 +95,7 @@ func GenDelayProof(ctx context.Context, message *arbostypes.MessageWithMetadata, Timestamp: message.Message.Header.Timestamp, InboxSeqNum: new(big.Int).SetUint64(seqNum), BaseFeeL1: message.Message.Header.L1BaseFee, - MessageDataHash: arbkeccak.Keccak256Hash(message.Message.L2msg), + MessageDataHash: crypto.Keccak256Hash(message.Message.L2msg), } delayProof := &bridgegen.DelayProof{ BeforeDelayedAcc: beforeDelayedAcc, diff --git a/arbnode/delayed.go b/arbnode/delayed.go index 98ca56e423..ca9190715e 100644 --- a/arbnode/delayed.go +++ b/arbnode/delayed.go @@ -15,7 +15,8 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" @@ -143,16 +144,16 @@ type DelayedInboxMessage struct { } func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash { - hash := arbkeccak.Keccak256( + hash := crypto.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - arbkeccak.Keccak256(m.Message.L2msg), + crypto.Keccak256(m.Message.L2msg), ) - return arbkeccak.Keccak256Hash(m.BeforeInboxAcc[:], hash) + return crypto.Keccak256Hash(m.BeforeInboxAcc[:], hash) } func (b *DelayedBridge) LookupMessagesInRange(ctx context.Context, from, to *big.Int, batchFetcher arbostypes.FallibleBatchFetcher) ([]*DelayedInboxMessage, error) { @@ -224,7 +225,7 @@ func (b *DelayedBridge) logsToDeliveredMessages(ctx context.Context, logs []type if !ok { return nil, fmt.Errorf("message %v data not found", parsedLog.MessageIndex) } - if arbkeccak.Keccak256Hash(data) != parsedLog.MessageDataHash { + if crypto.Keccak256Hash(data) != parsedLog.MessageDataHash { return nil, fmt.Errorf("found message %v data with mismatched hash", parsedLog.MessageIndex) } diff --git a/arbnode/mel/extraction/delayed_message_lookup.go b/arbnode/mel/extraction/delayed_message_lookup.go index 2a62995d4c..93d4829c93 100644 --- a/arbnode/mel/extraction/delayed_message_lookup.go +++ b/arbnode/mel/extraction/delayed_message_lookup.go @@ -9,7 +9,8 @@ import ( "sort" "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -118,7 +119,7 @@ func parseDelayedMessagesFromBlock( if !ok { return nil, fmt.Errorf("message %v data not found", parsedLog.MessageIndex) } - if arbkeccak.Keccak256Hash(data) != parsedLog.MessageDataHash { + if crypto.Keccak256Hash(data) != parsedLog.MessageDataHash { return nil, fmt.Errorf("found message %v data with mismatched hash", parsedLog.MessageIndex) } // Fill in the message data for the delayed message scaffolds. diff --git a/arbnode/mel/extraction/delayed_message_lookup_test.go b/arbnode/mel/extraction/delayed_message_lookup_test.go index 89fc73f7d5..3d3e422681 100644 --- a/arbnode/mel/extraction/delayed_message_lookup_test.go +++ b/arbnode/mel/extraction/delayed_message_lookup_test.go @@ -6,9 +6,9 @@ import ( "sort" "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/trie" @@ -257,7 +257,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: arbkeccak.Keccak256Hash(msgData), + MessageDataHash: crypto.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } @@ -359,7 +359,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: arbkeccak.Keccak256Hash(msgData), + MessageDataHash: crypto.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } @@ -451,7 +451,7 @@ func Test_parseDelayedMessagesFromBlock(t *testing.T) { Inbox: common.HexToAddress("0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef"), Kind: 1, Sender: [20]byte{}, - MessageDataHash: arbkeccak.Keccak256Hash(msgData), + MessageDataHash: crypto.Keccak256Hash(msgData), BaseFeeL1: big.NewInt(2), Timestamp: 0, } diff --git a/arbnode/mel/extraction/message_extraction_function.go b/arbnode/mel/extraction/message_extraction_function.go index fb1936a692..4f8fc57cd3 100644 --- a/arbnode/mel/extraction/message_extraction_function.go +++ b/arbnode/mel/extraction/message_extraction_function.go @@ -6,9 +6,9 @@ import ( "errors" "fmt" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" @@ -178,7 +178,7 @@ func extractMessagesImpl( if err != nil { return nil, nil, nil, fmt.Errorf("failed to parse batch posting report: %w", err) } - gotHash := arbkeccak.Keccak256Hash(serialized) + gotHash := crypto.Keccak256Hash(serialized) if gotHash != batchHash { return nil, nil, nil, fmt.Errorf( "batch data hash incorrect %v (wanted %v for batch %v)", diff --git a/arbnode/mel/extraction/message_extraction_function_test.go b/arbnode/mel/extraction/message_extraction_function_test.go index 2b06d52273..97ea1fffb7 100644 --- a/arbnode/mel/extraction/message_extraction_function_test.go +++ b/arbnode/mel/extraction/message_extraction_function_test.go @@ -7,9 +7,9 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -299,7 +299,7 @@ func failingSerializer(ctx context.Context, func successfulParseReport( rd io.Reader, ) (*big.Int, common.Address, common.Hash, uint64, *big.Int, uint64, error) { - return nil, common.Address{}, arbkeccak.Keccak256Hash([]byte("foobar")), 0, nil, 0, nil + return nil, common.Address{}, crypto.Keccak256Hash([]byte("foobar")), 0, nil, 0, nil } func emptyParseReport( diff --git a/arbnode/mel/messages.go b/arbnode/mel/messages.go index e6fc410588..3bab5d214d 100644 --- a/arbnode/mel/messages.go +++ b/arbnode/mel/messages.go @@ -1,9 +1,9 @@ package mel import ( - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/arbutil" @@ -43,30 +43,30 @@ type DelayedInboxMessage struct { } func (m *DelayedInboxMessage) AfterInboxAcc() common.Hash { - hash := arbkeccak.Keccak256( + hash := crypto.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - arbkeccak.Keccak256(m.Message.L2msg), + crypto.Keccak256(m.Message.L2msg), ) - return arbkeccak.Keccak256Hash(m.BeforeInboxAcc[:], hash) + return crypto.Keccak256Hash(m.BeforeInboxAcc[:], hash) } // Hash will replace AfterInboxAcc func (m *DelayedInboxMessage) Hash() common.Hash { - hash := arbkeccak.Keccak256( + hash := crypto.Keccak256( []byte{m.Message.Header.Kind}, m.Message.Header.Poster.Bytes(), arbmath.UintToBytes(m.Message.Header.BlockNumber), arbmath.UintToBytes(m.Message.Header.Timestamp), m.Message.Header.RequestId.Bytes(), arbmath.U256Bytes(m.Message.Header.L1BaseFee), - arbkeccak.Keccak256(m.Message.L2msg), + crypto.Keccak256(m.Message.L2msg), ) - return arbkeccak.Keccak256Hash(hash) + return crypto.Keccak256Hash(hash) } type BatchMetadata struct { diff --git a/arbos/addressTable/addressTable_test.go b/arbos/addressTable/addressTable_test.go index 02642d617f..b368f82881 100644 --- a/arbos/addressTable/addressTable_test.go +++ b/arbos/addressTable/addressTable_test.go @@ -7,8 +7,8 @@ import ( "bytes" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/storage" @@ -39,7 +39,7 @@ func TestAddressTable1(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) _, err := atab.Register(addr) Require(t, err) if size(t, atab) != 1 { @@ -85,7 +85,7 @@ func TestAddressTableCompressNotInTable(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) res, err := atab.Compress(addr) Require(t, err) @@ -112,7 +112,7 @@ func TestAddressTableCompressInTable(t *testing.T) { sto := storage.NewMemoryBacked(burn.NewSystemBurner(nil, false)) Initialize(sto) atab := Open(sto) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) _, err := atab.Register(addr) Require(t, err) diff --git a/arbos/arbostypes/incomingmessage.go b/arbos/arbostypes/incomingmessage.go index 0057334204..e3e17068ee 100644 --- a/arbos/arbostypes/incomingmessage.go +++ b/arbos/arbostypes/incomingmessage.go @@ -11,8 +11,8 @@ import ( "io" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/util" @@ -191,7 +191,7 @@ func (msg *L1IncomingMessage) FillInBatchGasFields(batchFetcher FallibleBatchFet if err != nil { return fmt.Errorf("failed to fetch batch mentioned by batch posting report: %w", err) } - gotHash := arbkeccak.Keccak256Hash(batchData) + gotHash := crypto.Keccak256Hash(batchData) if gotHash != batchHash { return fmt.Errorf("batch fetcher returned incorrect data hash %v (wanted %v for batch %v)", gotHash, batchHash, batchNum) } diff --git a/arbos/arbostypes/messagewithmeta.go b/arbos/arbostypes/messagewithmeta.go index 4458e2bf57..36ca90d728 100644 --- a/arbos/arbostypes/messagewithmeta.go +++ b/arbos/arbostypes/messagewithmeta.go @@ -5,8 +5,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" "github.com/offchainlabs/nitro/arbutil" @@ -46,7 +46,7 @@ func (m *MessageWithMetadata) Hash(sequenceNumber arbutil.MessageIndex, chainId return common.Hash{}, fmt.Errorf("unable to serialize message %v: %w", sequenceNumber, err) } - return arbkeccak.Keccak256Hash(uniquifyingPrefix, serializedExtraData, serializedMessage), nil + return crypto.Keccak256Hash(uniquifyingPrefix, serializedExtraData, serializedMessage), nil } type InboxMultiplexer interface { diff --git a/arbos/blockhash/blockhash_test.go b/arbos/blockhash/blockhash_test.go index aa4b905fc9..dba21bac06 100644 --- a/arbos/blockhash/blockhash_test.go +++ b/arbos/blockhash/blockhash_test.go @@ -6,8 +6,8 @@ package blockhash import ( "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/burn" @@ -36,7 +36,7 @@ func TestBlockhash(t *testing.T) { Fail(t, "should have generated error on Blockhash(4242) in new Blockhashes") } - hash0 := common.BytesToHash(arbkeccak.Keccak256([]byte{0})) + hash0 := common.BytesToHash(crypto.Keccak256([]byte{0})) err = bh.RecordNewL1Block(0, hash0, arbosVersion) Require(t, err) bnum, err = bh.L1BlockNumber() @@ -50,7 +50,7 @@ func TestBlockhash(t *testing.T) { Fail(t, "incorrect hash return for initial Blockhash(0)") } - hash4242 := common.BytesToHash(arbkeccak.Keccak256([]byte{42, 42})) + hash4242 := common.BytesToHash(crypto.Keccak256([]byte{42, 42})) err = bh.RecordNewL1Block(4242, hash4242, arbosVersion) Require(t, err) bnum, err = bh.L1BlockNumber() diff --git a/arbos/l1pricing/l1pricing.go b/arbos/l1pricing/l1pricing.go index 2c94162768..793250be26 100644 --- a/arbos/l1pricing/l1pricing.go +++ b/arbos/l1pricing/l1pricing.go @@ -9,12 +9,12 @@ import ( "fmt" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbcompress" @@ -558,13 +558,13 @@ var estimationPaddingUnits uint64 = 16 * params.TxDataNonZeroGasEIP2028 const estimationPaddingBasisPoints = 100 -var randomNonce = binary.BigEndian.Uint64(arbkeccak.Keccak256([]byte("Nonce"))[:8]) -var randomGasTipCap = new(big.Int).SetBytes(arbkeccak.Keccak256([]byte("GasTipCap"))[:4]) -var randomGasFeeCap = new(big.Int).SetBytes(arbkeccak.Keccak256([]byte("GasFeeCap"))[:4]) -var RandomGas = uint64(binary.BigEndian.Uint32(arbkeccak.Keccak256([]byte("Gas"))[:4])) +var randomNonce = binary.BigEndian.Uint64(crypto.Keccak256([]byte("Nonce"))[:8]) +var randomGasTipCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasTipCap"))[:4]) +var randomGasFeeCap = new(big.Int).SetBytes(crypto.Keccak256([]byte("GasFeeCap"))[:4]) +var RandomGas = uint64(binary.BigEndian.Uint32(crypto.Keccak256([]byte("Gas"))[:4])) var randV = arbmath.BigMulByUint(chaininfo.ArbitrumOneChainConfig().ChainID, 3) -var randR = arbkeccak.Keccak256Hash([]byte("R")).Big() -var randS = arbkeccak.Keccak256Hash([]byte("S")).Big() +var randR = crypto.Keccak256Hash([]byte("R")).Big() +var randS = crypto.Keccak256Hash([]byte("S")).Big() // The returned tx will be invalid, likely for a number of reasons such as an invalid signature. // It's only used to check how large it is after brotli level 0 compression. diff --git a/arbos/merkleAccumulator/merkleAccumulator.go b/arbos/merkleAccumulator/merkleAccumulator.go index f76a370c78..eb34cad23f 100644 --- a/arbos/merkleAccumulator/merkleAccumulator.go +++ b/arbos/merkleAccumulator/merkleAccumulator.go @@ -4,8 +4,8 @@ package merkleAccumulator import ( - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/util/arbmath" @@ -69,14 +69,14 @@ func (acc *MerkleAccumulator) Keccak(data ...[]byte) ([]byte, error) { if acc.backingStorage != nil { return acc.backingStorage.Keccak(data...) } - return arbkeccak.Keccak256(data...), nil + return crypto.Keccak256(data...), nil } func (acc *MerkleAccumulator) KeccakHash(data ...[]byte) (common.Hash, error) { if acc.backingStorage != nil { return acc.backingStorage.KeccakHash(data...) } - return arbkeccak.Keccak256Hash(data...), nil + return crypto.Keccak256Hash(data...), nil } func (acc *MerkleAccumulator) getPartial(level uint64) (*common.Hash, error) { @@ -131,7 +131,7 @@ func (acc *MerkleAccumulator) Append(itemHash common.Hash) ([]MerkleTreeNodeEven events := []MerkleTreeNodeEvent{} level := uint64(0) - soFar := arbkeccak.Keccak256(itemHash.Bytes()) + soFar := crypto.Keccak256(itemHash.Bytes()) for { if level == CalcNumPartials(size-1) { // -1 to counteract the acc.size++ at top of this function h := common.BytesToHash(soFar) diff --git a/arbos/parse_l2.go b/arbos/parse_l2.go index 09394099e1..776068eb16 100644 --- a/arbos/parse_l2.go +++ b/arbos/parse_l2.go @@ -8,9 +8,9 @@ import ( "math/big" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" @@ -40,8 +40,8 @@ func ParseL2Transactions(msg *arbostypes.L1IncomingMessage, chainId *big.Int, la return nil, errors.New("cannot issue L2 funded by L1 tx without L1 request id") } kind := msg.L2msg[0] - depositRequestId := arbkeccak.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big0)) - unsignedRequestId := arbkeccak.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big1)) + depositRequestId := crypto.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big0)) + unsignedRequestId := crypto.Keccak256Hash(msg.Header.RequestId[:], arbmath.U256Bytes(common.Big1)) tx, err := parseUnsignedTx(bytes.NewReader(msg.L2msg[1:]), msg.Header.Poster, &unsignedRequestId, chainId, kind) if err != nil { return nil, err @@ -146,7 +146,7 @@ func parseL2Message(rd io.Reader, poster common.Address, timestamp uint64, reque var nextRequestId *common.Hash if requestId != nil { - subRequestId := arbkeccak.Keccak256Hash(requestId[:], arbmath.U256Bytes(index)) + subRequestId := crypto.Keccak256Hash(requestId[:], arbmath.U256Bytes(index)) nextRequestId = &subRequestId } nestedSegments, err := parseL2Message(bytes.NewReader(nextMsg), poster, timestamp, nextRequestId, chainId, depth+1) diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index f33bb7978b..03e6f98311 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -9,7 +9,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" @@ -366,7 +367,7 @@ func (retryable *Retryable) MakeTx(chainId *big.Int, nonce uint64, gasFeeCap *bi } func RetryableEscrowAddress(ticketId common.Hash) common.Address { - return common.BytesToAddress(arbkeccak.Keccak256([]byte("retryable escrow"), ticketId.Bytes())) + return common.BytesToAddress(crypto.Keccak256([]byte("retryable escrow"), ticketId.Bytes())) } func RetryableSubmissionFee(calldataLengthInBytes int, l1BaseFee *big.Int) *big.Int { diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index 6cea1184c9..b298a003ae 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -11,7 +11,8 @@ import ( "sync/atomic" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/core/rawdb" @@ -333,7 +334,7 @@ func (s *Storage) Keccak(data ...[]byte) ([]byte, error) { if err := s.burner.Burn(multigas.ResourceKindComputation, cost); err != nil { return nil, err } - return arbkeccak.Keccak256(data...), nil + return crypto.Keccak256(data...), nil } func (s *Storage) KeccakHash(data ...[]byte) (common.Hash, error) { @@ -348,13 +349,13 @@ func (s *Storage) KeccakHash(data ...[]byte) (common.Hash, error) { // note: returned slice is not thread-safe func (s *Storage) cachedKeccak(data ...[]byte) []byte { if s.hashCache == nil { - return arbkeccak.Keccak256(data...) + return crypto.Keccak256(data...) } keyString := string(bytes.Join(data, []byte{})) if hash, wasCached := s.hashCache.Get(keyString); wasCached { return hash } - hash := arbkeccak.Keccak256(data...) + hash := crypto.Keccak256(data...) evicted := s.hashCache.Add(keyString, hash) if evicted && cacheFullLogged.CompareAndSwap(false, true) { log.Warn("Hash cache full, we didn't expect that. Some non-static storage keys may fill up the cache.") diff --git a/arbos/storage/storage_test.go b/arbos/storage/storage_test.go index 78dff5585d..750f257d48 100644 --- a/arbos/storage/storage_test.go +++ b/arbos/storage/storage_test.go @@ -8,9 +8,9 @@ import ( "sync" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/util/arbmath" @@ -106,7 +106,7 @@ func TestOpenCachedSubStorage(t *testing.T) { } var expectedKeys [][]byte for _, subSpaceID := range subSpaceIDs { - expectedKeys = append(expectedKeys, arbkeccak.Keccak256(s.storageKey, subSpaceID)) + expectedKeys = append(expectedKeys, crypto.Keccak256(s.storageKey, subSpaceID)) } n := len(subSpaceIDs) * 50 start := make(chan struct{}) diff --git a/arbutil/hash.go b/arbutil/hash.go index 26bacb78b0..c6e91c8ebf 100644 --- a/arbutil/hash.go +++ b/arbutil/hash.go @@ -3,8 +3,8 @@ package arbutil import ( "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) // PaddedKeccak256 pads each argument to 32 bytes, concatenates and returns @@ -14,7 +14,7 @@ func PaddedKeccak256(args ...[]byte) []byte { for _, arg := range args { data = append(data, common.BytesToHash(arg).Bytes()...) } - return arbkeccak.Keccak256(data) + return crypto.Keccak256(data) } // SumBytes sums two byte slices and returns the result. diff --git a/blsSignatures/blsSignatures.go b/blsSignatures/blsSignatures.go index 3b42c7752c..eba084584f 100644 --- a/blsSignatures/blsSignatures.go +++ b/blsSignatures/blsSignatures.go @@ -9,7 +9,7 @@ import ( "errors" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/bls12381" ) @@ -181,7 +181,7 @@ func VerifyAggregatedSignatureDifferentMessages(sig Signature, messages [][]byte // so that the result will not collide with a result generated in an ordinary signature. func hashToG1Curve(message []byte, keyValidationMode bool) (*bls12381.PointG1, error) { var padding [16]byte - h := arbkeccak.Keccak256(message) + h := crypto.Keccak256(message) if keyValidationMode { // modify padding, for domain separation padding[0] = 1 diff --git a/bold/chain-abstraction/execution_state.go b/bold/chain-abstraction/execution_state.go index 54bb742b1b..07d4c57d25 100644 --- a/bold/chain-abstraction/execution_state.go +++ b/bold/chain-abstraction/execution_state.go @@ -10,8 +10,8 @@ import ( "encoding/binary" "math" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/solgen/go/challengeV2gen" "github.com/offchainlabs/nitro/solgen/go/rollupgen" @@ -51,7 +51,7 @@ func (s GoGlobalState) Hash() common.Hash { data = append(data, s.SendRoot.Bytes()...) data = append(data, u64ToBe(s.Batch)...) data = append(data, u64ToBe(s.PosInBatch)...) - return arbkeccak.Keccak256Hash(data) + return crypto.Keccak256Hash(data) } func (s GoGlobalState) AsSolidityStruct() challengeV2gen.GlobalState { diff --git a/bold/chain-abstraction/interfaces.go b/bold/chain-abstraction/interfaces.go index 032ba5d316..282108dcea 100644 --- a/bold/chain-abstraction/interfaces.go +++ b/bold/chain-abstraction/interfaces.go @@ -12,10 +12,11 @@ import ( "strconv" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" @@ -134,7 +135,7 @@ type AssertionCreatedInfo struct { func (i AssertionCreatedInfo) ExecutionHash() common.Hash { afterGlobalStateHash := GoGlobalStateFromSolidity(i.AfterState.GlobalState).Hash() - return arbkeccak.Keccak256Hash(append([]byte{i.AfterState.MachineStatus}, afterGlobalStateHash.Bytes()...)) + return crypto.Keccak256Hash(append([]byte{i.AfterState.MachineStatus}, afterGlobalStateHash.Bytes()...)) } // AssertionChain can manage assertions in the protocol and retrieve diff --git a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go index 7e1f99b9db..6a5bf94093 100644 --- a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go +++ b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go @@ -11,11 +11,12 @@ import ( "strings" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/metrics" @@ -535,7 +536,7 @@ func calculateMutualId(level uint8, originId [32]byte, startHeight *big.Int, sta return common.Hash{}, err } // Pack stores level(uint8) as 32 bytes, so we need to slice off the first 31 bytes - return arbkeccak.Keccak256Hash(mutualIdByte[31:]), nil + return crypto.Keccak256Hash(mutualIdByte[31:]), nil } // GetEdge gets an edge by its hash. diff --git a/bold/state-commitments/history/history_commitment.go b/bold/state-commitments/history/history_commitment.go index 88229c3c31..5e04180c17 100644 --- a/bold/state-commitments/history/history_commitment.go +++ b/bold/state-commitments/history/history_commitment.go @@ -44,8 +44,8 @@ import ( "fmt" "github.com/ccoveille/go-safecast" + "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/bold/math" @@ -75,7 +75,7 @@ type treePosition struct { type historyCommitter struct { fillers []common.Hash - keccak arbkeccak.KeccakState + keccak crypto.KeccakState cursor treePosition lastLeafProver *lastLeafProver } @@ -83,7 +83,7 @@ type historyCommitter struct { func newCommitter() *historyCommitter { return &historyCommitter{ fillers: make([]common.Hash, 0), - keccak: arbkeccak.NewKeccakState(), + keccak: crypto.NewKeccakState(), } } diff --git a/bold/state-commitments/history/history_commitment_test.go b/bold/state-commitments/history/history_commitment_test.go index 64e878dfd0..11e14c8dec 100644 --- a/bold/state-commitments/history/history_commitment_test.go +++ b/bold/state-commitments/history/history_commitment_test.go @@ -8,9 +8,9 @@ import ( "fmt" "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/bold/state-commitments/legacy" @@ -19,7 +19,7 @@ import ( ) func FuzzHistoryCommitter(f *testing.F) { - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) f.Fuzz(func(t *testing.T, numReal uint64, virtual uint64, limit uint64) { // Set some bounds. numReal = numReal % (1 << 10) @@ -42,7 +42,7 @@ func FuzzHistoryCommitter(f *testing.F) { func BenchmarkPrefixProofGeneration_Legacy(b *testing.B) { for i := 0; i < b.N; i++ { prefixIndex := 13384 - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) hashes := make([]common.Hash, 1<<14) for i := 0; i < len(hashes); i++ { hashes[i] = simpleHash @@ -64,8 +64,8 @@ func BenchmarkPrefixProofGeneration_Legacy(b *testing.B) { func BenchmarkPrefixProofGeneration_Optimized(b *testing.B) { b.StopTimer() - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) - hashes := []common.Hash{arbkeccak.Keccak256Hash(simpleHash[:])} + simpleHash := crypto.Keccak256Hash([]byte("foo")) + hashes := []common.Hash{crypto.Keccak256Hash(simpleHash[:])} prefixIndex := uint64(13384) virtual := uint64(1 << 14) committer := newCommitter() @@ -80,20 +80,20 @@ func TestSimpleHistoryCommitment(t *testing.T) { aLeaf := common.HexToHash("0xA") bLeaf := common.HexToHash("0xB") // Level 0 - aHash := arbkeccak.Keccak256Hash(aLeaf[:]) - bHash := arbkeccak.Keccak256Hash(bLeaf[:]) + aHash := crypto.Keccak256Hash(aLeaf[:]) + bHash := crypto.Keccak256Hash(bLeaf[:]) // Level 1 - abHash := arbkeccak.Keccak256Hash(append(aHash[:], bHash[:]...)) - bzHash := arbkeccak.Keccak256Hash(append(bHash[:], emptyHash[:]...)) - bbHash := arbkeccak.Keccak256Hash(append(bHash[:], bHash[:]...)) + abHash := crypto.Keccak256Hash(append(aHash[:], bHash[:]...)) + bzHash := crypto.Keccak256Hash(append(bHash[:], emptyHash[:]...)) + bbHash := crypto.Keccak256Hash(append(bHash[:], bHash[:]...)) // Level 2 - abbzHash := arbkeccak.Keccak256Hash(append(abHash[:], bzHash[:]...)) - abbbHash := arbkeccak.Keccak256Hash(append(abHash[:], bbHash[:]...)) - ababHash := arbkeccak.Keccak256Hash(append(abHash[:], abHash[:]...)) - bbbbHash := arbkeccak.Keccak256Hash(append(bbHash[:], bbHash[:]...)) + abbzHash := crypto.Keccak256Hash(append(abHash[:], bzHash[:]...)) + abbbHash := crypto.Keccak256Hash(append(abHash[:], bbHash[:]...)) + ababHash := crypto.Keccak256Hash(append(abHash[:], abHash[:]...)) + bbbbHash := crypto.Keccak256Hash(append(bbHash[:], bbHash[:]...)) // Level 3 - ababbbbbHash := arbkeccak.Keccak256Hash(append(ababHash[:], bbbbHash[:]...)) - abababbbHash := arbkeccak.Keccak256Hash(append(ababHash[:], abbbHash[:]...)) + ababbbbbHash := crypto.Keccak256Hash(append(ababHash[:], bbbbHash[:]...)) + abababbbHash := crypto.Keccak256Hash(append(ababHash[:], abbbHash[:]...)) tests := []struct { name string @@ -167,7 +167,7 @@ func TestSimpleHistoryCommitment(t *testing.T) { func TestLegacyVsOptimized(t *testing.T) { t.Parallel() end := uint64(1 << 6) - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) for i := uint64(1); i < end; i++ { limit := nextPowerOf2(i) for j := i; j < limit; j++ { @@ -192,7 +192,7 @@ func TestLegacyVsOptimized(t *testing.T) { func TestLegacyVsOptimizedEdgeCases(t *testing.T) { t.Parallel() - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) tests := []struct { realLength int @@ -233,7 +233,7 @@ func TestLegacyVsOptimizedEdgeCases(t *testing.T) { func TestVirtualSparse(t *testing.T) { t.Parallel() - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) makeLeaves := func(n int) []common.Hash { leaves := make([]common.Hash, n) for i := range leaves { @@ -298,7 +298,7 @@ func TestVirtualSparse(t *testing.T) { func TestMaximumDepthHistoryCommitment(t *testing.T) { t.Parallel() - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) hashedLeaves := []common.Hash{ simpleHash, } @@ -308,7 +308,7 @@ func TestMaximumDepthHistoryCommitment(t *testing.T) { func BenchmarkMaximumDepthHistoryCommitment(b *testing.B) { b.StopTimer() - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) hashedLeaves := []common.Hash{ simpleHash, } @@ -320,7 +320,7 @@ func BenchmarkMaximumDepthHistoryCommitment(b *testing.B) { } func TestInclusionProofEquivalence(t *testing.T) { - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) leaves := []common.Hash{ simpleHash, simpleHash, @@ -335,7 +335,7 @@ func TestInclusionProofEquivalence(t *testing.T) { } func TestHashInto(t *testing.T) { - simpleHash := arbkeccak.Keccak256Hash([]byte("foo")) + simpleHash := crypto.Keccak256Hash([]byte("foo")) leaves := []common.Hash{ simpleHash, simpleHash, @@ -343,7 +343,7 @@ func TestHashInto(t *testing.T) { simpleHash, } comm := newCommitter() - want := arbkeccak.Keccak256Hash(simpleHash[:], simpleHash[:], simpleHash[:], simpleHash[:]) + want := crypto.Keccak256Hash(simpleHash[:], simpleHash[:], simpleHash[:], simpleHash[:]) var got common.Hash comm.hashInto(&got, &leaves[0], &leaves[1], &leaves[2], &leaves[3]) if got != want { diff --git a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go index 11e6f948f8..4f9f01ef59 100644 --- a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go +++ b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go @@ -10,9 +10,9 @@ import ( "runtime" "sync" + "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" @@ -47,9 +47,9 @@ func FullTree(leaves []common.Hash) ([][]common.Hash, error) { nextLayer := make([]common.Hash, (len(prevLayer)+1)/2) for i := 0; i < len(nextLayer); i++ { if 2*i+1 < len(prevLayer) { - nextLayer[i] = arbkeccak.Keccak256Hash(prevLayer[2*i].Bytes(), prevLayer[2*i+1].Bytes()) + nextLayer[i] = crypto.Keccak256Hash(prevLayer[2*i].Bytes(), prevLayer[2*i+1].Bytes()) } else { - nextLayer[i] = arbkeccak.Keccak256Hash(prevLayer[2*i].Bytes(), (common.Hash{}).Bytes()) + nextLayer[i] = crypto.Keccak256Hash(prevLayer[2*i].Bytes(), (common.Hash{}).Bytes()) } } layers[l] = nextLayer @@ -81,7 +81,7 @@ func GenerateInclusionProof(leaves []common.Hash, idx uint64) ([]common.Hash, er go func() { defer waitGroup.Done() for j := start; j < start+batchSize; j++ { - rehashed[j] = arbkeccak.Keccak256Hash(leaves[j].Bytes()) + rehashed[j] = crypto.Keccak256Hash(leaves[j].Bytes()) } }() } @@ -89,7 +89,7 @@ func GenerateInclusionProof(leaves []common.Hash, idx uint64) ([]common.Hash, er go func() { defer waitGroup.Done() for j := start; j < start+batchSize+batchRemainder; j++ { - rehashed[j] = arbkeccak.Keccak256Hash(leaves[j].Bytes()) + rehashed[j] = crypto.Keccak256Hash(leaves[j].Bytes()) } }() waitGroup.Wait() @@ -123,13 +123,13 @@ func CalculateRootFromProof(proof []common.Hash, index uint64, leaf common.Hash) if len(proof) > 256 { return common.Hash{}, ErrProofTooLong } - h := arbkeccak.Keccak256Hash(leaf[:]) + h := crypto.Keccak256Hash(leaf[:]) for i := 0; i < len(proof); i++ { node := proof[i] if index&(1< 0 { kind := preimage[0] - return kind != NodeByte && kind != LeafByte && hash == arbkeccak.Keccak256Hash(preimage) + return kind != NodeByte && kind != LeafByte && hash == crypto.Keccak256Hash(preimage) } return false } diff --git a/daprovider/das/dastree/dastree_test.go b/daprovider/das/dastree/dastree_test.go index 42ce537691..a85f8011da 100644 --- a/daprovider/das/dastree/dastree_test.go +++ b/daprovider/das/dastree/dastree_test.go @@ -8,8 +8,7 @@ import ( "math/rand" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" - + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" @@ -19,7 +18,7 @@ import ( func TestDASTree(t *testing.T) { store := make(map[bytes32][]byte) tests := [][]byte{ - {}, {0x32}, arbkeccak.Keccak256(), + {}, {0x32}, crypto.Keccak256(), make([]byte, BinSize), make([]byte, BinSize+1), make([]byte, 4*BinSize), } for i := 0; i < 64; i++ { @@ -30,7 +29,7 @@ func TestDASTree(t *testing.T) { record := func(key bytes32, value []byte, ty arbutil.PreimageType) { colors.PrintGrey("storing ", key, " ", pretty.PrettyBytes(value)) store[key] = value - if arbkeccak.Keccak256Hash(value) != key { + if crypto.Keccak256Hash(value) != key { Fail(t, "key not the hash of value") } } @@ -39,7 +38,7 @@ func TestDASTree(t *testing.T) { if !ok { Fail(t, "no preimage for key", key) } - if arbkeccak.Keccak256Hash(preimage) != key { + if crypto.Keccak256Hash(preimage) != key { Fail(t, "key not the hash of preimage") } colors.PrintBlue("loading ", key, " ", pretty.PrettyBytes(preimage)) diff --git a/daprovider/das/dasutil/dasutil.go b/daprovider/das/dasutil/dasutil.go index 8675e71dd5..b2c73853c1 100644 --- a/daprovider/das/dasutil/dasutil.go +++ b/daprovider/das/dasutil/dasutil.go @@ -11,8 +11,8 @@ import ( "fmt" "io" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbos/util" @@ -194,7 +194,7 @@ func recoverPayloadFromDasBatchInternal( } switch { - case version == 0 && arbkeccak.Keccak256Hash(preimage) != hash: + case version == 0 && crypto.Keccak256Hash(preimage) != hash: fallthrough case version == 1 && dastree.Hash(preimage) != hash: log.Error( @@ -246,7 +246,7 @@ func recoverPayloadFromDasBatchInternal( if version == 0 { treeLeaf := dastree.FlatHashToTreeLeaf(dataHash) preimageRecorder(dataHash, payload, arbutil.Keccak256PreimageType) - preimageRecorder(arbkeccak.Keccak256Hash(treeLeaf), treeLeaf, arbutil.Keccak256PreimageType) + preimageRecorder(crypto.Keccak256Hash(treeLeaf), treeLeaf, arbutil.Keccak256PreimageType) } else { dastree.RecordHash(preimageRecorder, payload) } diff --git a/daprovider/das/extra_signature_checker_test.go b/daprovider/das/extra_signature_checker_test.go index d481048397..15ebbf081e 100644 --- a/daprovider/das/extra_signature_checker_test.go +++ b/daprovider/das/extra_signature_checker_test.go @@ -10,7 +10,6 @@ import ( "io/ioutil" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/daprovider/das/dasutil" @@ -59,7 +58,7 @@ func TestSimpleSignatureCheck(t *testing.T) { Require(t, err) data := []byte("Hello World") - dataHash := arbkeccak.Keccak256(data) + dataHash := crypto.Keccak256(data) sig, err := crypto.Sign(dataHash, privateKey) Require(t, err) @@ -80,7 +79,7 @@ func TestEvenSimplerSignatureCheck(t *testing.T) { Require(t, err) data := []byte("Hello World") - dataHash := arbkeccak.Keccak256(data) + dataHash := crypto.Keccak256(data) sig, err := crypto.Sign(dataHash, privateKey) Require(t, err) diff --git a/daprovider/data_streaming/signing.go b/daprovider/data_streaming/signing.go index 07404f736d..4cd9bbaeb5 100644 --- a/daprovider/data_streaming/signing.go +++ b/daprovider/data_streaming/signing.go @@ -6,8 +6,7 @@ import ( "encoding/binary" "errors" - "github.com/ethereum/go-ethereum/arbkeccak" - + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/signature" ) @@ -19,7 +18,7 @@ type PayloadSigner struct { func DefaultPayloadSigner(signer signature.DataSignerFunc) *PayloadSigner { return CustomPayloadSigner(func(bytes []byte, extras ...uint64) ([]byte, error) { - return signer(arbkeccak.Keccak256(flattenDataForSigning(bytes, extras...))) + return signer(crypto.Keccak256(flattenDataForSigning(bytes, extras...))) }) } @@ -31,7 +30,7 @@ func CustomPayloadSigner(signingFunc func([]byte, ...uint64) ([]byte, error)) *P func PayloadCommiter() *PayloadSigner { return CustomPayloadSigner(func(bytes []byte, extras ...uint64) ([]byte, error) { - return arbkeccak.Keccak256(flattenDataForSigning(bytes, extras...)), nil + return crypto.Keccak256(flattenDataForSigning(bytes, extras...)), nil }) } @@ -55,7 +54,7 @@ func CustomPayloadVerifier(verifyingFunc func(ctx context.Context, signature []b func PayloadCommitmentVerifier() *PayloadVerifier { return CustomPayloadVerifier(func(ctx context.Context, signature []byte, data []byte, extras ...uint64) error { - expectedCommitment := arbkeccak.Keccak256(flattenDataForSigning(data, extras...)) + expectedCommitment := crypto.Keccak256(flattenDataForSigning(data, extras...)) if bytes.Equal(signature, expectedCommitment) { return nil } else { diff --git a/daprovider/referenceda/reference_reader.go b/daprovider/referenceda/reference_reader.go index 7e09edeeeb..4cec03f08b 100644 --- a/daprovider/referenceda/reference_reader.go +++ b/daprovider/referenceda/reference_reader.go @@ -9,7 +9,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" @@ -103,7 +104,7 @@ func (r *Reader) recoverInternal( // Record the mapping from certificate hash to actual payload data // This is what the replay binary expects: keccak256(certificate) -> payload - certHash := arbkeccak.Keccak256Hash(certBytes) + certHash := crypto.Keccak256Hash(certBytes) preimageRecorder(certHash, payload, arbutil.DACertificatePreimageType) } diff --git a/execution/gethexec/classicMessage.go b/execution/gethexec/classicMessage.go index 6eab3317a1..581f874111 100644 --- a/execution/gethexec/classicMessage.go +++ b/execution/gethexec/classicMessage.go @@ -10,8 +10,8 @@ import ( "math/big" "math/bits" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" ) @@ -32,7 +32,7 @@ type ClassicOutboxMsg struct { } func msgBatchKey(batchNum *big.Int) []byte { - return arbkeccak.Keccak256(append([]byte("msgBatch"), batchNum.Bytes()...)) + return crypto.Keccak256(append([]byte("msgBatch"), batchNum.Bytes()...)) } func (m *ClassicOutboxRetriever) GetMsg(batchNum *big.Int, index uint64) (*ClassicOutboxMsg, error) { diff --git a/execution/gethexec/express_lane_service_test.go b/execution/gethexec/express_lane_service_test.go index 6b03730c0f..eb1e5ed8fe 100644 --- a/execution/gethexec/express_lane_service_test.go +++ b/execution/gethexec/express_lane_service_test.go @@ -16,7 +16,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -968,7 +968,7 @@ func Benchmark_expressLaneService_validateExpressLaneTx(b *testing.B) { } func buildSignature(privateKey *ecdsa.PrivateKey, data []byte) ([]byte, error) { - prefixedData := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(data))), data...)) + prefixedData := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(data))), data...)) signature, err := crypto.Sign(prefixedData, privateKey) if err != nil { return nil, err diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index ba460ed8e2..1a6860ef2d 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -13,7 +13,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" @@ -386,7 +387,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) } if level == 0 { - hash = arbkeccak.Keccak256Hash(hash.Bytes()) + hash = crypto.Keccak256Hash(hash.Bytes()) } place := merkletree.NewLevelAndLeaf(level, leafAdded) @@ -444,7 +445,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) // move to the parent step.Level += 1 step.Leaf |= 1 << (step.Level - 1) - known[step] = arbkeccak.Keccak256Hash(left.Bytes(), right.Bytes()) + known[step] = crypto.Keccak256Hash(left.Bytes(), right.Bytes()) } } @@ -458,13 +459,13 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) } // recover the root and check correctness - recovery := arbkeccak.Keccak256Hash(send.Bytes()) + recovery := crypto.Keccak256Hash(send.Bytes()) recoveryStep := leaf for _, hash := range hashes { if recoveryStep&1 == 0 { - recovery = arbkeccak.Keccak256Hash(recovery.Bytes(), hash.Bytes()) + recovery = crypto.Keccak256Hash(recovery.Bytes(), hash.Bytes()) } else { - recovery = arbkeccak.Keccak256Hash(hash.Bytes(), recovery.Bytes()) + recovery = crypto.Keccak256Hash(hash.Bytes(), recovery.Bytes()) } recoveryStep >>= 1 } @@ -472,7 +473,7 @@ func (n NodeInterface) ConstructOutboxProof(c ctx, evm mech, size, leaf uint64) proof := merkletree.MerkleProof{ RootHash: root, // now resolved - LeafHash: arbkeccak.Keccak256Hash(send.Bytes()), + LeafHash: crypto.Keccak256Hash(send.Bytes()), LeafIndex: leaf, Proof: hashes, } diff --git a/precompiles/ArbAddressTable_test.go b/precompiles/ArbAddressTable_test.go index e24d092217..772e293d8b 100644 --- a/precompiles/ArbAddressTable_test.go +++ b/precompiles/ArbAddressTable_test.go @@ -8,10 +8,10 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" @@ -47,7 +47,7 @@ func TestAddressTable1(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) exists, err := atab.AddressExists(context, evm, addr) Require(t, err) @@ -107,7 +107,7 @@ func TestAddressTableCompressNotInTable(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) // verify that compressing addr produces the 21-byte format res, err := atab.Compress(context, evm, addr) @@ -135,7 +135,7 @@ func TestAddressTableCompressInTable(t *testing.T) { atab := ArbAddressTable{} context := testContext(common.Address{}, evm) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) // Register addr if _, err := atab.Register(context, evm, addr); err != nil { diff --git a/precompiles/ArbAggregator_test.go b/precompiles/ArbAggregator_test.go index 527ca9ece6..dd6a104cd4 100644 --- a/precompiles/ArbAggregator_test.go +++ b/precompiles/ArbAggregator_test.go @@ -7,8 +7,8 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/l1pricing" ) @@ -18,8 +18,8 @@ func TestFeeCollector(t *testing.T) { agg := ArbAggregator{} aggAddr := l1pricing.BatchPosterAddress - collectorAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{1})[:20]) - impostorAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{2})[:20]) + collectorAddr := common.BytesToAddress(crypto.Keccak256([]byte{1})[:20]) + impostorAddr := common.BytesToAddress(crypto.Keccak256([]byte{2})[:20]) aggCtx := testContext(aggAddr, evm) callerCtx := testContext(common.Address{}, evm) @@ -57,7 +57,7 @@ func TestTxBaseFee(t *testing.T) { evm := newMockEVMForTesting() agg := ArbAggregator{} - aggAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{0})[:20]) + aggAddr := common.BytesToAddress(crypto.Keccak256([]byte{0})[:20]) targetFee := big.NewInt(973) aggCtx := testContext(aggAddr, evm) diff --git a/precompiles/ArbGasInfo_test.go b/precompiles/ArbGasInfo_test.go index 721896295b..52d1d8e60d 100644 --- a/precompiles/ArbGasInfo_test.go +++ b/precompiles/ArbGasInfo_test.go @@ -7,10 +7,10 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbosState" @@ -29,7 +29,7 @@ func setupArbGasInfo( *ArbGasInfo, ) { evm := newMockEVMForTesting() - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) @@ -119,7 +119,7 @@ func TestGetPricesInArbGas(t *testing.T) { t.Parallel() evm := newMockEVMForTesting() - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) arbGasInfo := &ArbGasInfo{} callCtx := testContext(caller, evm) diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index 3ce796d85e..b8d89210f6 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,9 +9,9 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/holiman/uint256" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" @@ -28,15 +28,15 @@ import ( func TestArbOwner(t *testing.T) { evm := newMockEVMForTesting() - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) Require(t, state.ChainOwners().Add(caller)) - addr1 := common.BytesToAddress(arbkeccak.Keccak256([]byte{1})[:20]) - addr2 := common.BytesToAddress(arbkeccak.Keccak256([]byte{2})[:20]) - addr3 := common.BytesToAddress(arbkeccak.Keccak256([]byte{3})[:20]) + addr1 := common.BytesToAddress(crypto.Keccak256([]byte{1})[:20]) + addr2 := common.BytesToAddress(crypto.Keccak256([]byte{2})[:20]) + addr3 := common.BytesToAddress(crypto.Keccak256([]byte{3})[:20]) prec := &ArbOwner{} gasInfo := &ArbGasInfo{} @@ -210,7 +210,7 @@ func TestArbOwner(t *testing.T) { func TestArbOwnerSetChainConfig(t *testing.T) { evm := newMockEVMForTestingWithVersionAndRunMode(nil, core.NewMessageGasEstimationContext()) - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) Require(t, err) @@ -245,8 +245,8 @@ func TestArbOwnerSetChainConfig(t *testing.T) { func TestArbInfraFeeAccount(t *testing.T) { version0 := uint64(0) evm := newMockEVMForTestingWithVersion(&version0) - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) - newAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{0})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + newAddr := common.BytesToAddress(crypto.Keccak256([]byte{0})[:20]) callCtx := testContext(caller, evm) prec := &ArbOwner{} _, err := prec.GetInfraFeeAccount(callCtx, evm) diff --git a/precompiles/constraints_test.go b/precompiles/constraints_test.go index c3c489ddd3..759d7f675a 100644 --- a/precompiles/constraints_test.go +++ b/precompiles/constraints_test.go @@ -6,9 +6,9 @@ package precompiles import ( "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -31,7 +31,7 @@ func setupResourceConstraintHandles( t.Helper() evm := newMockEVMForTesting() - caller := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + caller := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) tracer := util.NewTracingInfo(evm, testhelpers.RandomAddress(), types.ArbosAddress, util.TracingDuringEVM) state, err := arbosState.OpenArbosState(evm.StateDB, burn.NewSystemBurner(tracer, false)) require.NoError(t, err) diff --git a/precompiles/precompile.go b/precompiles/precompile.go index f968365c46..ced5889d6b 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -17,7 +17,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -413,7 +414,7 @@ func MakePrecompile(metadata *bind.MetaData, implementer interface{}) (addr, *Pr var topic [32]byte if len(bytes) > 32 { - topic = *(*[32]byte)(arbkeccak.Keccak256(bytes)) + topic = *(*[32]byte)(crypto.Keccak256(bytes)) } else { offset := 32 - len(bytes) copy(topic[offset:], bytes) diff --git a/precompiles/precompile_test.go b/precompiles/precompile_test.go index f3deea9295..61398d4ff1 100644 --- a/precompiles/precompile_test.go +++ b/precompiles/precompile_test.go @@ -8,9 +8,9 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/storage" @@ -35,7 +35,7 @@ func TestEvents(t *testing.T) { } } - zeroHash := arbkeccak.Keccak256Hash([]byte{0x00}) + zeroHash := crypto.Keccak256Hash([]byte{0x00}) falseHash := common.Hash{} var data []byte diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index e692a7850c..677599a557 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -10,9 +10,9 @@ import ( "strings" "sync" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" @@ -255,7 +255,7 @@ func (s *BOLDStateProvider) StatesInBatchRange( } func machineHash(gs validator.GoGlobalState) common.Hash { - return arbkeccak.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) + return crypto.Keccak256Hash([]byte("Machine finished:"), gs.Hash().Bytes()) } func (s *BOLDStateProvider) findGlobalStateFromMessageCountAndBatch(count arbutil.MessageIndex, batchIndex l2stateprovider.Batch) (validator.GoGlobalState, error) { diff --git a/staker/legacy/assertion.go b/staker/legacy/assertion.go index 670f778b44..4253102079 100644 --- a/staker/legacy/assertion.go +++ b/staker/legacy/assertion.go @@ -6,8 +6,8 @@ package legacystaker import ( "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" "github.com/offchainlabs/nitro/util/arbmath" @@ -39,7 +39,7 @@ func HashChallengeState( for _, h := range hashes { hashesBytes = append(hashesBytes, h[:]...) } - return arbkeccak.Keccak256Hash( + return crypto.Keccak256Hash( arbmath.Uint64ToU256Bytes(segmentStart), arbmath.Uint64ToU256Bytes(segmentLength), hashesBytes, diff --git a/staker/legacy/block_challenge_backend.go b/staker/legacy/block_challenge_backend.go index c651fe5252..d4b2f6f3da 100644 --- a/staker/legacy/block_challenge_backend.go +++ b/staker/legacy/block_challenge_backend.go @@ -10,9 +10,9 @@ import ( "math" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution" @@ -184,9 +184,9 @@ func (b *BlockChallengeBackend) GetHashAtStep(_ context.Context, position uint64 if status == StatusFinished { data := []byte("Block state:") data = append(data, gs.Hash().Bytes()...) - return arbkeccak.Keccak256Hash(data), nil + return crypto.Keccak256Hash(data), nil } else if status == StatusTooFar { - return arbkeccak.Keccak256Hash([]byte("Block state, too far:")), nil + return crypto.Keccak256Hash([]byte("Block state, too far:")), nil } else { panic(fmt.Sprintf("Unknown block status: %v", status)) } diff --git a/staker/legacy/l1_validator.go b/staker/legacy/l1_validator.go index 74725f4af5..35e174e4a0 100644 --- a/staker/legacy/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -11,7 +11,8 @@ import ( "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" @@ -530,7 +531,7 @@ func (v *L1Validator) createNewNodeAction( } executionHash := assertion.ExecutionHash() - newNodeHash := arbkeccak.Keccak256Hash(hasSiblingByte[:], lastHash[:], executionHash[:], validatedBatchAcc[:], wasmModuleRoot[:]) + newNodeHash := crypto.Keccak256Hash(hasSiblingByte[:], lastHash[:], executionHash[:], validatedBatchAcc[:], wasmModuleRoot[:]) action := createNodeAction{ assertion: assertion, diff --git a/staker/legacy/rollup_watcher.go b/staker/legacy/rollup_watcher.go index 2710d1218b..0cc2becc07 100644 --- a/staker/legacy/rollup_watcher.go +++ b/staker/legacy/rollup_watcher.go @@ -15,7 +15,8 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" @@ -259,7 +260,7 @@ func (r *RollupWatcher) LookupNodeChildren(ctx context.Context, nodeNum uint64, if i > 0 { lastHashIsSibling[0] = 1 } - lastHash = arbkeccak.Keccak256Hash(lastHashIsSibling[:], lastHash[:], parsedLog.ExecutionHash[:], parsedLog.AfterInboxBatchAcc[:], parsedLog.WasmModuleRoot[:]) + lastHash = crypto.Keccak256Hash(lastHashIsSibling[:], lastHash[:], parsedLog.ExecutionHash[:], parsedLog.AfterInboxBatchAcc[:], parsedLog.WasmModuleRoot[:]) l1BlockProposed, err := arbutil.CorrespondingL1BlockNumber(ctx, r.client, ethLog.BlockNumber) if err != nil { return nil, err diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 9f69568f69..2a8265c792 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -15,7 +15,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" @@ -188,7 +189,7 @@ func dedupOptions(t *testing.T, options []*arbitrum_types.ConditionalOptions) [] for _, opt := range options { data, err := json.Marshal(opt) Require(t, err) - dataHash := arbkeccak.Keccak256Hash(data) + dataHash := crypto.Keccak256Hash(data) _, seen := seenBefore[dataHash] if !seen { result = append(result, opt) diff --git a/system_tests/infra_fee_test.go b/system_tests/infra_fee_test.go index dd3169b4e5..bd52566ca4 100644 --- a/system_tests/infra_fee_test.go +++ b/system_tests/infra_fee_test.go @@ -10,8 +10,8 @@ import ( "context" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" @@ -38,7 +38,7 @@ func TestInfraFee(t *testing.T) { Require(t, err) networkFeeAddr, err := arbownerPublic.GetNetworkFeeAccount(ownerCallOpts) Require(t, err) - infraFeeAddr := common.BytesToAddress(arbkeccak.Keccak256([]byte{3, 2, 6})) + infraFeeAddr := common.BytesToAddress(crypto.Keccak256([]byte{3, 2, 6})) tx, err := arbowner.SetInfraFeeAccount(&ownerTxOpts, infraFeeAddr) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) diff --git a/system_tests/multigas_stylus_program_test.go b/system_tests/multigas_stylus_program_test.go index a6598046e8..1e10c91755 100644 --- a/system_tests/multigas_stylus_program_test.go +++ b/system_tests/multigas_stylus_program_test.go @@ -8,10 +8,11 @@ import ( "math/big" "testing" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/params" @@ -95,7 +96,7 @@ func TestMultigasStylus_AccountAccessHostIOs(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - selector := arbkeccak.Keccak256([]byte(tc.selectorSignature))[:4] + selector := crypto.Keccak256([]byte(tc.selectorSignature))[:4] callData := append([]byte{}, selector...) callData = append(callData, common.LeftPadBytes(target.Bytes(), 32)...) diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 8ff5f0c1ad..639a6b16e1 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -13,7 +13,8 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -247,7 +248,7 @@ func TestOutboxProofs(t *testing.T) { leaf := new(big.Int).SetBytes(position[8:]).Uint64() if level == 0 { - hash = arbkeccak.Keccak256Hash(hash.Bytes()) + hash = crypto.Keccak256Hash(hash.Bytes()) } place := merkletree.LevelAndLeaf{ @@ -321,7 +322,7 @@ func TestOutboxProofs(t *testing.T) { // move to the parent step.Level += 1 step.Leaf |= 1 << (step.Level - 1) - known[step] = arbkeccak.Keccak256Hash(left.Bytes(), right.Bytes()) + known[step] = crypto.Keccak256Hash(left.Bytes(), right.Bytes()) } if known[step] != rootHash { @@ -348,7 +349,7 @@ func TestOutboxProofs(t *testing.T) { proof := merkletree.MerkleProof{ RootHash: rootHash, - LeafHash: arbkeccak.Keccak256Hash(provable.hash.Bytes()), + LeafHash: crypto.Keccak256Hash(provable.hash.Bytes()), LeafIndex: provable.leaf, Proof: hashes, } diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index e3d3736ee0..2d042c8552 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -10,7 +10,8 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -37,7 +38,7 @@ func TestArbAddressTableDoesntRevert(t *testing.T) { arbAddressTable, err := precompilesgen.NewArbAddressTable(types.ArbAddressTableAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) exists, err := arbAddressTable.AddressExists(callOpts, addr) Require(t, err) @@ -128,8 +129,8 @@ func TestArbSysDoesntRevert(t *testing.T) { arbSys, err := precompilesgen.NewArbSys(types.ArbSysAddress, builder.L2.Client) Require(t, err) - addr1 := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) - addr2 := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr1 := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) + addr2 := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) _, err = arbSys.MapL1SenderContractAddressToL2Alias(callOpts, addr1, addr2) Require(t, err) } @@ -181,7 +182,7 @@ func TestArbGasInfoDoesntRevert(t *testing.T) { defer cleanup() callOpts := &bind.CallOpts{Context: ctx} - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) arbGasInfo, err := precompilesgen.NewArbGasInfo(types.ArbGasInfoAddress, builder.L2.Client) Require(t, err) diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index ca2e6fc704..20290b5404 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -13,10 +13,11 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/google/go-cmp/cmp" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" @@ -334,7 +335,7 @@ func TestL1PricingRewardRecipient(t *testing.T) { defer cleanup() ctx := builder.ctx - rewardRecipient := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + rewardRecipient := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) tx, err := arbOwner.SetL1PricingRewardRecipient(&auth, rewardRecipient) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) @@ -1077,7 +1078,7 @@ func TestArbFunctionTable(t *testing.T) { arbFunctionTable, err := precompilesgen.NewArbFunctionTable(types.ArbFunctionTableAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) // should be a noop tx, err := arbFunctionTable.Upload(&auth, []byte{0, 0, 0, 0}) @@ -1253,7 +1254,7 @@ func TestArbAggregatorBatchPosters(t *testing.T) { arbDebug, err := precompilesgen.NewArbDebug(types.ArbDebugAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) // initially should have one batch poster bps, err := arbAggregator.GetBatchPosters(callOpts) @@ -1296,7 +1297,7 @@ func TestArbAggregatorGetPreferredAggregator(t *testing.T) { arbAggregator, err := precompilesgen.NewArbAggregator(types.ArbAggregatorAddress, builder.L2.Client) Require(t, err) - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) prefAgg, isDefault, err := arbAggregator.GetPreferredAggregator(callOpts, addr) Require(t, err) @@ -1332,7 +1333,7 @@ func TestArbDebugOverwriteContractCode(t *testing.T) { Require(t, err) // create EOA to test against - addr := common.BytesToAddress(arbkeccak.Keccak256([]byte{})[:20]) + addr := common.BytesToAddress(crypto.Keccak256([]byte{})[:20]) // test that code is empty code, err := builder.L2.Client.CodeAt(ctx, addr, nil) diff --git a/system_tests/program_ink_test.go b/system_tests/program_ink_test.go index ad4e208d9a..5b70e3f518 100644 --- a/system_tests/program_ink_test.go +++ b/system_tests/program_ink_test.go @@ -9,10 +9,10 @@ import ( "strings" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/arbos/util" @@ -623,7 +623,7 @@ func encodeHostioTestCalldata(t *testing.T, solFunc string, args []any) []byte { // For the functions that are not in the Hostio interface, we encoded them manually func encodeHostioFromSignature(t *testing.T, signature string, args []uint64) []byte { - data := arbkeccak.Keccak256([]byte(signature))[:4] + data := crypto.Keccak256([]byte(signature))[:4] for _, arg := range args { data = append(data, make([]byte, 24)...) // padding data = binary.BigEndian.AppendUint64(data, arg) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 59427036cf..d8f48212fe 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -18,7 +18,7 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/rawdb" @@ -118,7 +118,7 @@ func keccakTest(t *testing.T, jit bool, builderOpts ...func(*NodeBuilder)) { } preimage := []byte("°º¤ø,¸,ø¤°º¤ø,¸,ø¤°º¤ø,¸ nyan nyan ~=[,,_,,]:3 nyan nyan") - correct := arbkeccak.Keccak256Hash(preimage) + correct := crypto.Keccak256Hash(preimage) args := []byte{0x01} // keccak the preimage once args = append(args, preimage...) @@ -986,7 +986,7 @@ func testCreate(t *testing.T, jit bool) { create2Args = append(create2Args, deployCode...) create1Addr := crypto.CreateAddress(createAddr, 1) - create2Addr := crypto.CreateAddress2(createAddr, salt, arbkeccak.Keccak256(deployCode)) + create2Addr := crypto.CreateAddress2(createAddr, salt, crypto.Keccak256(deployCode)) create(create1Args, create1Addr) create(create2Args, create2Addr) @@ -1412,7 +1412,7 @@ func TestStylusPrecompileMethodsSimple(t *testing.T) { _, err = arbWasm.PageRamp(nil) Require(t, err) - codehash := arbkeccak.Keccak256Hash(wasm) + codehash := crypto.Keccak256Hash(wasm) cas, err := arbWasm.CodehashAsmSize(nil, codehash) Require(t, err) if cas == 0 { @@ -1458,7 +1458,7 @@ func TestProgramActivationLogs(t *testing.T) { if log.Program != programAddress { Fatal(t, "unexpected program in activation log: ", log.Program) } - if arbkeccak.Keccak256Hash(wasm) != log.Codehash { + if crypto.Keccak256Hash(wasm) != log.Codehash { Fatal(t, "unexpected codehash in activation log: ", log.Codehash) } } @@ -1553,7 +1553,7 @@ func TestProgramCacheManager(t *testing.T) { // deploy without activating a wasm wasm, _ := readWasmFile(t, rustFile("keccak")) program := deployContract(t, ctx, userAuth, l2client, wasm) - codehash := arbkeccak.Keccak256Hash(wasm) + codehash := crypto.Keccak256Hash(wasm) // try to manage the cache without authorization manager, tx, mock, err := localgen.DeploySimpleCacheManager(&ownerAuth, l2client) diff --git a/system_tests/seqfeed_test.go b/system_tests/seqfeed_test.go index d4a1a25ddd..bf303e54e1 100644 --- a/system_tests/seqfeed_test.go +++ b/system_tests/seqfeed_test.go @@ -11,9 +11,9 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" @@ -520,7 +520,7 @@ func TestRegressionInPopulateFeedBacklog(t *testing.T) { // sub in correct batch hash batchData, _, err := builder.L2.ConsensusNode.InboxReader.GetSequencerMessageBytes(ctx, 0) Require(t, err) - expectedBatchHash := arbkeccak.Keccak256Hash(batchData) + expectedBatchHash := crypto.Keccak256Hash(batchData) copy(data[52:52+32], expectedBatchHash[:]) dummyMessage := arbostypes.MessageWithMetadata{ diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index c4ca556520..dba7a0fb71 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -17,7 +17,8 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" @@ -384,7 +385,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool) managerAddr, err := stakerA.Rollup().ChallengeManager(&bind.CallOpts{Context: ctx}) Require(t, err) // 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103 - proxyAdminSlot := common.BigToHash(arbmath.BigSub(arbkeccak.Keccak256Hash([]byte("eip1967.proxy.admin")).Big(), common.Big1)) + proxyAdminSlot := common.BigToHash(arbmath.BigSub(crypto.Keccak256Hash([]byte("eip1967.proxy.admin")).Big(), common.Big1)) proxyAdminBytes, err := builder.L1.Client.StorageAt(ctx, managerAddr, proxyAdminSlot, nil) Require(t, err) proxyAdminAddr := common.BytesToAddress(proxyAdminBytes) diff --git a/system_tests/stylus_trace_test.go b/system_tests/stylus_trace_test.go index 99badb310a..da05678f55 100644 --- a/system_tests/stylus_trace_test.go +++ b/system_tests/stylus_trace_test.go @@ -13,7 +13,6 @@ import ( "github.com/holiman/uint256" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -139,7 +138,7 @@ func TestStylusOpcodeTraceNativeKeccak(t *testing.T) { args := binary.LittleEndian.AppendUint32(nil, 1) // rounds args = append(args, testhelpers.RandomSlice(123)...) - hash := arbkeccak.Keccak256Hash(args) // the keccak.wat program computes the hash of the whole args + hash := crypto.Keccak256Hash(args) // the keccak.wat program computes the hash of the whole args // native_keccak256 result := sendAndTraceTransaction(t, builder, program, nil, args) @@ -245,7 +244,7 @@ func TestStylusOpcodeTraceEvmData(t *testing.T) { Require(t, err) programCode, err := l2client.CodeAt(ctx, program, nil) Require(t, err) - programCodehash := arbkeccak.Keccak256(programCode) + programCodehash := crypto.Keccak256(programCode) owner := l2info.GetAddress("Owner") // read_args @@ -412,7 +411,7 @@ func TestStylusOpcodeTraceCreate(t *testing.T) { startValue := testhelpers.RandomCallValue(1e5) salt := testhelpers.RandomHash() create1Addr := crypto.CreateAddress(program, 1) - create2Addr := crypto.CreateAddress2(program, salt, arbkeccak.Keccak256(deployCode)) + create2Addr := crypto.CreateAddress2(program, salt, crypto.Keccak256(deployCode)) // create1 create1Args := []byte{0x01} diff --git a/system_tests/test_info.go b/system_tests/test_info.go index a471217bbe..618260dff0 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -12,7 +12,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" @@ -83,7 +83,7 @@ func NewL1TestInfo(t *testing.T) *BlockchainTestInfo { } func GetTestKeyForAccountName(t *testing.T, name string) *ecdsa.PrivateKey { - keyBytes := arbkeccak.Keccak256([]byte(name)) + keyBytes := crypto.Keccak256([]byte(name)) keyBytes[0] = 0 privateKey, err := crypto.ToECDSA(keyBytes) if err != nil { diff --git a/system_tests/timeboost_test.go b/system_tests/timeboost_test.go index 52a9c9679d..5affa795a0 100644 --- a/system_tests/timeboost_test.go +++ b/system_tests/timeboost_test.go @@ -15,10 +15,11 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" @@ -1995,7 +1996,7 @@ func (elc *expressLaneClient) sendExpressLaneRPC(msg *timeboost.JsonExpressLaneS } func signSubmission(message []byte, key *ecdsa.PrivateKey) ([]byte, error) { - prefixed := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(message))), message...)) + prefixed := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(message))), message...)) sig, err := secp256k1.Sign(prefixed, math.PaddedBigBytes(key.D, 32)) if err != nil { return nil, err diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index e50886e892..91c1cd39fc 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/rpc" @@ -117,7 +117,7 @@ func (r *mockExecRun) GetStepAt(position uint64) containers.PromiseInterface[*va resState = r.endState } return containers.NewReadyPromise[*validator.MachineStepResult](&validator.MachineStepResult{ - Hash: arbkeccak.Keccak256Hash(new(big.Int).SetUint64(position).Bytes()), + Hash: crypto.Keccak256Hash(new(big.Int).SetUint64(position).Bytes()), Position: position, Status: status, GlobalState: resState, diff --git a/timeboost/types.go b/timeboost/types.go index 6f3e097888..b8d986f96c 100644 --- a/timeboost/types.go +++ b/timeboost/types.go @@ -9,7 +9,7 @@ import ( "github.com/pkg/errors" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/arbkeccak" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" @@ -65,7 +65,7 @@ func (b *Bid) ToEIP712Hash(domainSeparator [32]byte) (common.Hash, error) { return common.Hash{}, err } - bidHash := arbkeccak.Keccak256Hash( + bidHash := crypto.Keccak256Hash( []byte("\x19\x01"), domainSeparator[:], messageHash, @@ -113,7 +113,7 @@ func (v *ValidatedBid) BigIntHash(domainSeparator [32]byte) *big.Int { bidHash, _ := bid.ToEIP712Hash(domainSeparator) bidder := v.Bidder.Bytes() - return new(big.Int).SetBytes(arbkeccak.Keccak256Hash(bidder, bidHash.Bytes()).Bytes()) + return new(big.Int).SetBytes(crypto.Keccak256Hash(bidder, bidHash.Bytes()).Bytes()) } func (v *ValidatedBid) ToJson() *JsonValidatedBid { @@ -236,7 +236,7 @@ func (els *ExpressLaneSubmission) Sender() (common.Address, error) { return common.Address{}, errors.Wrap(ErrMalformedData, "signature length is not 65") } // Recover the public key. - prefixed := arbkeccak.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(signingMessage))), signingMessage...)) + prefixed := crypto.Keccak256(append([]byte(fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(signingMessage))), signingMessage...)) sigItem := make([]byte, len(els.Signature)) copy(sigItem, els.Signature) // Signature verification expects the last byte of the signature to have 27 subtracted, diff --git a/util/merkletree/merkleAccumulator_test.go b/util/merkletree/merkleAccumulator_test.go index 069b5383db..041317c488 100644 --- a/util/merkletree/merkleAccumulator_test.go +++ b/util/merkletree/merkleAccumulator_test.go @@ -8,8 +8,8 @@ import ( "encoding/binary" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" ) @@ -43,7 +43,7 @@ func TestAccumulator1(t *testing.T) { if mt.Size() != 1 { t.Fatal(mt.Size()) } - if root(t, acc) != arbkeccak.Keccak256Hash(itemHash.Bytes()) { + if root(t, acc) != crypto.Keccak256Hash(itemHash.Bytes()) { Fail(t) } if root(t, acc) != mt.Hash() { @@ -78,9 +78,9 @@ func TestAccumulator3(t *testing.T) { Fail(t) } - expectedHash := arbkeccak.Keccak256( - arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash0.Bytes()), arbkeccak.Keccak256(itemHash1.Bytes())), - arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash2.Bytes()), make([]byte, 32)), + expectedHash := crypto.Keccak256( + crypto.Keccak256(crypto.Keccak256(itemHash0.Bytes()), crypto.Keccak256(itemHash1.Bytes())), + crypto.Keccak256(crypto.Keccak256(itemHash2.Bytes()), make([]byte, 32)), ) if root(t, acc) != common.BytesToHash(expectedHash) { Fail(t) @@ -120,9 +120,9 @@ func TestAccumulator4(t *testing.T) { Fail(t) } - expectedHash := arbkeccak.Keccak256( - arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash0.Bytes()), arbkeccak.Keccak256(itemHash1.Bytes())), - arbkeccak.Keccak256(arbkeccak.Keccak256(itemHash2.Bytes()), arbkeccak.Keccak256(itemHash3.Bytes())), + expectedHash := crypto.Keccak256( + crypto.Keccak256(crypto.Keccak256(itemHash0.Bytes()), crypto.Keccak256(itemHash1.Bytes())), + crypto.Keccak256(crypto.Keccak256(itemHash2.Bytes()), crypto.Keccak256(itemHash3.Bytes())), ) if root(t, acc) != common.BytesToHash(expectedHash) { Fail(t) @@ -168,7 +168,7 @@ func testSerDe(tree MerkleTree, t *testing.T) { func pseudorandomForTesting(x uint64) common.Hash { var buf [8]byte binary.BigEndian.PutUint64(buf[:], x) - return arbkeccak.Keccak256Hash(buf[:]) + return crypto.Keccak256Hash(buf[:]) } func accAppend(t *testing.T, acc *merkleAccumulator.MerkleAccumulator, itemHash common.Hash) { diff --git a/util/merkletree/merkleEventProof_test.go b/util/merkletree/merkleEventProof_test.go index e37c54a8b2..fdcfec6fce 100644 --- a/util/merkletree/merkleEventProof_test.go +++ b/util/merkletree/merkleEventProof_test.go @@ -6,8 +6,8 @@ package merkletree import ( "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/burn" "github.com/offchainlabs/nitro/arbos/merkleAccumulator" @@ -34,7 +34,7 @@ func TestProofForNext(t *testing.T) { if proof == nil { Fail(t, i) } - if proof.LeafHash != arbkeccak.Keccak256Hash(leaf.Bytes()) { + if proof.LeafHash != crypto.Keccak256Hash(leaf.Bytes()) { Fail(t, i) } if !proof.IsCorrect() { @@ -75,7 +75,7 @@ func ProofFromAccumulator(acc *merkleAccumulator.MerkleAccumulator, nextHash com return &MerkleProof{ RootHash: root, - LeafHash: arbkeccak.Keccak256Hash(nextHash.Bytes()), + LeafHash: crypto.Keccak256Hash(nextHash.Bytes()), LeafIndex: size, Proof: partials, }, nil diff --git a/util/merkletree/merkleTree.go b/util/merkletree/merkleTree.go index 89b1dee81b..d0ad45840b 100644 --- a/util/merkletree/merkleTree.go +++ b/util/merkletree/merkleTree.go @@ -8,8 +8,8 @@ import ( "io" "math/big" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/util" ) @@ -67,7 +67,7 @@ func newMerkleLeafFromReader(rd io.Reader) (MerkleTree, error) { } func (leaf *merkleTreeLeaf) Hash() common.Hash { - return arbkeccak.Keccak256Hash(leaf.hash.Bytes()) + return crypto.Keccak256Hash(leaf.hash.Bytes()) } func (leaf *merkleTreeLeaf) Size() uint64 { @@ -149,7 +149,7 @@ type merkleInternal struct { func NewMerkleInternal(left, right MerkleTree) MerkleTree { return &merkleInternal{ - arbkeccak.Keccak256Hash(left.Hash().Bytes(), right.Hash().Bytes()), + crypto.Keccak256Hash(left.Hash().Bytes(), right.Hash().Bytes()), left.Size() + right.Size(), left.Capacity() + right.Capacity(), left, @@ -308,9 +308,9 @@ func (proof *MerkleProof) IsCorrect() bool { for _, hashFromProof := range proof.Proof { if index&1 == 0 { - hash = arbkeccak.Keccak256Hash(hash.Bytes(), hashFromProof.Bytes()) + hash = crypto.Keccak256Hash(hash.Bytes(), hashFromProof.Bytes()) } else { - hash = arbkeccak.Keccak256Hash(hashFromProof.Bytes(), hash.Bytes()) + hash = crypto.Keccak256Hash(hashFromProof.Bytes(), hash.Bytes()) } index = index / 2 } diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 6aec515eb2..1116f0f2e0 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,10 +4,9 @@ import ( "context" "errors" + "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/pflag" - "github.com/ethereum/go-ethereum/arbkeccak" - "github.com/offchainlabs/nitro/util/contracts" ) @@ -69,7 +68,7 @@ func NewSignVerify(config *SignVerifyConfig, signerFunc DataSignerFunc, bpValida } func (v *SignVerify) VerifySignature(ctx context.Context, signature []byte, data ...[]byte) error { - ecdsaErr := v.verifier.verifyClosure(ctx, signature, arbkeccak.Keccak256Hash(data...)) + ecdsaErr := v.verifier.verifyClosure(ctx, signature, crypto.Keccak256Hash(data...)) if ecdsaErr == nil { return nil } @@ -89,5 +88,5 @@ func (v *SignVerify) SignMessage(data ...[]byte) ([]byte, error) { } return nil, errors.New("no private key. cannot sign messages") } - return v.signerFunc(arbkeccak.Keccak256Hash(data...).Bytes()) + return v.signerFunc(crypto.Keccak256Hash(data...).Bytes()) } diff --git a/util/signature/simple_hmac.go b/util/signature/simple_hmac.go index 7472d35570..0363d5b466 100644 --- a/util/signature/simple_hmac.go +++ b/util/signature/simple_hmac.go @@ -8,9 +8,9 @@ import ( "regexp" "strings" + "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/pflag" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" ) @@ -118,13 +118,13 @@ func (h *SimpleHmac) VerifySignature(sig []byte, data ...[]byte) error { return fmt.Errorf("%w: signature must be exactly 32 bytes", ErrSignatureNotVerified) } - expectHmac := arbkeccak.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) + expectHmac := crypto.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) if subtle.ConstantTimeCompare(expectHmac[:], sig) == 1 { return nil } if h.fallbackVerificationKey != nil { - expectHmac = arbkeccak.Keccak256Hash(prependBytes(h.fallbackVerificationKey[:], data...)...) + expectHmac = crypto.Keccak256Hash(prependBytes(h.fallbackVerificationKey[:], data...)...) if subtle.ConstantTimeCompare(expectHmac[:], sig) == 1 { return nil } @@ -136,7 +136,7 @@ func (h *SimpleHmac) VerifySignature(sig []byte, data ...[]byte) error { func (h *SimpleHmac) SignMessage(data ...[]byte) ([]byte, error) { var hmac [32]byte if h.signingKey != nil { - hmac = arbkeccak.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) + hmac = crypto.Keccak256Hash(prependBytes(h.signingKey[:], data...)...) } return hmac[:], nil } diff --git a/util/signature/verifier.go b/util/signature/verifier.go index 793926adf5..9e8a7c96eb 100644 --- a/util/signature/verifier.go +++ b/util/signature/verifier.go @@ -10,7 +10,6 @@ import ( "github.com/spf13/pflag" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -84,7 +83,7 @@ func (v *Verifier) VerifyHash(ctx context.Context, signature []byte, hash common } func (v *Verifier) VerifyData(ctx context.Context, signature []byte, data ...[]byte) error { - return v.verifyClosure(ctx, signature, arbkeccak.Keccak256Hash(data...)) + return v.verifyClosure(ctx, signature, crypto.Keccak256Hash(data...)) } func (v *Verifier) verifyClosure(ctx context.Context, sig []byte, hash common.Hash) error { diff --git a/util/signature/verifier_test.go b/util/signature/verifier_test.go index 70818e89cd..d40d27ed9e 100644 --- a/util/signature/verifier_test.go +++ b/util/signature/verifier_test.go @@ -8,7 +8,6 @@ import ( "errors" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/util/contracts" @@ -30,7 +29,7 @@ func TestVerifier(t *testing.T) { Require(t, err) data := []byte{0, 1, 2, 3, 4, 5, 6, 7} - hash := arbkeccak.Keccak256Hash(data) + hash := crypto.Keccak256Hash(data) signature, err := dataSigner(hash.Bytes()) Require(t, err, "error signing data") @@ -90,7 +89,7 @@ func TestVerifierBatchPoster(t *testing.T) { Require(t, err) data := []byte{0, 1, 2, 3, 4, 5, 6, 7} - hash := arbkeccak.Keccak256Hash(data) + hash := crypto.Keccak256Hash(data) signature, err := dataSigner(hash.Bytes()) Require(t, err, "error signing data") diff --git a/validator/execution_state.go b/validator/execution_state.go index 17ae59e089..0bd94f4d7d 100644 --- a/validator/execution_state.go +++ b/validator/execution_state.go @@ -5,8 +5,8 @@ import ( "fmt" "math" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/solgen/go/challenge_legacy_gen" "github.com/offchainlabs/nitro/solgen/go/rollup_legacy_gen" @@ -52,7 +52,7 @@ func (s GoGlobalState) Hash() common.Hash { data = append(data, s.SendRoot.Bytes()...) data = append(data, u64ToBe(s.Batch)...) data = append(data, u64ToBe(s.PosInBatch)...) - return arbkeccak.Keccak256Hash(data) + return crypto.Keccak256Hash(data) } func (s GoGlobalState) AsLegacySolidityStruct() rollup_legacy_gen.GlobalState { @@ -96,11 +96,11 @@ func (s *ExecutionState) AsLegacySolidityStruct() rollup_legacy_gen.ExecutionSta func (s *ExecutionState) BlockStateHash() common.Hash { if s.MachineStatus == MachineStatusFinished { - return arbkeccak.Keccak256Hash([]byte("Block state:"), s.GlobalState.Hash().Bytes()) + return crypto.Keccak256Hash([]byte("Block state:"), s.GlobalState.Hash().Bytes()) } else if s.MachineStatus == MachineStatusErrored { - return arbkeccak.Keccak256Hash([]byte("Block state, errored:"), s.GlobalState.Hash().Bytes()) + return crypto.Keccak256Hash([]byte("Block state, errored:"), s.GlobalState.Hash().Bytes()) } else if s.MachineStatus == MachineStatusTooFar { - return arbkeccak.Keccak256Hash([]byte("Block state, too far:")) + return crypto.Keccak256Hash([]byte("Block state, too far:")) } else { panic(fmt.Sprintf("invalid machine status %v", s.MachineStatus)) } diff --git a/validator/proofenhancement/proof_enhancer_test.go b/validator/proofenhancement/proof_enhancer_test.go index 09b44aecac..6a55d5a9cd 100644 --- a/validator/proofenhancement/proof_enhancer_test.go +++ b/validator/proofenhancement/proof_enhancer_test.go @@ -6,8 +6,8 @@ import ( "strings" "testing" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" @@ -84,7 +84,7 @@ func createTestCertificate(t *testing.T, data []byte) []byte { cert[0] = daprovider.DACertificateMessageHeaderFlag // Use Keccak256 for data hash - dataHash := arbkeccak.Keccak256(data) + dataHash := crypto.Keccak256(data) copy(cert[1:33], dataHash) // Mock signature values (v, r, s) @@ -100,7 +100,7 @@ func TestCustomDAProofEnhancement(t *testing.T) { // Test data testData := []byte("test custom DA preimage data") testCertificate := createTestCertificate(t, testData) - certHash := arbkeccak.Keccak256Hash(testCertificate) + certHash := crypto.Keccak256Hash(testCertificate) testOffset := uint64(10) // Create sequencer message with 40-byte header + certificate @@ -230,7 +230,7 @@ func TestValidateCertificateProofEnhancement(t *testing.T) { // Test data testData := []byte("test data for certificate validation") testCertificate := createTestCertificate(t, testData) - certHash := arbkeccak.Keccak256Hash(testCertificate) + certHash := crypto.Keccak256Hash(testCertificate) // Create sequencer message with 40-byte header + certificate sequencerMessage := make([]byte, 40+len(testCertificate)) @@ -328,7 +328,7 @@ func TestNewCustomDAProofEnhancer(t *testing.T) { // Test data testData := []byte("test custom DA data") testCertificate := createTestCertificate(t, testData) - certHash := arbkeccak.Keccak256Hash(testCertificate) + certHash := crypto.Keccak256Hash(testCertificate) testOffset := uint64(10) // Create sequencer message @@ -439,7 +439,7 @@ func TestProofEnhancerErrorCases(t *testing.T) { t.Run("CertificateHashMismatch", func(t *testing.T) { testCertificate := createTestCertificate(t, []byte("test data")) - wrongHash := arbkeccak.Keccak256Hash([]byte("wrong data")) + wrongHash := crypto.Keccak256Hash([]byte("wrong data")) sequencerMessage := make([]byte, 40+len(testCertificate)) copy(sequencerMessage[40:], testCertificate) @@ -487,7 +487,7 @@ func TestProofEnhancerErrorCases(t *testing.T) { enhancer := NewReadPreimageProofEnhancer(validator, inboxTracker, inboxReader) enhancerManager.RegisterEnhancer(MarkerCustomDAReadPreimage, enhancer) - certHash := arbkeccak.Keccak256Hash([]byte("test")) + certHash := crypto.Keccak256Hash([]byte("test")) mockProof := make([]byte, 100+32+8+1) mockProof[0] = ProofEnhancementFlag copy(mockProof[100:132], certHash[:]) diff --git a/validator/proofenhancement/readpreimage_proof_enhancer.go b/validator/proofenhancement/readpreimage_proof_enhancer.go index e3bf2ddffb..e8c0020b75 100644 --- a/validator/proofenhancement/readpreimage_proof_enhancer.go +++ b/validator/proofenhancement/readpreimage_proof_enhancer.go @@ -8,8 +8,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" @@ -93,7 +93,7 @@ func (e *ReadPreimageProofEnhancer) EnhanceProof(ctx context.Context, messageNum offset := binary.BigEndian.Uint64(proof[offsetPos:markerPos]) // Verify the certificate hash matches what's in the proof - certHash := arbkeccak.Keccak256Hash(certificate) + certHash := crypto.Keccak256Hash(certificate) if !bytes.Equal(certHash[:], certKeccak256[:]) { return nil, fmt.Errorf("certificate hash mismatch: expected %x, got %x", certKeccak256, certHash) } diff --git a/validator/proofenhancement/validatecertificate_proof_enhancer.go b/validator/proofenhancement/validatecertificate_proof_enhancer.go index 715f7a8707..0b58edf687 100644 --- a/validator/proofenhancement/validatecertificate_proof_enhancer.go +++ b/validator/proofenhancement/validatecertificate_proof_enhancer.go @@ -7,8 +7,8 @@ import ( "encoding/binary" "fmt" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/daprovider" @@ -75,7 +75,7 @@ func (e *ValidateCertificateProofEnhancer) EnhanceProof(ctx context.Context, mes certificate := sequencerMessage[SequencerMessageHeaderSize:] // Verify the certificate hash matches what's requested - actualHash := arbkeccak.Keccak256Hash(certificate) + actualHash := crypto.Keccak256Hash(certificate) if actualHash != common.BytesToHash(certHash[:]) { return nil, fmt.Errorf("certificate hash mismatch: expected %x, got %x", certHash, actualHash) } diff --git a/wavmio/stub.go b/wavmio/stub.go index b0a321de2b..a53bb96b99 100644 --- a/wavmio/stub.go +++ b/wavmio/stub.go @@ -13,8 +13,8 @@ import ( "io" "os" - "github.com/ethereum/go-ethereum/arbkeccak" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/offchainlabs/nitro/arbutil" @@ -70,7 +70,7 @@ func parsePreimageBytes(path string) { if uint64(read) != fieldSize { panic("missing bytes reading data") } - hash := arbkeccak.Keccak256Hash(dataBuf) + hash := crypto.Keccak256Hash(dataBuf) preimages[hash] = dataBuf } } From 5dcb2ffc1b1be398cf8b72f78e2b3bc56a781ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 15:26:09 +0100 Subject: [PATCH 16/21] Lint --- arbnode/delay_buffer.go | 3 +-- arbnode/delayed.go | 3 +-- arbnode/mel/extraction/delayed_message_lookup.go | 3 +-- arbnode/mel/extraction/delayed_message_lookup_test.go | 2 +- arbnode/mel/extraction/message_extraction_function_test.go | 2 +- arbos/retryables/retryable.go | 3 +-- arbos/storage/storage.go | 3 +-- bold/chain-abstraction/interfaces.go | 3 +-- .../sol-implementation/edge_challenge_manager.go | 3 +-- bold/state-commitments/history/history_commitment.go | 2 +- bold/state-commitments/history/history_commitment_test.go | 2 +- bold/state-commitments/inclusion-proofs/inclusion_proofs.go | 2 +- bold/state-commitments/prefix-proofs/merkle_expansions_test.go | 3 ++- bold/state-commitments/prefix-proofs/prefix_proofs.go | 2 +- bold/state-commitments/prefix-proofs/prefix_proofs_test.go | 1 - bold/testing/integration/prefixproofs_test.go | 1 - .../testing/mocks/state-provider/layer2_state_provider_test.go | 2 +- cmd/el-proxy/main.go | 2 +- cmd/mel-replay/delayed_message_db_test.go | 2 +- cmd/mel-replay/receipt_fetcher_test.go | 2 +- daprovider/das/dastree/dastree_test.go | 1 + daprovider/data_streaming/signing.go | 1 + daprovider/referenceda/reference_reader.go | 3 +-- execution/gethexec/express_lane_service_test.go | 1 - execution/nodeInterface/NodeInterface.go | 3 +-- precompiles/ArbOwner_test.go | 2 +- precompiles/constraints_test.go | 2 +- precompiles/precompile.go | 3 +-- staker/legacy/l1_validator.go | 3 +-- staker/legacy/rollup_watcher.go | 3 +-- system_tests/conditionaltx_test.go | 3 +-- system_tests/multigas_stylus_program_test.go | 3 +-- system_tests/outbox_test.go | 3 +-- system_tests/precompile_doesnt_revert_test.go | 3 +-- system_tests/precompile_test.go | 3 +-- system_tests/program_test.go | 1 - system_tests/staker_test.go | 3 +-- system_tests/test_info.go | 1 - system_tests/timeboost_test.go | 3 +-- timeboost/types.go | 1 - util/signature/sign_verify.go | 3 ++- util/signature/simple_hmac.go | 2 +- 42 files changed, 38 insertions(+), 59 deletions(-) diff --git a/arbnode/delay_buffer.go b/arbnode/delay_buffer.go index e2e00eeb67..89b7b71318 100644 --- a/arbnode/delay_buffer.go +++ b/arbnode/delay_buffer.go @@ -12,9 +12,8 @@ import ( "math/big" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/arbostypes" "github.com/offchainlabs/nitro/solgen/go/bridgegen" diff --git a/arbnode/delayed.go b/arbnode/delayed.go index ca9190715e..e76f674644 100644 --- a/arbnode/delayed.go +++ b/arbnode/delayed.go @@ -15,11 +15,10 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/arbnode/mel/extraction/delayed_message_lookup.go b/arbnode/mel/extraction/delayed_message_lookup.go index 93d4829c93..5385fc2121 100644 --- a/arbnode/mel/extraction/delayed_message_lookup.go +++ b/arbnode/mel/extraction/delayed_message_lookup.go @@ -9,10 +9,9 @@ import ( "sort" "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/arbnode/mel/extraction/delayed_message_lookup_test.go b/arbnode/mel/extraction/delayed_message_lookup_test.go index 3d3e422681..19c9f21dc4 100644 --- a/arbnode/mel/extraction/delayed_message_lookup_test.go +++ b/arbnode/mel/extraction/delayed_message_lookup_test.go @@ -6,11 +6,11 @@ import ( "sort" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/trie" "github.com/offchainlabs/nitro/arbnode/mel" diff --git a/arbnode/mel/extraction/message_extraction_function_test.go b/arbnode/mel/extraction/message_extraction_function_test.go index 97ea1fffb7..8bc60ab2e1 100644 --- a/arbnode/mel/extraction/message_extraction_function_test.go +++ b/arbnode/mel/extraction/message_extraction_function_test.go @@ -7,11 +7,11 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbnode/mel" "github.com/offchainlabs/nitro/arbos/arbostypes" diff --git a/arbos/retryables/retryable.go b/arbos/retryables/retryable.go index 03e6f98311..43e344f96f 100644 --- a/arbos/retryables/retryable.go +++ b/arbos/retryables/retryable.go @@ -9,12 +9,11 @@ import ( "math/big" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/storage" "github.com/offchainlabs/nitro/arbos/util" diff --git a/arbos/storage/storage.go b/arbos/storage/storage.go index b298a003ae..d06453b2d1 100644 --- a/arbos/storage/storage.go +++ b/arbos/storage/storage.go @@ -11,14 +11,13 @@ import ( "sync/atomic" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/lru" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/triedb" diff --git a/bold/chain-abstraction/interfaces.go b/bold/chain-abstraction/interfaces.go index 282108dcea..3d06adf724 100644 --- a/bold/chain-abstraction/interfaces.go +++ b/bold/chain-abstraction/interfaces.go @@ -12,13 +12,12 @@ import ( "strconv" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/bold/containers/option" diff --git a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go index 6a5bf94093..487d02bae2 100644 --- a/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go +++ b/bold/chain-abstraction/sol-implementation/edge_challenge_manager.go @@ -11,14 +11,13 @@ import ( "strings" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/metrics" "github.com/offchainlabs/nitro/bold/chain-abstraction" diff --git a/bold/state-commitments/history/history_commitment.go b/bold/state-commitments/history/history_commitment.go index 5e04180c17..305d6585ec 100644 --- a/bold/state-commitments/history/history_commitment.go +++ b/bold/state-commitments/history/history_commitment.go @@ -44,9 +44,9 @@ import ( "fmt" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/bold/math" ) diff --git a/bold/state-commitments/history/history_commitment_test.go b/bold/state-commitments/history/history_commitment_test.go index 11e14c8dec..af03b94c7d 100644 --- a/bold/state-commitments/history/history_commitment_test.go +++ b/bold/state-commitments/history/history_commitment_test.go @@ -8,10 +8,10 @@ import ( "fmt" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/bold/state-commitments/legacy" "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" diff --git a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go index 4f9f01ef59..8864966838 100644 --- a/bold/state-commitments/inclusion-proofs/inclusion_proofs.go +++ b/bold/state-commitments/inclusion-proofs/inclusion_proofs.go @@ -10,10 +10,10 @@ import ( "runtime" "sync" - "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/bold/state-commitments/prefix-proofs" ) diff --git a/bold/state-commitments/prefix-proofs/merkle_expansions_test.go b/bold/state-commitments/prefix-proofs/merkle_expansions_test.go index bbcad9f7d4..25162547fd 100644 --- a/bold/state-commitments/prefix-proofs/merkle_expansions_test.go +++ b/bold/state-commitments/prefix-proofs/merkle_expansions_test.go @@ -7,8 +7,9 @@ package prefixproofs import ( "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" + + "github.com/ethereum/go-ethereum/crypto" ) func TestMerkleExpansion(t *testing.T) { diff --git a/bold/state-commitments/prefix-proofs/prefix_proofs.go b/bold/state-commitments/prefix-proofs/prefix_proofs.go index 78e016db44..2e0d3742c2 100644 --- a/bold/state-commitments/prefix-proofs/prefix_proofs.go +++ b/bold/state-commitments/prefix-proofs/prefix_proofs.go @@ -108,10 +108,10 @@ import ( "math/bits" "github.com/ccoveille/go-safecast" - "github.com/ethereum/go-ethereum/crypto" "github.com/pkg/errors" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) const ( diff --git a/bold/state-commitments/prefix-proofs/prefix_proofs_test.go b/bold/state-commitments/prefix-proofs/prefix_proofs_test.go index 933a6c41af..ce61694188 100644 --- a/bold/state-commitments/prefix-proofs/prefix_proofs_test.go +++ b/bold/state-commitments/prefix-proofs/prefix_proofs_test.go @@ -14,7 +14,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/bold/testing/integration/prefixproofs_test.go b/bold/testing/integration/prefixproofs_test.go index f049f8e23d..a9202ad3af 100644 --- a/bold/testing/integration/prefixproofs_test.go +++ b/bold/testing/integration/prefixproofs_test.go @@ -14,7 +14,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" diff --git a/bold/testing/mocks/state-provider/layer2_state_provider_test.go b/bold/testing/mocks/state-provider/layer2_state_provider_test.go index f3a74af62d..fd2f50b496 100644 --- a/bold/testing/mocks/state-provider/layer2_state_provider_test.go +++ b/bold/testing/mocks/state-provider/layer2_state_provider_test.go @@ -12,10 +12,10 @@ import ( "math" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/bold/chain-abstraction" "github.com/offchainlabs/nitro/bold/layer2-state-provider" diff --git a/cmd/el-proxy/main.go b/cmd/el-proxy/main.go index 1934f92246..116890748a 100644 --- a/cmd/el-proxy/main.go +++ b/cmd/el-proxy/main.go @@ -25,12 +25,12 @@ import ( "syscall" "time" - "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/metrics" diff --git a/cmd/mel-replay/delayed_message_db_test.go b/cmd/mel-replay/delayed_message_db_test.go index 9043a873a5..a0d98cc0a0 100644 --- a/cmd/mel-replay/delayed_message_db_test.go +++ b/cmd/mel-replay/delayed_message_db_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" "github.com/offchainlabs/nitro/arbnode/mel" diff --git a/cmd/mel-replay/receipt_fetcher_test.go b/cmd/mel-replay/receipt_fetcher_test.go index 7987147758..bec77c9ea9 100644 --- a/cmd/mel-replay/receipt_fetcher_test.go +++ b/cmd/mel-replay/receipt_fetcher_test.go @@ -9,11 +9,11 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/trie" "github.com/offchainlabs/nitro/arbutil" diff --git a/daprovider/das/dastree/dastree_test.go b/daprovider/das/dastree/dastree_test.go index a85f8011da..5eed2091e6 100644 --- a/daprovider/das/dastree/dastree_test.go +++ b/daprovider/das/dastree/dastree_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/util/colors" "github.com/offchainlabs/nitro/util/pretty" diff --git a/daprovider/data_streaming/signing.go b/daprovider/data_streaming/signing.go index 4cd9bbaeb5..e67320a6fe 100644 --- a/daprovider/data_streaming/signing.go +++ b/daprovider/data_streaming/signing.go @@ -7,6 +7,7 @@ import ( "errors" "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/util/arbmath" "github.com/offchainlabs/nitro/util/signature" ) diff --git a/daprovider/referenceda/reference_reader.go b/daprovider/referenceda/reference_reader.go index 4cec03f08b..51170634fb 100644 --- a/daprovider/referenceda/reference_reader.go +++ b/daprovider/referenceda/reference_reader.go @@ -9,9 +9,8 @@ import ( "fmt" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" diff --git a/execution/gethexec/express_lane_service_test.go b/execution/gethexec/express_lane_service_test.go index eb1e5ed8fe..6aa8941bd3 100644 --- a/execution/gethexec/express_lane_service_test.go +++ b/execution/gethexec/express_lane_service_test.go @@ -16,7 +16,6 @@ import ( "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" diff --git a/execution/nodeInterface/NodeInterface.go b/execution/nodeInterface/NodeInterface.go index 1a6860ef2d..3169cd9a07 100644 --- a/execution/nodeInterface/NodeInterface.go +++ b/execution/nodeInterface/NodeInterface.go @@ -13,13 +13,12 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" diff --git a/precompiles/ArbOwner_test.go b/precompiles/ArbOwner_test.go index b8d89210f6..c978988a0e 100644 --- a/precompiles/ArbOwner_test.go +++ b/precompiles/ArbOwner_test.go @@ -9,13 +9,13 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/holiman/uint256" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos/arbosState" diff --git a/precompiles/constraints_test.go b/precompiles/constraints_test.go index 759d7f675a..b4ffa83dd3 100644 --- a/precompiles/constraints_test.go +++ b/precompiles/constraints_test.go @@ -6,12 +6,12 @@ package precompiles import ( "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/arbos/burn" diff --git a/precompiles/precompile.go b/precompiles/precompile.go index ced5889d6b..73315a4f15 100644 --- a/precompiles/precompile.go +++ b/precompiles/precompile.go @@ -17,11 +17,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" diff --git a/staker/legacy/l1_validator.go b/staker/legacy/l1_validator.go index 35e174e4a0..176edce94f 100644 --- a/staker/legacy/l1_validator.go +++ b/staker/legacy/l1_validator.go @@ -11,10 +11,9 @@ import ( "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" diff --git a/staker/legacy/rollup_watcher.go b/staker/legacy/rollup_watcher.go index 0cc2becc07..e09f7e9e43 100644 --- a/staker/legacy/rollup_watcher.go +++ b/staker/legacy/rollup_watcher.go @@ -15,10 +15,9 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" diff --git a/system_tests/conditionaltx_test.go b/system_tests/conditionaltx_test.go index 2a8265c792..823ec3a11a 100644 --- a/system_tests/conditionaltx_test.go +++ b/system_tests/conditionaltx_test.go @@ -15,12 +15,11 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/arbitrum" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rpc" "github.com/offchainlabs/nitro/execution/gethexec" diff --git a/system_tests/multigas_stylus_program_test.go b/system_tests/multigas_stylus_program_test.go index 1e10c91755..f6e400f05e 100644 --- a/system_tests/multigas_stylus_program_test.go +++ b/system_tests/multigas_stylus_program_test.go @@ -8,13 +8,12 @@ import ( "math/big" "testing" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/arbitrum/multigas" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/cmd/chaininfo" diff --git a/system_tests/outbox_test.go b/system_tests/outbox_test.go index 639a6b16e1..31495c5b04 100644 --- a/system_tests/outbox_test.go +++ b/system_tests/outbox_test.go @@ -13,11 +13,10 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/gethhook" diff --git a/system_tests/precompile_doesnt_revert_test.go b/system_tests/precompile_doesnt_revert_test.go index 2d042c8552..391b8690c7 100644 --- a/system_tests/precompile_doesnt_revert_test.go +++ b/system_tests/precompile_doesnt_revert_test.go @@ -10,10 +10,9 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/offchainlabs/nitro/arbos/l1pricing" "github.com/offchainlabs/nitro/cmd/chaininfo" diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 20290b5404..35443d7768 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -13,13 +13,12 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/crypto" "github.com/google/go-cmp/cmp" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/params" "github.com/offchainlabs/nitro/arbos" diff --git a/system_tests/program_test.go b/system_tests/program_test.go index d8f48212fe..06cfbb4fd7 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -18,7 +18,6 @@ import ( "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/rawdb" diff --git a/system_tests/staker_test.go b/system_tests/staker_test.go index dba7a0fb71..768d9ac71a 100644 --- a/system_tests/staker_test.go +++ b/system_tests/staker_test.go @@ -17,11 +17,10 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" diff --git a/system_tests/test_info.go b/system_tests/test_info.go index 618260dff0..a600c9bac5 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -12,7 +12,6 @@ import ( "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" diff --git a/system_tests/timeboost_test.go b/system_tests/timeboost_test.go index 5affa795a0..00d13aeade 100644 --- a/system_tests/timeboost_test.go +++ b/system_tests/timeboost_test.go @@ -15,15 +15,14 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto/secp256k1" "github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/log" diff --git a/timeboost/types.go b/timeboost/types.go index b8d986f96c..cabdf94467 100644 --- a/timeboost/types.go +++ b/timeboost/types.go @@ -9,7 +9,6 @@ import ( "github.com/pkg/errors" "github.com/ethereum/go-ethereum/arbitrum_types" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/util/signature/sign_verify.go b/util/signature/sign_verify.go index 1116f0f2e0..81eaf6a57d 100644 --- a/util/signature/sign_verify.go +++ b/util/signature/sign_verify.go @@ -4,9 +4,10 @@ import ( "context" "errors" - "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/pflag" + "github.com/ethereum/go-ethereum/crypto" + "github.com/offchainlabs/nitro/util/contracts" ) diff --git a/util/signature/simple_hmac.go b/util/signature/simple_hmac.go index 0363d5b466..44ec9b6baf 100644 --- a/util/signature/simple_hmac.go +++ b/util/signature/simple_hmac.go @@ -8,10 +8,10 @@ import ( "regexp" "strings" - "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/pflag" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" ) type SimpleHmac struct { From fea45e5e6f376b5cdc49df3bf8adc076c64f9fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Thu, 13 Nov 2025 15:36:47 +0100 Subject: [PATCH 17/21] remove print --- arbitrator/jit/src/arbkeccak.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index 6af68e8aca..7bd8d9ed99 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -11,8 +11,6 @@ pub fn keccak256( ) -> MaybeEscape { let (mut mem, wenv) = src.jit_env(); - eprintln!("HELLO"); - Ok(caller_env::arbkeccak::keccak256( &mut mem, &mut JitExecEnv { wenv }, From 460c6b0caac342f0a51edfbe916b592acfe3ccf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Tue, 18 Nov 2025 13:55:38 +0100 Subject: [PATCH 18/21] minor code adjustment --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 3d6ff7c861..47225f94fb 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 3d6ff7c8616be578273c7acf5fdd11068e852526 +Subproject commit 47225f94fba65b196a91fc1ccdf6e4850397f17b From 395a162a190fb57f991ff6609c29e73f01fd70b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Tue, 18 Nov 2025 14:17:42 +0100 Subject: [PATCH 19/21] minor refactor --- arbitrator/jit/src/arbkeccak.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index 7bd8d9ed99..ae253d5a6b 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -2,7 +2,6 @@ use caller_env::GuestPtr; use crate::caller_env::{JitEnv, JitExecEnv}; use crate::machine::{MaybeEscape, WasmEnvMut}; -#[allow(clippy::too_many_arguments)] pub fn keccak256( mut src: WasmEnvMut, in_buf_ptr: GuestPtr, From 19c740393edb7918a073166d3e27d0e8c7b3a698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Tue, 18 Nov 2025 14:21:45 +0100 Subject: [PATCH 20/21] linter --- arbitrator/jit/src/arbkeccak.rs | 7 ++++--- arbitrator/jit/src/machine.rs | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arbitrator/jit/src/arbkeccak.rs b/arbitrator/jit/src/arbkeccak.rs index ae253d5a6b..3b2daa6320 100644 --- a/arbitrator/jit/src/arbkeccak.rs +++ b/arbitrator/jit/src/arbkeccak.rs @@ -1,6 +1,6 @@ -use caller_env::GuestPtr; use crate::caller_env::{JitEnv, JitExecEnv}; use crate::machine::{MaybeEscape, WasmEnvMut}; +use caller_env::GuestPtr; pub fn keccak256( mut src: WasmEnvMut, @@ -10,11 +10,12 @@ pub fn keccak256( ) -> MaybeEscape { let (mut mem, wenv) = src.jit_env(); - Ok(caller_env::arbkeccak::keccak256( + caller_env::arbkeccak::keccak256( &mut mem, &mut JitExecEnv { wenv }, in_buf_ptr, in_buf_len, out_buf_ptr, - )) + ); + Ok(()) } diff --git a/arbitrator/jit/src/machine.rs b/arbitrator/jit/src/machine.rs index 3d29d99d12..bd46b45ee3 100644 --- a/arbitrator/jit/src/machine.rs +++ b/arbitrator/jit/src/machine.rs @@ -1,7 +1,10 @@ // Copyright 2022-2024, Offchain Labs, Inc. // For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE.md -use crate::{arbcompress, arbkeccak, caller_env::GoRuntimeState, prepare::prepare_env, program, socket, stylus_backend::CothreadHandler, wasip1_stub, wavmio, Opts}; +use crate::{ + arbcompress, arbkeccak, caller_env::GoRuntimeState, prepare::prepare_env, program, socket, + stylus_backend::CothreadHandler, wasip1_stub, wavmio, Opts, +}; use arbutil::{Bytes32, Color, PreimageType}; use eyre::{bail, ErrReport, Result, WrapErr}; use sha3::{Digest, Keccak256}; From 26bc97052e564276217207486ad98421b640472c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Miko=C5=82ajczyk?= Date: Tue, 18 Nov 2025 16:20:50 +0100 Subject: [PATCH 21/21] linter --- arbitrator/caller-env/src/arbkeccak.rs | 2 +- arbitrator/wasm-libraries/arbkeccak/src/lib.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/arbitrator/caller-env/src/arbkeccak.rs b/arbitrator/caller-env/src/arbkeccak.rs index 642dda59e9..2c06dd3371 100644 --- a/arbitrator/caller-env/src/arbkeccak.rs +++ b/arbitrator/caller-env/src/arbkeccak.rs @@ -1,6 +1,6 @@ +use crate::{ExecEnv, GuestPtr, MemAccess}; use core::mem::MaybeUninit; use tiny_keccak::{Hasher, Keccak}; -use crate::{ExecEnv, GuestPtr, MemAccess}; pub fn keccak256( mem: &mut M, diff --git a/arbitrator/wasm-libraries/arbkeccak/src/lib.rs b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs index d521ced49a..552934a689 100644 --- a/arbitrator/wasm-libraries/arbkeccak/src/lib.rs +++ b/arbitrator/wasm-libraries/arbkeccak/src/lib.rs @@ -6,11 +6,16 @@ use caller_env::{self, GuestPtr}; #[no_mangle] -pub unsafe extern "C" fn arbkeccak__keccak256(in_buf_ptr: GuestPtr, in_buf_len: u32, out_buf_ptr: GuestPtr) -{ +pub unsafe extern "C" fn arbkeccak__keccak256( + in_buf_ptr: GuestPtr, + in_buf_len: u32, + out_buf_ptr: GuestPtr, +) { caller_env::arbkeccak::keccak256( &mut caller_env::static_caller::STATIC_MEM, &mut caller_env::static_caller::STATIC_ENV, - in_buf_ptr, in_buf_len, out_buf_ptr + in_buf_ptr, + in_buf_len, + out_buf_ptr, ) }