Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Mar 26, 2024
1 parent f9683c7 commit 222adeb
Show file tree
Hide file tree
Showing 20 changed files with 46 additions and 46 deletions.
8 changes: 4 additions & 4 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ builds:
- -X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/pkg.Name=zetacored
- -X github.com/zeta-chain/zetacore/pkg.Version={{ .Version }}
- -X github.com/zeta-chain/zetacore/pkg.CommitHash={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/pkg.BuildTime=={{ .Env.BUILDTIME }}
- -X github.com/zeta-chain/zetacore/pkg/constant.Name=zetacored
- -X github.com/zeta-chain/zetacore/pkg/constant.Version={{ .Version }}
- -X github.com/zeta-chain/zetacore/pkg/constant.CommitHash={{ .Env.COMMIT }}
- -X github.com/zeta-chain/zetacore/pkg/constant.BuildTime={{ .Env.BUILDTIME }}
- -X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

- id: "zetaclientd"
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=zetacore \
-X github.com/cosmos/cosmos-sdk/version.ClientName=zetaclientd \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/zeta-chain/zetacore/pkg.Name=zetacored \
-X github.com/zeta-chain/zetacore/pkg.Version=$(VERSION) \
-X github.com/zeta-chain/zetacore/pkg.CommitHash=$(COMMIT) \
-X github.com/zeta-chain/zetacore/pkg.BuildTime=$(BUILDTIME) \
-X github.com/zeta-chain/zetacore/pkg/constant.Name=zetacored \
-X github.com/zeta-chain/zetacore/pkg/constant.Version=$(VERSION) \
-X github.com/zeta-chain/zetacore/pkg/constant.CommitHash=$(COMMIT) \
-X github.com/zeta-chain/zetacore/pkg/constant.BuildTime=$(BUILDTIME) \
-X github.com/cosmos/cosmos-sdk/types.DBBackend=pebbledb

BUILD_FLAGS := -ldflags '$(ldflags)' -tags pebbledb,ledger
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/crypto/secp256k1"
"github.com/zeta-chain/go-tss/p2p"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/authz"
"github.com/zeta-chain/zetacore/pkg/constant"
observerTypes "github.com/zeta-chain/zetacore/x/observer/types"
mc "github.com/zeta-chain/zetacore/zetaclient"
appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context"
Expand Down Expand Up @@ -170,7 +170,7 @@ func start(_ *cobra.Command, _ []string) error {
}
m.Start()

metrics.Info.WithLabelValues(pkg.Version).Set(1)
metrics.Info.WithLabelValues(constant.Version).Set(1)
metrics.LastStartTime.SetToCurrentTime()

var tssHistoricalList []observerTypes.TSS
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetaclientd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"

"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

var VersionCmd = &cobra.Command{
Expand All @@ -14,6 +14,6 @@ var VersionCmd = &cobra.Command{
}

func Version(_ *cobra.Command, _ []string) error {
fmt.Printf(pkg.Version)
fmt.Printf(constant.Version)
return nil
}
4 changes: 2 additions & 2 deletions cmd/zetatool/filterdeposit/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/cmd/zetatool/config"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

func NewBtcCmd() *cobra.Command {
Expand Down Expand Up @@ -162,7 +162,7 @@ func getHashList(cfg *config.Config, tssAddress string) ([]Deposit, error) {
if err != nil {
continue
}
if bytes.Equal(memoBytes, []byte(pkg.DonationMessage)) {
if bytes.Equal(memoBytes, []byte(constant.DonationMessage)) {
continue
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions cmd/zetatool/filterdeposit/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/zetaconnector.non-eth.sol"
"github.com/zeta-chain/zetacore/cmd/zetatool/config"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

const (
Expand Down Expand Up @@ -202,7 +202,7 @@ func getTSSDeposits(tssAddress string, startBlock uint64, endBlock uint64, apiKe

for _, tx := range txns {
if tx.To == tssAddress {
if strings.Compare(tx.Input, pkg.DonationMessage) == 0 {
if strings.Compare(tx.Input, constant.DonationMessage) == 0 {
continue // skip donation tx
}
if tx.TxReceiptStatus != "1" {
Expand Down
4 changes: 2 additions & 2 deletions e2e/e2etests/test_donation.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

// TestDonationEther tests donation of ether to the tss address
Expand All @@ -19,7 +19,7 @@ func TestDonationEther(r *runner.E2ERunner, args []string) {
panic("Invalid amount specified for TestDonationEther.")
}

txDonation, err := r.SendEther(r.TSSAddress, amount, []byte(pkg.DonationMessage))
txDonation, err := r.SendEther(r.TSSAddress, amount, []byte(constant.DonationMessage))
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/runner/bitcoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/rs/zerolog/log"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
"github.com/zeta-chain/zetacore/pkg/proofs"
"github.com/zeta-chain/zetacore/pkg/proofs/bitcoin"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
Expand Down Expand Up @@ -119,7 +119,7 @@ func (runner *E2ERunner) DepositBTC(testHeader bool) {
0.11,
utxos[4:5],
btc,
[]byte(pkg.DonationMessage),
[]byte(constant.DonationMessage),
runner.BTCDeployerAddress,
)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions e2e/runner/setup_evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/zeta-chain/zetacore/e2e/contracts/erc20"
"github.com/zeta-chain/zetacore/e2e/contracts/testdapp"
"github.com/zeta-chain/zetacore/e2e/utils"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

const (
Expand Down Expand Up @@ -62,7 +62,7 @@ func (runner *E2ERunner) SetupEVM(contractsDeployed bool) {

// donate to the TSS address to avoid account errors because deploying gas token ZRC20 will automatically mint
// gas token on ZetaChain to initialize the pool
txDonation, err := runner.SendEther(runner.TSSAddress, big.NewInt(101000000000000000), []byte(pkg.DonationMessage))
txDonation, err := runner.SendEther(runner.TSSAddress, big.NewInt(101000000000000000), []byte(constant.DonationMessage))
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/constant.go → pkg/constant/constant.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pkg
package constant

const (
// DonationMessage is the message for donation transactions
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.go → pkg/constant/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package pkg
package constant

var (
Name = ""
Expand Down
4 changes: 2 additions & 2 deletions rpc/namespaces/ethereum/web3/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
)

// PublicAPI is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
Expand All @@ -34,7 +34,7 @@ func NewPublicAPI() *PublicAPI {

// ClientVersion returns the client version in the Web3 user agent format.
func (a *PublicAPI) ClientVersion() string {
return fmt.Sprintf("%s/%s/%s/%s", pkg.Name, pkg.Version, runtime.GOOS+"-"+runtime.GOARCH, runtime.Version())
return fmt.Sprintf("%s/%s/%s/%s", constant.Name, constant.Version, runtime.GOOS+"-"+runtime.GOARCH, runtime.Version())
}

// Sha3 returns the keccak-256 hash of the passed-in input.
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_migrate_tss_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/ethereum/go-ethereum/crypto"
tmbytes "github.com/tendermint/tendermint/libs/bytes"
tmtypes "github.com/tendermint/tendermint/types"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto"
"github.com/zeta-chain/zetacore/pkg/gas"

Expand Down Expand Up @@ -87,7 +87,7 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s
Creator: "",
Index: index,
ZetaFees: sdkmath.Uint{},
RelayedMessage: fmt.Sprintf("%s:%s", pkg.CmdMigrateTssFunds, "Funds Migrator Admin Cmd"),
RelayedMessage: fmt.Sprintf("%s:%s", constant.CmdMigrateTssFunds, "Funds Migrator Admin Cmd"),
CctxStatus: &types.Status{
Status: types.CctxStatus_PendingOutbound,
StatusMessage: "",
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_whitelist_erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"math/big"

"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/pkg/constant"
authoritytypes "github.com/zeta-chain/zetacore/x/authority/types"

errorsmod "cosmossdk.io/errors"
Expand All @@ -16,7 +17,6 @@ import (
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"

"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/x/crosschain/types"
fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types"
)
Expand Down Expand Up @@ -116,7 +116,7 @@ func (k msgServer) WhitelistERC20(goCtx context.Context, msg *types.MsgWhitelist
Creator: msg.Creator,
Index: index,
ZetaFees: sdk.NewUint(0),
RelayedMessage: fmt.Sprintf("%s:%s", pkg.CmdWhitelistERC20, msg.Erc20Address),
RelayedMessage: fmt.Sprintf("%s:%s", constant.CmdWhitelistERC20, msg.Erc20Address),
CctxStatus: &types.Status{
Status: types.CctxStatus_PendingOutbound,
StatusMessage: "",
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_whitelist_erc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
keepertest "github.com/zeta-chain/zetacore/testutil/keeper"
"github.com/zeta-chain/zetacore/testutil/sample"
crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestKeeper_WhitelistERC20(t *testing.T) {
require.EqualValues(t, erc20Address, fc.Asset)
cctx, found := k.GetCrossChainTx(ctx, cctxIndex)
require.True(t, found)
require.EqualValues(t, fmt.Sprintf("%s:%s", pkg.CmdWhitelistERC20, erc20Address), cctx.RelayedMessage)
require.EqualValues(t, fmt.Sprintf("%s:%s", constant.CmdWhitelistERC20, erc20Address), cctx.RelayedMessage)

// check gas limit is set
gasLimit, err := zk.FungibleKeeper.QueryGasLimit(ctx, ethcommon.HexToAddress(zrc20))
Expand Down
4 changes: 2 additions & 2 deletions zetaclient/bitcoin/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"sync/atomic"
"time"

"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/pkg/constant"
"github.com/zeta-chain/zetacore/pkg/proofs"
corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context"

Expand Down Expand Up @@ -772,7 +772,7 @@ func GetBtcEvent(
logger.Warn().Err(err).Msgf("error hex decoding memo")
return nil, fmt.Errorf("error hex decoding memo: %s", err)
}
if bytes.Equal(memoBytes, []byte(pkg.DonationMessage)) {
if bytes.Equal(memoBytes, []byte(constant.DonationMessage)) {
logger.Info().Msgf("donation tx: %s; value %f", tx.Txid, value)
return nil, fmt.Errorf("donation tx: %s; value %f", tx.Txid, value)
}
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/evm/evm_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/zeta-chain/protocol-contracts/pkg/contracts/evm/erc20custody.sol"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/pkg/constant"
crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper"
"github.com/zeta-chain/zetacore/x/crosschain/types"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
Expand Down Expand Up @@ -297,9 +297,9 @@ func (signer *Signer) SignWithdrawTx(txData *OutBoundTransactionData) (*ethtypes
// cmd_migrate_tss_funds
func (signer *Signer) SignCommandTx(txData *OutBoundTransactionData, cmd string, params string) (*ethtypes.Transaction, error) {
switch cmd {
case pkg.CmdWhitelistERC20:
case constant.CmdWhitelistERC20:
return signer.SignWhitelistERC20Cmd(txData, params)
case pkg.CmdMigrateTssFunds:
case constant.CmdMigrateTssFunds:
return signer.SignMigrateTssFundsCmd(txData)
}
return nil, fmt.Errorf("SignCommandTx: unknown command %s", cmd)
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/evm/evm_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/constant"
"github.com/zeta-chain/zetacore/testutil/sample"
"github.com/zeta-chain/zetacore/x/crosschain/types"
crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types"
Expand Down Expand Up @@ -225,7 +225,7 @@ func TestSigner_SignCommandTx(t *testing.T) {
require.NoError(t, err)

t.Run("SignCommandTx CmdWhitelistERC20", func(t *testing.T) {
cmd := pkg.CmdWhitelistERC20
cmd := constant.CmdWhitelistERC20
params := ConnectorAddress.Hex()
// Call SignCommandTx
tx, err := evmSigner.SignCommandTx(txData, cmd, params)
Expand All @@ -242,7 +242,7 @@ func TestSigner_SignCommandTx(t *testing.T) {
})

t.Run("SignCommandTx CmdMigrateTssFunds", func(t *testing.T) {
cmd := pkg.CmdMigrateTssFunds
cmd := constant.CmdMigrateTssFunds
// Call SignCommandTx
tx, err := evmSigner.SignCommandTx(txData, cmd, "")
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/evm/inbounds.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
clienttypes "github.com/zeta-chain/zetacore/zetaclient/types"

ethcommon "github.com/ethereum/go-ethereum/common"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/constant"
"github.com/zeta-chain/zetacore/x/crosschain/types"
"github.com/zeta-chain/zetacore/zetaclient/zetabridge"
"golang.org/x/net/context"
Expand Down Expand Up @@ -236,7 +236,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody.
}

// donation check
if bytes.Equal(event.Message, []byte(pkg.DonationMessage)) {
if bytes.Equal(event.Message, []byte(constant.DonationMessage)) {
ob.logger.ExternalChainWatcher.Info().Msgf("thank you rich folk for your donation! tx %s chain %d", event.Raw.TxHash.Hex(), ob.chain.ChainId)
return nil
}
Expand Down Expand Up @@ -332,7 +332,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transacti
// donation check
// #nosec G703 err is already checked
data, _ := hex.DecodeString(message)
if bytes.Equal(data, []byte(pkg.DonationMessage)) {
if bytes.Equal(data, []byte(constant.DonationMessage)) {
ob.logger.ExternalChainWatcher.Info().Msgf("thank you rich folk for your donation! tx %s chain %d", tx.Hash, ob.chain.ChainId)
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions zetaclient/evm/inbounds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
lru "github.com/hashicorp/golang-lru"
"github.com/onrik/ethrpc"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/zetacore/pkg"
"github.com/zeta-chain/zetacore/pkg/chains"
"github.com/zeta-chain/zetacore/pkg/coin"
"github.com/zeta-chain/zetacore/pkg/constant"
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
"github.com/zeta-chain/zetacore/zetaclient/config"
"github.com/zeta-chain/zetacore/zetaclient/evm"
Expand Down Expand Up @@ -205,7 +205,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) {
})
t.Run("should not act on nil message", func(t *testing.T) {
tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas)
tx.Input = hex.EncodeToString([]byte(pkg.DonationMessage)) // donation will result in nil message
tx.Input = hex.EncodeToString([]byte(constant.DonationMessage)) // donation will result in nil message
require.NoError(t, evm.ValidateEvmTransaction(tx))
lastBlock := receipt.BlockNumber.Uint64() + confirmation

Expand Down Expand Up @@ -302,7 +302,7 @@ func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) {
require.Nil(t, msg)
})
t.Run("should return nil msg on donation transaction", func(t *testing.T) {
event.Message = []byte(pkg.DonationMessage)
event.Message = []byte(constant.DonationMessage)
msg := ob.BuildInboundVoteMsgForDepositedEvent(event, sender)
require.Nil(t, msg)
})
Expand Down

0 comments on commit 222adeb

Please sign in to comment.