Skip to content

Commit

Permalink
Upgrade optimism to v1.9.5 (#316)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop authored Dec 19, 2024
1 parent 7aa7d97 commit d8ecc8c
Show file tree
Hide file tree
Showing 38 changed files with 19,477 additions and 19,902 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ test-all:

.PHONY: e2e
e2e:
$(GO_WRAPPER) test -v ./e2e
mkdir -p $(E2E_ARTIFACTS_PATH)
$(GO_WRAPPER) test -v ./e2e > $(E2E_ARTIFACTS_PATH)/stdout 2> $(E2E_ARTIFACTS_PATH)/stderr

.PHONY: install-golangci-lint
install-golangci-lint:
Expand Down
5 changes: 4 additions & 1 deletion adapters.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
"github.com/ethereum/go-ethereum/common/hexutil"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/polymerdao/monomer/utils"
rolluptypes "github.com/polymerdao/monomer/x/rollup/types"
)

Expand All @@ -28,7 +29,9 @@ func AdaptPayloadTxsToCosmosTxs(ethTxs []hexutil.Bytes) (bfttypes.Txs, error) {
if ethL1AttributesTx.Type() != ethtypes.DepositTxType {
return nil, errors.New("first transaction is not a deposit transaction")
}
l1BlockInfo, err := derive.L1BlockInfoFromBytes(&rollup.Config{}, uint64(time.Now().Unix()), ethL1AttributesTx.Data())
l1BlockInfo, err := derive.L1BlockInfoFromBytes(&rollup.Config{
EcotoneTime: utils.Ptr(uint64(0)), // TODO: this is a hack, but it works for now.
}, uint64(time.Now().Unix()), ethL1AttributesTx.Data())
if err != nil {
return nil, fmt.Errorf("l1 block info from bytes: %v", err)
}
Expand Down
22 changes: 13 additions & 9 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ type Payload struct {
// from the consensus layer that must be included in the block.
InjectedTransactions bfttypes.Txs
// TODO: make the gas limit actually be enforced. Need to translate between cosmos and op gas limit.
GasLimit uint64
Timestamp uint64
NoTxPool bool
GasLimit uint64
Timestamp uint64
NoTxPool bool
ParentBeaconRoot *common.Hash
Coinbase common.Address
}

func (b *Builder) Build(ctx context.Context, payload *Payload) (*monomer.Block, error) {
Expand Down Expand Up @@ -131,11 +133,13 @@ func (b *Builder) Build(ctx context.Context, payload *Payload) (*monomer.Block,
return nil, fmt.Errorf("header by height: %v", err)
}
header := &monomer.Header{
ChainID: b.chainID,
Height: currentHeader.Height + 1,
Time: payload.Timestamp,
ParentHash: currentHeader.Hash,
GasLimit: payload.GasLimit,
ChainID: b.chainID,
Height: currentHeader.Height + 1,
Time: payload.Timestamp,
ParentHash: currentHeader.Hash,
GasLimit: payload.GasLimit,
ParentBeaconRoot: payload.ParentBeaconRoot,
Coinbase: payload.Coinbase,
}

cometHeader := header.ToComet()
Expand All @@ -160,7 +164,7 @@ func (b *Builder) Build(ctx context.Context, payload *Payload) (*monomer.Block,
return nil, fmt.Errorf("commit: %v", err)
}

ethState, err := state.New(currentHeader.StateRoot, b.ethstatedb, nil)
ethState, err := state.New(currentHeader.StateRoot, b.ethstatedb)
if err != nil {
return nil, fmt.Errorf("create ethereum state: %v", err)
}
Expand Down
34 changes: 18 additions & 16 deletions builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,20 @@ func TestBuild(t *testing.T) {

ethStateRoot := gotBlock.Header.StateRoot
header := &monomer.Header{
ChainID: env.g.ChainID,
Height: uint64(postBuildInfo.GetLastBlockHeight()),
Time: payload.Timestamp,
ParentHash: genesisHeader.Header.Hash,
StateRoot: ethStateRoot,
GasLimit: payload.GasLimit,
ChainID: env.g.ChainID,
Height: uint64(postBuildInfo.GetLastBlockHeight()),
Time: payload.Timestamp,
ParentHash: genesisHeader.Header.Hash,
StateRoot: ethStateRoot,
GasLimit: payload.GasLimit,
ParentBeaconRoot: payload.ParentBeaconRoot,
}
wantBlock, err := monomer.MakeBlock(header, bfttypes.ToTxs(allTxs))
require.NoError(t, err)
verifyBlockContent(t, wantBlock, gotBlock, builtBlock)

// Eth state db.
ethState, err := state.New(ethStateRoot, env.ethstatedb, nil)
ethState, err := state.New(ethStateRoot, env.ethstatedb)
require.NoError(t, err)
appHash, err := getAppHashFromEVM(ethState, header)
require.NoError(t, err)
Expand Down Expand Up @@ -244,7 +245,7 @@ func TestRollback(t *testing.T) {
require.NoError(t, env.blockStore.UpdateLabels(block.Header.Hash, block.Header.Hash, block.Header.Hash))

// Eth state db before rollback.
ethState, err := state.New(block.Header.StateRoot, env.ethstatedb, nil)
ethState, err := state.New(block.Header.StateRoot, env.ethstatedb)
require.NoError(t, err)
require.NotEqual(t, ethState.GetStorageRoot(contracts.L2ApplicationStateRootProviderAddr), gethtypes.EmptyRootHash)

Expand All @@ -267,7 +268,7 @@ func TestRollback(t *testing.T) {
// We trust that the other parts of a block store rollback were done as well.

// Eth state db after rollback.
ethState, err = state.New(genesisHeader.StateRoot, env.ethstatedb, nil)
ethState, err = state.New(genesisHeader.StateRoot, env.ethstatedb)
require.NoError(t, err)
require.Equal(t, ethState.GetStorageRoot(contracts.L2ApplicationStateRootProviderAddr), gethtypes.EmptyRootHash)

Expand Down Expand Up @@ -378,12 +379,13 @@ func TestBuildRollupTxs(t *testing.T) {

ethStateRoot := gotBlock.Header.StateRoot
header := monomer.Header{
ChainID: env.g.ChainID,
Height: uint64(postBuildInfo.GetLastBlockHeight()),
Time: payload.Timestamp,
ParentHash: genesisBlock.Header.Hash,
StateRoot: ethStateRoot,
GasLimit: payload.GasLimit,
ChainID: env.g.ChainID,
Height: uint64(postBuildInfo.GetLastBlockHeight()),
Time: payload.Timestamp,
ParentHash: genesisBlock.Header.Hash,
StateRoot: ethStateRoot,
GasLimit: payload.GasLimit,
ParentBeaconRoot: payload.ParentBeaconRoot,
}
wantBlock, err := monomer.MakeBlock(&header, txs)
require.NoError(t, err)
Expand Down Expand Up @@ -416,7 +418,7 @@ func setupTestEnvironment(t *testing.T) testEnvironment {
pool := mempool.New(testutils.NewMemDB(t))
blockStore := testutils.NewLocalMemDB(t)
txStore := txstore.NewTxStore(testutils.NewCometMemDB(t))
ethstatedb := testutils.NewEthStateDB(t)
ethstatedb := state.NewDatabaseForTesting()

app := testapp.NewTest(t, chainID.String())
appState := testapp.MakeGenesisAppState(t, app)
Expand Down
Binary file modified cmd/monogen/testapp.zip
Binary file not shown.
Loading

0 comments on commit d8ecc8c

Please sign in to comment.