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

refactor: migrate crosschain keeper #829

Merged
merged 33 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
27f981b
add proto file for crosschain events
kingpinXD Jul 13, 2023
6a18920
add proto file for observer and emission events
kingpinXD Jul 13, 2023
6aa735f
remove unnecessary print lines
kingpinXD Jul 13, 2023
21c97ed
Merge branch 'develop' into refactor/typed-events
kingpinXD Jul 13, 2023
ea1123f
move node account from x/crosschain to x/observer
kingpinXD Jul 13, 2023
afd5d69
cli tests for observer module
kingpinXD Jul 14, 2023
945b468
resolve conflicts for status.go
kingpinXD Jul 17, 2023
7437fbe
add ignore annotations for gosec
kingpinXD Jul 18, 2023
4560925
add ignore annotations for gosec
kingpinXD Jul 18, 2023
6939020
move permission flags to observer module
kingpinXD Jul 18, 2023
4b631c5
add cli tests for permission_flags
kingpinXD Jul 19, 2023
2cd7092
add last block count
kingpinXD Jul 19, 2023
469bae5
move keygen to observer module
kingpinXD Jul 19, 2023
b29814e
remove extra proto files
kingpinXD Jul 19, 2023
09ee703
modify makefile to remove old types
kingpinXD Jul 19, 2023
054cc1b
fix unit tests for keygen
kingpinXD Jul 19, 2023
253175b
add modifying keygen to Begin Block
kingpinXD Jul 20, 2023
262f65e
add modifying keygen to Begin Block
kingpinXD Jul 20, 2023
b1d03f1
add migrator for node accounts in v6.0.0
kingpinXD Jul 20, 2023
a9f7641
add migrator for keygen and permission flags in v6.0.0
kingpinXD Jul 20, 2023
2a69338
modify consensus version in version map to trigger migration function
kingpinXD Jul 20, 2023
e5b3ce9
add log lines to explain migration
kingpinXD Jul 20, 2023
9782bf1
Set value for last block height count
kingpinXD Jul 20, 2023
c0d104d
add early return if LastBlockHeight count is not found
kingpinXD Jul 20, 2023
1cf887d
reset lasBlock observer count on on change in value
kingpinXD Jul 21, 2023
967e8dd
reset lasBlock observer count on on change in value
kingpinXD Jul 21, 2023
a04ae76
Add grpc query for last observer count
kingpinXD Jul 21, 2023
6e2c6df
rebase develop to merge changes for typed events
kingpinXD Jul 21, 2023
452206c
fix errors due to types in inbound voter
kingpinXD Jul 21, 2023
5c4637e
increment to version 7
kingpinXD Jul 21, 2023
7eadeaf
rebase develop to add blame logic to observer module
kingpinXD Jul 24, 2023
b9532f7
Merge branch 'develop' into refactor/migrate-crosschain-keeper
kingpinXD Jul 25, 2023
35ee847
Merge branch 'develop' into refactor/migrate-crosschain-keeper
kingpinXD Jul 25, 2023
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
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ coverage-report: test-coverage
clean-test-dir:
@rm -rf x/crosschain/client/integrationtests/.zetacored
@rm -rf x/crosschain/client/querytests/.zetacored
@rm -rf x/observer/client/querytests/.zetacored

run-test:
@go test ${TEST_BUILD_FLAGS} ${TEST_DIR}
Expand Down Expand Up @@ -130,10 +131,13 @@ lint: lint-pre
@golangci-lint run

proto:
@echo "--> Generating Go from protocol buffer files"
@echo "--> Removing old Go types "
@find . -name '*.pb.go' -type f -delete
@echo "--> Generating new Go types from protocol buffer files"
@bash ./scripts/protoc-gen-go.sh
@echo "--> Generating OpenAPI specs"
@bash ./scripts/protoc-gen-openapi.sh

.PHONY: proto

specs:
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app

import (
zetaCoreModuleKeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
"time"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -102,7 +103,6 @@ import (

// this line is used by starport scaffolding # stargate/app/moduleImport
zetaCoreModule "github.com/zeta-chain/zetacore/x/crosschain"
zetaCoreModuleKeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
zetaCoreModuleTypes "github.com/zeta-chain/zetacore/x/crosschain/types"

emissionsModule "github.com/zeta-chain/zetacore/x/emissions"
Expand Down
6 changes: 5 additions & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
)

const releaseVersion = "v6.0.0"
const releaseVersion = "v7.0.0"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + releaseVersion)

// Updated version map to thelatest consensus versions from each module
for m, mb := range app.mm.Modules {
vm[m] = mb.ConsensusVersion()
}

