Skip to content

Commit

Permalink
working on nil beacon root error
Browse files Browse the repository at this point in the history
  • Loading branch information
joshklop committed Dec 18, 2024
1 parent 968b142 commit f755661
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 43 deletions.
18 changes: 10 additions & 8 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ 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
}

func (b *Builder) Build(ctx context.Context, payload *Payload) (*monomer.Block, error) {
Expand Down Expand Up @@ -131,11 +132,12 @@ 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,
}

cometHeader := header.ToComet()
Expand Down
26 changes: 14 additions & 12 deletions builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,13 @@ 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)
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
16 changes: 16 additions & 0 deletions e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,28 @@ func Run(
}

//nolint:gosec // We aren't worried about tainted cmd args.
/*
appCmd := setupCmd(exec.CommandContext(ctx,
"dlv",
"exec",
"--headless",
"--listen=127.0.0.1:2345",
"--api-version=2",
filepath.Join(appDirPath, appName+"d"),
"--",
"monomer",
"start",
"--minimum-gas-prices", "0.001wei",
"--monomer.dev-start",
"--log_no_color",
))*/
appCmd := setupCmd(exec.CommandContext(ctx,
filepath.Join(appDirPath, appName+"d"),
"monomer",
"start",
"--minimum-gas-prices", "0.001wei",
"--monomer.dev-start",
"--log_no_color",
))
appCmd.Dir = appDirPath
appCmd.Env = append(os.Environ(), "e2eapp_HOME="+outDir)
Expand Down
8 changes: 6 additions & 2 deletions e2e/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/polymerdao/monomer"
"github.com/polymerdao/monomer/e2e"
"github.com/polymerdao/monomer/testutils"
"github.com/polymerdao/monomer/utils"
rolluptypes "github.com/polymerdao/monomer/x/rollup/types"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -61,7 +62,9 @@ func checkForRollbacks(t *testing.T, stack *e2e.StackConfig) {
// Get the L1 block info from the first tx in the block
ethTxs, err := monomer.AdaptCosmosTxsToEthTxs(eventNewBlock.Block.Txs)
require.NoError(t, err)
l1BlockInfo, err := derive.L1BlockInfoFromBytes(&rollup.Config{}, uint64(eventNewBlock.Block.Time.Unix()), ethTxs[0].Data())
l1BlockInfo, err := derive.L1BlockInfoFromBytes(&rollup.Config{
EcotoneTime: utils.Ptr(uint64(0)), // TODO: hacky
}, uint64(eventNewBlock.Block.Time.Unix()), ethTxs[0].Data())
require.NoError(t, err)

// End the test once a sequencing window has passed.
Expand Down Expand Up @@ -242,6 +245,7 @@ func ethRollupFlow(t *testing.T, stack *e2e.StackConfig) {
// create a withdrawal tx to withdraw the deposited amount from L2 back to L1
withdrawalTx := e2e.NewWithdrawalTx(0, common.Address(userCosmosETHAddress), userETHAddress, withdrawalAmount, new(big.Int).SetUint64(params.TxGas))

t.Logf("FROM TEST: %s", userCosmosAddr)
baseAccount := queryAccount(t, stack, userCosmosAddr)
l2ChainID, err := stack.MonomerClient.ChainID(stack.Ctx)
require.NoError(t, err)
Expand Down Expand Up @@ -623,7 +627,7 @@ func queryAccount(t *testing.T, stack *e2e.StackConfig, address string) *authv1b
require.NoError(t, err)
queryResult, err := stack.L2Client.ABCIQuery(stack.Ctx, authv1beta1.Query_Account_FullMethodName, queryAccountBytes)
require.NoError(t, err)
require.Zero(t, queryResult.Response.Code)
require.Zero(t, queryResult.Response.Code, queryResult.Response.Log)
var accountResponse authv1beta1.QueryAccountResponse
require.NoError(t, protov1.Unmarshal(queryResult.Response.Value, &accountResponse))
var baseAccount authv1beta1.BaseAccount
Expand Down
38 changes: 20 additions & 18 deletions monomer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ func (id ChainID) Big() *big.Int {
}

type Header struct {
ChainID ChainID
Height uint64
Time uint64
ParentHash common.Hash
StateRoot common.Hash
GasLimit uint64
Hash common.Hash
ChainID ChainID
Height uint64
Time uint64
ParentHash common.Hash
StateRoot common.Hash
ParentBeaconRoot *common.Hash
GasLimit uint64
Hash common.Hash
}

func (h *Header) ToComet() *bfttypes.Header {
Expand Down Expand Up @@ -110,17 +111,18 @@ func MakeBlock(h *Header, txs bfttypes.Txs) (*Block, error) {
// Extrinsic properties on the header (like the block hash) need to be set separately by SetHeader.
func (h *Header) ToEth() *ethtypes.Header {
return &ethtypes.Header{
ParentHash: h.ParentHash,
Root: h.StateRoot,
Number: new(big.Int).SetUint64(h.Height),
GasLimit: h.GasLimit,
MixDigest: common.Hash{},
Time: h.Time,
UncleHash: ethtypes.EmptyUncleHash,
ReceiptHash: ethtypes.EmptyReceiptsHash,
BaseFee: common.Big0,
WithdrawalsHash: &ethtypes.EmptyWithdrawalsHash,
Difficulty: common.Big0,
ParentHash: h.ParentHash,
Root: h.StateRoot,
Number: new(big.Int).SetUint64(h.Height),
GasLimit: h.GasLimit,
MixDigest: common.Hash{},
Time: h.Time,
UncleHash: ethtypes.EmptyUncleHash,
ReceiptHash: ethtypes.EmptyReceiptsHash,
BaseFee: common.Big0,
WithdrawalsHash: &ethtypes.EmptyWithdrawalsHash,
Difficulty: common.Big0,
ParentBeaconRoot: h.ParentBeaconRoot,
}
}

Expand Down
2 changes: 1 addition & 1 deletion testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func generateCrossDomainDepositTx(t *testing.T, crossDomainMessageBz []byte) *ge
to := testutils.RandomAddress(rng)
depositTx := &gethtypes.DepositTx{
// L2 aliased L1CrossDomainMessenger proxy address
From: crossdomain.ApplyL1ToL2Alias(common.HexToAddress("0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE")),
From: crossdomain.ApplyL1ToL2Alias(common.HexToAddress("0x3d609De69E066F85C38AC274e3EeC251EcfDeAa1")),
To: &to,
Data: relayMessageBz,
}
Expand Down
4 changes: 2 additions & 2 deletions x/rollup/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ func DefaultParams() Params {
const (
defaultL1FeeRecipient string = "0x000000000000000000000000000000000000dEaD"
// defaultL1CrossDomainMessenger uses the devnet address of the L1 cross domain messenger contract as the default value.
defaultL1CrossDomainMessenger string = "0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE"
defaultL1CrossDomainMessenger string = "0x3d609De69E066F85C38AC274e3EeC251EcfDeAa1"
// defaultL1StandardBridge uses the devnet address of the L1 standard bridge contract as the default value.
defaultL1StandardBridge string = "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1"
defaultL1StandardBridge string = "0x9D34A2610Ea283f6d9AE29f9Cad82e00c4d38507"
defaultMinFeeWithdrawalAmount uint64 = 400_000
defaultFeeWithdrawalGasLimit uint64 = 400_000
)
Expand Down

0 comments on commit f755661

Please sign in to comment.