diff --git a/Makefile b/Makefile index 4c8db9052..0622ac924 100644 --- a/Makefile +++ b/Makefile @@ -243,7 +243,7 @@ endif .PHONY: run-tests test test-all $(TEST_TARGETS) -test-e2e: build-docker +test-e2e: build-docker-e2e go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 --tags=e2e test-sim-nondeterminism: @@ -408,6 +408,17 @@ proto-lint: ## Lint protobuf files .PHONY: proto-gen proto-swagger-gen proto-format prot-lint +############################################################################### +### E2E build ### +############################################################################### + +# Executed to build the binary for chain initialization, one of +## chain => test/e2e/initialization/chain/main.go +## node => test/e2e/initialization/node/main.go +e2e-build-script: + mkdir -p $(BUILDDIR) + go build -mod=readonly $(BUILD_FLAGS) -o $(BUILDDIR)/ ./test/e2e/initialization/$(E2E_SCRIPT_NAME) + ############################################################################### ### Docker ### ############################################################################### @@ -415,10 +426,14 @@ proto-lint: ## Lint protobuf files build-docker: ## Build babylond Docker image $(MAKE) -C contrib/images babylond +build-docker-e2e: + $(MAKE) -C contrib/images babylond-e2e + $(MAKE) -C contrib/images e2e-init-chain + build-cosmos-relayer-docker: ## Build Docker image for the Cosmos relayer $(MAKE) -C contrib/images cosmos-relayer -.PHONY: build-docker build-cosmos-relayer-docker +.PHONY: build-docker build-docker-e2e build-cosmos-relayer-docker ############################################################################### ### Localnet ### diff --git a/contrib/images/Makefile b/contrib/images/Makefile index 67e2fc470..675678121 100644 --- a/contrib/images/Makefile +++ b/contrib/images/Makefile @@ -1,20 +1,31 @@ RELAYER_TAG := $(shell grep '^ENV RELAYER_TAG' cosmos-relayer/Dockerfile | cut -f3 -d\ ) +BABYLON_FULL_PATH := $(shell git rev-parse --show-toplevel) all: babylond cosmos-relayer babylond: babylond-rmi - docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile \ - $(shell git rev-parse --show-toplevel) + docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile ${BABYLON_FULL_PATH} + +babylond-e2e: + docker build --tag babylonlabs-io/babylond -f babylond/Dockerfile ${BABYLON_FULL_PATH} \ + --build-arg BUILD_TAGS="e2e" babylond-rmi: docker rmi babylonlabs-io/babylond 2>/dev/null; true +e2e-init-chain-rmi: + docker rmi babylonlabs-io/babylond-e2e-init-chain --force 2>/dev/null; true + +e2e-init-chain: + docker build -t babylonlabs-io/babylond-e2e-init-chain --build-arg E2E_SCRIPT_NAME=chain \ + -f e2e-initialization/init.Dockerfile ${BABYLON_FULL_PATH} + cosmos-relayer: cosmos-relayer-rmi docker build --tag babylonlabs-io/cosmos-relayer:${RELAYER_TAG} -f cosmos-relayer/Dockerfile \ - $(shell git rev-parse --show-toplevel)/contrib/images/cosmos-relayer + ${BABYLON_FULL_PATH}/contrib/images/cosmos-relayer docker tag babylonlabs-io/cosmos-relayer:${RELAYER_TAG} babylonlabs-io/cosmos-relayer:latest cosmos-relayer-rmi: docker rmi babylonlabs-io/cosmos-relayer 2>/dev/null; true -.PHONY: all babylond cosmos-relayer babylond-rmi cosmos-relayer-rmi +.PHONY: all babylond cosmos-relayer babylond-e2e e2e-init-chain e2e-init-chain-rmi babylond-rmi cosmos-relayer-rmi diff --git a/contrib/images/e2e-initialization/init.Dockerfile b/contrib/images/e2e-initialization/init.Dockerfile new file mode 100644 index 000000000..2f95989ff --- /dev/null +++ b/contrib/images/e2e-initialization/init.Dockerfile @@ -0,0 +1,46 @@ +FROM golang:1.21 as build-env + +ARG E2E_SCRIPT_NAME +# Version to build. Default is empty +ARG VERSION + +# Copy All +WORKDIR /go/src/github.com/babylonlabs-io/babylon +COPY ./ /go/src/github.com/babylonlabs-io/babylon/ + +# If version is set, then checkout this version +RUN if [ -n "${VERSION}" ]; then \ + git checkout -f ${VERSION}; \ + fi + +RUN LEDGER_ENABLED=false LINK_STATICALLY=false E2E_SCRIPT_NAME=${E2E_SCRIPT_NAME} make e2e-build-script + +FROM debian:bookworm-slim AS wasm-link + +RUN apt-get update && apt-get install -y wget bash + +# Label should match your github repo +LABEL org.opencontainers.image.source="https://github.com/babylonlabs-io/babylond:${VERSION}" + +# Install libraries +# Cosmwasm - Download correct libwasmvm version +COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/go.mod /tmp +RUN WASMVM_VERSION=$(grep github.com/CosmWasm/wasmvm /tmp/go.mod | cut -d' ' -f2) && \ + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/libwasmvm.$(uname -m).so \ + -O /lib/libwasmvm.$(uname -m).so && \ + # verify checksum + wget https://github.com/CosmWasm/wasmvm/releases/download/$WASMVM_VERSION/checksums.txt -O /tmp/checksums.txt && \ + sha256sum /lib/libwasmvm.$(uname -m).so | grep $(cat /tmp/checksums.txt | grep libwasmvm.$(uname -m) | cut -d ' ' -f 1) +RUN rm -f /tmp/go.mod + +# Args only last for a single build stage - renew +ARG E2E_SCRIPT_NAME + +COPY --from=build-env /go/src/github.com/babylonlabs-io/babylon/build/${E2E_SCRIPT_NAME} /bin/${E2E_SCRIPT_NAME} + +# Docker ARGs are not expanded in ENTRYPOINT in the exec mode. At the same time, +# it is impossible to add CMD arguments when running a container in the shell mode. +# As a workaround, we create the entrypoint.sh script to bypass these issues. +RUN echo "#!/bin/bash\n${E2E_SCRIPT_NAME} \"\$@\"" >> entrypoint.sh && chmod +x entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] \ No newline at end of file diff --git a/test/e2e/btc_staking_e2e_test.go b/test/e2e/btc_staking_e2e_test.go index d4bcf2775..05c97395e 100644 --- a/test/e2e/btc_staking_e2e_test.go +++ b/test/e2e/btc_staking_e2e_test.go @@ -297,12 +297,12 @@ func (s *BTCStakingTestSuite) Test3CommitPublicRandomnessAndSubmitFinalitySignat s.Equal(prCommitMap[activatedHeight].Commitment, msgCommitPubRandList.Commitment) // no reward gauge for finality provider and delegation yet - fpBabylonAddr := sdk.AccAddress(nonValidatorNode.SecretKey.PubKey().Address().Bytes()) + fpBabylonAddr, err := sdk.AccAddressFromBech32(cacheFP.Addr) + s.NoError(err) + _, err = nonValidatorNode.QueryRewardGauge(fpBabylonAddr) - s.Error(err) - delBabylonAddr := sdk.AccAddress(nonValidatorNode.SecretKey.PubKey().Address().Bytes()) - _, err = nonValidatorNode.QueryRewardGauge(delBabylonAddr) - s.Error(err) + s.ErrorContains(err, itypes.ErrRewardGaugeNotFound.Error()) + delBabylonAddr := fpBabylonAddr /* submit finality signature @@ -358,8 +358,10 @@ func (s *BTCStakingTestSuite) Test4WithdrawReward() { s.NoError(err) // finality provider balance before withdraw - fpBabylonAddr := sdk.AccAddress(nonValidatorNode.SecretKey.PubKey().Address().Bytes()) - delBabylonAddr := sdk.AccAddress(nonValidatorNode.SecretKey.PubKey().Address().Bytes()) + fpBabylonAddr, err := sdk.AccAddressFromBech32(cacheFP.Addr) + s.NoError(err) + delBabylonAddr := fpBabylonAddr + fpBalance, err := nonValidatorNode.QueryBalances(fpBabylonAddr.String()) s.NoError(err) // finality provider reward gauge should not be fully withdrawn diff --git a/test/e2e/btc_timestamping_e2e_test.go b/test/e2e/btc_timestamping_e2e_test.go index 6b8282311..8e985113d 100644 --- a/test/e2e/btc_timestamping_e2e_test.go +++ b/test/e2e/btc_timestamping_e2e_test.go @@ -38,7 +38,6 @@ func (s *BTCTimestampingTestSuite) SetupSuite() { // 3. Run IBC relayer between the two chains. // 4. Execute various e2e tests, including IBC s.configurer, err = configurer.NewBTCTimestampingConfigurer(s.T(), true) - s.Require().NoError(err) err = s.configurer.ConfigureChains() @@ -50,7 +49,9 @@ func (s *BTCTimestampingTestSuite) SetupSuite() { func (s *BTCTimestampingTestSuite) TearDownSuite() { err := s.configurer.ClearResources() - s.Require().NoError(err) + if err != nil { + s.T().Logf("error to clear resources %s", err.Error()) + } } // Most simple test, just checking that two chains are up and connected through diff --git a/test/e2e/configurer/chain/chain.go b/test/e2e/configurer/chain/chain.go index a6d92dc3f..fbf678fc6 100644 --- a/test/e2e/configurer/chain/chain.go +++ b/test/e2e/configurer/chain/chain.go @@ -1,11 +1,14 @@ package chain import ( + "encoding/hex" "fmt" - ibctesting "github.com/cosmos/ibc-go/v8/testing" + "strings" "testing" "time" + ibctesting "github.com/cosmos/ibc-go/v8/testing" + coretypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -13,6 +16,7 @@ import ( "github.com/babylonlabs-io/babylon/test/e2e/configurer/config" "github.com/babylonlabs-io/babylon/test/e2e/containers" "github.com/babylonlabs-io/babylon/test/e2e/initialization" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) type Config struct { @@ -27,6 +31,7 @@ type Config struct { LatestProposalNumber int LatestLockNumber int NodeConfigs []*NodeConfig + BTCHeaders []*btclighttypes.BTCHeaderInfo IBCConfig *ibctesting.ChannelConfig LatestCodeId int @@ -57,6 +62,7 @@ func New(t *testing.T, containerManager *containers.Manager, id string, initVali ExpeditedVotingPeriod: config.PropDepositBlocks + numVal*config.PropVoteBlocks + config.PropBufferBlocks - 2, t: t, containerManager: containerManager, + BTCHeaders: []*btclighttypes.BTCHeaderInfo{}, } } @@ -173,3 +179,20 @@ func (c *Config) GetNodeAtIndex(nodeIndex int) (*NodeConfig, error) { } return c.NodeConfigs[nodeIndex], nil } + +// BTCHeaderBytesHexJoined join all the btc headers as byte string hex +func (c *Config) BTCHeaderBytesHexJoined() string { + if c.BTCHeaders == nil || len(c.BTCHeaders) == 0 { + return "" + } + + strBtcHeaders := make([]string, len(c.BTCHeaders)) + for i, btcHeader := range c.BTCHeaders { + bz, err := btcHeader.Marshal() + if err != nil { + panic(err) + } + strBtcHeaders[i] = hex.EncodeToString(bz) + } + return strings.Join(strBtcHeaders, ",") +} diff --git a/test/e2e/configurer/chain/queries.go b/test/e2e/configurer/chain/queries.go index ff4ae0302..80a3d6b83 100644 --- a/test/e2e/configurer/chain/queries.go +++ b/test/e2e/configurer/chain/queries.go @@ -243,14 +243,14 @@ func (n *NodeConfig) QueryHeaderDepth(hash string) (uint64, error) { return blcResponse.Depth, nil } -func (n *NodeConfig) QueryListHeaders(chainID string, pagination *query.PageRequest) (*zctypes.QueryListHeadersResponse, error) { +func (n *NodeConfig) QueryListHeaders(consumerID string, pagination *query.PageRequest) (*zctypes.QueryListHeadersResponse, error) { queryParams := url.Values{} if pagination != nil { queryParams.Set("pagination.key", base64.URLEncoding.EncodeToString(pagination.Key)) queryParams.Set("pagination.limit", strconv.Itoa(int(pagination.Limit))) } - path := fmt.Sprintf("babylon/zoneconcierge/v1/headers/%s", chainID) + path := fmt.Sprintf("babylon/zoneconcierge/v1/headers/%s", consumerID) bz, err := n.QueryGRPCGateway(path, queryParams) require.NoError(n.t, err) @@ -262,10 +262,10 @@ func (n *NodeConfig) QueryListHeaders(chainID string, pagination *query.PageRequ return &resp, nil } -func (n *NodeConfig) QueryFinalizedChainsInfo(chainIDs []string) ([]*zctypes.FinalizedChainInfo, error) { +func (n *NodeConfig) QueryFinalizedChainsInfo(consumerIDs []string) ([]*zctypes.FinalizedChainInfo, error) { queryParams := url.Values{} - for _, chainId := range chainIDs { - queryParams.Add("chain_ids", chainId) + for _, consumerID := range consumerIDs { + queryParams.Add("chain_ids", consumerID) } bz, err := n.QueryGRPCGateway("babylon/zoneconcierge/v1/finalized_chains_info", queryParams) @@ -279,11 +279,11 @@ func (n *NodeConfig) QueryFinalizedChainsInfo(chainIDs []string) ([]*zctypes.Fin return resp.FinalizedChainsInfo, nil } -func (n *NodeConfig) QueryEpochChainsInfo(epochNum uint64, chainIDs []string) ([]*zctypes.ChainInfo, error) { +func (n *NodeConfig) QueryEpochChainsInfo(epochNum uint64, consumerIDs []string) ([]*zctypes.ChainInfo, error) { queryParams := url.Values{} - for _, chainId := range chainIDs { + for _, consumerID := range consumerIDs { queryParams.Add("epoch_num", fmt.Sprintf("%d", epochNum)) - queryParams.Add("chain_ids", chainId) + queryParams.Add("chain_ids", consumerID) } bz, err := n.QueryGRPCGateway("babylon/zoneconcierge/v1/epoch_chains_info", queryParams) @@ -307,10 +307,10 @@ func (n *NodeConfig) QueryChains() (*[]string, error) { return &chainsResponse.ChainIds, nil } -func (n *NodeConfig) QueryChainsInfo(chainIDs []string) ([]*zctypes.ChainInfo, error) { +func (n *NodeConfig) QueryChainsInfo(consumerIDs []string) ([]*zctypes.ChainInfo, error) { queryParams := url.Values{} - for _, chainId := range chainIDs { - queryParams.Add("chain_ids", chainId) + for _, consumerId := range consumerIDs { + queryParams.Add("chain_ids", consumerId) } bz, err := n.QueryGRPCGateway("/babylon/zoneconcierge/v1/chains_info", queryParams) diff --git a/test/e2e/configurer/current.go b/test/e2e/configurer/current.go index ca2c26ae6..8888e78af 100644 --- a/test/e2e/configurer/current.go +++ b/test/e2e/configurer/current.go @@ -51,7 +51,10 @@ func (cb *CurrentBranchConfigurer) ConfigureChain(chainConfig *chain.Config) err tmpDir, chainConfig.ValidatorInitConfigs, time.Duration(chainConfig.VotingPeriod*1000000000), - time.Duration(chainConfig.ExpeditedVotingPeriod*1000000000), 0) + time.Duration(chainConfig.ExpeditedVotingPeriod*1000000000), + 0, + chainConfig.BTCHeaders, + ) if err != nil { return err } diff --git a/test/e2e/initialization/chain/main.go b/test/e2e/initialization/chain/main.go index 6d22e8e78..9f251c9f9 100644 --- a/test/e2e/initialization/chain/main.go +++ b/test/e2e/initialization/chain/main.go @@ -1,13 +1,16 @@ package main import ( + "encoding/hex" "encoding/json" "flag" "fmt" "os" + "strings" "time" "github.com/babylonlabs-io/babylon/test/e2e/initialization" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) func main() { @@ -16,6 +19,7 @@ func main() { dataDir string chainId string config string + btcHeadersBytesHexStr string votingPeriod time.Duration expeditedVotingPeriod time.Duration forkHeight int @@ -24,6 +28,7 @@ func main() { flag.StringVar(&dataDir, "data-dir", "", "chain data directory") flag.StringVar(&chainId, "chain-id", "", "chain ID") flag.StringVar(&config, "config", "", "serialized config") + flag.StringVar(&btcHeadersBytesHexStr, "btc-headers", "", "btc header bytes comma separated") flag.DurationVar(&votingPeriod, "voting-period", 30000000000, "voting period") flag.DurationVar(&expeditedVotingPeriod, "expedited-voting-period", 20000000000, "expedited voting period") flag.IntVar(&forkHeight, "fork-height", 0, "fork height") @@ -43,7 +48,8 @@ func main() { panic(err) } - createdChain, err := initialization.InitChain(chainId, dataDir, valConfig, votingPeriod, expeditedVotingPeriod, forkHeight) + btcHeaders := btcHeaderFromFlag(btcHeadersBytesHexStr) + createdChain, err := initialization.InitChain(chainId, dataDir, valConfig, votingPeriod, expeditedVotingPeriod, forkHeight, btcHeaders) if err != nil { panic(err) } @@ -54,3 +60,27 @@ func main() { panic(err) } } + +func btcHeaderFromFlag(btcHeadersBytesHexStr string) []*btclighttypes.BTCHeaderInfo { + btcHeaders := []*btclighttypes.BTCHeaderInfo{} + if len(btcHeadersBytesHexStr) == 0 { + return btcHeaders + } + + btcHeadersBytesHex := strings.Split(btcHeadersBytesHexStr, ",") + for _, btcHeaderBytesHex := range btcHeadersBytesHex { + btcHeaderBytes, err := hex.DecodeString(btcHeaderBytesHex) + if err != nil { + panic(err) + } + + btcHeader := &btclighttypes.BTCHeaderInfo{} + err = btcHeader.Unmarshal(btcHeaderBytes) + if err != nil { + panic(err) + } + + btcHeaders = append(btcHeaders, btcHeader) + } + return btcHeaders +} diff --git a/test/e2e/initialization/config.go b/test/e2e/initialization/config.go index 3e7119ae0..cb074552d 100644 --- a/test/e2e/initialization/config.go +++ b/test/e2e/initialization/config.go @@ -6,7 +6,7 @@ import ( "path/filepath" "time" - "cosmossdk.io/math" + sdkmath "cosmossdk.io/math" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -17,6 +17,8 @@ import ( crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" staketypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/cosmos/gogoproto/proto" @@ -25,6 +27,7 @@ import ( bbn "github.com/babylonlabs-io/babylon/types" btccheckpointtypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types" blctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" checkpointingtypes "github.com/babylonlabs-io/babylon/x/checkpointing/types" "github.com/babylonlabs-io/babylon/test/e2e/util" @@ -67,9 +70,9 @@ const ( ) var ( - StakeAmountIntA = math.NewInt(StakeAmountA) + StakeAmountIntA = sdkmath.NewInt(StakeAmountA) StakeAmountCoinA = sdk.NewCoin(BabylonDenom, StakeAmountIntA) - StakeAmountIntB = math.NewInt(StakeAmountB) + StakeAmountIntB = sdkmath.NewInt(StakeAmountB) StakeAmountCoinB = sdk.NewCoin(BabylonDenom, StakeAmountIntB) InitBalanceStrA = fmt.Sprintf("%d%s", BabylonBalanceA, BabylonDenom) @@ -166,7 +169,12 @@ func updateModuleGenesis[V proto.Message](appGenState map[string]json.RawMessage return nil } -func initGenesis(chain *internalChain, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) error { +func initGenesis( + chain *internalChain, + votingPeriod, expeditedVotingPeriod time.Duration, + forkHeight int, + btcHeaders []*btclighttypes.BTCHeaderInfo, +) error { // initialize a genesis file configDir := chain.nodes[0].configDir() @@ -216,6 +224,11 @@ func initGenesis(chain *internalChain, votingPeriod, expeditedVotingPeriod time. return err } + err = updateModuleGenesis(appGenState, govtypes.ModuleName, &govv1.GenesisState{}, updateGovGenesis(votingPeriod, expeditedVotingPeriod)) + if err != nil { + return err + } + err = updateModuleGenesis(appGenState, minttypes.ModuleName, &minttypes.GenesisState{}, updateMintGenesis) if err != nil { return err @@ -241,7 +254,7 @@ func initGenesis(chain *internalChain, votingPeriod, expeditedVotingPeriod time. return err } - err = updateModuleGenesis(appGenState, blctypes.ModuleName, blctypes.DefaultGenesis(), updateBtcLightClientGenesis) + err = updateModuleGenesis(appGenState, blctypes.ModuleName, blctypes.DefaultGenesis(), updateBtcLightClientGenesis(btcHeaders)) if err != nil { return err } @@ -288,6 +301,14 @@ func updateBankGenesis(bankGenState *banktypes.GenesisState) { }) } +func updateGovGenesis(votingPeriod, expeditedVotingPeriod time.Duration) func(govGenState *govv1.GenesisState) { + return func(govGenState *govv1.GenesisState) { + govGenState.Params.MinDeposit = sdk.NewCoins(sdk.NewCoin(BabylonDenom, sdkmath.NewInt(100))) + govGenState.Params.VotingPeriod = &votingPeriod + govGenState.Params.ExpeditedVotingPeriod = &expeditedVotingPeriod + } +} + func updateMintGenesis(mintGenState *minttypes.GenesisState) { mintGenState.Params.MintDenom = BabylonDenom } @@ -299,7 +320,7 @@ func updateStakeGenesis(stakeGenState *staketypes.GenesisState) { MaxEntries: 7, HistoricalEntries: 10000, UnbondingTime: staketypes.DefaultUnbondingTime, - MinCommissionRate: math.LegacyZeroDec(), + MinCommissionRate: sdkmath.LegacyZeroDec(), } } @@ -307,14 +328,21 @@ func updateCrisisGenesis(crisisGenState *crisistypes.GenesisState) { crisisGenState.ConstantFee.Denom = BabylonDenom } -func updateBtcLightClientGenesis(blcGenState *blctypes.GenesisState) { - btcSimnetGenesisHex := "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000" - baseBtcHeader, err := bbn.NewBTCHeaderBytesFromHex(btcSimnetGenesisHex) - if err != nil { - panic(err) +func updateBtcLightClientGenesis(btcHeaders []*btclighttypes.BTCHeaderInfo) func(blcGenState *blctypes.GenesisState) { + return func(blcGenState *btclighttypes.GenesisState) { + if len(btcHeaders) > 0 { + blcGenState.BtcHeaders = btcHeaders + return + } + + btcSimnetGenesisHex := "0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a45068653ffff7f2002000000" + baseBtcHeader, err := bbn.NewBTCHeaderBytesFromHex(btcSimnetGenesisHex) + if err != nil { + panic(err) + } + work := blctypes.CalcWork(&baseBtcHeader) + blcGenState.BtcHeaders = []*blctypes.BTCHeaderInfo{blctypes.NewBTCHeaderInfo(&baseBtcHeader, baseBtcHeader.Hash(), 0, &work)} } - work := blctypes.CalcWork(&baseBtcHeader) - blcGenState.BtcHeaders = []*blctypes.BTCHeaderInfo{blctypes.NewBTCHeaderInfo(&baseBtcHeader, baseBtcHeader.Hash(), 0, &work)} } func updateBtccheckpointGenesis(btccheckpointGenState *btccheckpointtypes.GenesisState) { diff --git a/test/e2e/initialization/export.go b/test/e2e/initialization/export.go index 663250876..ebe2c2522 100644 --- a/test/e2e/initialization/export.go +++ b/test/e2e/initialization/export.go @@ -2,8 +2,6 @@ package initialization import ( "fmt" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" ) type ChainMeta struct { @@ -17,7 +15,6 @@ type Node struct { Mnemonic string `json:"mnemonic"` PublicAddress string `json:"publicAddress"` WalletName string `json:"walletName"` - SecretKey cryptotypes.PrivKey PublicKey []byte `json:"publicKey"` PeerId string `json:"peerId"` IsValidator bool `json:"isValidator"` diff --git a/test/e2e/initialization/init.go b/test/e2e/initialization/init.go index 94e8ca3e5..af3b9e7bb 100644 --- a/test/e2e/initialization/init.go +++ b/test/e2e/initialization/init.go @@ -8,9 +8,16 @@ import ( appkeepers "github.com/babylonlabs-io/babylon/app/keepers" "github.com/babylonlabs-io/babylon/test/e2e/util" + btclighttypes "github.com/babylonlabs-io/babylon/x/btclightclient/types" ) -func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expeditedVotingPeriod time.Duration, forkHeight int) (*Chain, error) { +func InitChain( + id, dataDir string, + nodeConfigs []*NodeConfig, + votingPeriod, expeditedVotingPeriod time.Duration, + forkHeight int, + btcHeaders []*btclighttypes.BTCHeaderInfo, +) (*Chain, error) { chain, err := new(id, dataDir) if err != nil { return nil, err @@ -24,7 +31,7 @@ func InitChain(id, dataDir string, nodeConfigs []*NodeConfig, votingPeriod, expe chain.nodes = append(chain.nodes, newNode) } - if err := initGenesis(chain, votingPeriod, expeditedVotingPeriod, forkHeight); err != nil { + if err := initGenesis(chain, votingPeriod, expeditedVotingPeriod, forkHeight, btcHeaders); err != nil { return nil, err } diff --git a/test/e2e/initialization/init_test.go b/test/e2e/initialization/init_test.go index 8d21b1b4d..a4ba49dab 100644 --- a/test/e2e/initialization/init_test.go +++ b/test/e2e/initialization/init_test.go @@ -51,7 +51,7 @@ func TestChainInit(t *testing.T) { dataDir, err = os.MkdirTemp("", "bbn-e2e-testnet-test") ) - chain, err := initialization.InitChain(id, dataDir, nodeConfigs, time.Second*3, time.Second, forkHeight) + chain, err := initialization.InitChain(id, dataDir, nodeConfigs, time.Second*3, time.Second, forkHeight, nil) require.NoError(t, err) require.Equal(t, chain.ChainMeta.DataDir, dataDir) @@ -109,7 +109,7 @@ func TestSingleNodeInit(t *testing.T) { ) // Setup - existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, time.Second, forkHeight) + existingChain, err := initialization.InitChain(id, dataDir, existingChainNodeConfigs, time.Second*3, time.Second, forkHeight, nil) require.NoError(t, err) actualNode, err := initialization.InitSingleNode(existingChain.ChainMeta.Id, dataDir, filepath.Join(existingChain.Nodes[0].ConfigDir, "config", "genesis.json"), expectedConfig, time.Second*3, 3, "testHash", []string{"some server"}, []string{"some server"}) diff --git a/test/e2e/initialization/node.go b/test/e2e/initialization/node.go index 4346e7b31..17eddb24d 100644 --- a/test/e2e/initialization/node.go +++ b/test/e2e/initialization/node.go @@ -248,7 +248,6 @@ func (n *internalNode) export() *Node { Mnemonic: n.mnemonic, PublicAddress: addr.String(), WalletName: n.keyInfo.Name, - SecretKey: n.privateKey, PublicKey: pub.Bytes(), PeerId: n.peerId, IsValidator: n.isValidator,