diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 23bf31b912..16541f2291 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -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" diff --git a/Makefile b/Makefile index 440a761186..b8a6d7415f 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index c591cd781c..56d77e0950 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -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" @@ -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 diff --git a/cmd/zetaclientd/version.go b/cmd/zetaclientd/version.go index 5c0c274253..0cdc1ac59e 100644 --- a/cmd/zetaclientd/version.go +++ b/cmd/zetaclientd/version.go @@ -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{ @@ -14,6 +14,6 @@ var VersionCmd = &cobra.Command{ } func Version(_ *cobra.Command, _ []string) error { - fmt.Printf(pkg.Version) + fmt.Printf(constant.Version) return nil } diff --git a/cmd/zetatool/filterdeposit/btc.go b/cmd/zetatool/filterdeposit/btc.go index a8ded3f08b..684bb4b428 100644 --- a/cmd/zetatool/filterdeposit/btc.go +++ b/cmd/zetatool/filterdeposit/btc.go @@ -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 { @@ -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 { diff --git a/cmd/zetatool/filterdeposit/evm.go b/cmd/zetatool/filterdeposit/evm.go index 4e26ed1338..e9ed6b3d63 100644 --- a/cmd/zetatool/filterdeposit/evm.go +++ b/cmd/zetatool/filterdeposit/evm.go @@ -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 ( @@ -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" { diff --git a/e2e/e2etests/test_donation.go b/e2e/e2etests/test_donation.go index 07510df987..f6d9bac3ff 100644 --- a/e2e/e2etests/test_donation.go +++ b/e2e/e2etests/test_donation.go @@ -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 @@ -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) } diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 687e3aa8f3..df0c2d1a23 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -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" @@ -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 { diff --git a/e2e/runner/setup_evm.go b/e2e/runner/setup_evm.go index aef39cf338..e8ff909169 100644 --- a/e2e/runner/setup_evm.go +++ b/e2e/runner/setup_evm.go @@ -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 ( @@ -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) } diff --git a/pkg/constant.go b/pkg/constant/constant.go similarity index 97% rename from pkg/constant.go rename to pkg/constant/constant.go index c52094ac22..447eca98e5 100644 --- a/pkg/constant.go +++ b/pkg/constant/constant.go @@ -1,4 +1,4 @@ -package pkg +package constant const ( // DonationMessage is the message for donation transactions diff --git a/pkg/version.go b/pkg/constant/version.go similarity index 81% rename from pkg/version.go rename to pkg/constant/version.go index 6e1fc343d8..c8bd89866a 100644 --- a/pkg/version.go +++ b/pkg/constant/version.go @@ -1,4 +1,4 @@ -package pkg +package constant var ( Name = "" diff --git a/rpc/namespaces/ethereum/web3/api.go b/rpc/namespaces/ethereum/web3/api.go index 07ecc755e6..de40837ee1 100644 --- a/rpc/namespaces/ethereum/web3/api.go +++ b/rpc/namespaces/ethereum/web3/api.go @@ -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. @@ -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. diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds.go b/x/crosschain/keeper/msg_server_migrate_tss_funds.go index a9ad02429f..fa0c7fb1f4 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds.go @@ -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" @@ -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: "", diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20.go b/x/crosschain/keeper/msg_server_whitelist_erc20.go index 9bc6aba87d..e1b4dc705d 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20.go @@ -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" @@ -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" ) @@ -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: "", diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go index e208989e5e..66a1bcb0e9 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20_test.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20_test.go @@ -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" @@ -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)) diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index 60f1f83d85..8f9c1f9463 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -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" @@ -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) } diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index 974d44dbca..a5f6114822 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -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" @@ -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) diff --git a/zetaclient/evm/evm_signer_test.go b/zetaclient/evm/evm_signer_test.go index 5f82d9bf91..b78a3d1c26 100644 --- a/zetaclient/evm/evm_signer_test.go +++ b/zetaclient/evm/evm_signer_test.go @@ -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" @@ -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) @@ -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) diff --git a/zetaclient/evm/inbounds.go b/zetaclient/evm/inbounds.go index a8dee66c11..2daa4fc0c1 100644 --- a/zetaclient/evm/inbounds.go +++ b/zetaclient/evm/inbounds.go @@ -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" @@ -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 } @@ -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 } diff --git a/zetaclient/evm/inbounds_test.go b/zetaclient/evm/inbounds_test.go index e4625177e7..e24c66b4d5 100644 --- a/zetaclient/evm/inbounds_test.go +++ b/zetaclient/evm/inbounds_test.go @@ -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" @@ -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 @@ -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) })