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: change predeploy contract addresses #398

Merged
merged 14 commits into from
Dec 16, 2024
7 changes: 4 additions & 3 deletions kroma-bindings/predeploys/addresses_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

oppredeploys "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/kroma-network/kroma/kroma-bindings/bindings"
"github.com/kroma-network/kroma/op-bindings/predeploys"
)

func TestGethAddresses(t *testing.T) {
// We test if the addresses in geth match those in op-bindings, to avoid an import-cycle:
// we import geth in the monorepo, and do not want to import kroma-bindings into geth.
require.Equal(t, predeploys.L1BlockAddr, types.L1BlockAddr)
// we import geth in the monorepo, and do not want to import op-bindings into geth.
require.Equal(t, oppredeploys.L1BlockAddr, types.L1BlockAddr)
require.Equal(t, L1BlockAddr, types.KromaL1BlockAddr)
}

func uintToHash(v uint) common.Hash {
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/system_tob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import (
fuzz "github.com/google/gofuzz"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/kroma-chain-ops/crossdomain"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/geth"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-service/testutils/fuzzerutils"
"github.com/kroma-network/kroma/kroma-bindings/bindings"
"github.com/kroma-network/kroma/kroma-bindings/predeploys"
"github.com/kroma-network/kroma/kroma-chain-ops/crossdomain"
)

// TestGasPriceOracleFeeUpdates checks that the gas price oracle cannot be locked by mis-configuring parameters.
Expand Down
28 changes: 13 additions & 15 deletions op-node/rollup/derive/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
oppredeploys "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-service/eth"
)
Expand Down Expand Up @@ -109,13 +109,13 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex
}

// [Kroma: START]
// Include KromaMPT network upgrade transactions in the block before(parent block) of the KromaMPT target block.
// Include KromaMPT network upgrade transactions in the parent block of the KromaMPT target block.
if ba.rollupCfg.IsKromaMPTParentBlock(nextL2Time) {
kromaMPT, err := KromaMPTNetworkUpgradeTransactions()
mptUpgradeTxs, err := KromaMPTNetworkUpgradeTransactions()
if err != nil {
return nil, NewCriticalError(fmt.Errorf("failed to build kroma mpt network upgrade txs: %w", err))
}
upgradeTxs = append(upgradeTxs, kromaMPT...)
upgradeTxs = append(upgradeTxs, mptUpgradeTxs...)
}
// [Kroma: END]

