Skip to content

Commit

Permalink
Merge branch 'master' into missing_chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacolvin0 authored Nov 28, 2023
2 parents 607235b + be94504 commit d44159f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
9 changes: 7 additions & 2 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ type (
account *common.Address
}
resetObjectChange struct {
account *common.Address
prev *stateObject
prevdestruct bool
prevAccount []byte
Expand Down Expand Up @@ -181,7 +180,13 @@ func (ch resetObjectChange) revert(s *StateDB) {
}

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

func (ch selfDestructChange) revert(s *StateDB) {
Expand Down
1 change: 0 additions & 1 deletion core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,6 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
// cache the latest account/storage data.
prevAccount, ok := s.accountsOrigin[prev.address]
s.journal.append(resetObjectChange{
account: &addr,
prev: prev,
prevdestruct: prevdestruct,
prevAccount: s.accounts[prev.addrHash],
Expand Down
2 changes: 2 additions & 0 deletions core/state/statedb_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ func (test *stateTest) verify(root common.Hash, next common.Hash, db *trie.Datab
}

func TestStateChanges(t *testing.T) {
t.Skip("Arbitrum doesn't support some of these operations due to https://github.com/OffchainLabs/go-ethereum/pull/271")

config := &quick.Config{MaxCount: 1000}
err := quick.Check((*stateTest).run, config)
if cerr, ok := err.(*quick.CheckError); ok {
Expand Down
2 changes: 1 addition & 1 deletion core/state_processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestStateProcessorErrors(t *testing.T) {
},
}
blockchain, _ = NewBlockChain(db, nil, nil, gspec, nil, beacon.New(ethash.NewFaker()), vm.Config{}, nil, nil)
tooBigInitCode = [params.MaxInitCodeSize + 1]byte{}
tooBigInitCode = [params.DefaultMaxInitCodeSize + 1]byte{}
)

defer blockchain.Stop()
Expand Down
16 changes: 12 additions & 4 deletions ethdb/pebble/pebble.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,12 @@ func (b *batch) Replay(w ethdb.KeyValueWriter) error {

// pebbleIterator is a wrapper of underlying iterator in storage engine.
// The purpose of this structure is to implement the missing APIs.
//
// The pebble iterator is not thread-safe.
type pebbleIterator struct {
iter *pebble.Iterator
moved bool
iter *pebble.Iterator
moved bool
released bool
}

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

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

// Release releases associated resources. Release should always succeed and can
// be called multiple times without causing error.
func (iter *pebbleIterator) Release() { iter.iter.Close() }
func (iter *pebbleIterator) Release() {
if !iter.released {
iter.iter.Close()
iter.released = true
}
}
6 changes: 3 additions & 3 deletions params/config_arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type ArbitrumChainParams struct {
InitialArbOSVersion uint64
InitialChainOwner common.Address
GenesisBlockNum uint64
MaxCodeSize uint64 `json:"MaxCodeSize,omitempty"` // Maximum bytecode to permit for a contract. 0 value implies params.MaxCodeSize
MaxInitCodeSize uint64 `json:"MaxInitCodeSize,omitempty"` // Maximum initcode to permit in a creation transaction and create instructions. 0 value implies params.MaxInitCodeSize
MaxCodeSize uint64 `json:"MaxCodeSize,omitempty"` // Maximum bytecode to permit for a contract. 0 value implies params.DefaultMaxCodeSize
MaxInitCodeSize uint64 `json:"MaxInitCodeSize,omitempty"` // Maximum initcode to permit in a creation transaction and create instructions. 0 value implies params.DefaultMaxInitCodeSize
}

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

func (c *ChainConfig) MaxCodeSize() uint64 {
if c.ArbitrumChainParams.MaxCodeSize == 0 {
return MaxCodeSize
return DefaultMaxCodeSize
}
return c.ArbitrumChainParams.MaxCodeSize
}
Expand Down
4 changes: 2 additions & 2 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const (
DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have.
InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks.

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

// Precompiled contract gas prices

Expand Down

0 comments on commit d44159f

Please sign in to comment.