Skip to content

Commit

Permalink
Merge pull request #426 from kroma-network/dev
Browse files Browse the repository at this point in the history
feat: merge dev into main
  • Loading branch information
seolaoh authored Jan 24, 2025
2 parents 202e98b + c41ac14 commit 8674390
Show file tree
Hide file tree
Showing 23 changed files with 3,544 additions and 3,809 deletions.
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 v0.6.0
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/kroma-network/go-ethereum v0.6.1
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 v0.6.0 h1:XCV4jDcvgyewpPlhiHXMx6mifLCxJtH3zcBPia11K88=
github.com/kroma-network/go-ethereum v0.6.0/go.mod h1:ZG4M8oph2j0C+R6CtUXuHeeUk5TuN5hVyl9gfwZawJg=
github.com/kroma-network/go-ethereum v0.6.1 h1:04XgtYznMEL9wKrTtXLB2gGEgXpjYdSOAxNjalkCer0=
github.com/kroma-network/go-ethereum v0.6.1/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
2 changes: 1 addition & 1 deletion kroma-chain-ops/cmd/check-kroma-mpt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func checkL1BlockAddrAndData(ctx context.Context, env *actionEnv) error {
return fmt.Errorf("l1 info tx data length not matched before MPT, expected: %d, got: %d", derive.L1InfoEcotoneLen, len(prevL1InfoTx.Data()))
}
if len(mptL1InfoTx.Data()) != derive.L1InfoKromaMPTLen {
return fmt.Errorf("l1 info tx data length not matched before MPT, expected: %d, got: %d", derive.L1InfoKromaMPTLen, len(mptL1InfoTx.Data()))
return fmt.Errorf("l1 info tx data length not matched after MPT, expected: %d, got: %d", derive.L1InfoKromaMPTLen, len(mptL1InfoTx.Data()))
}

env.log.Info("L1Block address and tx data test: SUCCESS")
Expand Down
12 changes: 9 additions & 3 deletions op-batcher/batcher/channel_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ var (
ErrSeqWindowClose = errors.New("close to sequencer window timeout")
ErrTerminated = errors.New("channel terminated")
// [Kroma: START]
ErrJustBeforeKromaMPTTime = errors.New("reached the block just before KromaMPTTime")
ErrReachedKromaMPTParentBlock = errors.New("reached the parent block of KromaMPT")
ErrReachedKromaMPTBlock = errors.New("reached the KromaMPT block")
// [Kroma: END]
)

Expand Down Expand Up @@ -177,8 +178,13 @@ func (c *ChannelBuilder) AddBlock(block *types.Block) (*derive.L1BlockInfo, erro
if err = c.co.FullErr(); err != nil {
c.setFullErr(err)
// Adding this block still worked, so don't return error, just mark as full
} else /* [Kroma: START] */ if c.rollupCfg.KromaMPTTime != nil && block.Time() == *c.rollupCfg.KromaMPTTime-c.rollupCfg.BlockTime {
c.setFullErr(ErrJustBeforeKromaMPTTime)
}

// [Kroma: START]
if c.rollupCfg.IsKromaMPTParentBlock(block.Time()) {
c.setFullErr(ErrReachedKromaMPTParentBlock)
} else if c.rollupCfg.IsKromaMPTActivationBlock(block.Time()) {
c.setFullErr(ErrReachedKromaMPTBlock)
}
// [Kroma: END]

Expand Down
27 changes: 9 additions & 18 deletions op-batcher/batcher/channel_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"

"github.com/ethereum-optimism/optimism/op-batcher/metrics"
"github.com/ethereum-optimism/optimism/op-node/rollup"
"github.com/ethereum-optimism/optimism/op-node/rollup/derive"
derivetest "github.com/ethereum-optimism/optimism/op-node/rollup/derive/test"
"github.com/ethereum-optimism/optimism/op-service/eth"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)