Expand All @@ -132,22 +132,20 @@ func (ba *FetchingAttributesBuilder) PreparePayloadAttributes(ctx context.Contex
// [Kroma: START]
suggestedFeeRecipient := common.Address{}
if ba.rollupCfg.IsKromaMPT(nextL2Time) {
suggestedFeeRecipient = predeploys.SequencerFeeVaultAddr
suggestedFeeRecipient = oppredeploys.SequencerFeeVaultAddr
} else {
// In Kroma, the IsSystemTransaction field was deleted from DepositTx.
// After transitioning to MPT, we bring back the IsSystemTransaction field for compatibility with OP.
// Therefore, before MPT time, use KromaDepositTx struct to create deposit transactions without that field.
if !ba.rollupCfg.IsKromaMPT(nextL2Time) {
for i, otx := range txs {
if otx[0] != types.DepositTxType {
continue
}
tx, err := ToKromaDepositBytes(otx)
if err != nil {
return nil, NewCriticalError(err)
}
txs[i] = tx
for i, otx := range txs {
if otx[0] != types.DepositTxType {
continue
}
tx, err := ToKromaDepositBytes(otx)
if err != nil {
return nil, NewCriticalError(err)
}
txs[i] = tx
}
}
// [Kroma: END]
Expand Down
6 changes: 2 additions & 4 deletions op-node/rollup/derive/attributes_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ func TestAttributesQueue(t *testing.T) {
l2Fetcher.ExpectSystemConfigByL2Hash(safeHead.Hash, parentL1Cfg, nil)

parentBeaconRoot := l1Info.ParentBeaconRoot()
if cfg.IsEcotone(0) {
if parentBeaconRoot == nil { // default to zero hash if there is no beacon-block-root available
parentBeaconRoot = new(common.Hash)
}
if cfg.IsEcotone(safeHead.Time+cfg.BlockTime) && parentBeaconRoot == nil { // default to zero hash if there is no beacon-block-root available
parentBeaconRoot = new(common.Hash)
}
attrs := eth.PayloadAttributes{
Timestamp: eth.Uint64Quantity(safeHead.Time + cfg.BlockTime),
Expand Down
2 changes: 0 additions & 2 deletions op-node/rollup/derive/ecotone_upgrade_transactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ func toDepositTxn(t *testing.T, data hexutil.Bytes) (common.Address, *types.Tran
err := txn.UnmarshalBinary(data)
require.NoError(t, err)
require.Truef(t, txn.IsDepositTx(), "expected deposit txn, got %v", txn.Type())
/* [Kroma: START]
require.False(t, txn.IsSystemTx())
[Kroma: END] */

signer := types.NewLondonSigner(big.NewInt(420))
from, err := signer.Sender(txn)
Expand Down
64 changes: 33 additions & 31 deletions op-node/rollup/derive/kromampt_upgrade_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,49 @@ import (
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"

"github.com/ethereum-optimism/optimism/op-bindings/predeploys"
oppredeploys "github.com/ethereum-optimism/optimism/op-bindings/predeploys"
"github.com/kroma-network/kroma/kroma-bindings/bindings"
)

var (
KromaMPTDeployerAddress = common.HexToAddress("0x2551000000000000000000000000000000000000")
L1BlockMPTDeployerAddress = common.HexToAddress("0x2551000000000000000000000000000000000000")
BaseFeeVaultDeployerAddress = common.HexToAddress("0x2551000000000000000000000000000000000001")
L1FeeVaultDeployerAddress = common.HexToAddress("0x2551000000000000000000000000000000000002")
SequencerFeeVaultDeployerAddress = common.HexToAddress("0x2551000000000000000000000000000000000003")

newL1BlockMPTAddress = crypto.CreateAddress(KromaMPTDeployerAddress, 0)
newBaseFeeVaultAddress = crypto.CreateAddress(KromaMPTDeployerAddress, 1)
newL1FeeVaultAddress = crypto.CreateAddress(KromaMPTDeployerAddress, 2)
newSequencerFeeVaultAddress = crypto.CreateAddress(KromaMPTDeployerAddress, 3)
newL1BlockMPTAddress = crypto.CreateAddress(L1BlockMPTDeployerAddress, 0)
newBaseFeeVaultAddress = crypto.CreateAddress(BaseFeeVaultDeployerAddress, 0)
newL1FeeVaultAddress = crypto.CreateAddress(L1FeeVaultDeployerAddress, 0)
newSequencerFeeVaultAddress = crypto.CreateAddress(SequencerFeeVaultDeployerAddress, 0)

deployBaseFeeVaultSource = UpgradeDepositSource{Intent: "KromaMPT: BaseFee Vault Deployment"}
updateBaseFeeVaultProxySource = UpgradeDepositSource{Intent: "KromaMPT: BaseFee Vault Proxy Update"}
deployL1FeeVaultSource = UpgradeDepositSource{Intent: "KromaMPT: L1 Fee Vault Deployment"}
updateL1FeeVaultProxySource = UpgradeDepositSource{Intent: "KromaMPT: L1 Fee Vault Proxy Update"}
deploySequencerFeeVaultSource = UpgradeDepositSource{Intent: "KromaMPT: Sequencer Fee Vault Deployment"}
updateSequencerFeeVaultProxySource = UpgradeDepositSource{Intent: "KromaMPT: Sequencer Fee Vault Proxy Update"}
deployL1BlockMPTSource = UpgradeDepositSource{Intent: "KromaMPT: L1 Block Deployment"}
updateL1BlockMPTProxySource = UpgradeDepositSource{Intent: "KromaMPT: L1 Block Proxy Update"}

deployL1BlockMPTSource = UpgradeDepositSource{Intent: "KromaMPT: L1 Block Deployment"}
updateL1BlockMPTProxySource = UpgradeDepositSource{Intent: "KromaMPT: L1 Block Proxy Update"}
l1BlockMPTDeploymentBytecode = common.FromHex("0x608060405234801561001057600080fd5b5061053e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80638381f58a11610097578063c598591811610066578063c598591814610229578063e591b28214610249578063e81b2c6d14610289578063f82061401461029257600080fd5b80638381f58a146101e35780638b239f73146101f75780639e8c496614610200578063b80777ea1461020957600080fd5b806354fd4d50116100d357806354fd4d50146101335780635cf249691461017c57806364ca23ef1461018557806368d5dca6146101b257600080fd5b8063015d8eb9146100fa57806309bd5a601461010f578063440a5e201461012b575b600080fd5b61010d61010836600461044c565b61029b565b005b61011860025481565b6040519081526020015b60405180910390f35b61010d6103da565b61016f6040518060400160405280600581526020017f312e322e3000000000000000000000000000000000000000000000000000000081525081565b60405161012291906104be565b61011860015481565b6003546101999067ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610122565b6003546101ce9068010000000000000000900463ffffffff1681565b60405163ffffffff9091168152602001610122565b6000546101999067ffffffffffffffff1681565b61011860055481565b61011860065481565b6000546101999068010000000000000000900467ffffffffffffffff1681565b6003546101ce906c01000000000000000000000000900463ffffffff1681565b61026473deaddeaddeaddeaddeaddeaddeaddeaddead000181565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610122565b61011860045481565b61011860075481565b3373deaddeaddeaddeaddeaddeaddeaddeaddead000114610342576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603b60248201527f4c31426c6f636b3a206f6e6c7920746865206465706f7369746f72206163636f60448201527f756e742063616e20736574204c3120626c6f636b2076616c7565730000000000606482015260840160405180910390fd5b6000805467ffffffffffffffff98891668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909116998916999099179890981790975560019490945560029290925560038054919094167fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009190911617909255600491909155600555600655565b3373deaddeaddeaddeaddeaddeaddeaddeaddead00011461040357633cc50b456000526004601cfd5b60043560801c60035560143560801c600055602435600155604435600755606435600255608435600455565b803567ffffffffffffffff8116811461044757600080fd5b919050565b600080600080600080600080610100898b03121561046957600080fd5b6104728961042f565b975061048060208a0161042f565b9650604089013595506060890135945061049c60808a0161042f565b979a969950949793969560a0850135955060c08501359460e001359350915050565b600060208083528351808285015260005b818110156104eb578581018301518582016040015282016104cf565b818111156104fd576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201604001939250505056fea164736f6c634300080f000a")
feeVaultDeploymentBytecode = common.FromHex("0x608060405234801561001057600080fd5b5061053e806100206000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80638381f58a11610097578063c598591811610066578063c598591814610229578063e591b28214610249578063e81b2c6d14610289578063f82061401461029257600080fd5b80638381f58a146101e35780638b239f73146101f75780639e8c496614610200578063b80777ea1461020957600080fd5b806354fd4d50116100d357806354fd4d50146101335780635cf249691461017c57806364ca23ef1461018557806368d5dca6146101b257600080fd5b8063015d8eb9146100fa57806309bd5a601461010f578063440a5e201461012b575b600080fd5b61010d61010836600461044c565b61029b565b005b61011860025481565b6040519081526020015b60405180910390f35b61010d6103da565b61016f6040518060400160405280600581526020017f312e322e3000000000000000000000000000000000000000000000000000000081525081565b60405161012291906104be565b61011860015481565b6003546101999067ffffffffffffffff1681565b60405167ffffffffffffffff9091168152602001610122565b6003546101ce9068010000000000000000900463ffffffff1681565b60405163ffffffff9091168152602001610122565b6000546101999067ffffffffffffffff1681565b61011860055481565b61011860065481565b6000546101999068010000000000000000900467ffffffffffffffff1681565b6003546101ce906c01000000000000000000000000900463ffffffff1681565b61026473deaddeaddeaddeaddeaddeaddeaddeaddead000181565b60405173ffffffffffffffffffffffffffffffffffffffff9091168152602001610122565b61011860045481565b61011860075481565b3373deaddeaddeaddeaddeaddeaddeaddeaddead000114610342576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603b60248201527f4c31426c6f636b3a206f6e6c7920746865206465706f7369746f72206163636f60448201527f756e742063616e20736574204c3120626c6f636b2076616c7565730000000000606482015260840160405180910390fd5b6000805467ffffffffffffffff98891668010000000000000000027fffffffffffffffffffffffffffffffff00000000000000000000000000000000909116998916999099179890981790975560019490945560029290925560038054919094167fffffffffffffffffffffffffffffffffffffffffffffffff00000000000000009190911617909255600491909155600555600655565b3373deaddeaddeaddeaddeaddeaddeaddeaddead00011461040357633cc50b456000526004601cfd5b60043560801c60035560143560801c600055602435600155604435600755606435600255608435600455565b803567ffffffffffffffff8116811461044757600080fd5b919050565b600080600080600080600080610100898b03121561046957600080fd5b6104728961042f565b975061048060208a0161042f565b9650604089013595506060890135945061049c60808a0161042f565b979a969950949793969560a0850135955060c08501359460e001359350915050565b600060208083528351808285015260005b818110156104eb578581018301518582016040015282016104cf565b818111156104fd576000604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01692909201604001939250505056fea164736f6c634300080f000a")
l1BlockMPTDeploymentBytecode = common.FromHex(bindings.L1BlockMetaData.Bin)
sm-stack marked this conversation as resolved.
Show resolved Hide resolved
sequencerFeeVaultDeploymentBytecode = common.FromHex(bindings.ProtocolVaultMetaData.Bin)
baseFeeVaultDeploymentBytecode = common.FromHex(bindings.ProtocolVaultMetaData.Bin)
l1FeeVaultDeploymentBytecode = common.FromHex(bindings.L1FeeVaultMetaData.Bin)
)

// init overrides variables defined in the Kroma MPT upgrade.
func init() {
}

func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
upgradeTxns := make([]hexutil.Bytes, 0, 8)

deployL1BlockTransaction, err := types.NewTx(&types.DepositTx{
SourceHash: deployL1BlockMPTSource.SourceHash(),
From: L1BlockDeployerAddress,
From: L1BlockMPTDeployerAddress,
To: nil,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 375_000,
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
IsSystemTransaction: false,
Data: l1BlockMPTDeploymentBytecode,
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand All @@ -58,41 +59,46 @@ func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {

deployBaseFeeVault, err := types.NewTx(&types.DepositTx{
SourceHash: deployBaseFeeVaultSource.SourceHash(),
From: KromaMPTDeployerAddress,
From: BaseFeeVaultDeployerAddress,
To: nil,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 1_000_000,
IsSystemTransaction: false,
Data: feeVaultDeploymentBytecode,
Data: baseFeeVaultDeploymentBytecode,
}).MarshalBinary()
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}

upgradeTxns = append(upgradeTxns, deployBaseFeeVault)

deployL1FeeVault, err := types.NewTx(&types.DepositTx{
SourceHash: deployL1FeeVaultSource.SourceHash(),
From: KromaMPTDeployerAddress,
From: L1FeeVaultDeployerAddress,
To: nil,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 1_000_000,
IsSystemTransaction: false,
Data: feeVaultDeploymentBytecode,
Data: l1FeeVaultDeploymentBytecode,
}).MarshalBinary()
seolaoh marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}

upgradeTxns = append(upgradeTxns, deployL1FeeVault)

deploySequencerFeeVault, err := types.NewTx(&types.DepositTx{
SourceHash: deploySequencerFeeVaultSource.SourceHash(),
From: KromaMPTDeployerAddress,
From: SequencerFeeVaultDeployerAddress,
To: nil,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 1_000_000,
IsSystemTransaction: false,
Data: feeVaultDeploymentBytecode,
Data: sequencerFeeVaultDeploymentBytecode,
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand All @@ -102,14 +108,13 @@ func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
updateL1BlockProxy, err := types.NewTx(&types.DepositTx{
SourceHash: updateL1BlockMPTProxySource.SourceHash(),
From: common.Address{},
To: &predeploys.L1BlockAddr,
To: &oppredeploys.L1BlockAddr,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 50_000,
IsSystemTransaction: false,
Data: upgradeToCalldata(newL1BlockMPTAddress),
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand All @@ -119,14 +124,13 @@ func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
updateBaseFeeVaultProxy, err := types.NewTx(&types.DepositTx{
SourceHash: updateBaseFeeVaultProxySource.SourceHash(),
From: common.Address{},
To: &predeploys.BaseFeeVaultAddr,
To: &oppredeploys.BaseFeeVaultAddr,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 50_000,
IsSystemTransaction: false,
Data: upgradeToCalldata(newBaseFeeVaultAddress),
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand All @@ -136,14 +140,13 @@ func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
updateL1FeeVaultProxy, err := types.NewTx(&types.DepositTx{
SourceHash: updateL1FeeVaultProxySource.SourceHash(),
From: common.Address{},
To: &predeploys.L1FeeVaultAddr,
To: &oppredeploys.L1FeeVaultAddr,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 50_000,
IsSystemTransaction: false,
Data: upgradeToCalldata(newL1FeeVaultAddress),
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand All @@ -153,14 +156,13 @@ func KromaMPTNetworkUpgradeTransactions() ([]hexutil.Bytes, error) {
updateSequencerFeeVaultProxy, err := types.NewTx(&types.DepositTx{
SourceHash: updateSequencerFeeVaultProxySource.SourceHash(),
From: common.Address{},
To: &predeploys.SequencerFeeVaultAddr,
To: &oppredeploys.SequencerFeeVaultAddr,
Mint: big.NewInt(0),
Value: big.NewInt(0),
Gas: 50_000,
IsSystemTransaction: false,
Data: upgradeToCalldata(newSequencerFeeVaultAddress),
}).MarshalBinary()

if err != nil {
return nil, err
}
Expand Down
Loading