Skip to content

Commit

Permalink
Merge branch 'develop' into refactor-remove-params-from-config
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Feb 22, 2024
2 parents 0b0be9c + 5e548fc commit 1b46071
Show file tree
Hide file tree
Showing 38 changed files with 1,308 additions and 374 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ jobs:
command: |
echo "Running Build Tests"
make clean
make test
make test-coverage
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
file: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
slug: zeta-chain/node

- name: Build zetacored and zetaclientd
env:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,14 @@ jobs:
command: |
echo "Running Build Tests"
make clean
make test
make test-coverage
- name: Upload coverage reports to Codecov
uses: codecov/[email protected]
with:
file: coverage.out
token: ${{ secrets.CODECOV_TOKEN }}
slug: zeta-chain/node

- name: Build zetacored and zetaclientd
if: ${{ github.event.inputs.skip_checks != 'true' }}
Expand Down
5 changes: 3 additions & 2 deletions app/ante/handler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper"

cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
Expand Down Expand Up @@ -165,7 +166,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
// Set a gas meter with limit 0 as to prevent an infinite gas meter attack
// during runTx.
newCtx = SetGasMeter(simulate, ctx, 0)
return newCtx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx")
return newCtx, cosmoserrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx")
}

newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas())
Expand All @@ -183,7 +184,7 @@ func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
"out of gas in location: %v; gasWanted: %d, gasUsed: %d",
rType.Descriptor, gasTx.GetGas(), newCtx.GasMeter().GasConsumed())

err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log)
err = cosmoserrors.Wrap(sdkerrors.ErrOutOfGas, log)
default:
panic(r)
}
Expand Down
5 changes: 3 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"
"time"