// Decrement the consensus version of the cross chain module to trigger the migration v1 -> v2
vm[crosschaintypes.ModuleName] = vm[crosschaintypes.ModuleName] - 1
return app.mm.RunMigrations(ctx, app.configurator, vm)
})

Expand Down
8 changes: 4 additions & 4 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/rs/zerolog"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/zeta-chain/zetacore/common"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
mc "github.com/zeta-chain/zetacore/zetaclient"
"github.com/zeta-chain/zetacore/zetaclient/config"
tsscommon "gitlab.com/thorchain/tss/go-tss/common"
Expand Down Expand Up @@ -38,17 +38,17 @@ func GenerateTss(logger zerolog.Logger, cfg *config.Config, zetaBridge *mc.ZetaC
// This loop will try keygen at the keygen block and then wait for keygen to be successfully reported by all nodes before breaking out of the loop.
// If keygen is unsuccessful , it will reset the triedKeygenAtBlock flag and try again at a new keygen block.

if cfg.Keygen.Status == crosschaintypes.KeygenStatus_KeyGenSuccess {
if cfg.Keygen.Status == observerTypes.KeygenStatus_KeyGenSuccess {
cfg.TestTssKeysign = true
return tss, nil
}
// Arrive at this stage only if keygen is unsuccessfully reported by every node . This will reset the flag and to try again at a new keygen block
if cfg.Keygen.Status == crosschaintypes.KeygenStatus_KeyGenFailed {
if cfg.Keygen.Status == observerTypes.KeygenStatus_KeyGenFailed {
triedKeygenAtBlock = false
continue
}
// Try generating TSS at keygen block , only when status is pending keygen and generation has not been tried at the block
if cfg.Keygen.Status == crosschaintypes.KeygenStatus_PendingKeygen {
if cfg.Keygen.Status == observerTypes.KeygenStatus_PendingKeygen {
// Return error if RPC is not working
currentBlock, err := zetaBridge.GetZetaBlockHeight()
if err != nil {
Expand Down
26 changes: 13 additions & 13 deletions cmd/zetacored/observer_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func AddObserverAccountsCmd() *cobra.Command {
}
var observerMapper []*types.ObserverMapper
var grantAuthorizations []authz.GrantAuthorization
var nodeAccounts []*crosschaintypes.NodeAccount
var nodeAccounts []*types.NodeAccount
var keygenPubKeys []string
observersForChain := map[int64][]string{}
// DefaultChainsList is based on Build Flags
Expand Down Expand Up @@ -121,11 +121,11 @@ func AddObserverAccountsCmd() *cobra.Command {
Secp256k1: pubkey,
Ed25519: "",
}
na := crosschaintypes.NodeAccount{
na := types.NodeAccount{
Operator: info.ObserverAddress,
GranteeAddress: info.ZetaClientGranteeAddress,
GranteePubkey: &pubkeySet,
NodeStatus: crosschaintypes.NodeStatus_Active,
NodeStatus: types.NodeStatus_Active,
}
nodeAccounts = append(nodeAccounts, &na)
}
Expand Down Expand Up @@ -156,16 +156,6 @@ func AddObserverAccountsCmd() *cobra.Command {

// Add node accounts to cross chain genesis state
zetaCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, appState)
zetaCrossChainGenState.NodeAccountList = nodeAccounts
keyGenStatus := crosschaintypes.KeygenStatus_PendingKeygen
if keyGenBlock == 0 {
keyGenStatus = crosschaintypes.KeygenStatus_KeyGenSuccess
}
zetaCrossChainGenState.Keygen = &crosschaintypes.Keygen{
Status: keyGenStatus,
GranteePubkeys: keygenPubKeys,
BlockNumber: keyGenBlock,
}

if keyGenBlock == 0 {
operatorList := make([]string, len(nodeAccounts))
Expand All @@ -185,6 +175,16 @@ func AddObserverAccountsCmd() *cobra.Command {
// Add observers to observer genesis state
zetaObserverGenState := types.GetGenesisStateFromAppState(cdc, appState)
zetaObserverGenState.Observers = observerMapper
zetaObserverGenState.NodeAccountList = nodeAccounts
keyGenStatus := types.KeygenStatus_PendingKeygen
if keyGenBlock == 0 {
keyGenStatus = types.KeygenStatus_KeyGenSuccess
}
zetaObserverGenState.Keygen = &types.Keygen{
Status: keyGenStatus,
GranteePubkeys: keygenPubKeys,
BlockNumber: keyGenBlock,
}

// Add grant authorizations to authz genesis state
var authzGenState authz.GenesisState
Expand Down
Loading
Loading