Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: separate DepositTx and set suggested fee recipient #391

Merged
merged 5 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ require (

replace github.com/ethereum-optimism/optimism v1.7.2 => ./

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/kroma-network/go-ethereum v1.101308.3-0.20241129080356-056a5b4d3639
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/kroma-network/go-ethereum v1.101308.3-0.20241205054106-fd7e291968d6
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,8 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kroma-network/go-ethereum v1.101308.3-0.20241129080356-056a5b4d3639 h1:e4mSqeGxCFsRjxUf24HhdZwWAjM1Uu+Uw6A2cN3wYz0=
github.com/kroma-network/go-ethereum v1.101308.3-0.20241129080356-056a5b4d3639/go.mod h1:ZG4M8oph2j0C+R6CtUXuHeeUk5TuN5hVyl9gfwZawJg=
github.com/kroma-network/go-ethereum v1.101308.3-0.20241205054106-fd7e291968d6 h1:psD31rxeK1/94Uu3G1BpUlOYCOFzCtC4qGxqytfMWWo=
github.com/kroma-network/go-ethereum v1.101308.3-0.20241205054106-fd7e291968d6/go.mod h1:ZG4M8oph2j0C+R6CtUXuHeeUk5TuN5hVyl9gfwZawJg=
github.com/kroma-network/zktrie v0.5.1-0.20230420142222-950ce7a8ce84 h1:VpLCQx+tFV6Nk0hbs3Noyxma/q9wIDdyacKpGQWUMI8=
github.com/kroma-network/zktrie v0.5.1-0.20230420142222-950ce7a8ce84/go.mod h1:w54LrYo5rJEV503BgMPRNONsLTOEQv5V87q+uYaw9sM=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
Expand Down
9 changes: 9 additions & 0 deletions op-e2e/actions/ecotone_fork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ func TestEcotoneNetworkUpgradeTransactions(gt *testing.T) {
// See [derive.EcotoneNetworkUpgradeTransactions]
require.Equal(t, 7, len(transactions))

// [Kroma: START] Use KromaDepositTx instead of DepositTx
for i, otx := range transactions {
if otx.Type() == types.DepositTxType {
transactions[i], err = otx.ToKromaDepositTx()
require.NoError(t, err)
}
}
// [Kroma: END]

l1Info, err := derive.L1BlockInfoFromBytes(sd.RollupCfg, latestBlock.Time(), transactions[0].Data())
require.NoError(t, err)
require.Equal(t, derive.L1InfoBedrockLen, len(transactions[0].Data()))
Expand Down
8 changes: 4 additions & 4 deletions op-e2e/actions/l2_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"math/big"
"testing"

"github.com/ethereum-optimism/optimism/op-service/client/l2/engineapi"
"github.com/ethereum-optimism/optimism/op-service/client/l2/engineapi/test"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/beacon"
"github.com/ethereum/go-ethereum/consensus/ethash"
Expand All @@ -20,6 +18,8 @@ import (
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-service/client/l2/engineapi"
"github.com/ethereum-optimism/optimism/op-service/client/l2/engineapi/test"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/sources"
"github.com/ethereum-optimism/optimism/op-service/testlog"
Expand All @@ -46,7 +46,7 @@ func TestL2EngineAPI(gt *testing.T) {
chainA, _ := core.GenerateChain(sd.L2Cfg.Config, genesisBlock, consensus, db, 1, func(i int, gen *core.BlockGen) {
gen.SetCoinbase(common.Address{'A'})
})
payloadA, err := eth.BlockAsPayload(chainA[0], sd.RollupCfg.CanyonTime)
payloadA, err := eth.BlockAsPayload(chainA[0], sd.RollupCfg.CanyonTime, sd.RollupCfg.KromaMPTTime)
require.NoError(t, err)

// apply the payload
Expand All @@ -69,7 +69,7 @@ func TestL2EngineAPI(gt *testing.T) {
chainB, _ := core.GenerateChain(sd.L2Cfg.Config, genesisBlock, consensus, db, 1, func(i int, gen *core.BlockGen) {
gen.SetCoinbase(common.Address{'B'})
})
payloadB, err := eth.BlockAsPayload(chainB[0], sd.RollupCfg.CanyonTime)
payloadB, err := eth.BlockAsPayload(chainB[0], sd.RollupCfg.CanyonTime, sd.RollupCfg.KromaMPTTime)
require.NoError(t, err)

// apply the payload
Expand Down
21 changes: 21 additions & 0 deletions op-e2e/actions/l2_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,34 @@ func (s *L2Verifier) ActL2PipelineFull(t Testing) {
// ActL2UnsafeGossipReceive creates an action that can receive an unsafe execution payload, like gossipsub
func (s *L2Verifier) ActL2UnsafeGossipReceive(payload *eth.ExecutionPayloadEnvelope) Action {
return func(t Testing) {
// [Kroma: START] Use KromaDepositTx instead of DepositTx
for i, otx := range payload.ExecutionPayload.Transactions {
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
if otx[0] != types.DepositTxType {
continue
}
var err error
txBytes, err := derive.ToKromaDepositBytes(otx)
require.NoError(t, err)
payload.ExecutionPayload.Transactions[i] = txBytes
}
// [Kroma: END]
s.derivation.AddUnsafePayload(payload)
}
}

// ActL2InsertUnsafePayload creates an action that can insert an unsafe execution payload
func (s *L2Verifier) ActL2InsertUnsafePayload(payload *eth.ExecutionPayloadEnvelope) Action {
return func(t Testing) {
// [Kroma: START] Use KromaDepositTx instead of DepositTx
for i, otx := range payload.ExecutionPayload.Transactions {
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
if otx[0] != types.DepositTxType {
continue
}
var err error
payload.ExecutionPayload.Transactions[i], err = derive.ToKromaDepositBytes(otx)
require.NoError(t, err)
}
// [Kroma: END]
ref, err := derive.PayloadToBlockRef(s.rollupCfg, payload.ExecutionPayload)
require.NoError(t, err)
err = s.engine.InsertUnsafePayload(t.Ctx(), payload, ref)
Expand Down
12 changes: 12 additions & 0 deletions op-e2e/actions/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,18 @@ func (s *CrossLayerUser) CheckDepositTx(t Testing, l1TxHash common.Hash, index i
reconstructedDep, err := derive.UnmarshalDepositLogEvent(depositReceipt.Logs[index])
require.NoError(t, err, "Could not reconstruct L2 Deposit")
l2Tx := types.NewTx(reconstructedDep)
// [Kroma: START] Use KromaDepositTx instead of DepositTx
// If a receipt cannot be found using the DepositTx hash, it is converted to a KromaDepositTx.
_, err = s.L2.env.EthCl.TransactionReceipt(t.Ctx(), l2Tx.Hash())
if err != nil {
if errors.Is(err, ethereum.NotFound) {
l2Tx, err = l2Tx.ToKromaDepositTx()
require.NoError(t, err, "failed to convert DepositTx to KromaDepositTx")
} else {
require.Fail(t, "failed to get deposit tx with reconstructed tx hash", err)
}
}
// [Kroma: END]
s.L2.CheckReceipt(t, l2Success, l2Tx.Hash())
}
}
Expand Down
6 changes: 5 additions & 1 deletion op-e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func TestERC20BridgeDeposits(t *testing.T) {

depositTx, err := derive.UnmarshalDepositLogEvent(&depositEvent.Raw)
require.NoError(t, err)
_, err = wait.ForReceiptOK(context.Background(), l2Client, types.NewTx(depositTx).Hash())
// [Kroma: START] Use KromaDepositTx instead of DepositTx
kromaDepTx, err := types.NewTx(depositTx).ToKromaDepositTx()
require.NoError(t, err)
_, err = wait.ForReceiptOK(context.Background(), l2Client, kromaDepTx.Hash())
// [Kroma: END]
require.NoError(t, err)

// Ensure that the deposit went through
Expand Down
16 changes: 15 additions & 1 deletion op-e2e/op_geth.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
l2Client, err := ethclient.Dial(selectEndpoint(node))
require.Nil(t, err)

genesisPayload, err := eth.BlockAsPayload(l2GenesisBlock, cfg.DeployConfig.CanyonTime(l2GenesisBlock.Time()))
genesisPayload, err := eth.BlockAsPayload(l2GenesisBlock, cfg.DeployConfig.CanyonTime(l2GenesisBlock.Time()), cfg.DeployConfig.KromaMPTTime(l2GenesisBlock.Time()))

require.Nil(t, err)
return &OpGeth{
Expand Down Expand Up @@ -220,6 +220,20 @@ func (d *OpGeth) CreatePayloadAttributes(txs ...*types.Transaction) (*eth.Payloa
txBytes = append(txBytes, bin)
}

// [Kroma: START] Use KromaDepositTx instead of DepositTx
if d.L2ChainConfig.IsPreKromaMPT(uint64(timestamp)) {
for i := range txBytes {
if txBytes[i][0] == types.DepositTxType {
bin, err := derive.ToKromaDepositBytes(txBytes[i])
if err != nil {
return nil, fmt.Errorf("failed to convert DepositTx to KromaDepositTx: %w", err)
}
txBytes[i] = bin
}
}
}
// [Kroma: END]

var withdrawals *types.Withdrawals
if d.L2ChainConfig.IsCanyon(uint64(timestamp)) {
withdrawals = &types.Withdrawals{}
Expand Down
Loading