Skip to content

Commit

Permalink
op-deployer: Improve default hardfork choice
Browse files Browse the repository at this point in the history
The deploy config was previously created with Holocene activated by default. This PR updates the hardfork selection logic to choose default hardforks based on the contracts version.
  • Loading branch information
mslipper committed Jan 20, 2025
1 parent 39e9f1a commit db8dd67
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
25 changes: 25 additions & 0 deletions op-deployer/pkg/deployer/standard/standard.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import (
"fmt"
"net/url"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-node/rollup"
op_service "github.com/ethereum-optimism/optimism/op-service"

"github.com/BurntSushi/toml"

"github.com/ethereum-optimism/superchain-registry/superchain"
Expand Down Expand Up @@ -335,6 +339,27 @@ func ArtifactsHashForTag(tag string) (common.Hash, error) {
}
}

// DefaultHardforkScheduleForTag is used to determine which hardforks should be activated by default given a
// contract tag. For example, passing in v1.6.0 will return all hardforks up to and including Granite. This allows
// OP Deployer to set sane defaults for hardforks. This is not an ideal solution, but it will have to work until we get
// to MCP L2.
func DefaultHardforkScheduleForTag(tag string) *genesis.UpgradeScheduleDeployConfig {
sched := &genesis.UpgradeScheduleDeployConfig{
L2GenesisRegolithTimeOffset: op_service.U64UtilPtr(0),
L2GenesisCanyonTimeOffset: op_service.U64UtilPtr(0),
L2GenesisDeltaTimeOffset: op_service.U64UtilPtr(0),
L2GenesisEcotoneTimeOffset: op_service.U64UtilPtr(0),
L2GenesisFjordTimeOffset: op_service.U64UtilPtr(0),
L2GenesisGraniteTimeOffset: op_service.U64UtilPtr(0),
}

if tag == "op-contracts/v1.8.0-rc.4" {
sched.ActivateForkAtGenesis(rollup.Holocene)
}

return sched
}

func standardArtifactsURL(checksum string) string {
return fmt.Sprintf("https://storage.googleapis.com/oplabs-contract-artifacts/artifacts-v1-%s.tar.gz", checksum)
}
Expand Down
15 changes: 15 additions & 0 deletions op-deployer/pkg/deployer/standard/standard_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package standard

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestDefaultHardforkScheduleForTag(t *testing.T) {
sched := DefaultHardforkScheduleForTag(ContractsV160Tag)
require.Nil(t, sched.HoloceneTime(0))

sched = DefaultHardforkScheduleForTag(ContractsV180Tag)
require.NotNil(t, sched.HoloceneTime(0))
}
18 changes: 8 additions & 10 deletions op-deployer/pkg/deployer/state/deploy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"math/big"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/standard"

op_service "github.com/ethereum-optimism/optimism/op-service"

"github.com/ethereum-optimism/optimism/op-service/jsonutil"
Expand All @@ -25,6 +27,11 @@ var (
)

func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State, chainState *ChainState) (genesis.DeployConfig, error) {
upgradeSchedule := standard.DefaultHardforkScheduleForTag(intent.L1ContractsLocator.Tag)
if intent.UseInterop {
upgradeSchedule.UseInterop = true
}

cfg := genesis.DeployConfig{
L1DependenciesConfig: genesis.L1DependenciesConfig{
L1StandardBridgeProxy: chainState.L1StandardBridgeProxyAddress,
Expand Down Expand Up @@ -73,16 +80,7 @@ func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State,
// Any upgrades you enable here will be enabled for all new deployments.
// In-development hardforks should never be activated here. Instead, they
// should be specified as overrides.
UpgradeScheduleDeployConfig: genesis.UpgradeScheduleDeployConfig{
L2GenesisRegolithTimeOffset: op_service.U64UtilPtr(0),
L2GenesisCanyonTimeOffset: op_service.U64UtilPtr(0),
L2GenesisDeltaTimeOffset: op_service.U64UtilPtr(0),
L2GenesisEcotoneTimeOffset: op_service.U64UtilPtr(0),
L2GenesisFjordTimeOffset: op_service.U64UtilPtr(0),
L2GenesisGraniteTimeOffset: op_service.U64UtilPtr(0),
L2GenesisHoloceneTimeOffset: op_service.U64UtilPtr(0),
UseInterop: intent.UseInterop,
},
UpgradeScheduleDeployConfig: *upgradeSchedule,
L2CoreDeployConfig: genesis.L2CoreDeployConfig{
L1ChainID: intent.L1ChainID,
L2ChainID: chainState.ID.Big().Uint64(),
Expand Down

0 comments on commit db8dd67

Please sign in to comment.