From 3473ad121a5485e5ff5499da702589e11ce86458 Mon Sep 17 00:00:00 2001 From: Pangsu Date: Wed, 17 Jul 2024 17:21:16 +0900 Subject: [PATCH] feat: set suggested fee recipient for payload attributes --- op-node/rollup/derive/attributes.go | 8 +++++- .../rollup/derive/attributes_queue_test.go | 27 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/op-node/rollup/derive/attributes.go b/op-node/rollup/derive/attributes.go index fce69e197..6df0712c3 100644 --- a/op-node/rollup/derive/attributes.go +++ b/op-node/rollup/derive/attributes.go @@ -10,6 +10,7 @@ import ( "github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-service/eth" + "github.com/kroma-network/kroma/kroma-bindings/predeploys" ) // L1ReceiptsFetcher fetches L1 header info and receipts for the payload attributes derivation (the info tx and deposits) @@ -148,10 +149,15 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex } } + suggestedFeeRecipient := common.Address{} + if ba.rollupCfg.IsKromaMPT(nextL2Time) { + suggestedFeeRecipient = predeploys.ProtocolVaultAddr + } + return ð.PayloadAttributes{ Timestamp: hexutil.Uint64(nextL2Time), PrevRandao: eth.Bytes32(l1Info.MixDigest()), - SuggestedFeeRecipient: common.Address{}, + SuggestedFeeRecipient: suggestedFeeRecipient, Transactions: txs, NoTxPool: true, GasLimit: (*eth.Uint64Quantity)(&sysConfig.GasLimit), diff --git a/op-node/rollup/derive/attributes_queue_test.go b/op-node/rollup/derive/attributes_queue_test.go index cd421fff1..45bf49dbb 100644 --- a/op-node/rollup/derive/attributes_queue_test.go +++ b/op-node/rollup/derive/attributes_queue_test.go @@ -11,6 +11,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum-optimism/optimism/kroma-bindings/predeploys" "github.com/ethereum-optimism/optimism/op-node/rollup" "github.com/ethereum-optimism/optimism/op-service/eth" "github.com/ethereum-optimism/optimism/op-service/testlog" @@ -59,11 +60,7 @@ func TestAttributesQueue(t *testing.T) { ValidatorRewardScalar: [32]byte{}, } - rollupCfg := rollup.Config{} - l1InfoTx, err := L1InfoDepositBytes(&rollupCfg, expectedL1Cfg, safeHead.SequenceNumber+1, l1Info, 0) - require.NoError(t, err) - - testAttributes := func(l1InfoTx []byte) { + testAttributes := func(l1InfoTx []byte, suggestedFeeRecipient common.Address) { l1Fetcher := &testutils.MockL1Source{} defer l1Fetcher.AssertExpectations(t) l1Fetcher.ExpectInfoByHash(l1Info.InfoHash, l1Info, nil) @@ -73,7 +70,7 @@ func TestAttributesQueue(t *testing.T) { attrs := eth.PayloadAttributes{ Timestamp: eth.Uint64Quantity(safeHead.Time + cfg.BlockTime), PrevRandao: eth.Bytes32(l1Info.InfoMixDigest), - SuggestedFeeRecipient: common.Address{}, + SuggestedFeeRecipient: suggestedFeeRecipient, Transactions: []eth.Data{l1InfoTx, eth.Data("foobar"), eth.Data("example")}, NoTxPool: true, GasLimit: (*eth.Uint64Quantity)(&expectedL1Cfg.GasLimit), @@ -89,13 +86,23 @@ func TestAttributesQueue(t *testing.T) { } t.Run("before kroma mpt time", func(st *testing.T) { - testAttributes(l1InfoTx) + rollupCfg := rollup.Config{} + l1InfoTx, err := L1InfoDepositBytes(&rollupCfg, expectedL1Cfg, safeHead.SequenceNumber+1, l1Info, 0) + require.NoError(t, err) + + l1InfoTx, err = ToKromaDepositBytes(l1InfoTx) + require.NoError(st, err) + testAttributes(l1InfoTx, common.Address{}) }) t.Run("after kroma mpt time", func(st *testing.T) { zero := uint64(0) - rollupCfg.KromaMPTTime = &zero - - testAttributes(l1InfoTx) + cfg.KromaMPTTime = &zero + rollupCfg := rollup.Config{ + KromaMPTTime: &zero, + } + l1InfoTx, err := L1InfoDepositBytes(&rollupCfg, expectedL1Cfg, safeHead.SequenceNumber+1, l1Info, 0) + require.NoError(t, err) + testAttributes(l1InfoTx, predeploys.ProtocolVaultAddr) }) }