Skip to content

Commit

Permalink
feat: set suggested fee recipient for payload attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangssu committed Nov 9, 2024
1 parent 7e8fc98 commit 3473ad1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 7 additions & 1 deletion op-node/rollup/derive/attributes.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"
"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)
Expand Down Expand Up @@ -148,10 +149,15 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex
}
}

suggestedFeeRecipient := common.Address{}
if ba.rollupCfg.IsKromaMPT(nextL2Time) {
suggestedFeeRecipient = predeploys.ProtocolVaultAddr
}

return &eth.PayloadAttributes{
Timestamp: hexutil.Uint64(nextL2Time),
PrevRandao: eth.Bytes32(l1Info.MixDigest()),
SuggestedFeeRecipient: common.Address{},
SuggestedFeeRecipient: suggestedFeeRecipient,
Transactions: txs,
NoTxPool: true,
GasLimit: (*eth.Uint64Quantity)(&sysConfig.GasLimit),
Expand Down
27 changes: 17 additions & 10 deletions op-node/rollup/derive/attributes_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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),
Expand All @@ -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)
})
}

0 comments on commit 3473ad1

Please sign in to comment.