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(halo): uluwatu network upgrade #1983

Merged
merged 3 commits into from
Sep 27, 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 .github/workflows/release-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
file: scripts/halovisor/Dockerfile
build-args: |
HALO_VERSION_0_GENESIS=${{ github.ref_name }}
HALO_VERSION_1_ULUWATU=${{ github.ref_name }}
platforms: |
linux/amd64
push: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
with:
file: scripts/halovisor/Dockerfile
build-args: |
HALO_VERSION_0_GENESIS=${{ steps.git_ref.outputs.short_sha }}
HALO_VERSION_1_ULUWATU=${{ steps.git_ref.outputs.short_sha }}
platforms: |
linux/amd64
push: true
Expand Down
62 changes: 62 additions & 0 deletions e2e/app/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"time"

"github.com/omni-network/omni/contracts/bindings"
"github.com/omni-network/omni/e2e/app/eoa"
"github.com/omni-network/omni/e2e/netman"
"github.com/omni-network/omni/e2e/netman/pingpong"
"github.com/omni-network/omni/e2e/types"
"github.com/omni-network/omni/halo/genutil/evm/predeploys"
"github.com/omni-network/omni/lib/contracts"
"github.com/omni-network/omni/lib/errors"
"github.com/omni-network/omni/lib/k1util"
Expand All @@ -16,6 +18,7 @@ import (
e2e "github.com/cometbft/cometbft/test/e2e/pkg"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
)

const (
Expand Down Expand Up @@ -139,6 +142,10 @@ func Deploy(ctx context.Context, def Definition, cfg DeployConfig) (*pingpong.XD
return nil, errors.Wrap(err, "start all edges")
}

if err := maybeSubmitNetworkUpgrade(ctx, def); err != nil {
return nil, err
}

if err := FundValidatorsForTesting(ctx, def); err != nil {
return nil, err
}
Expand Down Expand Up @@ -382,3 +389,58 @@ func checkSupportedChains(ctx context.Context, n netman.Manager) (bool, error) {

return true, nil
}

// maybeSubmitNetworkUpgrade submits a network upgrade if required.
func maybeSubmitNetworkUpgrade(ctx context.Context, def Definition) error {
if def.Manifest.NetworkUpgradeHeight <= 0 {
log.Debug(ctx, "Not submitting network upgrade admin tx")

return nil // No explicit network upgrade required.
}

network := def.Testnet.Network

backend, err := def.Backends().Backend(network.Static().OmniExecutionChainID)
if err != nil {
return err
}

contract, err := bindings.NewUpgrade(common.HexToAddress(predeploys.Upgrade), backend)
if err != nil {
return err
}

txOpts, err := backend.BindOpts(ctx, eoa.MustAddress(network, eoa.RoleAdmin))
if err != nil {
return err
}

height, err := backend.BlockNumber(ctx)
if err != nil {
return err
}

const minDelay = 5 // Upgrades fail if processed too late (mempool is non-deterministic, so we need a buffer).
height += minDelay

// If requested height is later, use that as is.
if uint64(def.Manifest.NetworkUpgradeHeight) > height {
height = uint64(def.Manifest.NetworkUpgradeHeight)
}

log.Info(ctx, "Planning upgrade", "height", height, "name", latestUpgrade)

tx, err := contract.PlanUpgrade(txOpts, bindings.UpgradePlan{
Name: latestUpgrade,
Height: height,
Info: "e2e triggered upgrade",
})
if err != nil {
return errors.Wrap(err, "plan upgrade")
}
if _, err := backend.WaitMined(ctx, tx); err != nil {
return errors.Wrap(err, "wait mined")
}

return nil
}
9 changes: 9 additions & 0 deletions e2e/app/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/omni-network/omni/e2e/app/static"
"github.com/omni-network/omni/e2e/types"
"github.com/omni-network/omni/e2e/vmcompose"
uluwatu1 "github.com/omni-network/omni/halo/app/upgrades/uluwatu"
halocmd "github.com/omni-network/omni/halo/cmd"
halocfg "github.com/omni-network/omni/halo/config"
"github.com/omni-network/omni/halo/genutil"
Expand Down Expand Up @@ -48,6 +49,8 @@ const (

PrivvalKeyFile = "config/priv_validator_key.json"
PrivvalStateFile = "data/priv_validator_state.json"

latestUpgrade = uluwatu1.UpgradeName
)

// Setup sets up the testnet configuration.
Expand Down Expand Up @@ -87,10 +90,16 @@ func Setup(ctx context.Context, def Definition, depCfg DeployConfig) error {
valPrivKeys = append(valPrivKeys, val.PrivvalKey)
}

var upgrade string
if def.Manifest.NetworkUpgradeHeight == 0 {
upgrade = latestUpgrade // Genesis upgrade.
}

cosmosGenesis, err := genutil.MakeGenesis(
def.Manifest.Network,
time.Now(),
gethGenesis.ToBlock().Hash(),
upgrade,
vals...)
if err != nil {
return errors.Wrap(err, "make genesis")
Expand Down
1 change: 1 addition & 0 deletions e2e/manifests/backwards.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ network = "devnet"
anvil_chains = ["mock_l1", "mock_l2"]

multi_omni_evms = true
network_upgrade_height = -1 # Disable network upgrade

[node.validator01]
[node.validator02]
Expand Down
2 changes: 1 addition & 1 deletion e2e/manifests/ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ network = "devnet"
anvil_chains = ["mock_l2", "mock_l1"]

multi_omni_evms = true

network_upgrade_height = 15
pingpong_n = 5 # Increased ping pong to span validator updates

[node.validator01]
Expand Down
4 changes: 4 additions & 0 deletions e2e/types/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ type Manifest struct {
// This allows source code defined versions for protected networks.
// This overrides the --omni-image-tag if non-empty.
PinnedRelayerTag string `toml:"pinned_relayer_tag"`

// NetworkUpgradeHeight defines the network upgrade height, default is genesis, negative is disabled.
// Note that it might be scheduled at a later height.
NetworkUpgradeHeight int64 `toml:"network_upgrade_height"`
}

// Seeds returns a map of seed nodes by name.
Expand Down
8 changes: 7 additions & 1 deletion halo/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func newApp(
baseAppOpts ...func(*baseapp.BaseApp),
) (*App, error) {
depCfg := depinject.Configs(
appConfig,
appConfig(),
depinject.Provide(diProviders...),
depinject.Supply(
logger,
Expand Down Expand Up @@ -183,6 +183,12 @@ func newApp(
})
}

// setUpgradeHandlers should be called before `Load()`
// because StoreLoad is sealed after that
if err := app.setUpgradeHandlers(); err != nil {
return nil, errors.Wrap(err, "set upgrade handlers")
}

if err := app.Load(true); err != nil {
return nil, errors.Wrap(err, "load app")
}
Expand Down
Loading
Loading