func channelManagerTestConfig(maxFrameSize uint64, batchType uint) ChannelConfig {
Expand Down Expand Up @@ -485,7 +486,7 @@ func TestChannelManager_ChannelCreation(t *testing.T) {
}

// [Kroma: START]
func TestChannelManager_Close_BeforeMPTBlock(t *testing.T) {
func TestChannelManager_CheckFullErrorsOnKromaMPT(t *testing.T) {
require := require.New(t)

rng := rand.New(rand.NewSource(123))
Expand Down Expand Up @@ -524,27 +525,17 @@ func TestChannelManager_Close_BeforeMPTBlock(t *testing.T) {

require.NoError(m.AddL2Block(zktBlock1), "adding 1st L2 block")
require.NoError(m.AddL2Block(zktBlock2), "adding 2nd L2 block")
require.NoError(m.AddL2Block(mptBlock), "adding 3nd L2 block")
require.NoError(m.AddL2Block(mptBlock), "adding 3rd L2 block")

txdata, err := m.TxData(eth.BlockID{})
require.NoError(err)
ch1 := m.txChannels[txdata.ID().String()]
require.ErrorIs(ch1.FullErr(), ErrJustBeforeKromaMPTTime)

// current channel is not full yet
_, err = m.TxData(eth.BlockID{})
require.ErrorIs(err, io.EOF)
require.ErrorIs(ch1.FullErr(), ErrReachedKromaMPTParentBlock)

// Close immediately marks the channel as full with an ErrTerminated
// if the channel is not already full.
m.currentChannel.Close()
err = m.outputFrames()
require.NoError(err)
txdata, err = m.TxData(eth.BlockID{})
require.NoError(err)
ch2 := m.txChannels[txdata.ID().String()]
require.ErrorIs(ch2.FullErr(), ErrTerminated)
require.NotEqual(ch1.ID(), ch2.ID())
require.ErrorIs(ch2.FullErr(), ErrReachedKromaMPTBlock)
}

// [Kroma: END]
2 changes: 1 addition & 1 deletion op-node/chaincfg/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var Mainnet = &rollup.Config{
CanyonTime: u64Ptr(1708502400),
DeltaTime: u64Ptr(1709107200),
EcotoneTime: u64Ptr(1714032001),
KromaMPTTime: nil,
KromaMPTTime: u64Ptr(1739250001),
FjordTime: nil,
InteropTime: nil,
/* [Kroma: START]
Expand Down
2 changes: 1 addition & 1 deletion op-node/chaincfg/chains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ var mainnetCfg = rollup.Config{
CanyonTime: u64Ptr(1708502400),
DeltaTime: u64Ptr(1709107200),
EcotoneTime: u64Ptr(1714032001),
KromaMPTTime: nil,
KromaMPTTime: u64Ptr(1739250001),
FjordTime: nil,
InteropTime: nil,
/* [Kroma: START]
Expand Down
7 changes: 7 additions & 0 deletions op-node/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,13 @@ func (n *OpNode) OnUnsafeL2Payload(ctx context.Context, from peer.ID, envelope *
return nil
}

// [Kroma: START]
if n.runCfg.rollupCfg.IsKromaMPTActivationBlock(uint64(envelope.ExecutionPayload.Timestamp)) {
n.log.Info("Received the payload of the KromaMPT block from p2p but ignored it", "id", envelope.ExecutionPayload.ID(), "peer", from)
return nil
}
// [Kroma: END]

n.tracer.OnUnsafeL2Payload(ctx, from, envelope)

n.log.Info("Received signed execution payload from p2p", "id", envelope.ExecutionPayload.ID(), "peer", from)
Expand Down
8 changes: 8 additions & 0 deletions op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ func (c *Config) IsKromaMPT(timestamp uint64) bool {
return c.KromaMPTTime != nil && timestamp >= *c.KromaMPTTime
}

// IsKromaMPTActivationBlock returns whether the specified block is the first block subject to the
// KromaMPT upgrade. KromaMPT activation at genesis does not count.
func (c *Config) IsKromaMPTActivationBlock(l2BlockTime uint64) bool {
return c.IsKromaMPT(l2BlockTime) &&
l2BlockTime >= c.BlockTime &&
!c.IsKromaMPT(l2BlockTime-c.BlockTime)
}

// IsKromaMPTParentBlock returns whether the specified block is the parent block subject to the
// KromaMPT upgrade. KromaMPT activation at genesis does not count.
func (c *Config) IsKromaMPTParentBlock(l2BlockTime uint64) bool {
Expand Down
8 changes: 4 additions & 4 deletions ops-devnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ volumes:

services:
create-beacon-chain-genesis:
image: "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:latest"
image: "gcr.io/prysmaticlabs/prysm/cmd/prysmctl:v5.0.4"
command:
- testnet
- generate-genesis
Expand All @@ -30,7 +30,7 @@ services:
- "${PWD}/prysm-config.yml:/config.yml"

beacon-chain:
image: "gcr.io/prysmaticlabs/prysm/beacon-chain:latest"
image: "gcr.io/prysmaticlabs/prysm/beacon-chain:v5.0.4"
command:
- --datadir=/db/beacondata
- --min-sync-peers=0
Expand Down Expand Up @@ -108,7 +108,7 @@ services:

l2:
pid: host # allow debugging
image: kromanetwork/geth:v0.6.0
image: kromanetwork/geth:v0.6.1
ports:
- "9545:8545"
- "9546:8546"
Expand All @@ -128,7 +128,7 @@ services:

l2-historical:
pid: host # allow debugging
image: kromanetwork/geth:v0.6.0
image: kromanetwork/geth:v0.6.1
ports:
- "9445:8545"
- "9446:8546"
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/deploy-config/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"validatorManagerJailThreshold": 2,
"validatorManagerMaxFinalizations": 10,
"validatorManagerBaseReward": "0x15AF1D78B58C400000",
"validatorManagerMptFirstOutputIndex": "0x313B",
"assetManagerKgh": "0xacA91C74748090f861E25D142B6fCB265c6171c8",
"assetManagerVault": "0xe57E217d8ed498992452791622711B866403E950",
"assetManagerMinDelegationPeriod": 604800,
Expand Down Expand Up @@ -62,6 +63,8 @@
"zkVerifierHashScalar": "0x2FC715229F110C0240EEE5BDE4C9A1AD3BCD8F344A7450BB54D83BF2AB204F57",
"zkVerifierM56Px": "0x13AFF223C765EE57720AD99D4DAEF90D6509B97318A84CB5D926295874DFB9A8",
"zkVerifierM56Py": "0x2F94CE8D448F4C3FC89DBDF3320EE1850B3FFDC50D260E2BB09F6FEAED846B1B",
"zkProofVerifierSP1Verifier": "0xd2832Cf1fC8bA210FfABF62Db9A8781153131d16",
"zkProofVerifierVKey": "0x0082f10b794f55a90a98566913e7639ffeca0b7fcba30bdb1b3faed9c5534b75",
"governanceTokenProxySalt": "0x62770b858e90d560f80deb05ad8edbcc48e12d3b38110ce709025d5545a9d3c8",
"mintManagerOwner": "0xc0ab283E81aE99197Cfe1C8BEE9C593CD4FF7FB3",
"l1MintManagerRecipients": [
Expand Down
3 changes: 3 additions & 0 deletions packages/contracts/deploy-config/sepolia.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"validatorManagerJailThreshold": 2,
"validatorManagerMaxFinalizations": 10,
"validatorManagerBaseReward": "0x3782DACE9D900000",
"validatorManagerMptFirstOutputIndex": "0x24230",
"assetManagerKgh": "0x04d9D4908e59441b82d0bfA24a0461ea80B7D816",
"assetManagerVault": "0x944a6edDfd0d18c4D913b2B90f2Ee923B1bcd622",
"assetManagerMinDelegationPeriod": 21600,
Expand Down Expand Up @@ -69,6 +70,8 @@
"zkVerifierHashScalar": "0xD7496D9D15F9DB7697DF22201FBD73BDC504FBCCBDB34FAA64D43A80361484D",
"zkVerifierM56Px": "0x59F73EE44B2ACAC480F776270FBF58A5974CE47EC9F7682844E89F17CAEA4F2",
"zkVerifierM56Py": "0xD7DC3CAC83BA451AB1DD0428B4593FA07198058425B9D672C6F0C087432AF73",
"zkProofVerifierSP1Verifier": "0x3B6041173B80E77f038f3F2C0f9744f04837185e",
"zkProofVerifierVKey": "0x0082f10b794f55a90a98566913e7639ffeca0b7fcba30bdb1b3faed9c5534b75",
"governanceTokenProxySalt": "0x62770b858e90d560f80deb05ad8edbcc48e12d3b38110ce709025d5545a9d3c8",
"mintManagerOwner": "0x80e695eceb5bea3b1788c4dfb40b72afc59f60d8",
"l1MintManagerRecipients": [
Expand Down
Loading

0 comments on commit 8674390

Please sign in to comment.