Skip to content

Commit

Permalink
Merge branch 'develop' into cherry-pick-hotfix-v10.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie authored Oct 11, 2023
2 parents 7b87eda + f51f6e0 commit 8e1da99
Show file tree
Hide file tree
Showing 57 changed files with 1,998 additions and 543 deletions.
3 changes: 2 additions & 1 deletion cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ func keygenTss(cfg *config.Config, tss *mc.TSS, keygenLogger zerolog.Logger) err
if err != nil {
return err
}
zetaHash, err := tss.CoreBridge.PostBlameData(&res.Blame, common.ZetaChain().ChainId, digest)
index := fmt.Sprintf("keygen-%s-%d", digest, keyGen.BlockNumber)
zetaHash, err := tss.CoreBridge.PostBlameData(&res.Blame, common.ZetaChain().ChainId, index)
if err != nil {
keygenLogger.Error().Err(err).Msg("error sending blame data to core")
return err
Expand Down
14 changes: 13 additions & 1 deletion cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {

customAppTemplate, customAppConfig := initAppConfig()

return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, tmcfg.DefaultConfig())
return server.InterceptConfigsPreRunHandler(cmd, customAppTemplate, customAppConfig, initTmConfig())
},
}

Expand All @@ -107,6 +107,18 @@ func initAppConfig() (string, interface{}) {
return servercfg.AppConfig(zetacoredconfig.BaseDenom)
}

// initTmConfig overrides the default Tendermint config
func initTmConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()

// use mempool version 1 to enable tx priority
if cfg.Mempool != nil {
cfg.Mempool.Version = tmcfg.MempoolV1
}

