Skip to content

Commit

Permalink
Merge branch 'develop' into fix-MaxLookaheadNonce
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie authored Apr 23, 2024
2 parents 3c395cd + f4f5cd6 commit 333f7cd
Show file tree
Hide file tree
Showing 383 changed files with 19,922 additions and 7,469 deletions.
5 changes: 3 additions & 2 deletions Dockerfile-localnet
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM golang:1.20-alpine3.18
ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1
ENV GOCACHE=/root/.cache/go-build

RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux python3 py3-pip
RUN pip install requests
Expand All @@ -14,8 +15,8 @@ COPY go.sum .
RUN go mod download
COPY . .

RUN make install
RUN make install-zetae2e
RUN --mount=type=cache,target="/root/.cache/go-build" make install
RUN --mount=type=cache,target="/root/.cache/go-build" make install-zetae2e

RUN ssh-keygen -A
WORKDIR /root
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ TEST_DIR?="./..."
TEST_BUILD_FLAGS := -tags pebbledb,ledger
HSM_BUILD_FLAGS := -tags pebbledb,ledger,hsm_test

export DOCKER_BUILDKIT := 1

clean: clean-binaries clean-dir clean-test-dir clean-coverage

clean-binaries:
Expand Down
12 changes: 6 additions & 6 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/authz"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
tmlog "github.com/tendermint/tendermint/libs/log"
cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

Expand Down Expand Up @@ -168,12 +168,12 @@ func IsSystemTx(tx sdk.Tx, isAuthorizedSigner func(string) bool) bool {
}
}
switch innerMsg.(type) {
case *cctxtypes.MsgVoteGasPrice,
*cctxtypes.MsgVoteOnObservedInboundTx,
*cctxtypes.MsgVoteOnObservedOutboundTx,
*cctxtypes.MsgAddToOutTxTracker,
case *crosschaintypes.MsgVoteGasPrice,
*crosschaintypes.MsgVoteOnObservedInboundTx,
*crosschaintypes.MsgVoteOnObservedOutboundTx,
*crosschaintypes.MsgAddToOutTxTracker,
*observertypes.MsgVoteBlockHeader,
*observertypes.MsgVoteTSS,
*observertypes.MsgAddBlockHeader,
*observertypes.MsgAddBlameVote:
signers := innerMsg.GetSigners()
if len(signers) == 1 {
Expand Down
10 changes: 5 additions & 5 deletions app/ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ func TestIsSystemTx(t *testing.T) {
// *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
55 changes: 25 additions & 30 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 All @@ -574,29 +591,7 @@ func New(
// so that other modules that want to create or claim capabilities afterwards in InitChain
// can do so safely.
// NOTE: Cross-chain module must be initialized after observer module, as pending nonces in crosschain needs the tss pubkey from observer module
app.mm.SetOrderInitGenesis(
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
paramstypes.ModuleName,
group.ModuleName,
genutiltypes.ModuleName,
upgradetypes.ModuleName,
evidencetypes.ModuleName,
vestingtypes.ModuleName,
observertypes.ModuleName,
crosschaintypes.ModuleName,
fungibletypes.ModuleName,
emissionstypes.ModuleName,
authz.ModuleName,
authoritytypes.ModuleName,
)
app.mm.SetOrderInitGenesis(InitGenesisModuleList()...)

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
Expand Down
53 changes: 53 additions & 0 deletions app/init_genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package app

import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/authz"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/cosmos/cosmos-sdk/x/group"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
evmtypes "github.com/evmos/ethermint/x/evm/types"
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"
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"
)

func InitGenesisModuleList() []string {
return []string{
authtypes.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
crisistypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
paramstypes.ModuleName,
group.ModuleName,
genutiltypes.ModuleName,
upgradetypes.ModuleName,
evidencetypes.ModuleName,
vestingtypes.ModuleName,
observertypes.ModuleName,
crosschaintypes.ModuleName,
fungibleModuleTypes.ModuleName,
emissionsModuleTypes.ModuleName,
authz.ModuleName,
authoritytypes.ModuleName,
lightclienttypes.ModuleName,
}
}
5 changes: 3 additions & 2 deletions app/setup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ 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"
)

const releaseVersion = "v15"

func SetupHandlers(app *App) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) {
app.UpgradeKeeper.SetUpgradeHandler(releaseVersion, func(ctx sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) {
app.Logger().Info("Running upgrade handler for " + releaseVersion)
// Updated version map to the latest consensus versions from each module
for m, mb := range app.mm.Modules {
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
23 changes: 20 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@
* 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`.

* `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.
* 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.

### Refactor

* [1511](https://github.com/zeta-chain/node/pull/1511) - move ballot voting logic from `crosschain` to `observer`
Expand All @@ -29,19 +38,26 @@
* [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`
* [2059](https://github.com/zeta-chain/node/pull/2059) - Remove unused params from all functions in zetanode

### 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
* [2045](https://github.com/zeta-chain/node/pull/2046) - add grpc query with outbound rate limit for zetaclient to use
* [2046](https://github.com/zeta-chain/node/pull/2046) - add state variable in crosschain for rate limiter flags
* [2034](https://github.com/zeta-chain/node/pull/2034) - add support for zEVM message passing

### Tests

Expand All @@ -66,6 +82,7 @@
* [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
* [2047](https://github.com/zeta-chain/node/pull/2047) - fix liquidity cap advanced test

### 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 @@ -47,7 +47,7 @@ func DebugCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "get-ballot-from-intx [txHash] [chainID]",
Short: "provide txHash and chainID to get the ballot status for the txHash",
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
cobra.ExactArgs(2)
cfg, err := config.Load(debugArgs.zetaCoreHome)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetacored/addr_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ it always outputs three lines; the first line is the zeta1xxx address, the secon
and the third line is the ethereum address.
`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
addr, err := sdk.AccAddressFromBech32(args[0])
if err == nil {
valAddr := sdk.ValAddress(addr.Bytes())
Expand Down
2 changes: 1 addition & 1 deletion cmd/zetacored/collect_observer_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func CollectObserverInfoCmd() *cobra.Command {
Use: "collect-observer-info [folder]",
Short: "collect observer info from a folder , default path is ~/.zetacored/os_info/ \n",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
defaultHome := app.DefaultNodeHome
defaultFile := filepath.Join(defaultHome, "os_info")
if len(args) == 0 {
Expand Down
Loading

0 comments on commit 333f7cd

Please sign in to comment.