Skip to content

Commit

Permalink
Merge branch 'develop' into feat/init-lightclient
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis authored Apr 18, 2024
2 parents 626ed65 + f574d9c commit 5667cf6
Show file tree
Hide file tree
Showing 36 changed files with 231 additions and 1,241 deletions.
2 changes: 0 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,6 @@ func New(
appCodec,
keys[fungibletypes.StoreKey],
keys[fungibletypes.MemStoreKey],
app.GetSubspace(fungibletypes.ModuleName),
app.AccountKeeper,
app.EvmKeeper,
app.BankKeeper,
Expand All @@ -447,7 +446,6 @@ func New(
keys[crosschaintypes.StoreKey],
keys[crosschaintypes.MemStoreKey],
&stakingKeeper,
app.GetSubspace(crosschaintypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.ObserverKeeper,
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* [1853](https://github.com/zeta-chain/node/pull/1853) - refactor vote inbound tx and vote outbound tx
* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions
* [1976](https://github.com/zeta-chain/node/pull/1976) - add lightclient module for header and proof functionality
* [2001](https://github.com/zeta-chain/node/pull/2001) - replace broadcast mode block with sync and remove fungible params
* [1989](https://github.com/zeta-chain/node/pull/1989) - simplify `IsSendOutTxProcessed` method and add unit tests
* [2013](https://github.com/zeta-chain/node/pull/2013) - rename `GasPriceVoter` message to `VoteGasPrice`

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetacored/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewRootCmd() (*cobra.Command, appparams.EncodingConfig) {
WithLegacyAmino(encodingConfig.Amino).
WithInput(os.Stdin).
WithAccountRetriever(authtypes.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithBroadcastMode(flags.BroadcastSync).
WithHomeDir(app.DefaultNodeHome).
WithKeyringOptions(hd.EthSecp256k1Option()).
WithViper(EnvPrefix)
Expand Down
1 change: 0 additions & 1 deletion docs/cli/zetacored/zetacored_query_fungible.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ zetacored query fungible [flags]
* [zetacored query fungible gas-stability-pool-balance](zetacored_query_fungible_gas-stability-pool-balance.md) - query the balance of a gas stability pool for a chain
* [zetacored query fungible gas-stability-pool-balances](zetacored_query_fungible_gas-stability-pool-balances.md) - query all gas stability pool balances
* [zetacored query fungible list-foreign-coins](zetacored_query_fungible_list-foreign-coins.md) - list all ForeignCoins
* [zetacored query fungible params](zetacored_query_fungible_params.md) - shows the parameters of the module
* [zetacored query fungible show-foreign-coins](zetacored_query_fungible_show-foreign-coins.md) - shows a ForeignCoins
* [zetacored query fungible system-contract](zetacored_query_fungible_system-contract.md) - query system contract

33 changes: 0 additions & 33 deletions docs/cli/zetacored/zetacored_query_fungible_params.md

This file was deleted.

25 changes: 0 additions & 25 deletions docs/openapi/openapi.swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27401,21 +27401,6 @@ paths:
format: int64
tags:
- Query
/zeta-chain/fungible/params:
get:
summary: Parameters queries the parameters of the module.
operationId: Query_Params
responses:
"200":
description: A successful response.
schema:
$ref: '#/definitions/zetacorefungibleQueryParamsResponse'
default:
description: An unexpected error response.
schema:
$ref: '#/definitions/googlerpcStatus'
tags:
- Query
/zeta-chain/fungible/system_contract:
get:
summary: Queries SystemContract
Expand Down Expand Up @@ -54863,16 +54848,6 @@ definitions:
$ref: '#/definitions/zetacoreemissionsParams'
description: params holds all the parameters of this module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
zetacorefungibleParams:
type: object
description: Params defines the parameters for the module.
zetacorefungibleQueryParamsResponse:
type: object
properties:
params:
$ref: '#/definitions/zetacorefungibleParams'
description: params holds all the parameters of this module.
description: QueryParamsResponse is response type for the Query/Params RPC method.
zetacoreobserverParams:
type: object
properties:
Expand Down
85 changes: 72 additions & 13 deletions e2e/txserver/zeta_tx_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package txserver

import (
"context"
"encoding/hex"
"encoding/json"
"errors"
"fmt"
"math/big"
"os"
"strings"
"time"

lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"

Expand Down Expand Up @@ -35,6 +37,7 @@ import (
etherminttypes "github.com/evmos/ethermint/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
coretypes "github.com/tendermint/tendermint/rpc/core/types"
"github.com/zeta-chain/zetacore/cmd/zetacored/config"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
Expand All @@ -50,11 +53,12 @@ const EmissionsPoolAddress = "zeta1w43fn2ze2wyhu5hfmegr6vp52c3dgn0srdgymy"

// ZetaTxServer is a ZetaChain tx server for E2E test
type ZetaTxServer struct {
clientCtx client.Context
txFactory tx.Factory
name []string
mnemonic []string
address []string
clientCtx client.Context
txFactory tx.Factory
name []string
mnemonic []string
address []string
blockTimeout time.Duration
}

// NewZetaTxServer returns a new TxServer with provided account
Expand Down Expand Up @@ -104,11 +108,12 @@ func NewZetaTxServer(rpcAddr string, names []string, mnemonics []string, chainID
txf := newFactory(clientCtx)

return ZetaTxServer{
clientCtx: clientCtx,
txFactory: txf,
name: names,
mnemonic: mnemonics,
address: addresses,
clientCtx: clientCtx,
txFactory: txf,
name: names,
mnemonic: mnemonics,
address: addresses,
blockTimeout: 1 * time.Minute,
}, nil
}

Expand Down Expand Up @@ -159,6 +164,7 @@ func (zts ZetaTxServer) GetAccountMnemonic(index int) string {
}

// BroadcastTx broadcasts a tx to ZetaChain with the provided msg from the account
// and waiting for blockTime for tx to be included in the block
func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes.TxResponse, error) {
// Find number and sequence and set it
acc, err := zts.clientCtx.Keyring.Key(account)
Expand Down Expand Up @@ -190,8 +196,61 @@ func (zts ZetaTxServer) BroadcastTx(account string, msg sdktypes.Msg) (*sdktypes
return nil, err
}

// Broadcast tx
return zts.clientCtx.BroadcastTx(txBytes)
return broadcastWithBlockTimeout(zts, txBytes)
}

func broadcastWithBlockTimeout(zts ZetaTxServer, txBytes []byte) (*sdktypes.TxResponse, error) {
res, err := zts.clientCtx.BroadcastTx(txBytes)
if err != nil {
if res == nil {
return nil, err
}
return &sdktypes.TxResponse{
Code: res.Code,
Codespace: res.Codespace,
TxHash: res.TxHash,
}, err
}

exitAfter := time.After(zts.blockTimeout)
hash, err := hex.DecodeString(res.TxHash)
if err != nil {
return nil, err
}
for {
select {
case <-exitAfter:
return nil, fmt.Errorf("timed out after waiting for tx to get included in the block: %d", zts.blockTimeout)
case <-time.After(time.Millisecond * 100):
resTx, err := zts.clientCtx.Client.Tx(context.TODO(), hash, false)
if err == nil {
txRes, err := mkTxResult(zts.clientCtx, resTx)
if err == nil {
return txRes, nil
}
}
}
}
}

func mkTxResult(clientCtx client.Context, resTx *coretypes.ResultTx) (*sdktypes.TxResponse, error) {
txb, err := clientCtx.TxConfig.TxDecoder()(resTx.Tx)
if err != nil {
return nil, err
}
p, ok := txb.(intoAny)
if !ok {
return nil, fmt.Errorf("expecting a type implementing intoAny, got: %T", txb)
}
resBlock, err := clientCtx.Client.Block(context.TODO(), &resTx.Height)
if err != nil {
return nil, err
}
return sdktypes.NewResponseResultTx(resTx, p.AsAny(), resBlock.Block.Time.Format(time.RFC3339)), nil
}

type intoAny interface {
AsAny() *codectypes.Any
}

// EnableVerificationFlags enables the verification flags for the lightclient module
Expand Down Expand Up @@ -396,7 +455,7 @@ func newContext(
WithLegacyAmino(codec.NewLegacyAmino()).
WithInput(os.Stdin).
WithOutput(os.Stdout).
WithBroadcastMode(flags.BroadcastBlock).
WithBroadcastMode(flags.BroadcastSync).
WithClient(rpc).
WithSkipConfirmation(true).
WithFromName("creator").
Expand Down
16 changes: 8 additions & 8 deletions proto/crosschain/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types";

// GenesisState defines the metacore module's genesis state.
message GenesisState {
repeated OutTxTracker outTxTrackerList = 1 [(gogoproto.nullable) = false];
repeated GasPrice gasPriceList = 2;
repeated CrossChainTx CrossChainTxs = 3;
repeated LastBlockHeight lastBlockHeightList = 4;
repeated InTxHashToCctx inTxHashToCctxList = 5 [(gogoproto.nullable) = false];
repeated InTxTracker in_tx_tracker_list = 6 [(gogoproto.nullable) = false];
ZetaAccounting zeta_accounting = 7 [(gogoproto.nullable) = false];
repeated string FinalizedInbounds = 8;
repeated OutTxTracker outTxTrackerList = 2 [(gogoproto.nullable) = false];
repeated GasPrice gasPriceList = 5;
repeated CrossChainTx CrossChainTxs = 7;
repeated LastBlockHeight lastBlockHeightList = 8;
repeated InTxHashToCctx inTxHashToCctxList = 9 [(gogoproto.nullable) = false];
repeated InTxTracker in_tx_tracker_list = 11 [(gogoproto.nullable) = false];
ZetaAccounting zeta_accounting = 12 [(gogoproto.nullable) = false];
repeated string FinalizedInbounds = 16;
}
2 changes: 0 additions & 2 deletions proto/fungible/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ syntax = "proto3";
package zetachain.zetacore.fungible;

import "fungible/foreign_coins.proto";
import "fungible/params.proto";
import "fungible/system_contract.proto";
import "gogoproto/gogo.proto";

option go_package = "github.com/zeta-chain/zetacore/x/fungible/types";

// GenesisState defines the fungible module's genesis state.
message GenesisState {
Params params = 1 [(gogoproto.nullable) = false];
repeated ForeignCoins foreignCoinsList = 2 [(gogoproto.nullable) = false];
SystemContract systemContract = 3;
}
11 changes: 0 additions & 11 deletions proto/fungible/params.proto

This file was deleted.

15 changes: 0 additions & 15 deletions proto/fungible/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package zetachain.zetacore.fungible;

import "cosmos/base/query/v1beta1/pagination.proto";
import "fungible/foreign_coins.proto";
import "fungible/params.proto";
import "fungible/system_contract.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
Expand All @@ -12,11 +11,6 @@ option go_package = "github.com/zeta-chain/zetacore/x/fungible/types";

// Query defines the gRPC querier service.
service Query {
// Parameters queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/zeta-chain/fungible/params";
}

// Queries a ForeignCoins by index.
rpc ForeignCoins(QueryGetForeignCoinsRequest) returns (QueryGetForeignCoinsResponse) {
option (google.api.http).get = "/zeta-chain/fungible/foreign_coins/{index}";
Expand Down Expand Up @@ -53,15 +47,6 @@ service Query {
}
}

// QueryParamsRequest is request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
}

message QueryGetForeignCoinsRequest {
string index = 1;
}
Expand Down
2 changes: 0 additions & 2 deletions testutil/keeper/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func CrosschainKeeperWithMocks(
cdc,
db,
stateStore,
sdkKeepers.ParamsKeeper,
sdkKeepers.AuthKeeper,
sdkKeepers.BankKeeper,
sdkKeepers.EvmKeeper,
Expand Down Expand Up @@ -142,7 +141,6 @@ func CrosschainKeeperWithMocks(
storeKey,
memStoreKey,
stakingKeeper,
sdkKeepers.ParamsKeeper.Subspace(types.ModuleName),
authKeeper,
bankKeeper,
observerKeeper,
Expand Down
4 changes: 0 additions & 4 deletions testutil/keeper/fungible.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/cosmos/cosmos-sdk/store"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
"github.com/evmos/ethermint/x/evm/statedb"
evmtypes "github.com/evmos/ethermint/x/evm/types"
"github.com/stretchr/testify/mock"
Expand Down Expand Up @@ -44,7 +43,6 @@ func initFungibleKeeper(
cdc codec.Codec,
db *tmdb.MemDB,
ss store.CommitMultiStore,
paramKeeper paramskeeper.Keeper,
authKeeper types.AccountKeeper,
bankKeepr types.BankKeeper,
evmKeeper types.EVMKeeper,
Expand All @@ -60,7 +58,6 @@ func initFungibleKeeper(
cdc,
storeKey,
memKey,
paramKeeper.Subspace(types.ModuleName),
authKeeper,
evmKeeper,
bankKeepr,
Expand Down Expand Up @@ -155,7 +152,6 @@ func FungibleKeeperWithMocks(t testing.TB, mockOptions FungibleMockOptions) (*ke
cdc,
storeKey,
memStoreKey,
sdkKeepers.ParamsKeeper.Subspace(types.ModuleName),
authKeeper,
evmKeeper,
bankKeeper,
Expand Down
Loading

0 comments on commit 5667cf6

Please sign in to comment.