Skip to content

Commit

Permalink
rebase develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Apr 19, 2024
2 parents b8d5141 + e0ea646 commit 01794ce
Show file tree
Hide file tree
Showing 316 changed files with 18,024 additions and 7,678 deletions.
4 changes: 2 additions & 2 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
}
}
switch innerMsg.(type) {
case *cctxtypes.MsgGasPriceVoter,
case *cctxtypes.MsgVoteGasPrice,
*cctxtypes.MsgVoteOnObservedInboundTx,
*cctxtypes.MsgVoteOnObservedOutboundTx,
*cctxtypes.MsgAddToOutTxTracker,
*observertypes.MsgVoteBlockHeader,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlockHeader,
*observertypes.MsgAddBlameVote:
signers := innerMsg.GetSigners()
if len(signers) == 1 {
Expand Down
12 changes: 6 additions & 6 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ func (mah *MockAnteHandler) AnteHandle(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.C

func TestIsSystemTx(t *testing.T) {
// system tx types:
// *cctxtypes.MsgGasPriceVoter,
// *cctxtypes.MsgVoteGasPrice,
// *cctxtypes.MsgVoteOnObservedInboundTx,
// *cctxtypes.MsgVoteOnObservedOutboundTx,
// *cctxtypes.MsgAddToOutTxTracker,
// *observertypes.MsgVoteBlockHeader,
// *observertypes.MsgVoteTSS,
// *observertypes.MsgAddBlockHeader,
// *observertypes.MsgAddBlameVote:
buildTxFromMsg := func(msg sdk.Msg) sdk.Tx {
txBuilder := app.MakeEncodingConfig().TxConfig.NewTxBuilder()
Expand Down Expand Up @@ -187,17 +187,17 @@ func TestIsSystemTx(t *testing.T) {
true,
},
{
"MsgAddBlockHeader",
buildTxFromMsg(&observertypes.MsgAddBlockHeader{
"MsgVoteBlockHeader",
buildTxFromMsg(&observertypes.MsgVoteBlockHeader{
Creator: sample.AccAddress(),
}),
isAuthorized,

true,
},
{
"MsgExec{MsgAddBlockHeader}",
buildAuthzTxFromMsg(&observertypes.MsgAddBlockHeader{
"MsgExec{MsgVoteBlockHeader}",
buildAuthzTxFromMsg(&observertypes.MsgVoteBlockHeader{
Creator: sample.AccAddress(),
}),
isAuthorized,
Expand Down
31 changes: 24 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ import (
authoritykeeper "github.com/zeta-chain/zetacore/x/authority/keeper"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"

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

crosschainmodule "github.com/zeta-chain/zetacore/x/crosschain"
crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
Expand Down Expand Up @@ -181,6 +185,7 @@ var (
evm.AppModuleBasic{},
feemarket.AppModuleBasic{},
authoritymodule.AppModuleBasic{},
lightclientmodule.AppModuleBasic{},
crosschainmodule.AppModuleBasic{},
observermodule.AppModuleBasic{},
fungiblemodule.AppModuleBasic{},
Expand Down Expand Up @@ -255,11 +260,12 @@ type App struct {
FeeMarketKeeper feemarketkeeper.Keeper

// zetachain keepers
AuthorityKeeper authoritykeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper
AuthorityKeeper authoritykeeper.Keeper
LightclientKeeper lightclientkeeper.Keeper
CrosschainKeeper crosschainkeeper.Keeper
ObserverKeeper *observerkeeper.Keeper
FungibleKeeper fungiblekeeper.Keeper
EmissionsKeeper emissionskeeper.Keeper
}

// New returns a reference to an initialized ZetaApp.
Expand Down Expand Up @@ -295,6 +301,7 @@ func New(
evmtypes.StoreKey,
feemarkettypes.StoreKey,
authoritytypes.StoreKey,
lightclienttypes.StoreKey,
crosschaintypes.StoreKey,
observertypes.StoreKey,
fungibletypes.StoreKey,
Expand Down Expand Up @@ -364,6 +371,13 @@ func New(
authtypes.NewModuleAddress(govtypes.ModuleName),
)

app.LightclientKeeper = lightclientkeeper.NewKeeper(
appCodec,
keys[lightclienttypes.StoreKey],
keys[lightclienttypes.MemStoreKey],
app.AuthorityKeeper,
)

app.ObserverKeeper = observerkeeper.NewKeeper(
appCodec,
keys[observertypes.StoreKey],
Expand All @@ -372,6 +386,7 @@ func New(
&stakingKeeper,
app.SlashingKeeper,
app.AuthorityKeeper,
app.LightclientKeeper,
)

// register the staking hooks
Expand Down Expand Up @@ -419,7 +434,6 @@ func New(
appCodec,
keys[fungibletypes.StoreKey],
keys[fungibletypes.MemStoreKey],
app.GetSubspace(fungibletypes.ModuleName),
app.AccountKeeper,
app.EvmKeeper,
app.BankKeeper,
Expand All @@ -432,12 +446,12 @@ func New(
keys[crosschaintypes.StoreKey],
keys[crosschaintypes.MemStoreKey],
&stakingKeeper,
app.GetSubspace(crosschaintypes.ModuleName),
app.AccountKeeper,
app.BankKeeper,
app.ObserverKeeper,
&app.FungibleKeeper,
app.AuthorityKeeper,
app.LightclientKeeper,
)
app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, group.Config{
MaxExecutionPeriod: 2 * time.Hour, // Two hours.
Expand Down Expand Up @@ -509,6 +523,7 @@ func New(
evm.NewAppModule(app.EvmKeeper, app.AccountKeeper, evmSs),
feemarket.NewAppModule(app.FeeMarketKeeper, feeSs),
authoritymodule.NewAppModule(appCodec, app.AuthorityKeeper),
lightclientmodule.NewAppModule(appCodec, app.LightclientKeeper),
crosschainmodule.NewAppModule(appCodec, app.CrosschainKeeper),
observermodule.NewAppModule(appCodec, *app.ObserverKeeper),
fungiblemodule.NewAppModule(appCodec, app.FungibleKeeper),
Expand Down Expand Up @@ -543,6 +558,7 @@ func New(
emissionstypes.ModuleName,
authz.ModuleName,
authoritytypes.ModuleName,
lightclienttypes.ModuleName,
)
app.mm.SetOrderEndBlockers(
banktypes.ModuleName,
Expand All @@ -566,6 +582,7 @@ func New(
emissionstypes.ModuleName,
authz.ModuleName,
authoritytypes.ModuleName,
lightclienttypes.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down
2 changes: 2 additions & 0 deletions app/init_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
emissionsModuleTypes "github.com/zeta-chain/zetacore/x/emissions/types"
fungibleModuleTypes "github.com/zeta-chain/zetacore/x/fungible/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

Expand All @@ -47,5 +48,6 @@ func InitGenesisModuleList() []string {
emissionsModuleTypes.ModuleName,
authz.ModuleName,
authoritytypes.ModuleName,
lightclienttypes.ModuleName,
}
}
3 changes: 2 additions & 1 deletion app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

Expand All @@ -29,7 +30,7 @@ func SetupHandlers(app *App) {
}
if upgradeInfo.Name == releaseVersion && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{authoritytypes.ModuleName},
Added: []string{authoritytypes.ModuleName, lightclienttypes.ModuleName},
}
// Use upgrade store loader for the initial loading of all stores when app starts,
// it checks if version == upgradeHeight and applies store upgrades before loading the stores,
Expand Down
21 changes: 20 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@
* The `Policies` query of the `authority` module must be used to get the current admin policies.
* `PolicyType_group1` has been renamed into `PolicyType_groupEmergency` and `PolicyType_group2` has been renamed into `PolicyType_groupAdmin`.

* A new module called `lightclient` has been created for the blocker header and proof functionality to add inbound and outbound trackers in a permissionless manner (currently deactivated on live networks)
* The list of block headers are now stored in the `lightclient` module instead of the `observer` module.
* The message to vote on new block headers is still in the `observer` module but has been renamed to `MsgVoteBlockHeader` instead of `MsgAddBlockHeader`.
* The `GetAllBlockHeaders` query has been moved to the `lightclient` module and renamed to `BlockHeaderAll`.
* The `GetBlockHeaderByHash` query has been moved to the `lightclient` module and renamed to `BlockHeader`.
* The `GetBlockHeaderStateByChain` query has been moved to the `lightclient` module and renamed to `ChainState`.
* The `Prove` query has been moved to the `lightclient` module.
* The `BlockHeaderVerificationFlags` has been deprecated in `CrosschainFlags`, `VerificationFlags` should be used instead.

* `MsgGasPriceVoter` message in the `crosschain` module has been renamed to `MsgVoteGasPrice`.
* The structure of the message remains the same.

* `MsgCreateTSSVoter` message in the `crosschain` module has been moved to the `observer` module and renamed to `MsgVoteTSS`.
* The structure of the message remains the same.

Expand All @@ -26,17 +38,23 @@
* [1936](https://github.com/zeta-chain/node/pull/1936) - refactor common package into subpackages and rename to pkg
* [1966](https://github.com/zeta-chain/node/pull/1966) - move TSS vote message from crosschain to observer
* [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`

### Features

* [1789](https://github.com/zeta-chain/node/issues/1789) - block cross-chain transactions that involve restricted addresses
* [1755](https://github.com/zeta-chain/node/issues/1755) - use evm JSON RPC for inbound tx (including blob tx) observation.
* [1815](https://github.com/zeta-chain/node/pull/1815) - add authority module for authorized actions
* [1884](https://github.com/zeta-chain/node/pull/1884) - added zetatool cmd, added subcommand to filter deposits
* [1942](https://github.com/zeta-chain/node/pull/1982) - support Bitcoin P2TR, P2WSH, P2SH, P2PKH addresses
* [1935](https://github.com/zeta-chain/node/pull/1935) - add an operational authority group
* [1954](https://github.com/zeta-chain/node/pull/1954) - add metric for concurrent keysigns
* [1979](https://github.com/zeta-chain/node/pull/1979) - add script to import genesis data into an existing genesis file
* [2006](https://github.com/zeta-chain/node/pull/2006) - add Amoy testnet static chain information
* [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags

### Tests

Expand All @@ -60,6 +78,7 @@
* [1941](https://github.com/zeta-chain/node/pull/1941) - add unit tests for zetabridge package
* [1985](https://github.com/zeta-chain/node/pull/1985) - improve fungible module coverage
* [1992](https://github.com/zeta-chain/node/pull/1992) - remove setupKeeper from crosschain module
* [2008](https://github.com/zeta-chain/node/pull/2008) - add test for connector bytecode update

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func DebugCmd() *cobra.Command {
ob := evm.ChainClient{
Mu: &sync.Mutex{},
}
ob.WithZetaClient(bridge)
ob.WithZetaBridge(bridge)
ob.WithLogger(chainLogger)
var ethRPC *ethrpc.EthRPC
var client *ethclient.Client
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func start(_ *cobra.Command, _ []string) error {

// Initialize core parameters from zetacore
appContext := appcontext.NewAppContext(corecontext.NewZetaCoreContext(cfg), cfg)
err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true)
err = zetaBridge.UpdateZetaCoreContext(appContext.ZetaCoreContext(), true, startLogger)
if err != nil {
startLogger.Error().Err(err).Msg("Error getting core parameters")
return err
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
5 changes: 3 additions & 2 deletions cmd/zetae2e/balances.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/cmd/zetae2e/local"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
Expand Down Expand Up @@ -69,8 +70,8 @@ func runBalances(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.FungibleAdminName, // placeholder value, not used
local.FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions cmd/zetae2e/bitcoin_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/app"
zetae2econfig "github.com/zeta-chain/zetacore/cmd/zetae2e/config"
"github.com/zeta-chain/zetacore/cmd/zetae2e/local"
"github.com/zeta-chain/zetacore/e2e/config"
"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
Expand Down Expand Up @@ -69,8 +70,8 @@ func runBitcoinAddress(cmd *cobra.Command, args []string) error {
conf,
ethcommon.HexToAddress(evmAddr),
conf.Accounts.EVMPrivKey,
utils.FungibleAdminName, // placeholder value, not used
FungibleAdminMnemonic, // placeholder value, not used
utils.FungibleAdminName, // placeholder value, not used
local.FungibleAdminMnemonic, // placeholder value, not used
logger,
)
if err != nil {
Expand Down
19 changes: 12 additions & 7 deletions cmd/zetae2e/config/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/zeta-chain/zetacore/e2e/config"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"google.golang.org/grpc"
)
Expand All @@ -27,25 +28,26 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
authtypes.QueryClient,
banktypes.QueryClient,
observertypes.QueryClient,
lightclienttypes.QueryClient,
*ethclient.Client,
*bind.TransactOpts,
error,
) {
btcRPCClient, err := getBtcClient(conf.RPCs.Bitcoin)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err)
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get btc client: %w", err)
}
evmClient, evmAuth, err := getEVMClient(ctx, conf.RPCs.EVM, evmPrivKey)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err)
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get evm client: %w", err)
}
cctxClient, fungibleClient, authClient, bankClient, observerClient, err := getZetaClients(conf.RPCs.ZetaCoreGRPC)
cctxClient, fungibleClient, authClient, bankClient, observerClient, lightclientClient, err := getZetaClients(conf.RPCs.ZetaCoreGRPC)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zeta clients: %w", err)
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zeta clients: %w", err)
}
zevmClient, zevmAuth, err := getEVMClient(ctx, conf.RPCs.Zevm, evmPrivKey)
if err != nil {
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err)
return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, fmt.Errorf("failed to get zevm client: %w", err)
}
return btcRPCClient,
evmClient,
Expand All @@ -55,6 +57,7 @@ func getClientsFromConfig(ctx context.Context, conf config.Config, evmPrivKey st
authClient,
bankClient,
observerClient,
lightclientClient,
zevmClient,
zevmAuth,
nil
Expand Down Expand Up @@ -114,18 +117,20 @@ func getZetaClients(rpc string) (
authtypes.QueryClient,
banktypes.QueryClient,
observertypes.QueryClient,
lightclienttypes.QueryClient,
error,
) {
grpcConn, err := grpc.Dial(rpc, grpc.WithInsecure())
if err != nil {
return nil, nil, nil, nil, nil, err
return nil, nil, nil, nil, nil, nil, err
}

cctxClient := crosschaintypes.NewQueryClient(grpcConn)
fungibleClient := fungibletypes.NewQueryClient(grpcConn)
authClient := authtypes.NewQueryClient(grpcConn)
bankClient := banktypes.NewQueryClient(grpcConn)
observerClient := observertypes.NewQueryClient(grpcConn)
lightclientClient := lightclienttypes.NewQueryClient(grpcConn)

return cctxClient, fungibleClient, authClient, bankClient, observerClient, nil
return cctxClient, fungibleClient, authClient, bankClient, observerClient, lightclientClient, nil
}
Loading

0 comments on commit 01794ce

Please sign in to comment.