cosmoserrors "cosmossdk.io/errors"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -776,10 +777,10 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// VerifyAddressFormat verifies the address is compatible with ethereum
func VerifyAddressFormat(bz []byte) error {
if len(bz) == 0 {
return sdkerrors.Wrap(sdkerrors.ErrUnknownAddress, "invalid address; cannot be empty")
return cosmoserrors.Wrap(sdkerrors.ErrUnknownAddress, "invalid address; cannot be empty")
}
if len(bz) != AddrLen {
return sdkerrors.Wrapf(
return cosmoserrors.Wrapf(
sdkerrors.ErrUnknownAddress,
"invalid address length; got: %d, expect: %d", len(bz), AddrLen,
)
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* [1746](https://github.com/zeta-chain/node/pull/1746) - rename smoke tests to e2e tests
* [1753](https://github.com/zeta-chain/node/pull/1753) - fix gosec errors on usage of rand package
* [1762](https://github.com/zeta-chain/node/pull/1762) - improve coverage for fungibile module
* [1782](https://github.com/zeta-chain/node/pull/1782) - improve coverage for fungibile module system contract

### CI

Expand All @@ -52,6 +53,7 @@
* Added docker-compose and make commands for launching full nodes. `make mainnet-zetarpc-node` `make mainnet-bitcoind-node`
* Made adjustments to the docker-compose for launching mainnet full nodes to include examples of using the docker images build from the docker image build pipeline.
* [1736](https://github.com/zeta-chain/node/pull/1736) - chore: add Ethermint endpoints to OpenAPI
* [1781](https://github.com/zeta-chain/node/pull/1781) - add codecov coverage report in CI

### Features

Expand Down
74 changes: 74 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
coverage:
round: down
precision: 2
status:
project:
default:
threshold: 1% # allow this much decrease on project
zetacore:
if_ci_failed: error
target: 60%
flags:
- zetacore
zetaclient:
if_ci_failed: error
target: 60%
flags:
- zetaclient
common:
if_ci_failed: error
target: 60%
flags:
- common

comment:
layout: "reach, diff, files"
behavior: default
require_changes: true

flags:
zetacore:
carryforward: true
paths:
- "x/"
zetaclient:
carryforward: true
paths:
- "zetaclient/"
common:
carryforward: true
paths:
- "common/"

ignore:
- "x/**/client/"
- "x/**/keeper/keeper.go"
- "x/**/keeper/msg_server.go"
- "x/**/keeper/grpc_query_params.go"
- "x/**/types/codec.go"
- "x/**/types/errors.go"
- "x/**/types/keys.go"
- "x/**/types/key_*.go"
- "x/**/types/types.go"
- "x/**/types/expected_keepers.go"
- "x/**/module.go"
- "x/**/module_simulation.go"
- "x/**/simulation/"
- "*.proto"
- "*.md"
- "*.yml"
- "*.yaml"
- "*.pb.go"
- "*.pb.gw.go"
- "*.json"
- ".github/"
- "app/"
- "cmd/"
- "contrib/"
- "docs/"
- "rpc/"
- "proto/"
- "scripts/"
- "server/"
- "testutil/"
- "typescript/"
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_gas_price_voter.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"sort"
"strconv"

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

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)
Expand All @@ -31,7 +31,7 @@ func (k msgServer) GasPriceVoter(goCtx context.Context, msg *types.MsgGasPriceVo
return nil, observertypes.ErrNotAuthorizedPolicy
}
if chain == nil {
return nil, sdkerrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID : %d ", msg.ChainId))
return nil, cosmoserrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID : %d ", msg.ChainId))
}

gasPrice, isFound := k.GetGasPrice(ctx, chain.ChainId)
Expand Down
9 changes: 4 additions & 5 deletions x/crosschain/keeper/msg_server_vote_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import (
"context"
"fmt"

errorsmod "cosmossdk.io/errors"
cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/zetacore/common"
"github.com/zeta-chain/zetacore/x/crosschain/types"
observerKeeper "github.com/zeta-chain/zetacore/x/observer/keeper"
Expand Down Expand Up @@ -67,11 +66,11 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg
// GetChainFromChainID makes sure we are getting only supported chains , if a chain support has been turned on using gov proposal, this function returns nil
observationChain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, msg.SenderChainId)
if observationChain == nil {
return nil, sdkerrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID %d, Observation %s", msg.SenderChainId, observationType.String()))
return nil, cosmoserrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID %d, Observation %s", msg.SenderChainId, observationType.String()))
}
receiverChain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, msg.ReceiverChain)
if receiverChain == nil {
return nil, sdkerrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID %d, Observation %s", msg.ReceiverChain, observationType.String()))
return nil, cosmoserrors.Wrap(types.ErrUnsupportedChain, fmt.Sprintf("ChainID %d, Observation %s", msg.ReceiverChain, observationType.String()))
}
tssPub := ""
tss, tssFound := k.zetaObserverKeeper.GetTSS(ctx)
Expand All @@ -93,7 +92,7 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg
if isNew {
// Check if the inbound has already been processed.
if k.IsFinalizedInbound(ctx, msg.InTxHash, msg.SenderChainId, msg.EventIndex) {
return nil, errorsmod.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex))
return nil, cosmoserrors.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex))
}
observerKeeper.EmitEventBallotCreated(ctx, ballot, msg.InTxHash, observationChain.String())
}
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_vote_inbound_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) {
require.NoError(t, err)
}
ballot, _, _ := zk.ObserverKeeper.FindBallot(ctx, msg.Digest(), zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, msg.SenderChainId), observerTypes.ObservationType_InBoundTx)
require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation)
require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation)
cctx, found := k.GetCrossChainTx(ctx, msg.Digest())
require.True(t, found)
require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined)
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestNoDoubleEventProtections(t *testing.T) {
// Check that the vote passed
ballot, found := zk.ObserverKeeper.GetBallot(ctx, msg.Digest())
require.True(t, found)
require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation)
require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation)
//Perform the SAME event. Except, this time, we resubmit the event.
msg2 := &types.MsgVoteOnObservedInboundTx{
Creator: validatorAddr,
Expand Down
7 changes: 4 additions & 3 deletions x/crosschain/keeper/msg_server_vote_outbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math/big"

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

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -81,11 +82,11 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms
// Check if CCTX exists
cctx, found := k.GetCrossChainTx(ctx, msg.CctxHash)
if !found {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("CCTX %s does not exist", msg.CctxHash))
return nil, cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("CCTX %s does not exist", msg.CctxHash))
}

