Skip to content

Commit d44159f

Browse files
Merge branch 'master' into missing_chainId
2 parents 607235b + be94504 commit d44159f

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-13
lines changed

core/state/journal.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ type (
9090
account *common.Address
9191
}
9292
resetObjectChange struct {
93-
account *common.Address
9493
prev *stateObject
9594
prevdestruct bool
9695
prevAccount []byte
@@ -181,7 +180,13 @@ func (ch resetObjectChange) revert(s *StateDB) {
181180
}
182181

183182
func (ch resetObjectChange) dirtied() *common.Address {
184-
return ch.account
183+
// Arbitrum: We keep the behavior that existed before go-ethereum v1.12.1 and return nil,
184+
// instead of returning the reset address as upstream go-ethereum v1.12.1 does.
185+
// That's because, unlike for go-ethereum, whether this account is dirty or not is relevant for Arbitrum.
186+
// Arbitrum hooks manipulate the state in some ways that go-ethereum doesn't which cause that relevance,
187+
// e.g. subtracting balance from an account that hasn't been otherwise touched.
188+
// See https://github.com/OffchainLabs/nitro/pull/1976 for details
189+
return nil
185190
}
186191

187192
func (ch selfDestructChange) revert(s *StateDB) {

core/state/statedb.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,6 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
718718
// cache the latest account/storage data.
719719
prevAccount, ok := s.accountsOrigin[prev.address]
720720
s.journal.append(resetObjectChange{
721-
account: &addr,
722721
prev: prev,
723722
prevdestruct: prevdestruct,
724723
prevAccount: s.accounts[prev.addrHash],

core/state/statedb_fuzz_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ func (test *stateTest) verify(root common.Hash, next common.Hash, db *trie.Datab
365365
}
366366

367367
func TestStateChanges(t *testing.T) {
368+
t.Skip("Arbitrum doesn't support some of these operations due to https://github.com/OffchainLabs/go-ethereum/pull/271")
369+
368370
config := &quick.Config{MaxCount: 1000}
369371
err := quick.Check((*stateTest).run, config)
370372
if cerr, ok := err.(*quick.CheckError); ok {

core/state_processor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestStateProcessorErrors(t *testing.T) {
128128
},
129129
}
130130
blockchain, _ = NewBlockChain(db, nil, nil, gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil, nil)
131-
tooBigInitCode = [params.MaxInitCodeSize + 1]byte{}
131+
tooBigInitCode = [params.DefaultMaxInitCodeSize + 1]byte{}
132132
)
133133

134134
defer blockchain.Stop()

ethdb/pebble/pebble.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,12 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {
567567

568568
// pebbleIterator is a wrapper of underlying iterator in storage engine.
569569
// The purpose of this structure is to implement the missing APIs.
570+
//
571+
// The pebble iterator is not thread-safe.
570572
type pebbleIterator struct {
571-
iter *pebble.Iterator
572-
moved bool
573+
iter *pebble.Iterator
574+
moved bool
575+
released bool
573576
}
574577

575578
// NewIterator creates a binary-alphabetical iterator over a subset
@@ -581,7 +584,7 @@ func (d *Database) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
581584
UpperBound: upperBound(prefix),
582585
})
583586
iter.First()
584-
return &pebbleIterator{iter: iter, moved: true}
587+
return &pebbleIterator{iter: iter, moved: true, released: false}
585588
}
586589

587590
// Next moves the iterator to the next key/value pair. It returns whether the
@@ -616,4 +619,9 @@ func (iter *pebbleIterator) Value() []byte {
616619

617620
// Release releases associated resources. Release should always succeed and can
618621
// be called multiple times without causing error.
619-
func (iter *pebbleIterator) Release() { iter.iter.Close() }
622+
func (iter *pebbleIterator) Release() {
623+
if !iter.released {
624+
iter.iter.Close()
625+
iter.released = true
626+
}
627+
}

params/config_arbitrum.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ type ArbitrumChainParams struct {
2929
InitialArbOSVersion uint64
3030
InitialChainOwner common.Address
3131
GenesisBlockNum uint64
32-
MaxCodeSize uint64 `json:"MaxCodeSize,omitempty"` // Maximum bytecode to permit for a contract. 0 value implies params.MaxCodeSize
33-
MaxInitCodeSize uint64 `json:"MaxInitCodeSize,omitempty"` // Maximum initcode to permit in a creation transaction and create instructions. 0 value implies params.MaxInitCodeSize
32+
MaxCodeSize uint64 `json:"MaxCodeSize,omitempty"` // Maximum bytecode to permit for a contract. 0 value implies params.DefaultMaxCodeSize
33+
MaxInitCodeSize uint64 `json:"MaxInitCodeSize,omitempty"` // Maximum initcode to permit in a creation transaction and create instructions. 0 value implies params.DefaultMaxInitCodeSize
3434
}
3535

3636
func (c *ChainConfig) IsArbitrum() bool {
@@ -43,7 +43,7 @@ func (c *ChainConfig) IsArbitrumNitro(num *big.Int) bool {
4343

4444
func (c *ChainConfig) MaxCodeSize() uint64 {
4545
if c.ArbitrumChainParams.MaxCodeSize == 0 {
46-
return MaxCodeSize
46+
return DefaultMaxCodeSize
4747
}
4848
return c.ArbitrumChainParams.MaxCodeSize
4949
}

params/protocol_params.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ const (
124124
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
125125
InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.
126126

127-
MaxCodeSize = 24576 // Maximum bytecode to permit for a contract
128-
MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
127+
DefaultMaxCodeSize = 24576 // Maximum bytecode to permit for a contract
128+
DefaultMaxInitCodeSize = 2 * DefaultMaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions
129129

130130
// Precompiled contract gas prices
131131

0 commit comments

Comments
 (0)