Skip to content

Commit

Permalink
Merge branch 'develop' into defensive-rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
brewmaster012 authored Jul 25, 2023
2 parents 1e2146a + acca420 commit aac8a5f
Show file tree
Hide file tree
Showing 114 changed files with 6,871 additions and 7,768 deletions.
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

0 comments on commit aac8a5f

Please sign in to comment.