if cctx.GetCurrentOutTxParam().OutboundTxTssNonce != msg.OutTxTssNonce {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("OutTxTssNonce %d does not match CCTX OutTxTssNonce %d", msg.OutTxTssNonce, cctx.GetCurrentOutTxParam().OutboundTxTssNonce))
return nil, cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("OutTxTssNonce %d does not match CCTX OutTxTssNonce %d", msg.OutTxTssNonce, cctx.GetCurrentOutTxParam().OutboundTxTssNonce))
}

ballotIndex := msg.Digest()
Expand Down Expand Up @@ -117,7 +118,7 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms
log.Error().Msgf("VoteOnObservedOutboundTx: Mint mismatch: %s value received vs %s cctx amount",
msg.ValueReceived,
cctx.GetCurrentOutTxParam().Amount)
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("ValueReceived %s does not match sent value %s", msg.ValueReceived, cctx.GetCurrentOutTxParam().Amount))
return nil, cosmoserrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("ValueReceived %s does not match sent value %s", msg.ValueReceived, cctx.GetCurrentOutTxParam().Amount))
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/crosschain/keeper/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func setupZRC20Pool(
)
require.NoError(t, err)

// approve the router to spend the zeta
// approve the router to spend the zrc20
err = k.CallZRC20Approve(
ctx,
types.ModuleAddressEVM,
Expand Down
5 changes: 3 additions & 2 deletions x/crosschain/types/message_add_to_out_tx_tracker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/zetacore/common"
Expand Down Expand Up @@ -54,10 +55,10 @@ func (msg *MsgAddToOutTxTracker) GetSignBytes() []byte {
func (msg *MsgAddToOutTxTracker) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
if msg.ChainId < 0 {
return sdkerrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
return cosmoserrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
}
return nil
}
5 changes: 3 additions & 2 deletions x/crosschain/types/message_gas_price_voter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/zetacore/common"
Expand Down Expand Up @@ -42,10 +43,10 @@ func (msg *MsgGasPriceVoter) GetSignBytes() []byte {
func (msg *MsgGasPriceVoter) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
if msg.ChainId < 0 {
return sdkerrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
return cosmoserrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
}
return nil
}
5 changes: 3 additions & 2 deletions x/crosschain/types/message_remove_from_out_tx_tracker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
Expand Down Expand Up @@ -41,10 +42,10 @@ func (msg *MsgRemoveFromOutTxTracker) GetSignBytes() []byte {
func (msg *MsgRemoveFromOutTxTracker) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
if msg.ChainId < 0 {
return sdkerrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
return cosmoserrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId)
}
return nil
}
3 changes: 2 additions & 1 deletion x/crosschain/types/message_tss_voter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"fmt"

cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/zeta-chain/zetacore/common"
Expand Down Expand Up @@ -43,7 +44,7 @@ func (msg *MsgCreateTSSVoter) GetSignBytes() []byte {
func (msg *MsgCreateTSSVoter) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
return nil
}
Expand Down
9 changes: 5 additions & 4 deletions x/crosschain/types/message_vote_on_observed_inbound_tx.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

import (
cosmoserrors "cosmossdk.io/errors"
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -74,19 +75,19 @@ func (msg *MsgVoteOnObservedInboundTx) GetSignBytes() []byte {
func (msg *MsgVoteOnObservedInboundTx) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s): %s", err, msg.Creator)
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s): %s", err, msg.Creator)
}

if msg.SenderChainId < 0 {
return sdkerrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.SenderChainId)
return cosmoserrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.SenderChainId)
}

if msg.ReceiverChain < 0 {
return sdkerrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ReceiverChain)
return cosmoserrors.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ReceiverChain)
}

if len(msg.Message) > MaxMessageLength {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "message is too long: %d", len(msg.Message))
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "message is too long: %d", len(msg.Message))
}

return nil
Expand Down
Loading

0 comments on commit 1b46071

Please sign in to comment.