diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b301b791a..0bffc4f3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -213,47 +213,6 @@ jobs: run: | make test-e2e-cache-btc-staking - e2e-run-upgrade-vanilla: - needs: [e2e-docker-build-babylon, e2e-docker-build-babylon-before-upgrade, e2e-docker-build-e2e-init-chain] - runs-on: ubuntu-22.04 - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Download babylon artifact - uses: actions/download-artifact@v4 - with: - name: babylond-${{ github.sha }} - path: /tmp - - name: Download babylond-before-upgrade artifact - uses: actions/download-artifact@v4 - with: - name: babylond-before-upgrade - path: /tmp - - name: Download init-chain artifact - uses: actions/download-artifact@v4 - with: - name: init-chain - path: /tmp - - name: Docker load babylond - run: | - docker load < /tmp/docker-babylond.tar.gz - - - name: Docker load babylond-before-upgrade - run: | - docker load < /tmp/docker-babylond-before-upgrade.tar.gz - - - name: Docker load init chain - run: | - docker load < /tmp/docker-init-chain.tar.gz - - - name: Cache Go - uses: actions/setup-go@v5 - with: - go-version: 1.21 - - name: Run e2e TestSoftwareUpgradeTestSuite - run: | - sudo make test-e2e-cache-upgrade-vanilla - e2e-run-upgrade-signet: needs: [e2e-docker-build-babylon, e2e-docker-build-babylon-before-upgrade, e2e-docker-build-e2e-init-chain] runs-on: ubuntu-22.04 diff --git a/Makefile b/Makefile index d1105b12a..cb948bb78 100644 --- a/Makefile +++ b/Makefile @@ -274,9 +274,6 @@ test-e2e-cache-btc-timestamping-phase-2-rly: test-e2e-cache-btc-staking: go test -run TestBTCStakingTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e -test-e2e-cache-upgrade-vanilla: - go test -run TestSoftwareUpgradeTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e - test-e2e-cache-upgrade-signet: go test -run TestSoftwareUpgradeSignetLaunchTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e diff --git a/app/e2e_include_upgrades.go b/app/e2e_include_upgrades.go index 75e5d89de..d709c20bd 100644 --- a/app/e2e_include_upgrades.go +++ b/app/e2e_include_upgrades.go @@ -4,9 +4,8 @@ package app import ( "github.com/babylonlabs-io/babylon/app/upgrades/signetlaunch" - "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" ) func init() { - Upgrades = append(Upgrades, vanilla.Upgrade, signetlaunch.Upgrade) + Upgrades = append(Upgrades, signetlaunch.Upgrade) } diff --git a/app/upgrades/vanilla/README.md b/app/upgrades/vanilla/README.md deleted file mode 100644 index 3909ea3f3..000000000 --- a/app/upgrades/vanilla/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# vanilla - -This folder contains a vanilla software upgrade for testing purposes. -DO NOT USE IN PRODUCTION! diff --git a/app/upgrades/vanilla/upgrades.go b/app/upgrades/vanilla/upgrades.go deleted file mode 100644 index 99522243e..000000000 --- a/app/upgrades/vanilla/upgrades.go +++ /dev/null @@ -1,97 +0,0 @@ -// This code is only for testing purposes. -// DO NOT USE IN PRODUCTION! - -package vanilla - -import ( - "context" - - store "cosmossdk.io/store/types" - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/babylonlabs-io/babylon/app/keepers" - "github.com/babylonlabs-io/babylon/app/upgrades" - bbn "github.com/babylonlabs-io/babylon/types" - btcstakingkeeper "github.com/babylonlabs-io/babylon/x/btcstaking/keeper" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - "github.com/btcsuite/btcd/btcec/v2" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" -) - -var Upgrade = upgrades.Upgrade{ - UpgradeName: "vanilla", - CreateUpgradeHandler: CreateUpgradeHandler, - StoreUpgrades: store.StoreUpgrades{}, -} - -func CreateUpgradeHandler( - mm *module.Manager, - cfg module.Configurator, - _ upgrades.BaseAppParamManager, - keepers *keepers.AppKeepers, -) upgradetypes.UpgradeHandler { - return func(context context.Context, _plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - ctx := sdk.UnwrapSDKContext(context) - - migrations, err := mm.RunMigrations(ctx, cfg, fromVM) - if err != nil { - return nil, err - } - - propVanilla(ctx, &keepers.AccountKeeper, &keepers.BTCStakingKeeper) - - return migrations, nil - } -} - -func propVanilla( - ctx sdk.Context, - accountKeeper *authkeeper.AccountKeeper, - bsKeeper *btcstakingkeeper.Keeper, -) { - // remove the account with higher number and the lowest is the new fp addr - allAccounts := accountKeeper.GetAllAccounts(ctx) - var ( - accToRemove sdk.AccountI - accFp sdk.AccountI - ) - heighestAccNumber, lowestAccNumber := uint64(0), uint64(len(allAccounts)) - - for _, acc := range allAccounts { - accNumber := acc.GetAccountNumber() - if accNumber > heighestAccNumber { - heighestAccNumber = accNumber - accToRemove = acc - } - if accNumber < lowestAccNumber { - lowestAccNumber = accNumber - accFp = acc - } - } - - accountKeeper.RemoveAccount(ctx, accToRemove) - - // insert a FP from predefined public key - pk, err := btcec.ParsePubKey( - []byte{0x06, 0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, - 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07, - 0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, - 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98, 0x48, 0x3a, - 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, - 0xfc, 0x0e, 0x11, 0x08, 0xa8, 0xfd, 0x17, 0xb4, 0x48, - 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, - 0x10, 0xd4, 0xb8, - }, - ) - if err != nil { - panic(err) - } - - btcPK := bbn.NewBIP340PubKeyFromBTCPK(pk) - fp := &bstypes.FinalityProvider{ - Addr: accFp.GetAddress().String(), - BtcPk: btcPK, - } - bsKeeper.SetFinalityProvider(ctx, fp) -} diff --git a/app/upgrades/vanilla/upgrades_test.go b/app/upgrades/vanilla/upgrades_test.go deleted file mode 100644 index 19511629f..000000000 --- a/app/upgrades/vanilla/upgrades_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package vanilla_test - -import ( - "fmt" - "testing" - "time" - - "cosmossdk.io/core/appmodule" - "cosmossdk.io/core/header" - "cosmossdk.io/x/upgrade" - upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/babylonlabs-io/babylon/app" - v1 "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" - bstypes "github.com/babylonlabs-io/babylon/x/btcstaking/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/suite" -) - -const ( - DummyUpgradeHeight = 5 -) - -type UpgradeTestSuite struct { - suite.Suite - - ctx sdk.Context - app *app.BabylonApp - preModule appmodule.HasPreBlocker -} - -func (s *UpgradeTestSuite) SetupTest() { - // add the upgrade plan - app.Upgrades = append(app.Upgrades, v1.Upgrade) - - // set up app - s.app = app.Setup(s.T(), false) - s.ctx = s.app.BaseApp.NewContextLegacy(false, tmproto.Header{Height: 1, ChainID: "babylon-1", Time: time.Now().UTC()}) - s.preModule = upgrade.NewAppModule(s.app.UpgradeKeeper, s.app.AccountKeeper.AddressCodec()) -} - -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(UpgradeTestSuite)) -} - -func (s *UpgradeTestSuite) TestUpgradePayments() { - oldAcctNum := 0 - - testCases := []struct { - msg string - pre_update func() - update func() - post_update func() - expPass bool - }{ - { - "Test vanilla software upgrade gov prop", - func() { - allAccounts := s.app.AccountKeeper.GetAllAccounts(s.ctx) - oldAcctNum = len(allAccounts) - }, - func() { - // inject upgrade plan - s.ctx = s.ctx.WithBlockHeight(DummyUpgradeHeight - 1) - plan := upgradetypes.Plan{Name: v1.Upgrade.UpgradeName, Height: DummyUpgradeHeight} - err := s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, plan) - s.NoError(err) - - // ensure upgrade plan exists - actualPlan, err := s.app.UpgradeKeeper.GetUpgradePlan(s.ctx) - s.NoError(err) - s.Equal(plan, actualPlan) - - // execute upgrade - s.ctx = s.ctx.WithHeaderInfo(header.Info{Height: DummyUpgradeHeight, Time: s.ctx.BlockTime().Add(time.Second)}).WithBlockHeight(DummyUpgradeHeight) - s.NotPanics(func() { - _, err := s.preModule.PreBlock(s.ctx) - s.NoError(err) - }) - }, - func() { - // ensure the account is removed - allAccounts := s.app.AccountKeeper.GetAllAccounts(s.ctx) - newAcctNum := len(allAccounts) - s.Equal(newAcctNum, oldAcctNum-1) - - // ensure finality provider is inserted - resp, err := s.app.BTCStakingKeeper.FinalityProviders(s.ctx, &bstypes.QueryFinalityProvidersRequest{}) - s.NoError(err) - s.Len(resp.FinalityProviders, 1) - }, - true, - }, - } - - for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.msg), func() { - s.SetupTest() // reset - - tc.pre_update() - tc.update() - tc.post_update() - }) - } -} diff --git a/contrib/images/Makefile b/contrib/images/Makefile index 47febc890..1c0260999 100644 --- a/contrib/images/Makefile +++ b/contrib/images/Makefile @@ -1,6 +1,6 @@ RELAYER_TAG := $(shell grep '^ENV RELAYER_TAG' cosmos-relayer/Dockerfile | cut -f3 -d\ ) BABYLON_FULL_PATH := $(shell git rev-parse --show-toplevel) -BABYLON_VERSION_BEFORE_UPGRADE ?= v0.9.0 +BABYLON_VERSION_BEFORE_UPGRADE ?= v0.9.1 all: babylond cosmos-relayer diff --git a/test/e2e/configurer/config/constants.go b/test/e2e/configurer/config/constants.go index 75a5815c5..af9e03e6e 100644 --- a/test/e2e/configurer/config/constants.go +++ b/test/e2e/configurer/config/constants.go @@ -16,6 +16,5 @@ const ( // PropSubmitBlocks estimated number of blocks it takes to submit for a proposal PropSubmitBlocks float32 = 1 // Upgrade prop files json - UpgradeVanillaFilePath = "/upgrades/vanilla.json" UpgradeSignetLaunchFilePath = "/upgrades/signet-launch.json" ) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 801e6d511..d5096131f 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -36,11 +36,6 @@ func TestBTCStakingTestSuite(t *testing.T) { suite.Run(t, new(BTCStakingTestSuite)) } -// TestSoftwareUpgradeTestSuite tests software upgrade protocol end-to-end -func TestSoftwareUpgradeTestSuite(t *testing.T) { - suite.Run(t, new(SoftwareUpgradeVanillaTestSuite)) -} - // TestSoftwareUpgradeSignetLaunchTestSuite tests software upgrade of signet launch end-to-end func TestSoftwareUpgradeSignetLaunchTestSuite(t *testing.T) { suite.Run(t, new(SoftwareUpgradeSignetLaunchTestSuite)) diff --git a/test/e2e/software_upgrade_e2e_vanilla_test.go b/test/e2e/software_upgrade_e2e_vanilla_test.go deleted file mode 100644 index 5dba61c1f..000000000 --- a/test/e2e/software_upgrade_e2e_vanilla_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package e2e - -import ( - "github.com/stretchr/testify/suite" - - v1 "github.com/babylonlabs-io/babylon/app/upgrades/vanilla" - "github.com/babylonlabs-io/babylon/test/e2e/configurer" - "github.com/babylonlabs-io/babylon/test/e2e/configurer/config" -) - -type SoftwareUpgradeVanillaTestSuite struct { - suite.Suite - - configurer configurer.Configurer -} - -func (s *SoftwareUpgradeVanillaTestSuite) SetupSuite() { - s.T().Log("setting up e2e integration test suite...") - var err error - - s.configurer, err = configurer.NewSoftwareUpgradeConfigurer(s.T(), false, config.UpgradeVanillaFilePath, nil) - s.NoError(err) - err = s.configurer.ConfigureChains() - s.NoError(err) - err = s.configurer.RunSetup() // upgrade happens at the setup of configurer. - s.NoError(err) -} - -func (s *SoftwareUpgradeVanillaTestSuite) TearDownSuite() { - err := s.configurer.ClearResources() - if err != nil { - s.T().Logf("error to clear resources %s", err.Error()) - } -} - -// TestUpgradeVanilla only checks that new fp was added. -func (s *SoftwareUpgradeVanillaTestSuite) TestUpgradeVanilla() { - // chain is already upgraded, only checks for differences in state are expected - chainA := s.configurer.GetChainConfig(0) - chainA.WaitUntilHeight(30) // five blocks more than upgrade - - n, err := chainA.GetDefaultNode() - s.NoError(err) - - expectedUpgradeHeight := int64(25) - - // makes sure that the upgrade was actually executed - resp := n.QueryAppliedPlan(v1.Upgrade.UpgradeName) - s.EqualValues(expectedUpgradeHeight, resp.Height, "the plan should be applied at the height 25") - - fps := n.QueryFinalityProviders() - s.Len(fps, 1, "it should have one finality provider, since the vanilla upgrade just added a new one") -} diff --git a/test/e2e/upgrades/vanilla.json b/test/e2e/upgrades/vanilla.json deleted file mode 100644 index 7461f0b22..000000000 --- a/test/e2e/upgrades/vanilla.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "title": "any title", - "summary": "any summary", - "messages": [ - { - "@type": "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade", - "authority": "bbn10d07y265gmmuvt4z0w9aw880jnsr700jduz5f2", - "plan": { "name": "vanilla", "info": "Msg info", "height": 25 } - } - ], - "deposit": "500000000ubbn", - "initial_deposit": "500000000ubbn", - "initialDeposit": "500000000ubbn" -} \ No newline at end of file