Skip to content

Commit

Permalink
feat: add Kroma Burgundy upgrade time
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangssu committed Mar 5, 2024
1 parent 646eb95 commit 7762631
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,4 @@ require (

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

replace github.com/ethereum/go-ethereum v1.13.8 => github.com/kroma-network/go-ethereum v0.4.4
replace github.com/ethereum/go-ethereum v1.13.8 => github.com/kroma-network/go-ethereum v0.4.3-0.20240304033547-c8ef45c4754e
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,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.4.4 h1:7GvW/4Hj7N73BrL+k0MYav+kCI2aEpr7BPOrOkxyJLI=
github.com/kroma-network/go-ethereum v0.4.4/go.mod h1:SsK2EAbCigQsKUmhnHSe9KXrUEg2RKJcKFT2+/f2Q+M=
github.com/kroma-network/go-ethereum v0.4.3-0.20240304033547-c8ef45c4754e h1:RhGy+YJE0dd2X2ek/+tSgPyyxGHGORAetnvdPKYX6+8=
github.com/kroma-network/go-ethereum v0.4.3-0.20240304033547-c8ef45c4754e/go.mod h1:SsK2EAbCigQsKUmhnHSe9KXrUEg2RKJcKFT2+/f2Q+M=
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
17 changes: 17 additions & 0 deletions kroma-bindings/predeploys/predeploy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package predeploys

import (
"github.com/ethereum/go-ethereum/common"
)

type DeployConfig interface {
GovernanceEnabled() bool
CanyonTime(genesisTime uint64) *uint64
BurgundyTime(genesisTime uint64) *uint64
}

type Predeploy struct {
Address common.Address
ProxyDisabled bool
Enabled func(config DeployConfig) bool
}
22 changes: 22 additions & 0 deletions kroma-chain-ops/genesis/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ type DeployConfig struct {
ZKVerifierHashScalar *hexutil.Big `json:"zkVerifierHashScalar"`
ZKVerifierM56Px *hexutil.Big `json:"zkVerifierM56Px"`
ZKVerifierM56Py *hexutil.Big `json:"zkVerifierM56Py"`

// L2GenesisBurgundyTimeOffset is the number of seconds after genesis block that Kroma Burgundy hard fork activates.
// Set it to 0 to activate at genesis. Nil to disable Burgundy.
L2GenesisBurgundyTimeOffset *hexutil.Uint64 `json:"l2GenesisBurgundyTimeOffset,omitempty"`
// [Kroma: END]
}

Expand Down Expand Up @@ -591,6 +595,21 @@ func (d *DeployConfig) InteropTime(genesisTime uint64) *uint64 {
return &v
}

// [Kroma: START]

func (d *DeployConfig) BurgundyTime(genesisTime uint64) *uint64 {
if d.L2GenesisBurgundyTimeOffset == nil {
return nil
}
v := uint64(0)
if offset := *d.L2GenesisBurgundyTimeOffset; offset > 0 {
v = genesisTime + uint64(offset)
}
return &v
}

// [Kroma: END

// RollupConfig converts a DeployConfig to a rollup.Config
func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHash common.Hash, l2GenesisBlockNumber uint64) (*rollup.Config, error) {
if d.KromaPortalProxy == (common.Address{}) {
Expand Down Expand Up @@ -634,6 +653,9 @@ func (d *DeployConfig) RollupConfig(l1StartBlock *types.Block, l2GenesisBlockHas
EclipseTime: d.EclipseTime(l1StartBlock.Time()),
FjordTime: d.FjordTime(l1StartBlock.Time()),
InteropTime: d.InteropTime(l1StartBlock.Time()),
// [Kroma: START]
BurgundyTime: d.BurgundyTime(l1StartBlock.Time()),
// [Kroma: END]
}, nil
}

Expand Down
1 change: 1 addition & 0 deletions kroma-chain-ops/genesis/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
// [Kroma: START]
// kroma-geth is not yet ready. it should be upstream to v1.101304.2
// InteropTime: config.InteropTime(block.Time()),
BurgundyTime: config.BurgundyTime(block.Time()),
//
Kroma: &params.KromaConfig{
EIP1559Denominator: eip1559Denom,
Expand Down
14 changes: 13 additions & 1 deletion op-e2e/e2eutils/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var testingJWTSecret = [32]byte{123}
func WriteDefaultJWT(t TestingBase) string {
// Sadly the geth node config cannot load JWT secret from memory, it has to be a file
jwtPath := path.Join(t.TempDir(), "jwt_secret")
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(testingJWTSecret[:])), 0600); err != nil {
if err := os.WriteFile(jwtPath, []byte(hexutil.Encode(testingJWTSecret[:])), 0o600); err != nil {
t.Fatalf("failed to prepare jwt file for geth: %v", err)
}
return jwtPath
Expand Down Expand Up @@ -66,6 +66,7 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams {
// [Kroma: END]
deployConfig.L2GenesisCanyonTimeOffset = CanyonTimeOffset()
// [Kroma: START]
deployConfig.L2GenesisBurgundyTimeOffset = BurgundyTimeOffset()
deployConfig.ValidatorPoolRoundDuration = deployConfig.L2OutputOracleSubmissionInterval * deployConfig.L2BlockTime / 2
// [Kroma: END]

Expand Down Expand Up @@ -174,6 +175,9 @@ func Setup(t require.TestingT, deployParams *DeployParams, alloc *AllocParams) *
EclipseTime: deployConf.EclipseTime(uint64(deployConf.L1GenesisBlockTimestamp)),
FjordTime: deployConf.FjordTime(uint64(deployConf.L1GenesisBlockTimestamp)),
InteropTime: deployConf.InteropTime(uint64(deployConf.L1GenesisBlockTimestamp)),
// [Kroma: START]
BurgundyTime: deployConf.BurgundyTime(uint64(deployConf.L1GenesisBlockTimestamp)),
// [Kroma: END]
}

require.NoError(t, rollupCfg.Check())
Expand Down Expand Up @@ -208,3 +212,11 @@ func CanyonTimeOffset() *hexutil.Uint64 {
}
return nil
}

func BurgundyTimeOffset() *hexutil.Uint64 {
if os.Getenv("OP_E2E_USE_BURGUNDY") == "true" {
offset := hexutil.Uint64(0)
return &offset
}
return nil
}
12 changes: 12 additions & 0 deletions op-node/rollup/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ type Config struct {
// [Kroma: START]
// L1 address that declares the protocol versions, optional (Beta feature)
// ProtocolVersionsAddress common.Address `json:"protocol_versions_address,omitempty"`

// BurgundyTime sets the activation time of the Kroma Burgundy network upgrade.
// Active if BurgundyTime != nil && L2 block timestamp >= *BurgundyTime, inactive otherwise.
BurgundyTime *uint64 `json:"burgundy_time,omitempty"`
// [Kroma: END]
}

Expand Down Expand Up @@ -310,6 +314,11 @@ func (c *Config) IsInterop(timestamp uint64) bool {
return c.InteropTime != nil && timestamp >= *c.InteropTime
}

// IsBurgundy returns true if the Kroma Burgundy hardfork is active at or past the given timestamp.
func (c *Config) IsBurgundy(timestamp uint64) bool {
return c.BurgundyTime != nil && timestamp >= *c.BurgundyTime
}

// Description outputs a banner describing the important parts of rollup configuration in a human-readable form.
// Optionally provide a mapping of L2 chain IDs to network names to label the L2 chain with if not unknown.
// The config should be config.Check()-ed before creating a description.
Expand Down Expand Up @@ -345,6 +354,8 @@ func (c *Config) Description(l2Chains map[string]string) string {
// Report the protocol version
// [Kroma: START]
// banner += fmt.Sprintf("Node supports up to OP-Stack Protocol Version: %s\n", OPStackSupport)
banner += "Kroma Network Upgrades (timestamp based):\n"
banner += fmt.Sprintf(" - Burgundy: %s\n", fmtForkTimeOrUnset(c.BurgundyTime))
// [Kroma: END]
return banner
}
Expand Down Expand Up @@ -374,6 +385,7 @@ func (c *Config) LogDescription(log log.Logger, l2Chains map[string]string) {
"eclipse_time", fmtForkTimeOrUnset(c.EclipseTime),
"fjord_time", fmtForkTimeOrUnset(c.FjordTime),
"interop_time", fmtForkTimeOrUnset(c.InteropTime),
"burgundy_time", fmtForkTimeOrUnset(c.BurgundyTime),
)
}

Expand Down
2 changes: 1 addition & 1 deletion ops-devnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:

l2:
pid: host # allow debugging
image: kromanetwork/geth:v0.4.4
image: kromanetwork/geth:tge
ports:
- "9545:8545"
- "9546:8546"
Expand Down

0 comments on commit 7762631

Please sign in to comment.