return cfg
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig) {
rootCmd.AddCommand(
ethermintclient.ValidateChainID(
Expand Down
39 changes: 39 additions & 0 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27295,6 +27295,32 @@ paths:
type: string
tags:
- Query
/zeta-chain/observer/blame_by_chain_and_nonce/{chain_id}/{nonce}:
get:
summary: Queries a list of VoterByIdentifier items.
operationId: Query_BlamesByChainAndNonce
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/observerQueryBlameByChainAndNonceResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: chain_id
in: path
required: true
type: string
format: int64
- name: nonce
in: path
required: true
type: string
format: int64
tags:
- Query
/zeta-chain/observer/blame_by_identifier/{blame_identifier}:
get:
summary: Queries a list of VoterByIdentifier items.
Expand Down Expand Up @@ -50449,6 +50475,11 @@ definitions:
type: object
crosschainMsgWhitelistERC20Response:
type: object
properties:
zrc20_address:
type: string
cctx_index:
type: string
crosschainOutTxTracker:
type: object
properties:
Expand Down Expand Up @@ -51114,6 +51145,14 @@ definitions:
$ref: '#/definitions/observerObservationType'
ballot_status:
$ref: '#/definitions/observerBallotStatus'
observerQueryBlameByChainAndNonceResponse:
type: object
properties:
blame_info:
type: array
items:
type: object
$ref: '#/definitions/observerBlame'
observerQueryBlameByIdentifierResponse:
type: object
properties:
Expand Down
3 changes: 3 additions & 0 deletions docs/spec/crosschain/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ message MsgVoteOnObservedInboundTx {

## MsgWhitelistERC20

WhitelistERC20 deploys a new zrc20, create a foreign coin object for the ERC20
and emit a crosschain tx to whitelist the ERC20 on the external chain

```proto
message MsgWhitelistERC20 {
string creator = 1;
Expand Down
1 change: 1 addition & 0 deletions docs/spec/fungible/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ message MsgUpdateZRC20WithdrawFee {
string creator = 1;
string zrc20_address = 2;
string new_withdraw_fee = 6;
string new_gas_limit = 7;
}
```

Expand Down
5 changes: 4 additions & 1 deletion proto/crosschain/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ message MsgWhitelistERC20 {
int64 gas_limit = 7;
}

message MsgWhitelistERC20Response {}
message MsgWhitelistERC20Response {
string zrc20_address = 1;
string cctx_index = 2;
}

message MsgAddToOutTxTracker {
string creator = 1;
Expand Down
2 changes: 2 additions & 0 deletions proto/fungible/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ message EventZRC20WithdrawFeeUpdated {
string old_withdraw_fee = 5;
string new_withdraw_fee = 6;
string signer = 7;
string old_gas_limit = 8;
string new_gas_limit = 9;
}

message EventZRC20PausedStatusUpdated {
Expand Down
4 changes: 4 additions & 0 deletions proto/fungible/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ message MsgUpdateZRC20WithdrawFee {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = false
];
string new_gas_limit = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint",
(gogoproto.nullable) = false
];
}

message MsgUpdateZRC20WithdrawFeeResponse {}
Expand Down
14 changes: 14 additions & 0 deletions proto/observer/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ service Query {
option (google.api.http).get = "/zeta-chain/observer/get_all_blame_records";
}

// Queries a list of VoterByIdentifier items.
rpc BlamesByChainAndNonce(QueryBlameByChainAndNonceRequest) returns (QueryBlameByChainAndNonceResponse) {
option (google.api.http).get = "/zeta-chain/observer/blame_by_chain_and_nonce/{chain_id}/{nonce}";
}

rpc GetAllBlockHeaders(QueryAllBlockHeaderRequest) returns (QueryAllBlockHeaderResponse) {
option (google.api.http).get = "/zeta-chain/observer/get_all_block_headers";
}
Expand Down Expand Up @@ -211,6 +216,15 @@ message QueryAllBlameRecordsResponse {
repeated Blame blame_info = 1;
}

message QueryBlameByChainAndNonceRequest {
int64 chain_id = 1;
int64 nonce = 2;
}

message QueryBlameByChainAndNonceResponse {
repeated Blame blame_info = 1;
}

message QueryAllBlockHeaderRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion testutil/keeper/mocks/crosschain/account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/crosschain/bank.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/crosschain/fungible.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 3 additions & 13 deletions testutil/keeper/mocks/crosschain/observer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/crosschain/staking.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/fungible/account.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/fungible/bank.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/fungible/evm.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion testutil/keeper/mocks/fungible/observer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions x/crosschain/keeper/cctx_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"errors"
"fmt"

cosmoserrors "cosmossdk.io/errors"
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/common"
"github.com/zeta-chain/zetacore/x/crosschain/types"
Expand All @@ -24,24 +24,24 @@ func (k Keeper) UpdateNonce(ctx sdk.Context, receiveChainID int64, cctx *types.C

nonce, found := k.GetChainNonces(ctx, chain.ChainName.String())
if !found {
return sdkerrors.Wrap(types.ErrCannotFindReceiverNonce, fmt.Sprintf("Chain(%s) | Identifiers : %s ", chain.ChainName.String(), cctx.LogIdentifierForCCTX()))
return cosmoserrors.Wrap(types.ErrCannotFindReceiverNonce, fmt.Sprintf("Chain(%s) | Identifiers : %s ", chain.ChainName.String(), cctx.LogIdentifierForCCTX()))
}

// SET nonce
cctx.GetCurrentOutTxParam().OutboundTxTssNonce = nonce.Nonce
tss, found := k.GetTSS(ctx)
if !found {
return sdkerrors.Wrap(types.ErrCannotFindTSSKeys, fmt.Sprintf("Chain(%s) | Identifiers : %s ", chain.ChainName.String(), cctx.LogIdentifierForCCTX()))
return cosmoserrors.Wrap(types.ErrCannotFindTSSKeys, fmt.Sprintf("Chain(%s) | Identifiers : %s ", chain.ChainName.String(), cctx.LogIdentifierForCCTX()))
}

p, found := k.GetPendingNonces(ctx, tss.TssPubkey, receiveChainID)
if !found {
return sdkerrors.Wrap(types.ErrCannotFindPendingNonces, fmt.Sprintf("chain_id %d, nonce %d", receiveChainID, nonce.Nonce))
return cosmoserrors.Wrap(types.ErrCannotFindPendingNonces, fmt.Sprintf("chain_id %d, nonce %d", receiveChainID, nonce.Nonce))
}

// #nosec G701 always in range
if p.NonceHigh != int64(nonce.Nonce) {
return sdkerrors.Wrap(types.ErrNonceMismatch, fmt.Sprintf("chain_id %d, high nonce %d, current nonce %d", receiveChainID, p.NonceHigh, nonce.Nonce))
return cosmoserrors.Wrap(types.ErrNonceMismatch, fmt.Sprintf("chain_id %d, high nonce %d, current nonce %d", receiveChainID, p.NonceHigh, nonce.Nonce))
}

nonce.Nonce++
Expand Down
12 changes: 6 additions & 6 deletions x/crosschain/keeper/gas_payment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) {
zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar")
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down Expand Up @@ -330,7 +330,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) {
zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foobar", "foobar")
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, zrc20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down Expand Up @@ -384,7 +384,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) {
)
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down Expand Up @@ -497,7 +497,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) {
gasZRC20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chainID, "foo", "foo")
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down Expand Up @@ -551,7 +551,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) {
)
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down Expand Up @@ -605,7 +605,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) {
)
_, err := zk.FungibleKeeper.UpdateZRC20WithdrawFee(
sdk.UnwrapSDKContext(ctx),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee)),
fungibletypes.NewMsgUpdateZRC20WithdrawFee(admin, gasZRC20.String(), sdk.NewUint(withdrawFee), math.Uint{}),
)
require.NoError(t, err)
k.SetGasPrice(ctx, types.GasPrice{
Expand Down
10 changes: 4 additions & 6 deletions x/crosschain/keeper/keeper_chain_nonces.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"fmt"

zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -108,12 +107,11 @@ func (k msgServer) NonceVoter(goCtx context.Context, msg *types.MsgNonceVoter) (
ctx := sdk.UnwrapSDKContext(goCtx)
chain := k.zetaObserverKeeper.GetParams(ctx).GetChainFromChainID(msg.ChainId)
if chain == nil {
return nil, zetaObserverTypes.ErrSupportedChains
return nil, observertypes.ErrSupportedChains
}

ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain)
if !ok {
return nil, err
if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, chain); !ok {
return nil, observertypes.ErrNotAuthorizedPolicy
}
chainNonce, isFound := k.GetChainNonces(ctx, chain.ChainName.String())

Expand Down
5 changes: 2 additions & 3 deletions x/crosschain/keeper/keeper_cross_chain_tx_vote_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg
tssPub = tss.TssPubkey
}
// IsAuthorized does various checks against the list of observer mappers
ok, err := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain)
if !ok {
return nil, err
if ok := k.zetaObserverKeeper.IsAuthorized(ctx, msg.Creator, observationChain); !ok {
return nil, observerTypes.ErrNotAuthorizedPolicy
}

index := msg.Digest()
Expand Down
Loading

0 comments on commit 8e1da99

Please sign in to comment.