Skip to content

Commit

Permalink
Merge branch 'master' into duplicate-getblocknumber
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 authored Nov 21, 2023
2 parents 94867c6 + 1c3f4ad commit ff8746d
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 29 deletions.
4 changes: 2 additions & 2 deletions arbnode/inbox_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,11 @@ func (r *InboxReader) run(ctx context.Context, hadError bool) error {
} else if err != nil {
// Unknown error (database error?)
return err
} else if haveAcc == batch.BeforeInboxAcc {
} else if haveAcc == batch.AfterInboxAcc {
// Skip this batch, as we already have it in the database
sequencerBatches = sequencerBatches[1:]
} else {
// The first batch BeforeInboxAcc matches, but this batch doesn't,
// The first batch AfterInboxAcc matches, but this batch doesn't,
// so we'll successfully reorg it when we hit the addMessages
break
}
Expand Down
21 changes: 15 additions & 6 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -786,8 +786,23 @@ func (n *Node) Start(ctx context.Context) error {
return fmt.Errorf("error starting inbox reader: %w", err)
}
}
// must init broadcast server before trying to sequence anything
if n.BroadcastServer != nil {
err = n.BroadcastServer.Start(ctx)
if err != nil {
return fmt.Errorf("error starting feed broadcast server: %w", err)
}
}
if n.SeqCoordinator != nil {
n.SeqCoordinator.Start(ctx)
} else {
if n.DelayedSequencer != nil {
err := n.DelayedSequencer.ForceSequenceDelayed(ctx)
if err != nil {
return fmt.Errorf("error initially sequencing delayed instructions: %w", err)
}
}
n.Execution.Activate()
}
if n.MaintenanceRunner != nil {
n.MaintenanceRunner.Start(ctx)
Expand Down Expand Up @@ -834,12 +849,6 @@ func (n *Node) Start(ctx context.Context) error {
if n.L1Reader != nil {
n.L1Reader.Start(ctx)
}
if n.BroadcastServer != nil {
err = n.BroadcastServer.Start(ctx)
if err != nil {
return fmt.Errorf("error starting feed broadcast server: %w", err)
}
}
if n.BroadcastClients != nil {
go func() {
if n.InboxReader != nil {
Expand Down
3 changes: 0 additions & 3 deletions arbnode/seq_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,6 @@ func NewSeqCoordinator(
config: config,
signer: signer,
}
if sequencer != nil {
sequencer.Pause()
}
streamer.SetSeqCoordinator(coordinator)
return coordinator, nil
}
Expand Down
4 changes: 3 additions & 1 deletion arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,9 @@ func (s *TransactionStreamer) AddFakeInitMessage() error {
if err != nil {
return fmt.Errorf("failed to serialize chain config: %w", err)
}
msg := append(append(math.U256Bytes(s.chainConfig.ChainID), 0), chainConfigJson...)
// TODO: once we have a safe U256Bytes that does a copy internally, use that instead of doing an explicit copy here
chainIdBytes := math.U256Bytes(new(big.Int).Set(s.chainConfig.ChainID))
msg := append(append(chainIdBytes, 0), chainConfigJson...)
return s.AddMessages(0, false, []arbostypes.MessageWithMetadata{{
Message: &arbostypes.L1IncomingMessage{
Header: &arbostypes.L1IncomingMessageHeader{
Expand Down
1 change: 1 addition & 0 deletions execution/gethexec/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ func NewSequencer(execEngine *ExecutionEngine, l1Reader *headerreader.HeaderRead
containers.NewLruCacheWithOnEvict(config.NonceCacheSize, s.onNonceFailureEvict),
func() time.Duration { return configFetcher().NonceFailureCacheExpiry },
}
s.Pause()
execEngine.EnableReorgSequencing()
return s, nil
}
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 48 files
+2 −2 accounts/keystore/account_cache.go
+14 −5 build/ci.go
+1 −1 build/deb/ethereum/deb.rules
+9 −3 cmd/devp2p/dns_route53.go
+10 −4 cmd/devp2p/nodeset.go
+6 −6 common/types.go
+1 −1 consensus/clique/snapshot.go
+1 −1 consensus/clique/snapshot_test.go
+2 −2 core/blockchain.go
+2 −2 core/rawdb/accessors_chain.go
+3 −5 core/rawdb/chain_iterator_test.go
+7 −2 core/state/journal.go
+2 −2 core/state/snapshot/difflayer.go
+11 −7 core/state/snapshot/iterator_fast.go
+0 −1 core/state/statedb.go
+2 −0 core/state/statedb_fuzz_test.go
+8 −8 core/txpool/blobpool/metrics.go
+1 −1 eth/api_debug_test.go
+2 −2 eth/gasprice/feehistory.go
+3 −3 eth/gasprice/gasprice.go
+8 −8 eth/protocols/snap/sync_test.go
+1 −1 eth/tracers/api_test.go
+1 −1 ethdb/dbtest/testsuite.go
+7 −9 ethdb/leveldb/leveldb.go
+4 −4 go.mod
+8 −8 go.sum
+11 −6 internal/build/env.go
+2 −2 internal/build/gotool.go
+1 −1 internal/ethapi/api_test.go
+8 −2 les/servingqueue.go
+8 −2 les/utils/limiter.go
+4 −4 metrics/writer.go
+1 −1 metrics/writer_test.go
+4 −4 p2p/discover/table_util_test.go
+2 −2 p2p/discover/v4_lookup_test.go
+2 −2 p2p/discover/v5_udp_test.go
+2 −2 p2p/dnsdisc/tree.go
+1 −1 p2p/peer.go
+11 −4 p2p/protocol.go
+1 −1 p2p/server.go
+1 −1 params/version.go
+2 −2 tests/fuzzers/rangeproof/rangeproof-fuzzer.go
+2 −2 tests/fuzzers/stacktrie/trie_fuzzer.go
+2 −2 trie/iterator_test.go
+16 −16 trie/proof_test.go
+3 −3 trie/triedb/pathdb/history.go
+1 −1 trie/triedb/pathdb/testutils.go
+2 −4 trie/trienode/node.go
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/elastic/gosigar v0.14.2 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/ethereum/c-kzg-4844 v0.3.0 // indirect
github.com/ethereum/c-kzg-4844 v0.3.1 // indirect
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 // indirect
github.com/flynn/noise v1.0.0 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect
Expand Down Expand Up @@ -248,7 +248,7 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/samber/lo v1.36.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/urfave/cli/v2 v2.24.1 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down Expand Up @@ -277,8 +277,8 @@ require (
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/text v0.13.0 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw=
github.com/ethereum/c-kzg-4844 v0.3.0 h1:3Y3hD6l5i0dEYsBL50C+Om644kve3pNqoAcvE26o9zI=
github.com/ethereum/c-kzg-4844 v0.3.0/go.mod h1:WI2Nd82DMZAAZI1wV2neKGost9EKjvbpQR9OqE5Qqa8=
github.com/ethereum/c-kzg-4844 v0.3.1 h1:sR65+68+WdnMKxseNWxSJuAv2tsUrihTpVBTfM/U5Zg=
github.com/ethereum/c-kzg-4844 v0.3.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5 h1:BBso6MBKW8ncyZLv37o+KNyy0HrrHgfnOaGQC2qvN+A=
github.com/facebookgo/atomicfile v0.0.0-20151019160806-2de1f203e7d5/go.mod h1:JpoxHjuQauoxiFMl1ie8Xc/7TfLuMZ5eOCONd1sUBHg=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
Expand Down Expand Up @@ -1589,8 +1589,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b h1:u49mjRnygnB34h8OKbnNJFVUtWSKIKb1KukdV8bILUM=
github.com/supranational/blst v0.3.11-0.20230406105308-e9dfc5ee724b/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
Expand Down Expand Up @@ -1798,8 +1798,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU=
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad h1:g0bG7Z4uG+OgH2QDODnjp6ggkk1bJDsINcuWmJN1iJU=
golang.org/x/exp v0.0.0-20230810033253-352e893a4cad/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand All @@ -1824,8 +1824,8 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU=
golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
6 changes: 3 additions & 3 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (b *NodeBuilder) Build(t *testing.T) func() {
} else {
l2 := NewTestClient(b.ctx)
b.L2Info, l2.ConsensusNode, l2.Client =
createTestNode(t, b.ctx, b.L2Info, b.nodeConfig, b.execConfig, b.takeOwnership)
createTestNode(t, b.ctx, b.L2Info, b.nodeConfig, b.execConfig, b.chainConfig, b.takeOwnership)
b.L2 = l2
}
b.L2.ExecNode = getExecNode(t, b.L2.ConsensusNode)
Expand Down Expand Up @@ -801,7 +801,7 @@ func createTestNodeWithL1(
// L2 -Only. Enough for tests that needs no interface to L1
// Requires precompiles.AllowDebugPrecompiles = true
func createTestNode(
t *testing.T, ctx context.Context, l2Info *BlockchainTestInfo, nodeConfig *arbnode.Config, execConfig *gethexec.Config, takeOwnership bool,
t *testing.T, ctx context.Context, l2Info *BlockchainTestInfo, nodeConfig *arbnode.Config, execConfig *gethexec.Config, chainConfig *params.ChainConfig, takeOwnership bool,
) (*BlockchainTestInfo, *arbnode.Node, *ethclient.Client) {
if nodeConfig == nil {
nodeConfig = arbnode.ConfigDefaultL2Test()
Expand All @@ -814,7 +814,7 @@ func createTestNode(

AddDefaultValNode(t, ctx, nodeConfig, true)

l2info, stack, chainDb, arbDb, blockchain := createL2BlockChain(t, l2Info, "", params.ArbitrumDevTestChainConfig(), &execConfig.Caching)
l2info, stack, chainDb, arbDb, blockchain := createL2BlockChain(t, l2Info, "", chainConfig, &execConfig.Caching)

Require(t, execConfig.Validate())
execConfigFetcher := func() *gethexec.Config { return execConfig }
Expand Down
143 changes: 143 additions & 0 deletions system_tests/deployment_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE

package arbtest

import (
"bytes"
"context"
"math/big"
"strings"
"testing"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/params"
)

func testContractDeployment(t *testing.T, ctx context.Context, client *ethclient.Client, contractCode []byte, accountInfo *AccountInfo, expectedEstimateGasError error) {
// First, we need to make the "deploy code" which returns the contractCode to be deployed
deployCode := []byte{
0x7F, // PUSH32
}
// len(contractCode)
deployCode = append(deployCode, math.U256Bytes(big.NewInt(int64(len(contractCode))))...)
var codeOffset byte = 42
deployCode = append(deployCode, []byte{
0x80, // DUP
0x60, codeOffset, // PUSH1 [codeOffset]
0x60, 0x00, // PUSH1 0
0x39, // CODECOPY
0x60, 0x00, // PUSH1 0
0xF3, // RETURN
}...)
if len(deployCode) != int(codeOffset) {
Fatal(t, "computed codeOffset", codeOffset, "incorrectly, should be", len(deployCode))
}
deployCode = append(deployCode, contractCode...)

deploymentGas, err := client.EstimateGas(ctx, ethereum.CallMsg{
Data: deployCode,
})
if expectedEstimateGasError != nil {
if err == nil {
Fatal(t, "missing expected contract deployment error", expectedEstimateGasError)
} else if strings.Contains(err.Error(), expectedEstimateGasError.Error()) {
// success
return
}
// else, fall through to Require, as this error is unexpected
}
Require(t, err)

chainId, err := client.ChainID(ctx)
Require(t, err)
latestHeader, err := client.HeaderByNumber(ctx, nil)
Require(t, err)
nonce, err := client.PendingNonceAt(ctx, accountInfo.Address)
Require(t, err)

tx := types.NewTx(&types.DynamicFeeTx{
ChainID: chainId,
Nonce: nonce,
GasTipCap: common.Big0,
GasFeeCap: latestHeader.BaseFee,
Gas: deploymentGas,
To: nil,
Value: common.Big0,
Data: deployCode,
})
tx, err = types.SignTx(tx, types.LatestSignerForChainID(chainId), accountInfo.PrivateKey)
Require(t, err)

err = client.SendTransaction(ctx, tx)
Require(t, err)
receipt, err := EnsureTxSucceeded(ctx, client, tx)
Require(t, err)

deployedCode, err := client.CodeAt(ctx, receipt.ContractAddress, receipt.BlockNumber)
Require(t, err)
if !bytes.Equal(deployedCode, contractCode) {
Fatal(t, "expected to deploy code of length", len(contractCode), "but got code of length", len(deployedCode))
}

callResult, err := client.CallContract(ctx, ethereum.CallMsg{To: &receipt.ContractAddress}, nil)
Require(t, err)
if len(callResult) > 0 {
Fatal(t, "somehow got a non-empty result from contract of", callResult)
}
}

// Makes a contract which does nothing but takes up a given length
func makeContractOfLength(length int) []byte {
ret := make([]byte, length)
for i := 0; i < length; i++ {
if i%2 == 0 {
ret[i] = 0x58 // PC
} else {
ret[i] = 0x50 // POP
}
}
return ret
}

func TestContractDeployment(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
cleanup := builder.Build(t)
defer cleanup()

account := builder.L2Info.GetInfoWithPrivKey("Faucet")
for _, size := range []int{0, 1, 1000, 20000, params.MaxCodeSize} {
testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(size), account, nil)
}

testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(40000), account, vm.ErrMaxCodeSizeExceeded)
testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(60000), account, core.ErrMaxInitCodeSizeExceeded)
}

func TestExtendedContractDeployment(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

builder := NewNodeBuilder(ctx).DefaultConfig(t, false)
builder.chainConfig.ArbitrumChainParams.MaxCodeSize = params.MaxCodeSize * 3
builder.chainConfig.ArbitrumChainParams.MaxInitCodeSize = params.MaxInitCodeSize * 3
cleanup := builder.Build(t)
defer cleanup()

account := builder.L2Info.GetInfoWithPrivKey("Faucet")
for _, size := range []int{0, 1, 1000, 20000, 30000, 40000, 60000, params.MaxCodeSize * 3} {
testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(size), account, nil)
}

testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(100000), account, vm.ErrMaxCodeSizeExceeded)
testContractDeployment(t, ctx, builder.L2.Client, makeContractOfLength(200000), account, core.ErrMaxInitCodeSizeExceeded)
}
Loading

0 comments on commit ff8746d

Please sign in to comment.