Skip to content

Commit

Permalink
Merge branch 'develop' into custom-mempool-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito authored May 20, 2024
2 parents 990af2c + 47c8205 commit 3ca41f3
Show file tree
Hide file tree
Showing 322 changed files with 9,944 additions and 8,169 deletions.
8 changes: 4 additions & 4 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
}
switch innerMsg.(type) {
case *crosschaintypes.MsgVoteGasPrice,
*crosschaintypes.MsgVoteOnObservedInboundTx,
*crosschaintypes.MsgVoteOnObservedOutboundTx,
*crosschaintypes.MsgAddToOutTxTracker,
*crosschaintypes.MsgAddToInTxTracker,
*crosschaintypes.MsgVoteOutbound,
*crosschaintypes.MsgVoteInbound,
*crosschaintypes.MsgAddOutboundTracker,
*crosschaintypes.MsgAddInboundTracker,
*observertypes.MsgVoteBlockHeader,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlameVote:
Expand Down
40 changes: 20 additions & 20 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ func (mah *MockAnteHandler) AnteHandle(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.C
func TestIsSystemTx(t *testing.T) {
// system tx types:
// *cctxtypes.MsgVoteGasPrice,
// *cctxtypes.MsgVoteOnObservedInboundTx,
// *cctxtypes.MsgVoteOnObservedOutboundTx,
// *cctxtypes.MsgAddToOutTxTracker,
// *cctxtypes.MsgAddToInTxTracker,
// *cctxtypes.MsgVoteInbound,
// *cctxtypes.MsgVoteOutbound,
// *cctxtypes.MsgAddOutboundTracker,
// *cctxtypes.MsgAddInboundTracker,
// *observertypes.MsgVoteBlockHeader,
// *observertypes.MsgVoteTSS,
// *observertypes.MsgAddBlameVote:
Expand Down Expand Up @@ -115,17 +115,17 @@ func TestIsSystemTx(t *testing.T) {
},

{
"MsgVoteOnObservedInboundTx",
buildTxFromMsg(&crosschaintypes.MsgVoteOnObservedInboundTx{
"MsgVoteInbound",
buildTxFromMsg(&crosschaintypes.MsgVoteInbound{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgVoteOnObservedInboundTx}",
buildAuthzTxFromMsg(&crosschaintypes.MsgVoteOnObservedInboundTx{
"MsgExec{MsgVoteInbound}",
buildAuthzTxFromMsg(&crosschaintypes.MsgVoteInbound{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand All @@ -134,53 +134,53 @@ func TestIsSystemTx(t *testing.T) {
},

{
"MsgVoteOnObservedOutboundTx",
buildTxFromMsg(&crosschaintypes.MsgVoteOnObservedOutboundTx{
"MsgVoteOutbound",
buildTxFromMsg(&crosschaintypes.MsgVoteOutbound{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgVoteOnObservedOutboundTx}",
buildAuthzTxFromMsg(&crosschaintypes.MsgVoteOnObservedOutboundTx{
"MsgExec{MsgVoteOutbound}",
buildAuthzTxFromMsg(&crosschaintypes.MsgVoteOutbound{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgAddToOutTxTracker",
buildTxFromMsg(&crosschaintypes.MsgAddToOutTxTracker{
"MsgAddOutboundTracker",
buildTxFromMsg(&crosschaintypes.MsgAddOutboundTracker{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgAddToOutTxTracker}",
buildAuthzTxFromMsg(&crosschaintypes.MsgAddToOutTxTracker{
"MsgExec{MsgAddOutboundTracker}",
buildAuthzTxFromMsg(&crosschaintypes.MsgAddOutboundTracker{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgAddToInTxTracker",
buildTxFromMsg(&crosschaintypes.MsgAddToInTxTracker{
"MsgAddInboundTracker",
buildTxFromMsg(&crosschaintypes.MsgAddInboundTracker{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgAddToInTxTracker}",
buildAuthzTxFromMsg(&crosschaintypes.MsgAddToInTxTracker{
"MsgExec{MsgAddInboundTracker}",
buildAuthzTxFromMsg(&crosschaintypes.MsgAddInboundTracker{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand Down
8 changes: 4 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# CHANGELOG

## Unreleased

### Breaking Changes
* `MsgUpdateVerificationFlags` has been removed, and replaced with `MsgEnableHeaderVerification` and `MsgDisableHeaderVerification` messages.
* `MsgEnableHeaderVerification` message enables block header verification for a list of chains and can be triggered via `PolicyType_groupOperational`
* `MsgDisableHeaderVerification` message disables block header verification for a list of chains and can be triggered via `PolicyType_emergency`
* Observer param `ballot_maturity_blocks` is part of `emissions` module now. Observer `params` are deprecated and removed from `observer` module.

* [List of the breaking changes can be found in this document](docs/releases/v17_breaking_changes.md)

### Features

Expand All @@ -24,6 +23,7 @@
* [2032](https://github.com/zeta-chain/node/pull/2032) - improve some general structure of the ZetaClient codebase
* [2097](https://github.com/zeta-chain/node/pull/2097) - refactor lightclient verification flags to account for individual chains
* [2071](https://github.com/zeta-chain/node/pull/2071) - Modify chains struct to add all chain related information
* [2118](https://github.com/zeta-chain/node/pull/2118) - consolidate inbound and outbound naming
* [2124](https://github.com/zeta-chain/node/pull/2124) - removed unused variables and method
* [2150](https://github.com/zeta-chain/node/pull/2150) - created `chains` `zetacore` `orchestrator` packages in zetaclient and reorganized source files accordingly.
* [2205](https://github.com/zeta-chain/node/pull/2205) - remove deprecated variables pre-v17
Expand Down
10 changes: 5 additions & 5 deletions cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func init() {

func DebugCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "get-ballot-from-intx [txHash] [chainID]",
Use: "get-inbound-ballot [inboundHash] [chainID]",
Short: "provide txHash and chainID to get the ballot status for the txHash",
RunE: func(_ *cobra.Command, args []string) error {
cobra.ExactArgs(2)
Expand All @@ -58,7 +58,7 @@ func DebugCmd() *cobra.Command {
if err != nil {
return err
}
txHash := args[0]
inboundHash := args[0]
var ballotIdentifier string
chainLogger := zerolog.New(io.Discard).Level(zerolog.Disabled)

Expand Down Expand Up @@ -117,8 +117,8 @@ func DebugCmd() *cobra.Command {
evmObserver.WithChain(*chains.GetChainFromChainID(chainID))
}
}
hash := ethcommon.HexToHash(txHash)
tx, isPending, err := evmObserver.TransactionByHash(txHash)
hash := ethcommon.HexToHash(inboundHash)
tx, isPending, err := evmObserver.TransactionByHash(inboundHash)
if err != nil {
return fmt.Errorf("tx not found on chain %s , %d", err.Error(), chain.ChainId)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func DebugCmd() *cobra.Command {
return err
}
btcObserver.WithBtcClient(btcClient)
ballotIdentifier, err = btcObserver.CheckReceiptForBtcTxHash(txHash, false)
ballotIdentifier, err = btcObserver.CheckReceiptForBtcTxHash(inboundHash, false)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const (
tssPubKey = "tss-pubkey"
)

func AddObserverAccountsCmd() *cobra.Command {
func AddObserverListCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add-observer-list [observer-list.json] ",
Short: "Add a list of observers to the observer mapper ,default path is ~/.zetacored/os_info/observer_info.json",
Expand All @@ -56,22 +56,27 @@ func AddObserverAccountsCmd() *cobra.Command {
if len(args) == 0 {
args = append(args, defaultFile)
}

keyGenBlock, err := cmd.Flags().GetInt64(keygenBlock)
if err != nil {
return err
}

tssPubkey, err := cmd.Flags().GetString(tssPubKey)
if err != nil {
return err
}

if keyGenBlock == 0 && tssPubkey == "" {
panic("TSS pubkey is required if keygen block is set to 0")
}

file := args[0]
observerInfo, err := ParsefileToObserverDetails(file)
if err != nil {
return err
}

var observerSet types.ObserverSet
var grantAuthorizations []authz.GrantAuthorization
var nodeAccounts []*types.NodeAccount
Expand All @@ -82,14 +87,17 @@ func AddObserverAccountsCmd() *cobra.Command {
if !ok {
panic("Failed to parse string to int for observer")
}

hotkeyTokens, ok := sdk.NewIntFromString(HotkeyTokens)
if !ok {
panic("Failed to parse string to int for hotkey")
}

observerTokens, ok := sdk.NewIntFromString(ObserverTokens)
if !ok {
panic("Failed to parse string to int for hotkey")
}

ValidatorBalance := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, validatorTokens))
HotkeyBalance := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, hotkeyTokens))
ObserverBalance := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, observerTokens))
Expand Down Expand Up @@ -119,6 +127,7 @@ func AddObserverAccountsCmd() *cobra.Command {
if err != nil {
panic(err)
}

pubkeySet := crypto.PubKeySet{
Secp256k1: pubkey,
Ed25519: "",
Expand Down Expand Up @@ -161,6 +170,7 @@ func AddObserverAccountsCmd() *cobra.Command {
KeyGenZetaHeight: 0,
}
}

observerSet.ObserverList = removeDuplicate(observerSet.ObserverList)
// Add observers to observer genesis state
zetaObserverGenState := types.GetGenesisStateFromAppState(cdc, appState)
Expand Down Expand Up @@ -193,25 +203,30 @@ func AddObserverAccountsCmd() *cobra.Command {
if err != nil {
return fmt.Errorf("failed to marshal Observer List into Genesis File: %w", err)
}

zetaObserverStateBz, err := json.Marshal(zetaObserverGenState)
if err != nil {
return fmt.Errorf("failed to marshal Observer List into Genesis File: %w", err)
}

err = codectypes.UnpackInterfaces(authzGenState, cdc)
if err != nil {
return fmt.Errorf("failed to authz grants into upackeder: %w", err)
}

authZStateBz, err := cdc.MarshalJSON(&authzGenState)
if err != nil {
return fmt.Errorf("failed to authz grants into Genesis File: %w", err)
}

appState[types.ModuleName] = zetaObserverStateBz
appState[authz.ModuleName] = authZStateBz
appState[crosschaintypes.ModuleName] = zetaCrossChainStateBz
modifiedAppState, err := AddGenesisAccount(clientCtx, balances, appState)
if err != nil {
panic(err)
}

// Create new genesis file
appStateJSON, err := json.Marshal(modifiedAppState)
if err != nil {
Expand All @@ -225,6 +240,7 @@ func AddObserverAccountsCmd() *cobra.Command {
}
cmd.Flags().Int64(keygenBlock, 20, "set keygen block , default is 20")
cmd.Flags().String(tssPubKey, "", "set TSS pubkey if using older keygen")

return cmd
}

Expand Down Expand Up @@ -278,11 +294,11 @@ func addZetaClientGrants(grants []authz.GrantAuthorization, info ObserverInfoRea
Expiration: nil,
})
}

return grants
}

func addGovGrants(grants []authz.GrantAuthorization, info ObserverInfoReader) []authz.GrantAuthorization {

txTypes := []string{sdk.MsgTypeURL(&v1beta1.MsgVote{}),
sdk.MsgTypeURL(&v1beta1.MsgSubmitProposal{}),
sdk.MsgTypeURL(&v1beta1.MsgDeposit{}),
Expand All @@ -292,6 +308,7 @@ func addGovGrants(grants []authz.GrantAuthorization, info ObserverInfoReader) []
sdk.MsgTypeURL(&v1.MsgDeposit{}),
sdk.MsgTypeURL(&v1.MsgVoteWeighted{}),
}

for _, txType := range txTypes {
auth, err := codectypes.NewAnyWithValue(authz.NewGenericAuthorization(txType))
if err != nil {
Expand All @@ -304,6 +321,7 @@ func addGovGrants(grants []authz.GrantAuthorization, info ObserverInfoReader) []
Expiration: nil,
})
}

return grants
}

Expand Down Expand Up @@ -332,6 +350,7 @@ func addStakingGrants(grants []authz.GrantAuthorization, info ObserverInfoReader
if !ok {
panic("Failed to parse staking max tokens")
}

alllowList := stakingtypes.StakeAuthorization_AllowList{AllowList: &stakingtypes.StakeAuthorization_Validators{Address: info.StakingValidatorAllowList}}

stakingAuth, err := codectypes.NewAnyWithValue(&stakingtypes.StakeAuthorization{
Expand All @@ -342,6 +361,7 @@ func addStakingGrants(grants []authz.GrantAuthorization, info ObserverInfoReader
if err != nil {
panic(err)
}

grants = append(grants, authz.GrantAuthorization{
Granter: info.ObserverAddress,
Grantee: info.StakingGranteeAddress,
Expand All @@ -356,6 +376,7 @@ func addStakingGrants(grants []authz.GrantAuthorization, info ObserverInfoReader
if err != nil {
panic(err)
}

grants = append(grants, authz.GrantAuthorization{
Granter: info.ObserverAddress,
Grantee: info.StakingGranteeAddress,
Expand All @@ -370,12 +391,14 @@ func addStakingGrants(grants []authz.GrantAuthorization, info ObserverInfoReader
if err != nil {
panic(err)
}

grants = append(grants, authz.GrantAuthorization{
Granter: info.ObserverAddress,
Grantee: info.StakingGranteeAddress,
Authorization: reDelauth,
Expiration: nil,
})

return grants

}
Expand Down Expand Up @@ -418,12 +441,14 @@ func AddGenesisAccount(clientCtx client.Context, balances []banktypes.Balance, a
if err != nil {
return appState, fmt.Errorf("failed to convert accounts into any's: %w", err)
}

authGenState.Accounts = genAccs

authGenStateBz, err := clientCtx.Codec.MarshalJSON(&authGenState)
if err != nil {
return appState, fmt.Errorf("failed to marshal auth genesis state: %w", err)
}

appState[authtypes.ModuleName] = authGenStateBz
bankGenState := banktypes.GetGenesisStateFromAppState(clientCtx.Codec, appState)
bankGenState.Balances = append(bankGenState.Balances, balances...)
Expand All @@ -434,6 +459,7 @@ func AddGenesisAccount(clientCtx client.Context, balances []banktypes.Balance, a
if err != nil {
return appState, fmt.Errorf("failed to marshal bank genesis state: %w", err)
}

appState[banktypes.ModuleName] = bankGenStateBz

return appState, nil
Expand All @@ -445,5 +471,6 @@ func isValidatorOnly(isObserver string) bool {
} else if isObserver == "n" {
return true
}

panic("Invalid Input for isObserver field, Check observer_info.json file")
}
2 changes: 1 addition & 1 deletion cmd/zetacored/collect_observer_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func CollectObserverInfoCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "collect-observer-info [folder]",
Short: "collect observer info from a folder , default path is ~/.zetacored/os_info/ \n",
Short: "collect observer info into the genesis from a folder , default path is ~/.zetacored/os_info/ \n",
Args: cobra.MaximumNArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
defaultHome := app.DefaultNodeHome
Expand Down
Loading

0 comments on commit 3ca41f3

Please sign in to comment.