diff --git a/cmd/zetaclientd/debug.go b/cmd/zetaclientd/debug.go index e60cf7e7a9..76450875cb 100644 --- a/cmd/zetaclientd/debug.go +++ b/cmd/zetaclientd/debug.go @@ -10,7 +10,8 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/onrik/ethrpc" - "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/zetaclient/bitcoin" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" "github.com/zeta-chain/zetacore/zetaclient/evm" @@ -90,12 +91,12 @@ func DebugCmd() *cobra.Command { return err } - chain := pkg.GetChainFromChainID(chainID) + chain := chains.GetChainFromChainID(chainID) if chain == nil { return fmt.Errorf("invalid chain id") } - if pkg.IsEVMChain(chain.ChainId) { + if chains.IsEVMChain(chain.ChainId) { ob := evm.ChainClient{ Mu: &sync.Mutex{}, @@ -104,7 +105,7 @@ func DebugCmd() *cobra.Command { ob.WithLogger(chainLogger) var ethRPC *ethrpc.EthRPC var client *ethclient.Client - coinType := pkg.CoinType_Cmd + coinType := coin.CoinType_Cmd for chain, evmConfig := range cfg.GetAllEVMConfigs() { if chainID == chain { ethRPC = ethrpc.NewEthRPC(evmConfig.Endpoint) @@ -114,7 +115,7 @@ func DebugCmd() *cobra.Command { } ob.WithEvmClient(client) ob.WithEvmJSONRPC(ethRPC) - ob.WithChain(*pkg.GetChainFromChainID(chainID)) + ob.WithChain(*chains.GetChainFromChainID(chainID)) } } hash := ethcommon.HexToHash(txHash) @@ -144,29 +145,29 @@ func DebugCmd() *cobra.Command { } evmChainParams.ZetaTokenContractAddress = chainParams.ZetaTokenContractAddress if strings.EqualFold(tx.To, chainParams.ConnectorContractAddress) { - coinType = pkg.CoinType_Zeta + coinType = coin.CoinType_Zeta } else if strings.EqualFold(tx.To, chainParams.Erc20CustodyContractAddress) { - coinType = pkg.CoinType_ERC20 + coinType = coin.CoinType_ERC20 } else if strings.EqualFold(tx.To, tssEthAddress) { - coinType = pkg.CoinType_Gas + coinType = coin.CoinType_Gas } } } switch coinType { - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: ballotIdentifier, err = ob.CheckAndVoteInboundTokenZeta(tx, receipt, false) if err != nil { return err } - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: ballotIdentifier, err = ob.CheckAndVoteInboundTokenERC20(tx, receipt, false) if err != nil { return err } - case pkg.CoinType_Gas: + case coin.CoinType_Gas: ballotIdentifier, err = ob.CheckAndVoteInboundTokenGas(tx, receipt, false) if err != nil { return err @@ -175,13 +176,13 @@ func DebugCmd() *cobra.Command { fmt.Println("CoinType not detected") } fmt.Println("CoinType : ", coinType) - } else if pkg.IsBitcoinChain(chain.ChainId) { + } else if chains.IsBitcoinChain(chain.ChainId) { obBtc := bitcoin.BTCChainClient{ Mu: &sync.Mutex{}, } obBtc.WithZetaClient(bridge) obBtc.WithLogger(chainLogger) - obBtc.WithChain(*pkg.GetChainFromChainID(chainID)) + obBtc.WithChain(*chains.GetChainFromChainID(chainID)) connCfg := &rpcclient.ConnConfig{ Host: cfg.BitcoinConfig.RPCHost, User: cfg.BitcoinConfig.RPCUsername, diff --git a/cmd/zetaclientd/keygen_tss.go b/cmd/zetaclientd/keygen_tss.go index 91d9efcf7f..72c7946da3 100644 --- a/cmd/zetaclientd/keygen_tss.go +++ b/cmd/zetaclientd/keygen_tss.go @@ -17,7 +17,7 @@ import ( tsscommon "github.com/zeta-chain/go-tss/common" "github.com/zeta-chain/go-tss/keygen" "github.com/zeta-chain/go-tss/p2p" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/metrics" ) @@ -37,7 +37,7 @@ func GenerateTss( // Bitcoin chain ID is currently used for using the correct signature format // TODO: remove this once we have a better way to determine the signature format // https://github.com/zeta-chain/node/issues/1397 - bitcoinChainID := pkg.BtcRegtestChain().ChainId + bitcoinChainID := chains.BtcRegtestChain().ChainId btcChain, _, btcEnabled := appContext.GetBTCChainAndConfig() if btcEnabled { bitcoinChainID = btcChain.ChainId @@ -109,7 +109,7 @@ func GenerateTss( err = keygenTss(keyGen, tss, keygenLogger) if err != nil { keygenLogger.Error().Err(err).Msg("keygenTss error") - tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, pkg.ReceiveStatus_Failed) + tssFailedVoteHash, err := zetaBridge.SetTSS("", keyGen.BlockNumber, chains.ReceiveStatus_Failed) if err != nil { keygenLogger.Error().Err(err).Msg("Failed to broadcast Failed TSS Vote to zetacore") return nil, err @@ -127,7 +127,7 @@ func GenerateTss( } // If TSS is successful , broadcast the vote to zetacore and set Pubkey - tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, pkg.ReceiveStatus_Success) + tssSuccessVoteHash, err := zetaBridge.SetTSS(newTss.CurrentPubkey, keyGen.BlockNumber, chains.ReceiveStatus_Success) if err != nil { keygenLogger.Error().Err(err).Msg("TSS successful but unable to broadcast vote to zeta-core") return nil, err diff --git a/cmd/zetaclientd/start.go b/cmd/zetaclientd/start.go index 7946dcd158..c591cd781c 100644 --- a/cmd/zetaclientd/start.go +++ b/cmd/zetaclientd/start.go @@ -21,6 +21,7 @@ import ( "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" 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" @@ -99,7 +100,7 @@ func start(_ *cobra.Command, _ []string) error { } zetaBridge.WaitForCoreToCreateBlocks() startLogger.Info().Msgf("ZetaBridge is ready") - zetaBridge.SetAccountNumber(pkg.ZetaClientGranteeKey) + zetaBridge.SetAccountNumber(authz.ZetaClientGranteeKey) // cross-check chainid res, err := zetaBridge.GetNodeInfo() diff --git a/cmd/zetacored/get_pubkey.go b/cmd/zetacored/get_pubkey.go index cb5f61e5c2..4743a5dd14 100644 --- a/cmd/zetacored/get_pubkey.go +++ b/cmd/zetacored/get_pubkey.go @@ -6,8 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto" "github.com/spf13/cobra" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/pkg/cosmos" + zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto" ) func GetPubKeyCmd() *cobra.Command { @@ -33,8 +33,8 @@ func GetPubKeyCmd() *cobra.Command { return cmd } -func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (pkg.PubKeySet, error) { - pubkeySet := pkg.PubKeySet{ +func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (zetacrypto.PubKeySet, error) { + pubkeySet := zetacrypto.PubKeySet{ Secp256k1: "", Ed25519: "", } @@ -52,7 +52,7 @@ func GetPubKeySet(clientctx client.Context, tssAccountName, password string) (pk if err != nil { return pubkeySet, err } - pubkey, err := pkg.NewPubKey(s) + pubkey, err := zetacrypto.NewPubKey(s) if err != nil { return pubkeySet, err } diff --git a/cmd/zetacored/observer_accounts.go b/cmd/zetacored/observer_accounts.go index 02f8ba49bd..a4f6dedf84 100644 --- a/cmd/zetacored/observer_accounts.go +++ b/cmd/zetacored/observer_accounts.go @@ -23,7 +23,7 @@ import ( "github.com/spf13/cobra" "github.com/zeta-chain/zetacore/app" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/crypto" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -115,11 +115,11 @@ func AddObserverAccountsCmd() *cobra.Command { observerSet.ObserverList = append(observerSet.ObserverList, info.ObserverAddress) if info.ZetaClientGranteePubKey != "" { - pubkey, err := pkg.NewPubKey(info.ZetaClientGranteePubKey) + pubkey, err := crypto.NewPubKey(info.ZetaClientGranteePubKey) if err != nil { panic(err) } - pubkeySet := pkg.PubKeySet{ + pubkeySet := crypto.PubKeySet{ Secp256k1: pubkey, Ed25519: "", } diff --git a/common/bitcoin/proof_test.go b/common/bitcoin/proof_test.go deleted file mode 100644 index 0f521c4934..0000000000 --- a/common/bitcoin/proof_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package bitcoin - -import ( - "bytes" - "encoding/base64" - "encoding/hex" - "encoding/json" - "testing" - - "github.com/btcsuite/btcd/btcjson" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/wire" - "github.com/btcsuite/btcutil" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/common/testdata" -) - -func TestBitcoinMerkleProof(t *testing.T) { - blocks := testdata.LoadTestBlocks(t) - - t.Run("it should verify merkle proof", func(t *testing.T) { - for _, b := range blocks.Blocks { - // Deserialize the header bytes from base64 - headerBytes, err := base64.StdEncoding.DecodeString(b.HeaderBase64) - require.NoError(t, err) - header := unmarshalHeader(t, headerBytes) - - // Deserialize the block bytes from base64 - blockBytes, err := base64.StdEncoding.DecodeString(b.BlockBase64) - require.NoError(t, err) - blockVerbose := &btcjson.GetBlockVerboseTxResult{} - err = json.Unmarshal(blockBytes, blockVerbose) - require.NoError(t, err) - - txns := getBlockTxs(t, blockVerbose) - - // Build a Merkle tree from the transaction hashes and verify each transaction - mk := NewMerkle(txns) - for i, tx := range txns { - path, index, err := mk.BuildMerkleProof(i) - require.NoError(t, err) - - // True proof should verify - pass := Prove(*tx.Hash(), header.MerkleRoot, path, index) - require.True(t, pass) - - // Fake proof should not verify - fakeIndex := index ^ 0xffffffff // flip all bits - pass = Prove(*tx.Hash(), header.MerkleRoot, path, fakeIndex) - require.False(t, pass) - } - } - }) - - t.Run("it should fail if tree is empty", func(t *testing.T) { - mt := Merkle{ - tree: []*chainhash.Hash{}, - } - - _, _, err := mt.BuildMerkleProof(0) - require.Error(t, err) - }) - - t.Run("it should fail if tree len + 1 is not power of 2", func(t *testing.T) { - mt := Merkle{ - tree: []*chainhash.Hash{{}, {}}, - } - - _, _, err := mt.BuildMerkleProof(0) - require.Error(t, err) - }) - - t.Run("it should fail if txIndex out of range", func(t *testing.T) { - mt := Merkle{ - tree: []*chainhash.Hash{{}}, - } - - _, _, err := mt.BuildMerkleProof(2) - require.Error(t, err) - }) -} - -func unmarshalHeader(t *testing.T, headerBytes []byte) *wire.BlockHeader { - var header wire.BlockHeader - err := header.Deserialize(bytes.NewReader(headerBytes)) - require.NoError(t, err) - return &header -} - -func getBlockTxs(t *testing.T, blockVerbose *btcjson.GetBlockVerboseTxResult) []*btcutil.Tx { - txns := []*btcutil.Tx{} - for _, res := range blockVerbose.Tx { - txBytes, err := hex.DecodeString(res.Hex) - require.NoError(t, err) - tx, err := btcutil.NewTxFromBytes(txBytes) - require.NoError(t, err) - txns = append(txns, tx) - } - return txns -} diff --git a/common/ethereum/proof_test.go b/common/ethereum/proof_test.go deleted file mode 100644 index da0a60e463..0000000000 --- a/common/ethereum/proof_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package ethereum - -import ( - "testing" - - "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/common/testdata" -) - -func TestProofGeneration(t *testing.T) { - header, err := testdata.ReadEthHeader() - require.NoError(t, err) - - var receipts types.Receipts - for i := 0; i < testdata.TxsCount; i++ { - receipt, err := testdata.ReadEthReceipt(i) - require.NoError(t, err) - receipts = append(receipts, &receipt) - } - - // generate a trie from the receipts and compare the root hash with the one in the header - receiptTree := NewTrie(receipts) - require.EqualValues(t, header.ReceiptHash.Hex(), receiptTree.Trie.Hash().Hex()) - - t.Run("generate proof for receipts", func(t *testing.T) { - for i, receipt := range receipts { - // generate a proof for each receipt and verify it - proof, err := receiptTree.GenerateProof(i) - require.NoError(t, err) - - verified, err := proof.Verify(header.ReceiptHash, i) - require.NoError(t, err) - - // recover the receipt from the proof and compare it with the original receipt - // NOTE: eth receipts only hashes the following fields - // data := &receiptRLP{r.statusEncoding(), r.CumulativeGasUsed, r.Bloom, r.Logs} - var verifiedReceipt types.Receipt - err = verifiedReceipt.UnmarshalBinary(verified) - require.NoError(t, err) - require.EqualValues(t, receipt.Status, verifiedReceipt.Status) - require.EqualValues(t, receipt.CumulativeGasUsed, verifiedReceipt.CumulativeGasUsed) - require.EqualValues(t, receipt.Bloom.Bytes(), verifiedReceipt.Bloom.Bytes()) - require.EqualValues(t, len(receipt.Logs), len(verifiedReceipt.Logs)) - for i, log := range receipt.Logs { - require.EqualValues(t, log.Address, verifiedReceipt.Logs[i].Address) - require.EqualValues(t, log.Topics, verifiedReceipt.Logs[i].Topics) - require.EqualValues(t, log.Data, verifiedReceipt.Logs[i].Data) - } - } - }) - - t.Run("should error verify for negative key", func(t *testing.T) { - proof, err := receiptTree.GenerateProof(0) - require.NoError(t, err) - - verified, err := proof.Verify(header.ReceiptHash, -1) - require.Error(t, err) - require.Nil(t, verified) - }) - - t.Run("should not generate proof for negative tx index", func(t *testing.T) { - proof, err := receiptTree.GenerateProof(-1) - require.Error(t, err) - require.Nil(t, proof) - }) - - t.Run("has key", func(t *testing.T) { - proof, err := receiptTree.GenerateProof(0) - require.NoError(t, err) - require.Greater(t, len(proof.Keys), 0) - - proof2, err := receiptTree.GenerateProof(1) - require.NoError(t, err) - require.Equal(t, len(proof2.Keys), 3) - - key := proof.Keys[0] - has, err := proof.Has(key) - require.NoError(t, err) - require.True(t, has) - - err = proof.Put(key, proof.Values[0]) - require.NoError(t, err) - - key2 := proof2.Keys[2] - has, err = proof.Has(key2) - require.NoError(t, err) - require.False(t, has) - }) - - t.Run("get key", func(t *testing.T) { - proof, err := receiptTree.GenerateProof(0) - require.NoError(t, err) - require.Greater(t, len(proof.Keys), 0) - - proof2, err := receiptTree.GenerateProof(1) - require.NoError(t, err) - require.Equal(t, len(proof2.Keys), 3) - - key := proof.Keys[0] - _, err = proof.Get(key) - require.NoError(t, err) - - key2 := proof2.Keys[2] - _, err = proof.Get(key2) - require.Error(t, err) - }) - - t.Run("delete key", func(t *testing.T) { - proof, err := receiptTree.GenerateProof(0) - require.NoError(t, err) - require.Greater(t, len(proof.Keys), 0) - - proof2, err := receiptTree.GenerateProof(1) - require.NoError(t, err) - require.Equal(t, len(proof2.Keys), 3) - - key := proof.Keys[0] - err = proof.Delete(key) - require.NoError(t, err) - - err = proof.Delete(key) - require.Error(t, err) - - key2 := proof2.Keys[2] - err = proof.Delete(key2) - require.Error(t, err) - }) -} diff --git a/e2e/e2etests/test_bitcoin_withdraw.go b/e2e/e2etests/test_bitcoin_withdraw.go index 61b0ca3f1f..3920b7b3ce 100644 --- a/e2e/e2etests/test_bitcoin_withdraw.go +++ b/e2e/e2etests/test_bitcoin_withdraw.go @@ -10,7 +10,7 @@ import ( "github.com/btcsuite/btcutil" "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/chains" "github.com/zeta-chain/zetacore/zetaclient/testutils" ) @@ -122,7 +122,7 @@ func WithdrawBitcoin(r *runner.E2ERunner, amount *big.Int) { func WithdrawBitcoinRestricted(r *runner.E2ERunner, amount *big.Int) { // use restricted BTC P2WPKH address - addressRestricted, err := pkg.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, pkg.BtcRegtestChain().ChainId) + addressRestricted, err := chains.DecodeBtcAddress(testutils.RestrictedBtcAddressTest, chains.BtcRegtestChain().ChainId) if err != nil { panic(err) } diff --git a/e2e/e2etests/test_update_bytecode.go b/e2e/e2etests/test_update_bytecode.go index 3cdca22d02..a36af1db7c 100644 --- a/e2e/e2etests/test_update_bytecode.go +++ b/e2e/e2etests/test_update_bytecode.go @@ -7,7 +7,7 @@ import ( "github.com/zeta-chain/zetacore/e2e/contracts/testzrc20" "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/coin" "github.com/zeta-chain/zetacore/testutil/sample" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -32,7 +32,7 @@ func TestUpdateBytecode(r *runner.E2ERunner, _ []string) { r.ZEVMClient, big.NewInt(5), // #nosec G701 test - always in range - uint8(pkg.CoinType_Gas), + uint8(coin.CoinType_Gas), ) if err != nil { panic(err) diff --git a/e2e/e2etests/test_zeta_withdraw.go b/e2e/e2etests/test_zeta_withdraw.go index 0afe9d0eaa..2b5dc055e0 100644 --- a/e2e/e2etests/test_zeta_withdraw.go +++ b/e2e/e2etests/test_zeta_withdraw.go @@ -9,7 +9,7 @@ import ( "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" "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/chains" cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -135,7 +135,7 @@ func TestZetaWithdrawBTCRevert(r *runner.E2ERunner, args []string) { lessThanAmount := amount.Div(amount, big.NewInt(10)) // 1/10 of amount tx, err = r.ConnectorZEVM.Send(r.ZEVMAuth, connectorzevm.ZetaInterfacesSendInput{ - DestinationChainId: big.NewInt(pkg.BtcRegtestChain().ChainId), + DestinationChainId: big.NewInt(chains.BtcRegtestChain().ChainId), DestinationAddress: r.DeployerAddress.Bytes(), DestinationGasLimit: big.NewInt(400_000), Message: nil, diff --git a/e2e/runner/bitcoin.go b/e2e/runner/bitcoin.go index 2d405c0909..687e3aa8f3 100644 --- a/e2e/runner/bitcoin.go +++ b/e2e/runner/bitcoin.go @@ -17,7 +17,9 @@ import ( "github.com/rs/zerolog/log" "github.com/zeta-chain/zetacore/e2e/utils" "github.com/zeta-chain/zetacore/pkg" - "github.com/zeta-chain/zetacore/pkg/bitcoin" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" zetabitcoin "github.com/zeta-chain/zetacore/zetaclient/bitcoin" @@ -387,10 +389,10 @@ func (runner *E2ERunner) ProveBTCTransaction(txHash *chainhash.Hash) { // verify merkle proof through RPC res, err := runner.ObserverClient.Prove(runner.Ctx, &observertypes.QueryProveRequest{ - ChainId: pkg.BtcRegtestChain().ChainId, + ChainId: chains.BtcRegtestChain().ChainId, TxHash: txHash.String(), BlockHash: blockHash.String(), - Proof: pkg.NewBitcoinProof(txBytes, path, index), + Proof: proofs.NewBitcoinProof(txBytes, path, index), TxIndex: 0, // bitcoin doesn't use txIndex }) if err != nil { diff --git a/e2e/runner/evm.go b/e2e/runner/evm.go index 31609e789d..8a931eeccd 100644 --- a/e2e/runner/evm.go +++ b/e2e/runner/evm.go @@ -8,8 +8,9 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/zeta-chain/zetacore/e2e/utils" - "github.com/zeta-chain/zetacore/pkg" - "github.com/zeta-chain/zetacore/pkg/ethereum" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" + "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -244,8 +245,8 @@ func (runner *E2ERunner) ProveEthTransaction(receipt *ethtypes.Receipt) { BlockHash: blockHash.Hex(), TxIndex: int64(txIndex), TxHash: txHash.Hex(), - Proof: pkg.NewEthereumProof(txProof), - ChainId: pkg.GoerliLocalnetChain().ChainId, + Proof: proofs.NewEthereumProof(txProof), + ChainId: chains.GoerliLocalnetChain().ChainId, }) if err != nil { panic(err) diff --git a/e2e/runner/setup_zeta.go b/e2e/runner/setup_zeta.go index c55b45ad3a..28d9f25658 100644 --- a/e2e/runner/setup_zeta.go +++ b/e2e/runner/setup_zeta.go @@ -5,6 +5,7 @@ import ( "time" "github.com/zeta-chain/zetacore/e2e/txserver" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/btcsuite/btcutil" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -18,7 +19,6 @@ import ( "github.com/zeta-chain/zetacore/e2e/contracts/contextapp" "github.com/zeta-chain/zetacore/e2e/contracts/zevmswap" e2eutils "github.com/zeta-chain/zetacore/e2e/utils" - "github.com/zeta-chain/zetacore/pkg" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -31,7 +31,7 @@ var EmissionsPoolFunding = big.NewInt(0).Mul(big.NewInt(1e18), big.NewInt(2e7)) func (runner *E2ERunner) SetTSSAddresses() error { runner.Logger.Print("⚙️ setting up TSS address") - btcChainID, err := pkg.GetBTCChainIDFromChainParams(runner.BitcoinParams) + btcChainID, err := chains.GetBTCChainIDFromChainParams(runner.BitcoinParams) if err != nil { return err } @@ -175,7 +175,7 @@ func (runner *E2ERunner) SetZEVMContracts() { // SetupETHZRC20 sets up the ETH ZRC20 in the runner from the values queried from the chain func (runner *E2ERunner) SetupETHZRC20() { - ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(pkg.GoerliLocalnetChain().ChainId)) + ethZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.GoerliLocalnetChain().ChainId)) if err != nil { panic(err) } @@ -192,7 +192,7 @@ func (runner *E2ERunner) SetupETHZRC20() { // SetupBTCZRC20 sets up the BTC ZRC20 in the runner from the values queried from the chain func (runner *E2ERunner) SetupBTCZRC20() { - BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(pkg.BtcRegtestChain().ChainId)) + BTCZRC20Addr, err := runner.SystemContract.GasCoinZRC20ByChainId(&bind.CallOpts{}, big.NewInt(chains.BtcRegtestChain().ChainId)) if err != nil { panic(err) } diff --git a/e2e/txserver/zeta_tx_server.go b/e2e/txserver/zeta_tx_server.go index ddfbadcb73..f610b8b2bf 100644 --- a/e2e/txserver/zeta_tx_server.go +++ b/e2e/txserver/zeta_tx_server.go @@ -34,7 +34,8 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" rpchttp "github.com/tendermint/tendermint/rpc/client/http" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" emissionstypes "github.com/zeta-chain/zetacore/x/emissions/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" @@ -233,11 +234,11 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - pkg.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain().ChainId, 18, "ETH", "gETH", - pkg.CoinType_Gas, + coin.CoinType_Gas, 100000, )) if err != nil { @@ -248,11 +249,11 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) _, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), "", - pkg.BtcRegtestChain().ChainId, + chains.BtcRegtestChain().ChainId, 8, "BTC", "tBTC", - pkg.CoinType_Gas, + coin.CoinType_Gas, 100000, )) if err != nil { @@ -263,11 +264,11 @@ func (zts ZetaTxServer) DeploySystemContractsAndZRC20(account, erc20Addr string) res, err = zts.BroadcastTx(account, fungibletypes.NewMsgDeployFungibleCoinZRC20( addr.String(), erc20Addr, - pkg.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain().ChainId, 6, "USDT", "USDT", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, 100000, )) if err != nil { diff --git a/pkg/authz_tx_types.go b/pkg/authz/authz_tx_types.go similarity index 97% rename from pkg/authz_tx_types.go rename to pkg/authz/authz_tx_types.go index ce618233f1..74eafc93d0 100644 --- a/pkg/authz_tx_types.go +++ b/pkg/authz/authz_tx_types.go @@ -1,4 +1,4 @@ -package pkg +package authz type TxType string diff --git a/pkg/authz_tx_types_test.go b/pkg/authz/authz_tx_types_test.go similarity index 98% rename from pkg/authz_tx_types_test.go rename to pkg/authz/authz_tx_types_test.go index 1020b0df1b..49252706fe 100644 --- a/pkg/authz_tx_types_test.go +++ b/pkg/authz/authz_tx_types_test.go @@ -1,4 +1,4 @@ -package pkg +package authz import ( "testing" diff --git a/pkg/chain_test.go b/pkg/chain_test.go deleted file mode 100644 index 368317ecc8..0000000000 --- a/pkg/chain_test.go +++ /dev/null @@ -1,381 +0,0 @@ -package pkg - -import ( - "encoding/hex" - "testing" - - "github.com/btcsuite/btcd/btcec" - "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcutil" - ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/stretchr/testify/require" -) - -func TestChain_EncodeAddress(t *testing.T) { - tests := []struct { - name string - chain Chain - b []byte - want string - wantErr bool - }{ - { - name: "should error if b is not a valid address on the bitcoin network", - chain: Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, - }, - b: []byte("bc1qk0cc73p8m7hswn8y2q080xa4e5pxapnqgp7h9c"), - want: "", - wantErr: true, - }, - { - name: "should pass if b is a valid address on the network", - chain: Chain{ - ChainName: ChainName_btc_mainnet, - ChainId: 8332, - }, - b: []byte("bc1qk0cc73p8m7hswn8y2q080xa4e5pxapnqgp7h9c"), - want: "bc1qk0cc73p8m7hswn8y2q080xa4e5pxapnqgp7h9c", - wantErr: false, - }, - { - name: "should error if b is not a valid address on the evm network", - chain: Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - }, - b: ethcommon.Hex2Bytes("0x321"), - want: "", - wantErr: true, - }, - { - name: "should pass if b is a valid address on the evm network", - chain: Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - }, - b: []byte("0x321"), - want: "0x0000000000000000000000000000003078333231", - wantErr: false, - }, - { - name: "should error if chain not supported", - chain: Chain{ - ChainName: 999, - ChainId: 999, - }, - b: ethcommon.Hex2Bytes("0x321"), - want: "", - wantErr: true, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - s, err := tc.chain.EncodeAddress(tc.b) - if tc.wantErr { - require.Error(t, err) - return - } - require.Equal(t, tc.want, s) - }) - } -} - -func TestChain_DecodeAddress(t *testing.T) { - tests := []struct { - name string - chain Chain - b string - want []byte - wantErr bool - }{ - { - name: "should decode on btc chain", - chain: Chain{ - ChainName: ChainName_btc_testnet, - ChainId: 18332, - }, - want: []byte("bc1qk0cc73p8m7hswn8y2q080xa4e5pxapnqgp7h9c"), - b: "bc1qk0cc73p8m7hswn8y2q080xa4e5pxapnqgp7h9c", - wantErr: false, - }, - { - name: "should decode on evm chain", - chain: Chain{ - ChainName: ChainName_goerli_testnet, - ChainId: 5, - }, - want: ethcommon.HexToAddress("0x321").Bytes(), - b: "0x321", - wantErr: false, - }, - { - name: "should error if chain not supported", - chain: Chain{ - ChainName: 999, - ChainId: 999, - }, - want: ethcommon.Hex2Bytes("0x321"), - b: "", - wantErr: true, - }, - } - - for _, tc := range tests { - tc := tc - t.Run(tc.name, func(t *testing.T) { - s, err := tc.chain.DecodeAddress(tc.b) - if tc.wantErr { - require.Error(t, err) - return - } - require.Equal(t, tc.want, s) - }) - } -} - -func TestChain_InChainList(t *testing.T) { - require.True(t, ZetaChainMainnet().InChainList(ZetaChainList())) - require.True(t, ZetaMocknetChain().InChainList(ZetaChainList())) - require.True(t, ZetaPrivnetChain().InChainList(ZetaChainList())) - require.True(t, ZetaTestnetChain().InChainList(ZetaChainList())) - require.False(t, EthChain().InChainList(ZetaChainList())) -} - -func TestIsZetaChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Zeta Mainnet", ZetaChainMainnet().ChainId, true}, - {"Zeta Testnet", ZetaTestnetChain().ChainId, true}, - {"Zeta Mocknet", ZetaMocknetChain().ChainId, true}, - {"Zeta Privnet", ZetaPrivnetChain().ChainId, true}, - {"Non-Zeta", EthChain().ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsZetaChain(tt.chainID)) - }) - } -} - -func TestIsEVMChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"Non-EVM", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsEVMChain(tt.chainID)) - }) - } -} - -func TestIsHeaderSupportedEVMChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Goerli Localnet", GoerliLocalnetChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"BSC Testnet", BscTestnetChain().ChainId, true}, - {"BSC Mainnet", BscMainnetChain().ChainId, true}, - {"Non-EVM", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsHeaderSupportedEvmChain(tt.chainID)) - }) - } -} - -func TestSupportMerkleProof(t *testing.T) { - tests := []struct { - name string - chain Chain - want bool - }{ - {"Ethereum Mainnet", EthChain(), true}, - {"BSC Testnet", BscTestnetChain(), true}, - {"BSC Mainnet", BscMainnetChain(), true}, - {"Non-EVM", BtcMainnetChain(), true}, - {"Zeta Mainnet", ZetaChainMainnet(), false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, tt.chain.SupportMerkleProof()) - }) - } -} - -func TestIsBitcoinChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Bitcoin Mainnet", BtcMainnetChain().ChainId, true}, - {"Bitcoin Testnet", BtcTestNetChain().ChainId, true}, - {"Bitcoin Regtest", BtcRegtestChain().ChainId, true}, - {"Non-Bitcoin", EthChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsBitcoinChain(tt.chainID)) - }) - } -} - -func TestIsEthereumChain(t *testing.T) { - tests := []struct { - name string - chainID int64 - want bool - }{ - {"Ethereum Mainnet", EthChain().ChainId, true}, - {"Goerli Testnet", GoerliChain().ChainId, true}, - {"Sepolia Testnet", SepoliaChain().ChainId, true}, - {"Non-Ethereum", BtcMainnetChain().ChainId, false}, - {"Zeta Mainnet", ZetaChainMainnet().ChainId, false}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - require.Equal(t, tt.want, IsEthereumChain(tt.chainID)) - }) - } -} - -func TestChain_IsExternalChain(t *testing.T) { - require.False(t, ZetaChainMainnet().IsExternalChain()) - require.True(t, EthChain().IsExternalChain()) -} - -func TestChain_IsZetaChain(t *testing.T) { - require.True(t, ZetaChainMainnet().IsZetaChain()) - require.False(t, EthChain().IsZetaChain()) -} - -func TestChain_IsEmpty(t *testing.T) { - require.True(t, Chain{}.IsEmpty()) - require.False(t, ZetaChainMainnet().IsEmpty()) -} - -func TestChain_WitnessProgram(t *testing.T) { - // Ordinarily the private key would come from whatever storage mechanism - // is being used, but for this example just hard code it. - privKeyBytes, err := hex.DecodeString("22a47fa09a223f2aa079edf85a7c2" + - "d4f8720ee63e502ee2869afab7de234b80c") - require.NoError(t, err) - - t.Run("should return btc address", func(t *testing.T) { - _, pubKey := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes) - pubKeyHash := btcutil.Hash160(pubKey.SerializeCompressed()) - addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) - require.NoError(t, err) - - chain := BtcTestNetChain() - _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) - require.NoError(t, err) - }) - - t.Run("should fail for wrong chain id", func(t *testing.T) { - _, pubKey := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes) - pubKeyHash := btcutil.Hash160(pubKey.SerializeCompressed()) - addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) - require.NoError(t, err) - - chain := GoerliChain() - _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()) - require.Error(t, err) - }) - - t.Run("should fail for wrong witness program", func(t *testing.T) { - _, pubKey := btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes) - pubKeyHash := btcutil.Hash160(pubKey.SerializeCompressed()) - addr, err := btcutil.NewAddressWitnessPubKeyHash(pubKeyHash, &chaincfg.RegressionNetParams) - require.NoError(t, err) - - chain := BtcTestNetChain() - _, err = chain.BTCAddressFromWitnessProgram(addr.WitnessProgram()[0:19]) - require.Error(t, err) - }) -} - -func TestChains_Has(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaTestnetChain()} - require.True(t, chains.Has(ZetaChainMainnet())) - require.False(t, chains.Has(EthChain())) -} - -func TestChains_Distinct(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaChainMainnet(), ZetaTestnetChain()} - distinctChains := chains.Distinct() - require.Len(t, distinctChains, 2) -} - -func TestChains_Strings(t *testing.T) { - chains := Chains{ZetaChainMainnet(), ZetaTestnetChain()} - strings := chains.Strings() - expected := []string{chains[0].String(), chains[1].String()} - require.Equal(t, expected, strings) -} - -func TestGetChainFromChainID(t *testing.T) { - chain := GetChainFromChainID(ZetaChainMainnet().ChainId) - require.Equal(t, ZetaChainMainnet(), *chain) - require.Nil(t, GetChainFromChainID(9999)) -} - -func TestGetBTCChainParams(t *testing.T) { - params, err := GetBTCChainParams(BtcMainnetChain().ChainId) - require.NoError(t, err) - require.Equal(t, &chaincfg.MainNetParams, params) - - _, err = GetBTCChainParams(9999) - require.Error(t, err) -} - -func TestGetBTCChainIDFromChainParams(t *testing.T) { - chainID, err := GetBTCChainIDFromChainParams(&chaincfg.MainNetParams) - require.NoError(t, err) - require.Equal(t, int64(8332), chainID) - - chainID, err = GetBTCChainIDFromChainParams(&chaincfg.RegressionNetParams) - require.NoError(t, err) - require.Equal(t, int64(18444), chainID) - - chainID, err = GetBTCChainIDFromChainParams(&chaincfg.TestNet3Params) - require.NoError(t, err) - require.Equal(t, int64(18332), chainID) - - _, err = GetBTCChainIDFromChainParams(&chaincfg.Params{Name: "unknown"}) - require.Error(t, err) -} - -func TestChainIDInChainList(t *testing.T) { - require.True(t, ChainIDInChainList(ZetaChainMainnet().ChainId, ZetaChainList())) - require.False(t, ChainIDInChainList(EthChain().ChainId, ZetaChainList())) -} diff --git a/pkg/address.go b/pkg/chains/address.go similarity index 99% rename from pkg/address.go rename to pkg/chains/address.go index d38aab79e9..6ee8647f8b 100644 --- a/pkg/address.go +++ b/pkg/chains/address.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "errors" diff --git a/pkg/address_test.go b/pkg/chains/address_test.go similarity index 99% rename from pkg/address_test.go rename to pkg/chains/address_test.go index ea32cb9e89..f34b1145c5 100644 --- a/pkg/address_test.go +++ b/pkg/chains/address_test.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "errors" diff --git a/pkg/bitcoin.go b/pkg/chains/bitcoin.go similarity index 98% rename from pkg/bitcoin.go rename to pkg/chains/bitcoin.go index 77c70e351b..42f5ee7db2 100644 --- a/pkg/bitcoin.go +++ b/pkg/chains/bitcoin.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "fmt" diff --git a/pkg/bitcoin_test.go b/pkg/chains/bitcoin_test.go similarity index 98% rename from pkg/bitcoin_test.go rename to pkg/chains/bitcoin_test.go index 2f28e91fff..042cc6acaa 100644 --- a/pkg/bitcoin_test.go +++ b/pkg/chains/bitcoin_test.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "testing" diff --git a/pkg/chain.go b/pkg/chains/chain.go similarity index 99% rename from pkg/chain.go rename to pkg/chains/chain.go index 1f48d28d65..9d24216272 100644 --- a/pkg/chain.go +++ b/pkg/chains/chain.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "fmt" diff --git a/pkg/chain_id.go b/pkg/chains/chain_id.go similarity index 98% rename from pkg/chain_id.go rename to pkg/chains/chain_id.go index 8356a925bd..18b0704752 100644 --- a/pkg/chain_id.go +++ b/pkg/chains/chain_id.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "errors" diff --git a/pkg/chain_id_test.go b/pkg/chains/chain_id_test.go similarity index 89% rename from pkg/chain_id_test.go rename to pkg/chains/chain_id_test.go index 139412f0e4..63395a2265 100644 --- a/pkg/chain_id_test.go +++ b/pkg/chains/chain_id_test.go @@ -1,10 +1,9 @@ -package pkg_test +package chains import ( "testing" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" ) func TestCosmosToEthChainID(t *testing.T) { @@ -51,7 +50,7 @@ func TestCosmosToEthChainID(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - ethChainID, err := pkg.CosmosToEthChainID(tc.chainID) + ethChainID, err := CosmosToEthChainID(tc.chainID) if tc.isErr { require.Error(t, err) } else { diff --git a/common/chain_test.go b/pkg/chains/chain_test.go similarity index 99% rename from common/chain_test.go rename to pkg/chains/chain_test.go index f694439d8c..8d491d1780 100644 --- a/common/chain_test.go +++ b/pkg/chains/chain_test.go @@ -1,4 +1,4 @@ -package common +package chains import ( "encoding/hex" diff --git a/pkg/chains.go b/pkg/chains/chains.go similarity index 99% rename from pkg/chains.go rename to pkg/chains/chains.go index 63aec166fc..ef1ffc9caf 100644 --- a/pkg/chains.go +++ b/pkg/chains/chains.go @@ -1,4 +1,4 @@ -package pkg +package chains import "fmt" diff --git a/pkg/chains/chains.pb.go b/pkg/chains/chains.pb.go new file mode 100644 index 0000000000..a305e7adbd --- /dev/null +++ b/pkg/chains/chains.pb.go @@ -0,0 +1,450 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/chains/chains.proto + +package chains + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ReceiveStatus int32 + +const ( + ReceiveStatus_Created ReceiveStatus = 0 + ReceiveStatus_Success ReceiveStatus = 1 + ReceiveStatus_Failed ReceiveStatus = 2 +) + +var ReceiveStatus_name = map[int32]string{ + 0: "Created", + 1: "Success", + 2: "Failed", +} + +var ReceiveStatus_value = map[string]int32{ + "Created": 0, + "Success": 1, + "Failed": 2, +} + +func (x ReceiveStatus) String() string { + return proto.EnumName(ReceiveStatus_name, int32(x)) +} + +func (ReceiveStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{0} +} + +type ChainName int32 + +const ( + ChainName_empty ChainName = 0 + ChainName_eth_mainnet ChainName = 1 + ChainName_zeta_mainnet ChainName = 2 + ChainName_btc_mainnet ChainName = 3 + ChainName_polygon_mainnet ChainName = 4 + ChainName_bsc_mainnet ChainName = 5 + // Testnet + ChainName_goerli_testnet ChainName = 6 + ChainName_mumbai_testnet ChainName = 7 + ChainName_ganache_testnet ChainName = 8 + ChainName_baobab_testnet ChainName = 9 + ChainName_bsc_testnet ChainName = 10 + ChainName_zeta_testnet ChainName = 11 + ChainName_btc_testnet ChainName = 12 + ChainName_sepolia_testnet ChainName = 13 + // LocalNet + // zeta_localnet = 13; + ChainName_goerli_localnet ChainName = 14 + ChainName_btc_regtest ChainName = 15 +) + +var ChainName_name = map[int32]string{ + 0: "empty", + 1: "eth_mainnet", + 2: "zeta_mainnet", + 3: "btc_mainnet", + 4: "polygon_mainnet", + 5: "bsc_mainnet", + 6: "goerli_testnet", + 7: "mumbai_testnet", + 8: "ganache_testnet", + 9: "baobab_testnet", + 10: "bsc_testnet", + 11: "zeta_testnet", + 12: "btc_testnet", + 13: "sepolia_testnet", + 14: "goerli_localnet", + 15: "btc_regtest", +} + +var ChainName_value = map[string]int32{ + "empty": 0, + "eth_mainnet": 1, + "zeta_mainnet": 2, + "btc_mainnet": 3, + "polygon_mainnet": 4, + "bsc_mainnet": 5, + "goerli_testnet": 6, + "mumbai_testnet": 7, + "ganache_testnet": 8, + "baobab_testnet": 9, + "bsc_testnet": 10, + "zeta_testnet": 11, + "btc_testnet": 12, + "sepolia_testnet": 13, + "goerli_localnet": 14, + "btc_regtest": 15, +} + +func (x ChainName) String() string { + return proto.EnumName(ChainName_name, int32(x)) +} + +func (ChainName) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{1} +} + +type Chain struct { + ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=chains.ChainName" json:"chain_name,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` +} + +func (m *Chain) Reset() { *m = Chain{} } +func (m *Chain) String() string { return proto.CompactTextString(m) } +func (*Chain) ProtoMessage() {} +func (*Chain) Descriptor() ([]byte, []int) { + return fileDescriptor_37ad35e0488e8bbc, []int{0} +} +func (m *Chain) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Chain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Chain.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Chain) XXX_Merge(src proto.Message) { + xxx_messageInfo_Chain.Merge(m, src) +} +func (m *Chain) XXX_Size() int { + return m.Size() +} +func (m *Chain) XXX_DiscardUnknown() { + xxx_messageInfo_Chain.DiscardUnknown(m) +} + +var xxx_messageInfo_Chain proto.InternalMessageInfo + +func (m *Chain) GetChainName() ChainName { + if m != nil { + return m.ChainName + } + return ChainName_empty +} + +func (m *Chain) GetChainId() int64 { + if m != nil { + return m.ChainId + } + return 0 +} + +func init() { + proto.RegisterEnum("chains.ReceiveStatus", ReceiveStatus_name, ReceiveStatus_value) + proto.RegisterEnum("chains.ChainName", ChainName_name, ChainName_value) + proto.RegisterType((*Chain)(nil), "chains.Chain") +} + +func init() { proto.RegisterFile("pkg/chains/chains.proto", fileDescriptor_37ad35e0488e8bbc) } + +var fileDescriptor_37ad35e0488e8bbc = []byte{ + // 390 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x92, 0x31, 0xaf, 0xd3, 0x30, + 0x10, 0x80, 0xe3, 0xbc, 0xd7, 0xf4, 0xe5, 0xfa, 0x5e, 0x1b, 0x0c, 0x12, 0xa5, 0x43, 0x54, 0x31, + 0x95, 0x4a, 0x34, 0x08, 0x46, 0x36, 0x2a, 0x21, 0xb1, 0x30, 0xb4, 0x4c, 0x2c, 0x95, 0xe3, 0x9c, + 0x1c, 0x8b, 0x24, 0x8e, 0x12, 0x07, 0xa9, 0xfc, 0x0a, 0x7e, 0x04, 0x03, 0xbf, 0x80, 0xdf, 0xc0, + 0xd8, 0x91, 0x11, 0xb5, 0x7f, 0xe4, 0xc9, 0x4e, 0x93, 0x4c, 0xb9, 0xfb, 0xfc, 0xf9, 0xee, 0x14, + 0x1f, 0x3c, 0x2f, 0xbf, 0x89, 0x88, 0xa7, 0x4c, 0x16, 0xf5, 0xf5, 0xb3, 0x29, 0x2b, 0xa5, 0x15, + 0xf5, 0xda, 0x6c, 0xf1, 0x4c, 0x28, 0xa1, 0x2c, 0x8a, 0x4c, 0xd4, 0x9e, 0xbe, 0xfc, 0x02, 0xa3, + 0xad, 0x39, 0xa7, 0x6f, 0x00, 0xac, 0x78, 0x28, 0x58, 0x8e, 0x73, 0xb2, 0x24, 0xab, 0xe9, 0xdb, + 0x27, 0x9b, 0x6b, 0x25, 0xab, 0x7c, 0x66, 0x39, 0xee, 0x7c, 0xde, 0x85, 0xf4, 0x05, 0xdc, 0xb5, + 0x37, 0x64, 0x32, 0x77, 0x97, 0x64, 0x75, 0xb3, 0x1b, 0xdb, 0xfc, 0x53, 0xb2, 0x7e, 0x0f, 0x0f, + 0x3b, 0xe4, 0x28, 0xbf, 0xe3, 0x5e, 0x33, 0xdd, 0xd4, 0x74, 0x02, 0xe3, 0x6d, 0x85, 0x4c, 0x63, + 0x12, 0x38, 0x26, 0xd9, 0x37, 0x9c, 0x63, 0x5d, 0x07, 0x84, 0x02, 0x78, 0x1f, 0x99, 0xcc, 0x30, + 0x09, 0xdc, 0xc5, 0xed, 0xef, 0x5f, 0x21, 0x59, 0xff, 0x71, 0xc1, 0xef, 0x1b, 0x52, 0x1f, 0x46, + 0x98, 0x97, 0xfa, 0x18, 0x38, 0x74, 0x06, 0x13, 0xd4, 0xe9, 0x21, 0x67, 0xb2, 0x28, 0x50, 0x07, + 0x84, 0x06, 0x70, 0xff, 0x03, 0x35, 0xeb, 0x89, 0x6b, 0x94, 0x58, 0xf3, 0x1e, 0xdc, 0xd0, 0xa7, + 0x30, 0x2b, 0x55, 0x76, 0x14, 0xaa, 0xe8, 0xe1, 0xad, 0xb5, 0xea, 0xc1, 0x1a, 0x51, 0x0a, 0x53, + 0xa1, 0xb0, 0xca, 0xe4, 0x41, 0x63, 0xad, 0x0d, 0xf3, 0x0c, 0xcb, 0x9b, 0x3c, 0x66, 0x03, 0x1b, + 0x9b, 0x6a, 0x82, 0x15, 0x8c, 0xa7, 0xd8, 0xc3, 0x3b, 0x23, 0xc6, 0x4c, 0xc5, 0x2c, 0xee, 0x99, + 0xdf, 0x75, 0xe8, 0x00, 0xf4, 0xa3, 0x76, 0x64, 0xd2, 0x8d, 0xda, 0x81, 0x7b, 0x53, 0xbc, 0xc6, + 0x52, 0x65, 0x72, 0xb0, 0x1e, 0x6c, 0xc7, 0x76, 0xb2, 0x4c, 0x71, 0x96, 0x19, 0x38, 0xed, 0xae, + 0x56, 0x28, 0x8c, 0x18, 0xcc, 0xda, 0x1f, 0xf7, 0x61, 0xfb, 0xf7, 0x1c, 0x92, 0xd3, 0x39, 0x24, + 0xff, 0xcf, 0x21, 0xf9, 0x79, 0x09, 0x9d, 0xd3, 0x25, 0x74, 0xfe, 0x5d, 0x42, 0xe7, 0xeb, 0x2b, + 0x21, 0x75, 0xda, 0xc4, 0x1b, 0xae, 0xf2, 0xc8, 0x8c, 0xf1, 0xda, 0x3e, 0x94, 0x0d, 0xb9, 0xaa, + 0x30, 0x1a, 0x76, 0x27, 0xf6, 0xec, 0x5e, 0xbc, 0x7b, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xad, 0x5e, + 0x66, 0xdc, 0x50, 0x02, 0x00, 0x00, +} + +func (m *Chain) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Chain) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ChainId != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.ChainId)) + i-- + dAtA[i] = 0x10 + } + if m.ChainName != 0 { + i = encodeVarintChains(dAtA, i, uint64(m.ChainName)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintChains(dAtA []byte, offset int, v uint64) int { + offset -= sovChains(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Chain) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ChainName != 0 { + n += 1 + sovChains(uint64(m.ChainName)) + } + if m.ChainId != 0 { + n += 1 + sovChains(uint64(m.ChainId)) + } + return n +} + +func sovChains(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozChains(x uint64) (n int) { + return sovChains(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Chain) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Chain: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Chain: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainName", wireType) + } + m.ChainName = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainName |= ChainName(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + m.ChainId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChains + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ChainId |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChains(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChains + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipChains(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChains + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChains + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowChains + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthChains + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupChains + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthChains + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthChains = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowChains = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupChains = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/chains_test.go b/pkg/chains/chains_test.go similarity index 99% rename from pkg/chains_test.go rename to pkg/chains/chains_test.go index e6e74d5be1..070cb5922e 100644 --- a/pkg/chains_test.go +++ b/pkg/chains/chains_test.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "testing" diff --git a/pkg/utils.go b/pkg/chains/utils.go similarity index 99% rename from pkg/utils.go rename to pkg/chains/utils.go index f61dcc2117..6a6a6f4091 100644 --- a/pkg/utils.go +++ b/pkg/chains/utils.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "encoding/hex" diff --git a/pkg/utils_test.go b/pkg/chains/utils_test.go similarity index 99% rename from pkg/utils_test.go rename to pkg/chains/utils_test.go index 8a6b18f5f5..ca1f4722ef 100644 --- a/pkg/utils_test.go +++ b/pkg/chains/utils_test.go @@ -1,4 +1,4 @@ -package pkg +package chains import ( "encoding/hex" diff --git a/pkg/coin.go b/pkg/coin/coin.go similarity index 98% rename from pkg/coin.go rename to pkg/coin/coin.go index 3488cd96e8..74bbca935b 100644 --- a/pkg/coin.go +++ b/pkg/coin/coin.go @@ -1,4 +1,4 @@ -package pkg +package coin import ( "fmt" diff --git a/pkg/coin/coin.pb.go b/pkg/coin/coin.pb.go new file mode 100644 index 0000000000..ac4a65780c --- /dev/null +++ b/pkg/coin/coin.pb.go @@ -0,0 +1,76 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/coin/coin.proto + +package coin + +import ( + fmt "fmt" + math "math" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type CoinType int32 + +const ( + CoinType_Zeta CoinType = 0 + CoinType_Gas CoinType = 1 + CoinType_ERC20 CoinType = 2 + CoinType_Cmd CoinType = 3 +) + +var CoinType_name = map[int32]string{ + 0: "Zeta", + 1: "Gas", + 2: "ERC20", + 3: "Cmd", +} + +var CoinType_value = map[string]int32{ + "Zeta": 0, + "Gas": 1, + "ERC20": 2, + "Cmd": 3, +} + +func (x CoinType) String() string { + return proto.EnumName(CoinType_name, int32(x)) +} + +func (CoinType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_dc61d0144bf70fc2, []int{0} +} + +func init() { + proto.RegisterEnum("coin.CoinType", CoinType_name, CoinType_value) +} + +func init() { proto.RegisterFile("pkg/coin/coin.proto", fileDescriptor_dc61d0144bf70fc2) } + +var fileDescriptor_dc61d0144bf70fc2 = []byte{ + // 178 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0xc8, 0x4e, 0xd7, + 0x4f, 0xce, 0xcf, 0xcc, 0x03, 0x13, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x2c, 0x20, 0xb6, + 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x40, 0x1f, 0xc4, 0x82, 0xc8, 0x69, 0x99, 0x73, 0x71, + 0x38, 0xe7, 0x67, 0xe6, 0x85, 0x54, 0x16, 0xa4, 0x0a, 0x71, 0x70, 0xb1, 0x44, 0xa5, 0x96, 0x24, + 0x0a, 0x30, 0x08, 0xb1, 0x73, 0x31, 0xbb, 0x27, 0x16, 0x0b, 0x30, 0x0a, 0x71, 0x72, 0xb1, 0xba, + 0x06, 0x39, 0x1b, 0x19, 0x08, 0x30, 0x81, 0xc4, 0x9c, 0x73, 0x53, 0x04, 0x98, 0xa5, 0x58, 0x56, + 0x2c, 0x91, 0x63, 0x74, 0x72, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, + 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, + 0xf5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xaa, 0xd4, 0x92, 0x44, + 0xdd, 0xe4, 0x8c, 0xc4, 0xcc, 0x3c, 0x30, 0x33, 0x39, 0xbf, 0x28, 0x55, 0x1f, 0xe6, 0xc4, 0x24, + 0x36, 0xb0, 0x13, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4c, 0x7f, 0xab, 0x6e, 0xb5, 0x00, + 0x00, 0x00, +} diff --git a/pkg/coin_test.go b/pkg/coin/coin_test.go similarity index 85% rename from pkg/coin_test.go rename to pkg/coin/coin_test.go index 52131e01c3..6110c20538 100644 --- a/pkg/coin_test.go +++ b/pkg/coin/coin_test.go @@ -1,11 +1,10 @@ -package pkg_test +package coin import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" ) func Test_GetAzetaDecFromAmountInZeta(t *testing.T) { @@ -54,7 +53,7 @@ func Test_GetAzetaDecFromAmountInZeta(t *testing.T) { } for _, tc := range tt { t.Run(tc.name, func(t *testing.T) { - azeta, err := pkg.GetAzetaDecFromAmountInZeta(tc.zetaAmount) + azeta, err := GetAzetaDecFromAmountInZeta(tc.zetaAmount) tc.err(t, err) if err == nil { require.Equal(t, tc.azetaAmount, azeta) @@ -68,56 +67,56 @@ func TestGetCoinType(t *testing.T) { tests := []struct { name string coin string - want pkg.CoinType + want CoinType wantErr bool }{ { name: "valid coin type 0", coin: "0", - want: pkg.CoinType(0), + want: CoinType(0), wantErr: false, }, { name: "valid coin type 1", coin: "1", - want: pkg.CoinType(1), + want: CoinType(1), wantErr: false, }, { name: "valid coin type 2", coin: "2", - want: pkg.CoinType(2), + want: CoinType(2), wantErr: false, }, { name: "valid coin type 3", coin: "3", - want: pkg.CoinType(3), + want: CoinType(3), wantErr: false, }, { name: "invalid coin type negative", coin: "-1", - want: pkg.CoinType_Cmd, + want: CoinType_Cmd, wantErr: true, }, { name: "invalid coin type large number", coin: "4", - want: pkg.CoinType_Cmd, + want: CoinType_Cmd, wantErr: true, }, { name: "invalid coin type non-integer", coin: "abc", - want: pkg.CoinType_Cmd, + want: CoinType_Cmd, wantErr: true, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := pkg.GetCoinType(tt.coin) + got, err := GetCoinType(tt.coin) if tt.wantErr { require.Error(t, err) } else { diff --git a/pkg/crypto/crypto.pb.go b/pkg/crypto/crypto.pb.go new file mode 100644 index 0000000000..db9a9a6821 --- /dev/null +++ b/pkg/crypto/crypto.pb.go @@ -0,0 +1,371 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/crypto/crypto.proto + +package crypto + +import ( + fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/gogo/protobuf/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// PubKeySet contains two pub keys , secp256k1 and ed25519 +type PubKeySet struct { + Secp256k1 PubKey `protobuf:"bytes,1,opt,name=secp256k1,proto3,casttype=PubKey" json:"secp256k1,omitempty"` + Ed25519 PubKey `protobuf:"bytes,2,opt,name=ed25519,proto3,casttype=PubKey" json:"ed25519,omitempty"` +} + +func (m *PubKeySet) Reset() { *m = PubKeySet{} } +func (m *PubKeySet) String() string { return proto.CompactTextString(m) } +func (*PubKeySet) ProtoMessage() {} +func (*PubKeySet) Descriptor() ([]byte, []int) { + return fileDescriptor_5643a513c82df681, []int{0} +} +func (m *PubKeySet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PubKeySet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PubKeySet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PubKeySet) XXX_Merge(src proto.Message) { + xxx_messageInfo_PubKeySet.Merge(m, src) +} +func (m *PubKeySet) XXX_Size() int { + return m.Size() +} +func (m *PubKeySet) XXX_DiscardUnknown() { + xxx_messageInfo_PubKeySet.DiscardUnknown(m) +} + +var xxx_messageInfo_PubKeySet proto.InternalMessageInfo + +func (m *PubKeySet) GetSecp256k1() PubKey { + if m != nil { + return m.Secp256k1 + } + return "" +} + +func (m *PubKeySet) GetEd25519() PubKey { + if m != nil { + return m.Ed25519 + } + return "" +} + +func init() { + proto.RegisterType((*PubKeySet)(nil), "crypto.PubKeySet") +} + +func init() { proto.RegisterFile("pkg/crypto/crypto.proto", fileDescriptor_5643a513c82df681) } + +var fileDescriptor_5643a513c82df681 = []byte{ + // 195 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2f, 0xc8, 0x4e, 0xd7, + 0x4f, 0x2e, 0xaa, 0x2c, 0x28, 0xc9, 0x87, 0x52, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x6c, + 0x10, 0x9e, 0x94, 0x48, 0x7a, 0x7e, 0x7a, 0x3e, 0x58, 0x48, 0x1f, 0xc4, 0x82, 0xc8, 0x2a, 0x65, + 0x70, 0x71, 0x06, 0x94, 0x26, 0x79, 0xa7, 0x56, 0x06, 0xa7, 0x96, 0x08, 0x99, 0x72, 0x71, 0x16, + 0xa7, 0x26, 0x17, 0x18, 0x99, 0x9a, 0x65, 0x1b, 0x4a, 0x30, 0x2a, 0x30, 0x6a, 0x70, 0x3a, 0x89, + 0x3f, 0xba, 0x27, 0xcf, 0x19, 0x0c, 0x13, 0xfc, 0x75, 0x4f, 0x9e, 0x0d, 0xa2, 0x3c, 0x08, 0xa1, + 0x52, 0x48, 0x85, 0x8b, 0x3d, 0x35, 0xc5, 0xc8, 0xd4, 0xd4, 0xd0, 0x52, 0x82, 0x09, 0xac, 0x89, + 0x0b, 0x49, 0x1d, 0x4c, 0xca, 0xc9, 0xf9, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, + 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, + 0xa2, 0x34, 0xd3, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0xab, 0x52, 0x4b, + 0x12, 0x75, 0x93, 0x33, 0x12, 0x33, 0xf3, 0xc0, 0xcc, 0xe4, 0xfc, 0xa2, 0x54, 0x7d, 0x84, 0xcf, + 0x92, 0xd8, 0xc0, 0xae, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x44, 0x43, 0x35, 0xee, + 0x00, 0x00, 0x00, +} + +func (m *PubKeySet) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PubKeySet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PubKeySet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ed25519) > 0 { + i -= len(m.Ed25519) + copy(dAtA[i:], m.Ed25519) + i = encodeVarintCrypto(dAtA, i, uint64(len(m.Ed25519))) + i-- + dAtA[i] = 0x12 + } + if len(m.Secp256k1) > 0 { + i -= len(m.Secp256k1) + copy(dAtA[i:], m.Secp256k1) + i = encodeVarintCrypto(dAtA, i, uint64(len(m.Secp256k1))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintCrypto(dAtA []byte, offset int, v uint64) int { + offset -= sovCrypto(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PubKeySet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Secp256k1) + if l > 0 { + n += 1 + l + sovCrypto(uint64(l)) + } + l = len(m.Ed25519) + if l > 0 { + n += 1 + l + sovCrypto(uint64(l)) + } + return n +} + +func sovCrypto(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozCrypto(x uint64) (n int) { + return sovCrypto(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PubKeySet) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrypto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PubKeySet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PubKeySet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Secp256k1", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrypto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrypto + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrypto + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Secp256k1 = PubKey(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCrypto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCrypto + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCrypto + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ed25519 = PubKey(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipCrypto(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthCrypto + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipCrypto(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCrypto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCrypto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowCrypto + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthCrypto + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupCrypto + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthCrypto + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthCrypto = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowCrypto = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupCrypto = fmt.Errorf("proto: unexpected end of group") +) diff --git a/pkg/pubkey.go b/pkg/crypto/pubkey.go similarity index 91% rename from pkg/pubkey.go rename to pkg/crypto/pubkey.go index 4fc03a38b1..703d0bdad4 100644 --- a/pkg/pubkey.go +++ b/pkg/crypto/pubkey.go @@ -1,4 +1,4 @@ -package pkg +package crypto import ( "encoding/json" @@ -15,6 +15,7 @@ import ( eth "github.com/ethereum/go-ethereum/crypto" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/cosmos" ) @@ -71,31 +72,31 @@ func (pubKey PubKey) String() string { } // GetAddress will return an address for the given chain -func (pubKey PubKey) GetAddress(chain Chain) (Address, error) { - if IsEVMChain(chain.ChainId) { +func (pubKey PubKey) GetAddress(chain chains.Chain) (chains.Address, error) { + if chains.IsEVMChain(chain.ChainId) { return pubKey.GetEVMAddress() } - return NoAddress, nil + return chains.NoAddress, nil } // GetEVMAddress will return the evm address -func (pubKey PubKey) GetEVMAddress() (Address, error) { +func (pubKey PubKey) GetEVMAddress() (chains.Address, error) { if pubKey.IsEmpty() { - return NoAddress, nil + return chains.NoAddress, nil } // retrieve compressed pubkey bytes from bechh32 encoded str pk, err := cosmos.GetPubKeyFromBech32(cosmos.Bech32PubKeyTypeAccPub, string(pubKey)) if err != nil { - return NoAddress, err + return chains.NoAddress, err } // parse compressed bytes removing 5 first bytes (amino encoding) to get uncompressed pub, err := secp256k1.ParsePubKey(pk.Bytes()) if err != nil { - return NoAddress, err + return chains.NoAddress, err } str := strings.ToLower(eth.PubkeyToAddress(*pub.ToECDSA()).String()) - return NewAddress(str), nil + return chains.NewAddress(str), nil } // MarshalJSON to Marshals to JSON using Bech32 diff --git a/pkg/pubkey_test.go b/pkg/crypto/pubkey_test.go similarity index 96% rename from pkg/pubkey_test.go rename to pkg/crypto/pubkey_test.go index 01c55ad919..f86f07fcc0 100644 --- a/pkg/pubkey_test.go +++ b/pkg/crypto/pubkey_test.go @@ -1,4 +1,4 @@ -package pkg +package crypto import ( "encoding/hex" @@ -13,6 +13,7 @@ import ( . "gopkg.in/check.v1" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/cosmos" ) @@ -131,23 +132,23 @@ func (s *PubKeyTestSuite) TestPubKeyGetAddress(c *C) { c.Assert(err, IsNil) c.Assert(os.Setenv("NET", "mainnet"), IsNil) - addrETH, err := pk.GetAddress(GoerliChain()) + addrETH, err := pk.GetAddress(chains.GoerliChain()) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mainnet) c.Assert(os.Setenv("NET", "testnet"), IsNil) - addrETH, err = pk.GetAddress(GoerliChain()) + addrETH, err = pk.GetAddress(chains.GoerliChain()) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.testnet) c.Assert(os.Setenv("NET", "mocknet"), IsNil) - addrETH, err = pk.GetAddress(GoerliChain()) + addrETH, err = pk.GetAddress(chains.GoerliChain()) c.Assert(err, IsNil) c.Assert(addrETH.String(), Equals, d.addrETH.mocknet) - addrETH, err = pk.GetAddress(BtcRegtestChain()) + addrETH, err = pk.GetAddress(chains.BtcRegtestChain()) c.Assert(err, IsNil) - c.Assert(addrETH, Equals, NoAddress) + c.Assert(addrETH, Equals, chains.NoAddress) } } @@ -349,7 +350,7 @@ func TestGetEVMAddress(t *testing.T) { pubKey := PubKey("") e, err := pubKey.GetEVMAddress() require.Nil(t, err) - require.Equal(t, NoAddress, e) + require.Equal(t, chains.NoAddress, e) }) t.Run("should return addr from pubkey", func(t *testing.T) { @@ -365,6 +366,6 @@ func TestGetEVMAddress(t *testing.T) { pk := PubKey("invalid") e, err := pk.GetEVMAddress() require.NotNil(t, err) - require.Equal(t, NoAddress, e) + require.Equal(t, chains.NoAddress, e) }) } diff --git a/pkg/tss.go b/pkg/crypto/tss.go similarity index 98% rename from pkg/tss.go rename to pkg/crypto/tss.go index c2f857608d..fc3c36ed8a 100644 --- a/pkg/tss.go +++ b/pkg/crypto/tss.go @@ -1,4 +1,4 @@ -package pkg +package crypto import ( "github.com/btcsuite/btcd/chaincfg" diff --git a/pkg/tss_test.go b/pkg/crypto/tss_test.go similarity index 99% rename from pkg/tss_test.go rename to pkg/crypto/tss_test.go index 3a36213829..10497f1e85 100644 --- a/pkg/tss_test.go +++ b/pkg/crypto/tss_test.go @@ -1,4 +1,4 @@ -package pkg +package crypto import ( "testing" diff --git a/pkg/gas_limits.go b/pkg/gas/gas_limits.go similarity index 98% rename from pkg/gas_limits.go rename to pkg/gas/gas_limits.go index 7409a2ceb1..d4a3938adb 100644 --- a/pkg/gas_limits.go +++ b/pkg/gas/gas_limits.go @@ -1,4 +1,4 @@ -package pkg +package gas import ( sdkmath "cosmossdk.io/math" diff --git a/pkg/gas_limits_test.go b/pkg/gas/gas_limits_test.go similarity index 99% rename from pkg/gas_limits_test.go rename to pkg/gas/gas_limits_test.go index d4cdcac249..e9b1bbecd0 100644 --- a/pkg/gas_limits_test.go +++ b/pkg/gas/gas_limits_test.go @@ -1,4 +1,4 @@ -package pkg +package gas import ( "testing" diff --git a/pkg/bitcoin/bitcoin.pb.go b/pkg/proofs/bitcoin/bitcoin.pb.go similarity index 86% rename from pkg/bitcoin/bitcoin.pb.go rename to pkg/proofs/bitcoin/bitcoin.pb.go index 2a6c3aa1ec..07f03aa927 100644 --- a/pkg/bitcoin/bitcoin.pb.go +++ b/pkg/proofs/bitcoin/bitcoin.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pkg/bitcoin/bitcoin.proto +// source: pkg/proofs/bitcoin/bitcoin.proto package bitcoin @@ -33,7 +33,7 @@ func (m *Proof) Reset() { *m = Proof{} } func (m *Proof) String() string { return proto.CompactTextString(m) } func (*Proof) ProtoMessage() {} func (*Proof) Descriptor() ([]byte, []int) { - return fileDescriptor_0c0df266727f042c, []int{0} + return fileDescriptor_683fe0fe4796f27d, []int{0} } func (m *Proof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -87,22 +87,22 @@ func init() { proto.RegisterType((*Proof)(nil), "bitcoin.Proof") } -func init() { proto.RegisterFile("pkg/bitcoin/bitcoin.proto", fileDescriptor_0c0df266727f042c) } +func init() { proto.RegisterFile("pkg/proofs/bitcoin/bitcoin.proto", fileDescriptor_683fe0fe4796f27d) } -var fileDescriptor_0c0df266727f042c = []byte{ - // 178 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0xc8, 0x4e, 0xd7, - 0x4f, 0xca, 0x2c, 0x49, 0xce, 0xcf, 0xcc, 0x83, 0xd1, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, - 0xec, 0x50, 0xae, 0x92, 0x0f, 0x17, 0x6b, 0x40, 0x51, 0x7e, 0x7e, 0x9a, 0x90, 0x24, 0x17, 0x47, - 0x49, 0x45, 0x7c, 0x52, 0x65, 0x49, 0x6a, 0xb1, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x7b, - 0x49, 0x85, 0x13, 0x88, 0x2b, 0x24, 0xc4, 0xc5, 0x52, 0x90, 0x58, 0x92, 0x21, 0xc1, 0x04, 0x16, - 0x06, 0xb3, 0x85, 0x44, 0xb8, 0x58, 0x33, 0xf3, 0x52, 0x52, 0x2b, 0x24, 0x98, 0x15, 0x18, 0x35, - 0x78, 0x83, 0x20, 0x1c, 0x27, 0x97, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, - 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, - 0xd2, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0xaf, 0x4a, 0x2d, 0x49, - 0xd4, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0x03, 0x33, 0x93, 0xf3, 0x8b, 0x52, 0xf5, 0x91, 0x9c, 0x9a, - 0xc4, 0x06, 0x76, 0xa3, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x87, 0x34, 0x28, 0xd8, 0xc0, 0x00, - 0x00, 0x00, +var fileDescriptor_683fe0fe4796f27d = []byte{ + // 183 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x28, 0xc8, 0x4e, 0xd7, + 0x2f, 0x28, 0xca, 0xcf, 0x4f, 0x2b, 0xd6, 0x4f, 0xca, 0x2c, 0x49, 0xce, 0xcf, 0xcc, 0x83, 0xd1, + 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xec, 0x50, 0xae, 0x92, 0x0f, 0x17, 0x6b, 0x00, 0x48, + 0xa1, 0x90, 0x24, 0x17, 0x47, 0x49, 0x45, 0x7c, 0x52, 0x65, 0x49, 0x6a, 0xb1, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x4f, 0x10, 0x7b, 0x49, 0x85, 0x13, 0x88, 0x2b, 0x24, 0xc4, 0xc5, 0x52, 0x90, 0x58, + 0x92, 0x21, 0xc1, 0x04, 0x16, 0x06, 0xb3, 0x85, 0x44, 0xb8, 0x58, 0x33, 0xf3, 0x52, 0x52, 0x2b, + 0x24, 0x98, 0x15, 0x18, 0x35, 0x78, 0x83, 0x20, 0x1c, 0x27, 0xef, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, + 0xd5, 0xaf, 0x4a, 0x2d, 0x49, 0xd4, 0x4d, 0xce, 0x48, 0xcc, 0xcc, 0x03, 0x33, 0x93, 0xf3, 0x8b, + 0x52, 0xf5, 0x31, 0x5d, 0x9c, 0xc4, 0x06, 0x76, 0xaa, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x4f, + 0xf2, 0x97, 0x80, 0xce, 0x00, 0x00, 0x00, } func (m *Proof) Marshal() (dAtA []byte, err error) { diff --git a/pkg/bitcoin/bitcoin_spv.go b/pkg/proofs/bitcoin/bitcoin_spv.go similarity index 100% rename from pkg/bitcoin/bitcoin_spv.go rename to pkg/proofs/bitcoin/bitcoin_spv.go diff --git a/pkg/bitcoin/bitcoin_spv_test.go b/pkg/proofs/bitcoin/bitcoin_spv_test.go similarity index 100% rename from pkg/bitcoin/bitcoin_spv_test.go rename to pkg/proofs/bitcoin/bitcoin_spv_test.go diff --git a/pkg/bitcoin/proof.go b/pkg/proofs/bitcoin/proof.go similarity index 100% rename from pkg/bitcoin/proof.go rename to pkg/proofs/bitcoin/proof.go diff --git a/pkg/bitcoin/proof_test.go b/pkg/proofs/bitcoin/proof_test.go similarity index 100% rename from pkg/bitcoin/proof_test.go rename to pkg/proofs/bitcoin/proof_test.go diff --git a/pkg/ethereum/ethereum.pb.go b/pkg/proofs/ethereum/ethereum.pb.go similarity index 86% rename from pkg/ethereum/ethereum.pb.go rename to pkg/proofs/ethereum/ethereum.pb.go index d2c6b29db2..4cbfd2ba74 100644 --- a/pkg/ethereum/ethereum.pb.go +++ b/pkg/proofs/ethereum/ethereum.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pkg/ethereum/ethereum.proto +// source: pkg/proofs/ethereum/ethereum.proto package ethereum @@ -32,7 +32,7 @@ func (m *Proof) Reset() { *m = Proof{} } func (m *Proof) String() string { return proto.CompactTextString(m) } func (*Proof) ProtoMessage() {} func (*Proof) Descriptor() ([]byte, []int) { - return fileDescriptor_824ba8ad73eb50c7, []int{0} + return fileDescriptor_bd99cabd67598caa, []int{0} } func (m *Proof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,20 +79,23 @@ func init() { proto.RegisterType((*Proof)(nil), "ethereum.Proof") } -func init() { proto.RegisterFile("pkg/ethereum/ethereum.proto", fileDescriptor_824ba8ad73eb50c7) } +func init() { + proto.RegisterFile("pkg/proofs/ethereum/ethereum.proto", fileDescriptor_bd99cabd67598caa) +} -var fileDescriptor_824ba8ad73eb50c7 = []byte{ - // 156 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2e, 0xc8, 0x4e, 0xd7, - 0x4f, 0x2d, 0xc9, 0x48, 0x2d, 0x4a, 0x2d, 0xcd, 0x85, 0x33, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, - 0x85, 0x38, 0x60, 0x7c, 0x25, 0x63, 0x2e, 0xd6, 0x80, 0xa2, 0xfc, 0xfc, 0x34, 0x21, 0x21, 0x2e, - 0x96, 0xec, 0xd4, 0xca, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x9e, 0x20, 0x30, 0x5b, 0x48, 0x8c, - 0x8b, 0xad, 0x2c, 0x31, 0xa7, 0x34, 0xb5, 0x58, 0x82, 0x09, 0x2c, 0x0a, 0xe5, 0x39, 0xb9, 0x9e, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x76, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x55, 0x6a, 0x49, 0xa2, 0x6e, 0x72, 0x46, 0x62, 0x66, 0x1e, - 0x98, 0x99, 0x9c, 0x5f, 0x94, 0xaa, 0x8f, 0xec, 0xa8, 0x24, 0x36, 0xb0, 0x63, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x74, 0x7b, 0xe9, 0x63, 0xab, 0x00, 0x00, 0x00, +var fileDescriptor_bd99cabd67598caa = []byte{ + // 161 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0xc8, 0x4e, 0xd7, + 0x2f, 0x28, 0xca, 0xcf, 0x4f, 0x2b, 0xd6, 0x4f, 0x2d, 0xc9, 0x48, 0x2d, 0x4a, 0x2d, 0xcd, 0x85, + 0x33, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x38, 0x60, 0x7c, 0x25, 0x63, 0x2e, 0xd6, 0x00, + 0x90, 0x5a, 0x21, 0x21, 0x2e, 0x96, 0xec, 0xd4, 0xca, 0x62, 0x09, 0x46, 0x05, 0x66, 0x0d, 0x9e, + 0x20, 0x30, 0x5b, 0x48, 0x8c, 0x8b, 0xad, 0x2c, 0x31, 0xa7, 0x34, 0xb5, 0x58, 0x82, 0x09, 0x2c, + 0x0a, 0xe5, 0x39, 0xf9, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, + 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x51, + 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x55, 0x6a, 0x49, 0xa2, 0x6e, + 0x72, 0x46, 0x62, 0x66, 0x1e, 0x98, 0x99, 0x9c, 0x5f, 0x94, 0xaa, 0x8f, 0xc5, 0x6d, 0x49, 0x6c, + 0x60, 0x37, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xc4, 0xcc, 0xc8, 0xb9, 0x00, 0x00, + 0x00, } func (m *Proof) Marshal() (dAtA []byte, err error) { diff --git a/pkg/ethereum/proof.go b/pkg/proofs/ethereum/proof.go similarity index 100% rename from pkg/ethereum/proof.go rename to pkg/proofs/ethereum/proof.go diff --git a/pkg/ethereum/proof_test.go b/pkg/proofs/ethereum/proof_test.go similarity index 100% rename from pkg/ethereum/proof_test.go rename to pkg/proofs/ethereum/proof_test.go diff --git a/pkg/headers.go b/pkg/proofs/headers.go similarity index 97% rename from pkg/headers.go rename to pkg/proofs/headers.go index f618a70678..64d2a6b2f1 100644 --- a/pkg/headers.go +++ b/pkg/proofs/headers.go @@ -1,4 +1,4 @@ -package pkg +package proofs import ( "bytes" @@ -13,7 +13,8 @@ import ( "github.com/btcsuite/btcutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/zeta-chain/zetacore/pkg/bitcoin" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" ) // NewEthereumHeader returns a new HeaderData containing an Ethereum header @@ -148,7 +149,7 @@ func ValidateBitcoinHeader(headerBytes []byte, blockHash []byte, chainID int64) } // Timestamp must be not earlier than genesis block - chainParams, err := GetBTCChainParams(chainID) + chainParams, err := chains.GetBTCChainParams(chainID) if err != nil { return fmt.Errorf("cannot get chain params (%s) for chain id (%d)", err, chainID) } diff --git a/pkg/headers_test.go b/pkg/proofs/headers_test.go similarity index 91% rename from pkg/headers_test.go rename to pkg/proofs/headers_test.go index 6c7daed12d..f9499a9c2b 100644 --- a/pkg/headers_test.go +++ b/pkg/proofs/headers_test.go @@ -1,4 +1,4 @@ -package pkg_test +package proofs import ( "bytes" @@ -16,7 +16,6 @@ import ( "github.com/btcsuite/btcd/wire" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/pkg/testdata" ) @@ -37,7 +36,7 @@ func TestTrueEthereumHeader(t *testing.T) { err = header.EncodeRLP(&buffer) require.NoError(t, err) - headerData := pkg.NewEthereumHeader(buffer.Bytes()) + headerData := NewEthereumHeader(buffer.Bytes()) err = headerData.Validate(header.Hash().Bytes(), 1, 18495266) require.NoError(t, err) @@ -66,7 +65,7 @@ func TestFalseEthereumHeader(t *testing.T) { err = header.EncodeRLP(&buffer) require.NoError(t, err) - headerData := pkg.NewEthereumHeader(buffer.Bytes()) + headerData := NewEthereumHeader(buffer.Bytes()) err = headerData.Validate(hash.Bytes(), 1, 18495267) require.Error(t, err) } @@ -100,7 +99,7 @@ func TestFakeBitcoinHeader(t *testing.T) { } func TestNonExistentHeaderType(t *testing.T) { - headerData := pkg.HeaderData{} + headerData := HeaderData{} err := headerData.Validate([]byte{}, 18332, 0) require.EqualError(t, err, "unrecognized header type") @@ -184,7 +183,7 @@ func unmarshalHeader(t *testing.T, headerBytes []byte) *wire.BlockHeader { func validateTrueBitcoinHeader(t *testing.T, header *wire.BlockHeader, headerBytes []byte) { blockHash := header.BlockHash() - headerData := pkg.NewBitcoinHeader(headerBytes) + headerData := NewBitcoinHeader(headerBytes) // True Bitcoin header should pass validation err := headerData.Validate(blockHash[:], 18332, 0) require.NoError(t, err) @@ -202,7 +201,7 @@ func validateFakeBitcoinHeader(t *testing.T, header *wire.BlockHeader, headerByt blockHash := header.BlockHash() // Incorrect header length should fail validation - err := pkg.ValidateBitcoinHeader(headerBytes[:79], blockHash[:], 18332) + err := ValidateBitcoinHeader(headerBytes[:79], blockHash[:], 18332) require.Error(t, err) // Incorrect version should fail validation @@ -210,7 +209,7 @@ func validateFakeBitcoinHeader(t *testing.T, header *wire.BlockHeader, headerByt fakeHeader.Version = 0 fakeBytes := marshalHeader(t, fakeHeader) fakeHash := fakeHeader.BlockHash() - err = pkg.ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) + err = ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) require.Error(t, err) // Incorrect timestamp should fail validation @@ -219,24 +218,24 @@ func validateFakeBitcoinHeader(t *testing.T, header *wire.BlockHeader, headerByt fakeHeader.Timestamp = chaincfg.TestNet3Params.GenesisBlock.Header.Timestamp.Add(-time.Second) fakeBytes = marshalHeader(t, fakeHeader) fakeHash = fakeHeader.BlockHash() - err = pkg.ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) + err = ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) require.Error(t, err) // Case2: timestamp is after 2 hours in the future fakeHeader = copyHeader(header) fakeHeader.Timestamp = header.Timestamp.Add(time.Second * (blockchain.MaxTimeOffsetSeconds + 1)) fakeBytes = marshalHeader(t, fakeHeader) - err = pkg.NewBitcoinHeader(fakeBytes).ValidateTimestamp(header.Timestamp) + err = NewBitcoinHeader(fakeBytes).ValidateTimestamp(header.Timestamp) require.Error(t, err) // Incorrect block hash should fail validation fakeHeader = copyHeader(header) header.Nonce = 0 fakeBytes = marshalHeader(t, header) - err = pkg.ValidateBitcoinHeader(fakeBytes, blockHash[:], 18332) + err = ValidateBitcoinHeader(fakeBytes, blockHash[:], 18332) require.Error(t, err) // PoW not satisfied should fail validation fakeHash = fakeHeader.BlockHash() - err = pkg.ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) + err = ValidateBitcoinHeader(fakeBytes, fakeHash[:], 18332) require.Error(t, err) } diff --git a/pkg/proof.go b/pkg/proofs/proof.go similarity index 95% rename from pkg/proof.go rename to pkg/proofs/proof.go index 42ff19d0e8..85b62d6bd0 100644 --- a/pkg/proof.go +++ b/pkg/proofs/proof.go @@ -1,4 +1,4 @@ -package pkg +package proofs import ( "bytes" @@ -8,8 +8,8 @@ import ( "github.com/btcsuite/btcutil" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" - "github.com/zeta-chain/zetacore/pkg/bitcoin" - "github.com/zeta-chain/zetacore/pkg/ethereum" + "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" + "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" ) // ErrInvalidProof is a error type for invalid proofs embedding the underlying error diff --git a/pkg/proof_test.go b/pkg/proofs/proof_test.go similarity index 80% rename from pkg/proof_test.go rename to pkg/proofs/proof_test.go index e25aad49a2..44f28535cb 100644 --- a/pkg/proof_test.go +++ b/pkg/proofs/proof_test.go @@ -1,4 +1,4 @@ -package pkg_test +package proofs import ( "errors" @@ -12,12 +12,9 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" - "github.com/zeta-chain/zetacore/pkg/bitcoin" - "github.com/zeta-chain/zetacore/pkg/ethereum" + "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" + "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" "github.com/zeta-chain/zetacore/pkg/testdata" - "github.com/zeta-chain/zetacore/x/crosschain/keeper" - crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcjson" @@ -30,11 +27,11 @@ const ( ) func Test_IsErrorInvalidProof(t *testing.T) { - require.False(t, pkg.IsErrorInvalidProof(nil)) - require.False(t, pkg.IsErrorInvalidProof(errors.New("foo"))) + require.False(t, IsErrorInvalidProof(nil)) + require.False(t, IsErrorInvalidProof(errors.New("foo"))) invalidProofErr := errors.New("foo") - invalidProof := pkg.NewErrInvalidProof(invalidProofErr) - require.True(t, pkg.IsErrorInvalidProof(invalidProof)) + invalidProof := NewErrInvalidProof(invalidProofErr) + require.True(t, IsErrorInvalidProof(invalidProof)) require.Equal(t, invalidProofErr.Error(), invalidProof.Error()) } @@ -65,7 +62,7 @@ func TestEthereumMerkleProof(t *testing.T) { b, err := rlp.EncodeToBytes(&header) require.NoError(t, err) - headerData := pkg.NewEthereumHeader(b) + headerData := NewEthereumHeader(b) t.Run("should verify tx proof", func(t *testing.T) { var txs types.Transactions for i := 0; i < testdata.TxsCount; i++ { @@ -83,7 +80,7 @@ func TestEthereumMerkleProof(t *testing.T) { proof, err := txsTree.GenerateProof(i) require.NoError(t, err) - ethProof := pkg.NewEthereumProof(proof) + ethProof := NewEthereumProof(proof) _, err = ethProof.Verify(headerData, i) require.NoError(t, err) @@ -107,7 +104,7 @@ func TestEthereumMerkleProof(t *testing.T) { proof, err := txsTree.GenerateProof(i) require.NoError(t, err) - ethProof := pkg.NewEthereumProof(proof) + ethProof := NewEthereumProof(proof) _, err = ethProof.Verify(headerData, i) require.Error(t, err) @@ -153,16 +150,6 @@ func validateBitcoinBlock(t *testing.T, _ *wire.BlockHeader, headerBytes []byte, tx, err := btcutil.NewTxFromBytes(txBytes) require.NoError(t, err) - // Validate Tss SegWit transaction if it's an outTx - if res.Txid == outTxid { - msg := &crosschaintypes.MsgAddToOutTxTracker{ - ChainId: pkg.BtcTestNetChain().ChainId, - Nonce: nonce, - TxHash: outTxid, - } - err = keeper.VerifyBTCOutTxBody(msg, txBytes, tssAddress) - require.NoError(t, err) - } txns = append(txns, tx) txBodies = append(txBodies, txBytes) } @@ -174,15 +161,15 @@ func validateBitcoinBlock(t *testing.T, _ *wire.BlockHeader, headerBytes []byte, require.NoError(t, err) // True proof should verify - proof := pkg.NewBitcoinProof(txBodies[i], path, index) - txBytes, err := proof.Verify(pkg.NewBitcoinHeader(headerBytes), 0) + proof := NewBitcoinProof(txBodies[i], path, index) + txBytes, err := proof.Verify(NewBitcoinHeader(headerBytes), 0) require.NoError(t, err) require.Equal(t, txBytes, txBodies[i]) // Fake proof should not verify fakeIndex := index ^ 0xffffffff // flip all bits - fakeProof := pkg.NewBitcoinProof(txBodies[i], path, fakeIndex) - txBytes, err = fakeProof.Verify(pkg.NewBitcoinHeader(headerBytes), 0) + fakeProof := NewBitcoinProof(txBodies[i], path, fakeIndex) + txBytes, err = fakeProof.Verify(NewBitcoinHeader(headerBytes), 0) require.Error(t, err) require.Nil(t, txBytes) } diff --git a/pkg/proto/pkg.pb.go b/pkg/proofs/proofs.pb.go similarity index 52% rename from pkg/proto/pkg.pb.go rename to pkg/proofs/proofs.pb.go index 5d14e0cf5f..f866e9d782 100644 --- a/pkg/proto/pkg.pb.go +++ b/pkg/proofs/proofs.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pkg/pkg.proto +// source: pkg/proofs/proofs.proto -package proto +package proofs import ( fmt "fmt" @@ -11,8 +11,8 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - bitcoin "github.com/zeta-chain/zetacore/pkg/bitcoin" - ethereum "github.com/zeta-chain/zetacore/pkg/ethereum" + bitcoin "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin" + ethereum "github.com/zeta-chain/zetacore/pkg/proofs/ethereum" ) // Reference imports to suppress errors if they are not otherwise used. @@ -26,240 +26,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type ReceiveStatus int32 - -const ( - ReceiveStatus_Created ReceiveStatus = 0 - ReceiveStatus_Success ReceiveStatus = 1 - ReceiveStatus_Failed ReceiveStatus = 2 -) - -var ReceiveStatus_name = map[int32]string{ - 0: "Created", - 1: "Success", - 2: "Failed", -} - -var ReceiveStatus_value = map[string]int32{ - "Created": 0, - "Success": 1, - "Failed": 2, -} - -func (x ReceiveStatus) String() string { - return proto.EnumName(ReceiveStatus_name, int32(x)) -} - -func (ReceiveStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{0} -} - -type CoinType int32 - -const ( - CoinType_Zeta CoinType = 0 - CoinType_Gas CoinType = 1 - CoinType_ERC20 CoinType = 2 - CoinType_Cmd CoinType = 3 -) - -var CoinType_name = map[int32]string{ - 0: "Zeta", - 1: "Gas", - 2: "ERC20", - 3: "Cmd", -} - -var CoinType_value = map[string]int32{ - "Zeta": 0, - "Gas": 1, - "ERC20": 2, - "Cmd": 3, -} - -func (x CoinType) String() string { - return proto.EnumName(CoinType_name, int32(x)) -} - -func (CoinType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{1} -} - -type ChainName int32 - -const ( - ChainName_empty ChainName = 0 - ChainName_eth_mainnet ChainName = 1 - ChainName_zeta_mainnet ChainName = 2 - ChainName_btc_mainnet ChainName = 3 - ChainName_polygon_mainnet ChainName = 4 - ChainName_bsc_mainnet ChainName = 5 - // Testnet - ChainName_goerli_testnet ChainName = 6 - ChainName_mumbai_testnet ChainName = 7 - ChainName_ganache_testnet ChainName = 8 - ChainName_baobab_testnet ChainName = 9 - ChainName_bsc_testnet ChainName = 10 - ChainName_zeta_testnet ChainName = 11 - ChainName_btc_testnet ChainName = 12 - ChainName_sepolia_testnet ChainName = 13 - // LocalNet - // zeta_localnet = 13; - ChainName_goerli_localnet ChainName = 14 - ChainName_btc_regtest ChainName = 15 -) - -var ChainName_name = map[int32]string{ - 0: "empty", - 1: "eth_mainnet", - 2: "zeta_mainnet", - 3: "btc_mainnet", - 4: "polygon_mainnet", - 5: "bsc_mainnet", - 6: "goerli_testnet", - 7: "mumbai_testnet", - 8: "ganache_testnet", - 9: "baobab_testnet", - 10: "bsc_testnet", - 11: "zeta_testnet", - 12: "btc_testnet", - 13: "sepolia_testnet", - 14: "goerli_localnet", - 15: "btc_regtest", -} - -var ChainName_value = map[string]int32{ - "empty": 0, - "eth_mainnet": 1, - "zeta_mainnet": 2, - "btc_mainnet": 3, - "polygon_mainnet": 4, - "bsc_mainnet": 5, - "goerli_testnet": 6, - "mumbai_testnet": 7, - "ganache_testnet": 8, - "baobab_testnet": 9, - "bsc_testnet": 10, - "zeta_testnet": 11, - "btc_testnet": 12, - "sepolia_testnet": 13, - "goerli_localnet": 14, - "btc_regtest": 15, -} - -func (x ChainName) String() string { - return proto.EnumName(ChainName_name, int32(x)) -} - -func (ChainName) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{2} -} - -// PubKeySet contains two pub keys , secp256k1 and ed25519 -type PubKeySet struct { - Secp256k1 PubKey `protobuf:"bytes,1,opt,name=secp256k1,proto3,casttype=PubKey" json:"secp256k1,omitempty"` - Ed25519 PubKey `protobuf:"bytes,2,opt,name=ed25519,proto3,casttype=PubKey" json:"ed25519,omitempty"` -} - -func (m *PubKeySet) Reset() { *m = PubKeySet{} } -func (m *PubKeySet) String() string { return proto.CompactTextString(m) } -func (*PubKeySet) ProtoMessage() {} -func (*PubKeySet) Descriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{0} -} -func (m *PubKeySet) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PubKeySet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PubKeySet.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PubKeySet) XXX_Merge(src proto.Message) { - xxx_messageInfo_PubKeySet.Merge(m, src) -} -func (m *PubKeySet) XXX_Size() int { - return m.Size() -} -func (m *PubKeySet) XXX_DiscardUnknown() { - xxx_messageInfo_PubKeySet.DiscardUnknown(m) -} - -var xxx_messageInfo_PubKeySet proto.InternalMessageInfo - -func (m *PubKeySet) GetSecp256k1() PubKey { - if m != nil { - return m.Secp256k1 - } - return "" -} - -func (m *PubKeySet) GetEd25519() PubKey { - if m != nil { - return m.Ed25519 - } - return "" -} - -type Chain struct { - ChainName ChainName `protobuf:"varint,1,opt,name=chain_name,json=chainName,proto3,enum=pkg.ChainName" json:"chain_name,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *Chain) Reset() { *m = Chain{} } -func (m *Chain) String() string { return proto.CompactTextString(m) } -func (*Chain) ProtoMessage() {} -func (*Chain) Descriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{1} -} -func (m *Chain) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Chain) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Chain.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *Chain) XXX_Merge(src proto.Message) { - xxx_messageInfo_Chain.Merge(m, src) -} -func (m *Chain) XXX_Size() int { - return m.Size() -} -func (m *Chain) XXX_DiscardUnknown() { - xxx_messageInfo_Chain.DiscardUnknown(m) -} - -var xxx_messageInfo_Chain proto.InternalMessageInfo - -func (m *Chain) GetChainName() ChainName { - if m != nil { - return m.ChainName - } - return ChainName_empty -} - -func (m *Chain) GetChainId() int64 { - if m != nil { - return m.ChainId - } - return 0 -} - type BlockHeader struct { Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` Hash []byte `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` @@ -273,7 +39,7 @@ func (m *BlockHeader) Reset() { *m = BlockHeader{} } func (m *BlockHeader) String() string { return proto.CompactTextString(m) } func (*BlockHeader) ProtoMessage() {} func (*BlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{2} + return fileDescriptor_248469268b1ea9af, []int{0} } func (m *BlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -349,7 +115,7 @@ func (m *HeaderData) Reset() { *m = HeaderData{} } func (m *HeaderData) String() string { return proto.CompactTextString(m) } func (*HeaderData) ProtoMessage() {} func (*HeaderData) Descriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{3} + return fileDescriptor_248469268b1ea9af, []int{1} } func (m *HeaderData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -435,7 +201,7 @@ func (m *Proof) Reset() { *m = Proof{} } func (m *Proof) String() string { return proto.CompactTextString(m) } func (*Proof) ProtoMessage() {} func (*Proof) Descriptor() ([]byte, []int) { - return fileDescriptor_9a6ed24fa3ed052d, []int{4} + return fileDescriptor_248469268b1ea9af, []int{2} } func (m *Proof) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -510,134 +276,39 @@ func (*Proof) XXX_OneofWrappers() []interface{} { } func init() { - proto.RegisterEnum("pkg.ReceiveStatus", ReceiveStatus_name, ReceiveStatus_value) - proto.RegisterEnum("pkg.CoinType", CoinType_name, CoinType_value) - proto.RegisterEnum("pkg.ChainName", ChainName_name, ChainName_value) - proto.RegisterType((*PubKeySet)(nil), "pkg.PubKeySet") - proto.RegisterType((*Chain)(nil), "pkg.Chain") - proto.RegisterType((*BlockHeader)(nil), "pkg.BlockHeader") - proto.RegisterType((*HeaderData)(nil), "pkg.HeaderData") - proto.RegisterType((*Proof)(nil), "pkg.Proof") -} - -func init() { proto.RegisterFile("pkg/pkg.proto", fileDescriptor_9a6ed24fa3ed052d) } - -var fileDescriptor_9a6ed24fa3ed052d = []byte{ - // 690 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x94, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xc7, 0xed, 0xdc, 0x7d, 0x72, 0xb3, 0xe6, 0xfb, 0xf4, 0x7d, 0x6d, 0x91, 0x92, 0x2a, 0x42, - 0xa2, 0x54, 0x6a, 0x42, 0x83, 0xc2, 0x45, 0xec, 0x12, 0x2e, 0x45, 0x48, 0xa8, 0x38, 0xac, 0xba, - 0x89, 0xc6, 0xf6, 0xc1, 0xb6, 0x12, 0x7b, 0x2c, 0x7b, 0x82, 0x14, 0x76, 0xbc, 0x01, 0x0f, 0xd1, - 0x05, 0x4f, 0xc0, 0x33, 0x74, 0xd9, 0x25, 0xab, 0x0a, 0xa5, 0x6f, 0xc1, 0x0a, 0xcd, 0xd8, 0xe3, - 0x94, 0x95, 0xcf, 0xf9, 0xff, 0x7f, 0xe7, 0x62, 0x7b, 0x34, 0xd0, 0x8e, 0x97, 0xde, 0x28, 0x5e, - 0x7a, 0xc3, 0x38, 0x61, 0x9c, 0x91, 0x72, 0xbc, 0xf4, 0x0e, 0xfe, 0xf5, 0x98, 0xc7, 0x64, 0x3e, - 0x12, 0x51, 0x66, 0x1d, 0xec, 0x0b, 0xd2, 0x0e, 0xb8, 0xc3, 0x82, 0x48, 0x3d, 0x73, 0xeb, 0x9e, - 0xb0, 0x90, 0xfb, 0x98, 0xe0, 0x3a, 0x2c, 0x82, 0xcc, 0x1c, 0xf8, 0x60, 0x9c, 0xaf, 0xed, 0x77, - 0xb8, 0x99, 0x23, 0x27, 0x13, 0x30, 0x52, 0x74, 0xe2, 0xf1, 0xe4, 0xc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0x0b, 0x72, 0x5a, 0x28, 0x25, 0x81, 0xd8, - 0xdc, 0x29, 0x84, 0x32, 0xf9, 0x07, 0xba, 0x31, 0x5b, 0x6d, 0x3c, 0x16, 0x15, 0x62, 0x45, 0x52, - 0xe9, 0x8e, 0xaa, 0x12, 0x02, 0x1d, 0x8f, 0x61, 0xb2, 0x0a, 0x16, 0x1c, 0x53, 0x2e, 0xb4, 0x9a, - 0xd0, 0xc2, 0x75, 0x68, 0xd3, 0x9d, 0x56, 0x17, 0xdd, 0x3c, 0x1a, 0x51, 0xc7, 0xc7, 0x42, 0x6c, - 0x08, 0xd0, 0xa6, 0xcc, 0xa6, 0x76, 0xa1, 0x19, 0x6a, 0x82, 0x12, 0xa0, 0x58, 0x55, 0x29, 0x4d, - 0xb5, 0xaa, 0x12, 0x5a, 0xa2, 0x79, 0x8a, 0x31, 0x5b, 0x05, 0x3b, 0xaa, 0x2d, 0x27, 0x66, 0x9b, - 0xad, 0x98, 0x43, 0x57, 0x42, 0xec, 0xa8, 0xd2, 0x04, 0x3d, 0x01, 0x9a, 0xdd, 0xec, 0xc3, 0x4d, - 0xa7, 0x57, 0xdb, 0x9e, 0x7e, 0xbd, 0xed, 0xe9, 0xbf, 0xb6, 0x3d, 0xfd, 0xdb, 0x6d, 0x4f, 0xbb, - 0xbe, 0xed, 0x69, 0x3f, 0x6f, 0x7b, 0xda, 0xc5, 0x91, 0x17, 0x70, 0x7f, 0x6d, 0x0f, 0x1d, 0x16, - 0x8e, 0xc4, 0x1a, 0x27, 0xf2, 0xf8, 0xcb, 0xd0, 0x61, 0x09, 0x8e, 0xe4, 0xdd, 0x24, 0x2e, 0x11, - 0xbb, 0x26, 0x1f, 0x8f, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x86, 0x9e, 0x4b, 0x02, 0xaf, 0x04, - 0x00, 0x00, -} - -func (m *PubKeySet) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PubKeySet) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PubKeySet) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Ed25519) > 0 { - i -= len(m.Ed25519) - copy(dAtA[i:], m.Ed25519) - i = encodeVarintPkg(dAtA, i, uint64(len(m.Ed25519))) - i-- - dAtA[i] = 0x12 - } - if len(m.Secp256k1) > 0 { - i -= len(m.Secp256k1) - copy(dAtA[i:], m.Secp256k1) - i = encodeVarintPkg(dAtA, i, uint64(len(m.Secp256k1))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Chain) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *Chain) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Chain) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.ChainId != 0 { - i = encodeVarintPkg(dAtA, i, uint64(m.ChainId)) - i-- - dAtA[i] = 0x10 - } - if m.ChainName != 0 { - i = encodeVarintPkg(dAtA, i, uint64(m.ChainName)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + proto.RegisterType((*BlockHeader)(nil), "proofs.BlockHeader") + proto.RegisterType((*HeaderData)(nil), "proofs.HeaderData") + proto.RegisterType((*Proof)(nil), "proofs.Proof") +} + +func init() { proto.RegisterFile("pkg/proofs/proofs.proto", fileDescriptor_248469268b1ea9af) } + +var fileDescriptor_248469268b1ea9af = []byte{ + // 373 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xbd, 0x6e, 0xea, 0x30, + 0x14, 0xc7, 0x63, 0x08, 0xe1, 0xea, 0x84, 0x0b, 0x92, 0x75, 0x75, 0x6f, 0x2e, 0x43, 0x88, 0xb2, + 0x14, 0x86, 0x26, 0x15, 0x55, 0xa5, 0xce, 0x69, 0x07, 0xba, 0x55, 0x19, 0xbb, 0x44, 0x26, 0x71, + 0xe3, 0x88, 0x82, 0xa3, 0x60, 0x96, 0x6e, 0x7d, 0x83, 0xbe, 0x45, 0x5f, 0x85, 0x91, 0xb1, 0x53, + 0x55, 0xc1, 0x8b, 0x54, 0x71, 0x6c, 0x60, 0xf2, 0xf9, 0xf8, 0x9d, 0xbf, 0xcf, 0x07, 0xfc, 0x2b, + 0x17, 0x79, 0x58, 0x56, 0x9c, 0x3f, 0xaf, 0xd5, 0x13, 0x94, 0x15, 0x17, 0x1c, 0x5b, 0x8d, 0x37, + 0xfc, 0x93, 0xf3, 0x9c, 0xcb, 0x50, 0x58, 0x5b, 0x4d, 0x76, 0xe8, 0x9d, 0x95, 0xcd, 0x0b, 0x91, + 0xf2, 0x62, 0xa5, 0x5f, 0x45, 0xf8, 0x67, 0x04, 0x15, 0x8c, 0x56, 0x74, 0xb3, 0x3c, 0x1a, 0x0d, + 0xe3, 0x7f, 0x20, 0xb0, 0xa3, 0x17, 0x9e, 0x2e, 0x66, 0x94, 0x64, 0xb4, 0xc2, 0x7f, 0xc1, 0x62, + 0xb4, 0xc8, 0x99, 0x70, 0x90, 0x87, 0xc6, 0xed, 0x58, 0x79, 0x18, 0x83, 0xc9, 0xc8, 0x9a, 0x39, + 0x2d, 0x0f, 0x8d, 0x7b, 0xb1, 0xb4, 0xf1, 0x08, 0xec, 0x92, 0x54, 0x74, 0x25, 0x12, 0x99, 0x6a, + 0xcb, 0x14, 0x34, 0xa1, 0x59, 0x0d, 0xfc, 0x87, 0x5f, 0x29, 0x23, 0xc5, 0x2a, 0x29, 0x32, 0xc7, + 0x94, 0x72, 0x5d, 0xe9, 0x3f, 0x64, 0xf8, 0xaa, 0xfe, 0xa7, 0xfe, 0xd1, 0xe9, 0x78, 0x68, 0x6c, + 0x4f, 0x71, 0xa0, 0x46, 0x6f, 0xfa, 0xb8, 0x27, 0x82, 0x44, 0xe6, 0xf6, 0x6b, 0x64, 0xc4, 0x8a, + 0xf3, 0x19, 0xc0, 0x29, 0x87, 0x27, 0x30, 0xd0, 0x93, 0x24, 0x4a, 0xa8, 0x6e, 0xb8, 0x37, 0x33, + 0xe2, 0xbe, 0x4e, 0xa8, 0x91, 0x2e, 0xa0, 0xaf, 0xf6, 0xa2, 0xc9, 0x96, 0x22, 0x7f, 0xab, 0x78, + 0x03, 0x46, 0x16, 0x98, 0x19, 0x11, 0xc4, 0x7f, 0x43, 0xd0, 0x79, 0xac, 0xbb, 0xc1, 0xb7, 0x70, + 0x14, 0x4b, 0x64, 0x7f, 0xf2, 0x13, 0x7b, 0x3a, 0x08, 0x8e, 0x6b, 0x94, 0x60, 0xad, 0xa5, 0x23, + 0x4d, 0xe5, 0x0d, 0x68, 0x71, 0x55, 0xd8, 0x92, 0x85, 0xfd, 0x40, 0x9f, 0x48, 0xd7, 0xf5, 0x54, + 0x40, 0xfa, 0x51, 0x17, 0x3a, 0x12, 0x8f, 0xee, 0xb6, 0x7b, 0x17, 0xed, 0xf6, 0x2e, 0xfa, 0xde, + 0xbb, 0xe8, 0xfd, 0xe0, 0x1a, 0xbb, 0x83, 0x6b, 0x7c, 0x1e, 0x5c, 0xe3, 0x69, 0x92, 0x17, 0x82, + 0x6d, 0xe6, 0x41, 0xca, 0x97, 0xe1, 0x2b, 0x15, 0xe4, 0x52, 0xae, 0x54, 0x9a, 0x29, 0xaf, 0x68, + 0x78, 0x3a, 0xfa, 0xdc, 0x92, 0x37, 0xbe, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x53, 0xf1, 0xe6, + 0x53, 0x62, 0x02, 0x00, 0x00, } func (m *BlockHeader) Marshal() (dAtA []byte, err error) { @@ -666,31 +337,31 @@ func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintPkg(dAtA, i, uint64(size)) + i = encodeVarintProofs(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a if m.ChainId != 0 { - i = encodeVarintPkg(dAtA, i, uint64(m.ChainId)) + i = encodeVarintProofs(dAtA, i, uint64(m.ChainId)) i-- dAtA[i] = 0x20 } if len(m.ParentHash) > 0 { i -= len(m.ParentHash) copy(dAtA[i:], m.ParentHash) - i = encodeVarintPkg(dAtA, i, uint64(len(m.ParentHash))) + i = encodeVarintProofs(dAtA, i, uint64(len(m.ParentHash))) i-- dAtA[i] = 0x1a } if len(m.Hash) > 0 { i -= len(m.Hash) copy(dAtA[i:], m.Hash) - i = encodeVarintPkg(dAtA, i, uint64(len(m.Hash))) + i = encodeVarintProofs(dAtA, i, uint64(len(m.Hash))) i-- dAtA[i] = 0x12 } if m.Height != 0 { - i = encodeVarintPkg(dAtA, i, uint64(m.Height)) + i = encodeVarintProofs(dAtA, i, uint64(m.Height)) i-- dAtA[i] = 0x8 } @@ -739,7 +410,7 @@ func (m *HeaderData_EthereumHeader) MarshalToSizedBuffer(dAtA []byte) (int, erro if m.EthereumHeader != nil { i -= len(m.EthereumHeader) copy(dAtA[i:], m.EthereumHeader) - i = encodeVarintPkg(dAtA, i, uint64(len(m.EthereumHeader))) + i = encodeVarintProofs(dAtA, i, uint64(len(m.EthereumHeader))) i-- dAtA[i] = 0xa } @@ -755,7 +426,7 @@ func (m *HeaderData_BitcoinHeader) MarshalToSizedBuffer(dAtA []byte) (int, error if m.BitcoinHeader != nil { i -= len(m.BitcoinHeader) copy(dAtA[i:], m.BitcoinHeader) - i = encodeVarintPkg(dAtA, i, uint64(len(m.BitcoinHeader))) + i = encodeVarintProofs(dAtA, i, uint64(len(m.BitcoinHeader))) i-- dAtA[i] = 0x12 } @@ -807,7 +478,7 @@ func (m *Proof_EthereumProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintPkg(dAtA, i, uint64(size)) + i = encodeVarintProofs(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -828,15 +499,15 @@ func (m *Proof_BitcoinProof) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintPkg(dAtA, i, uint64(size)) + i = encodeVarintProofs(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } return len(dAtA) - i, nil } -func encodeVarintPkg(dAtA []byte, offset int, v uint64) int { - offset -= sovPkg(v) +func encodeVarintProofs(dAtA []byte, offset int, v uint64) int { + offset -= sovProofs(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -846,38 +517,6 @@ func encodeVarintPkg(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *PubKeySet) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Secp256k1) - if l > 0 { - n += 1 + l + sovPkg(uint64(l)) - } - l = len(m.Ed25519) - if l > 0 { - n += 1 + l + sovPkg(uint64(l)) - } - return n -} - -func (m *Chain) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ChainName != 0 { - n += 1 + sovPkg(uint64(m.ChainName)) - } - if m.ChainId != 0 { - n += 1 + sovPkg(uint64(m.ChainId)) - } - return n -} - func (m *BlockHeader) Size() (n int) { if m == nil { return 0 @@ -885,21 +524,21 @@ func (m *BlockHeader) Size() (n int) { var l int _ = l if m.Height != 0 { - n += 1 + sovPkg(uint64(m.Height)) + n += 1 + sovProofs(uint64(m.Height)) } l = len(m.Hash) if l > 0 { - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } l = len(m.ParentHash) if l > 0 { - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } if m.ChainId != 0 { - n += 1 + sovPkg(uint64(m.ChainId)) + n += 1 + sovProofs(uint64(m.ChainId)) } l = m.Header.Size() - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) return n } @@ -923,7 +562,7 @@ func (m *HeaderData_EthereumHeader) Size() (n int) { _ = l if m.EthereumHeader != nil { l = len(m.EthereumHeader) - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } return n } @@ -935,7 +574,7 @@ func (m *HeaderData_BitcoinHeader) Size() (n int) { _ = l if m.BitcoinHeader != nil { l = len(m.BitcoinHeader) - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } return n } @@ -959,7 +598,7 @@ func (m *Proof_EthereumProof) Size() (n int) { _ = l if m.EthereumProof != nil { l = m.EthereumProof.Size() - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } return n } @@ -971,218 +610,16 @@ func (m *Proof_BitcoinProof) Size() (n int) { _ = l if m.BitcoinProof != nil { l = m.BitcoinProof.Size() - n += 1 + l + sovPkg(uint64(l)) + n += 1 + l + sovProofs(uint64(l)) } return n } -func sovPkg(x uint64) (n int) { +func sovProofs(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozPkg(x uint64) (n int) { - return sovPkg(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *PubKeySet) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PubKeySet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PubKeySet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Secp256k1", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPkg - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPkg - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Secp256k1 = PubKey(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPkg - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPkg - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Ed25519 = PubKey(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPkg(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPkg - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Chain) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: Chain: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Chain: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainName", wireType) - } - m.ChainName = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ChainName |= ChainName(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) - } - m.ChainId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPkg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ChainId |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipPkg(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPkg - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil +func sozProofs(x uint64) (n int) { + return sovProofs(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *BlockHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -1192,7 +629,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1220,7 +657,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1239,7 +676,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1252,11 +689,11 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1273,7 +710,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1286,11 +723,11 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1307,7 +744,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { m.ChainId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1326,7 +763,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1339,11 +776,11 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1354,12 +791,12 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPkg(dAtA[iNdEx:]) + skippy, err := skipProofs(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1381,7 +818,7 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1409,7 +846,7 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1422,11 +859,11 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1442,7 +879,7 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1455,11 +892,11 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1470,12 +907,12 @@ func (m *HeaderData) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPkg(dAtA[iNdEx:]) + skippy, err := skipProofs(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1497,7 +934,7 @@ func (m *Proof) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1525,7 +962,7 @@ func (m *Proof) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1538,11 +975,11 @@ func (m *Proof) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1560,7 +997,7 @@ func (m *Proof) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowPkg + return ErrIntOverflowProofs } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1573,11 +1010,11 @@ func (m *Proof) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if postIndex > l { return io.ErrUnexpectedEOF @@ -1590,12 +1027,12 @@ func (m *Proof) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipPkg(dAtA[iNdEx:]) + skippy, err := skipProofs(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPkg + return ErrInvalidLengthProofs } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1609,7 +1046,7 @@ func (m *Proof) Unmarshal(dAtA []byte) error { } return nil } -func skipPkg(dAtA []byte) (n int, err error) { +func skipProofs(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -1617,7 +1054,7 @@ func skipPkg(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPkg + return 0, ErrIntOverflowProofs } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1634,7 +1071,7 @@ func skipPkg(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPkg + return 0, ErrIntOverflowProofs } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1650,7 +1087,7 @@ func skipPkg(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowPkg + return 0, ErrIntOverflowProofs } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -1663,14 +1100,14 @@ func skipPkg(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthPkg + return 0, ErrInvalidLengthProofs } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupPkg + return 0, ErrUnexpectedEndOfGroupProofs } depth-- case 5: @@ -1679,7 +1116,7 @@ func skipPkg(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthPkg + return 0, ErrInvalidLengthProofs } if depth == 0 { return iNdEx, nil @@ -1689,7 +1126,7 @@ func skipPkg(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthPkg = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowPkg = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupPkg = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthProofs = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowProofs = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupProofs = fmt.Errorf("proto: unexpected end of group") ) diff --git a/proto/crosschain/cross_chain_tx.proto b/proto/crosschain/cross_chain_tx.proto index 88c1f525c6..4ed336ed8f 100644 --- a/proto/crosschain/cross_chain_tx.proto +++ b/proto/crosschain/cross_chain_tx.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/coin/coin.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; @@ -26,7 +26,7 @@ message InboundTxParams { string sender = 1; // this address is the immediate contract/EOA that calls the Connector.send() int64 sender_chain_id = 2; string tx_origin = 3; // this address is the EOA that signs the inbound tx - pkg.CoinType coin_type = 4; + coin.CoinType coin_type = 4; string asset = 5; // for ERC20 coin type, the asset is an address of the ERC20 contract string amount = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", @@ -50,7 +50,7 @@ message ZetaAccounting { message OutboundTxParams { string receiver = 1; int64 receiver_chainId = 2; - pkg.CoinType coin_type = 3; + coin.CoinType coin_type = 3; string amount = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Uint", (gogoproto.nullable) = false diff --git a/proto/crosschain/events.proto b/proto/crosschain/events.proto index 05dff47ebe..05786446ed 100644 --- a/proto/crosschain/events.proto +++ b/proto/crosschain/events.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; diff --git a/proto/crosschain/in_tx_tracker.proto b/proto/crosschain/in_tx_tracker.proto index 09c098888a..a29d0d6f55 100644 --- a/proto/crosschain/in_tx_tracker.proto +++ b/proto/crosschain/in_tx_tracker.proto @@ -1,12 +1,12 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; -import "pkg/pkg.proto"; +import "pkg/coin/coin.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; message InTxTracker { int64 chain_id = 1; string tx_hash = 2; - pkg.CoinType coin_type = 3; + coin.CoinType coin_type = 3; } diff --git a/proto/crosschain/tx.proto b/proto/crosschain/tx.proto index c697ad6f10..d6e4fc093b 100644 --- a/proto/crosschain/tx.proto +++ b/proto/crosschain/tx.proto @@ -2,7 +2,9 @@ syntax = "proto3"; package zetachain.zetacore.crosschain; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/chains/chains.proto"; +import "pkg/coin/coin.proto"; +import "pkg/proofs/proofs.proto"; option go_package = "github.com/zeta-chain/zetacore/x/crosschain/types"; @@ -28,7 +30,7 @@ message MsgCreateTSSVoter { string creator = 1; string tss_pubkey = 2; int64 keyGenZetaHeight = 3; - pkg.ReceiveStatus status = 4; + chains.ReceiveStatus status = 4; } message MsgCreateTSSVoterResponse {} @@ -54,8 +56,8 @@ message MsgAddToInTxTracker { string creator = 1; int64 chain_id = 2; string tx_hash = 3; - pkg.CoinType coin_type = 4; - pkg.Proof proof = 5; + coin.CoinType coin_type = 4; + proofs.Proof proof = 5; string block_hash = 6; int64 tx_index = 7; } @@ -81,7 +83,7 @@ message MsgAddToOutTxTracker { int64 chain_id = 2; uint64 nonce = 3; string tx_hash = 4; - pkg.Proof proof = 5; + proofs.Proof proof = 5; string block_hash = 6; int64 tx_index = 7; } @@ -124,10 +126,10 @@ message MsgVoteOnObservedOutboundTx { (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"value_received\"" ]; - pkg.ReceiveStatus status = 6; + chains.ReceiveStatus status = 6; int64 outTx_chain = 7; uint64 outTx_tss_nonce = 8; - pkg.CoinType coin_type = 9; + coin.CoinType coin_type = 9; } message MsgVoteOnObservedOutboundTxResponse {} @@ -148,7 +150,7 @@ message MsgVoteOnObservedInboundTx { string in_tx_hash = 9; uint64 in_block_height = 10; uint64 gas_limit = 11; - pkg.CoinType coin_type = 12; + coin.CoinType coin_type = 12; string tx_origin = 13; string asset = 14; // event index of the sent asset in the observed tx diff --git a/proto/fungible/events.proto b/proto/fungible/events.proto index 7751c8f9a0..6e47edbfb8 100644 --- a/proto/fungible/events.proto +++ b/proto/fungible/events.proto @@ -3,7 +3,7 @@ package zetachain.zetacore.fungible; import "fungible/tx.proto"; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/coin/coin.proto"; option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; @@ -21,7 +21,7 @@ message EventZRC20Deployed { string name = 4; string symbol = 5; int64 decimals = 6; - pkg.CoinType coin_type = 7; + coin.CoinType coin_type = 7; string erc20 = 8; int64 gas_limit = 9; } @@ -29,7 +29,7 @@ message EventZRC20Deployed { message EventZRC20WithdrawFeeUpdated { string msg_type_url = 1; int64 chain_id = 2; - pkg.CoinType coin_type = 3; + coin.CoinType coin_type = 3; string zrc20_address = 4; string old_withdraw_fee = 5; string new_withdraw_fee = 6; diff --git a/proto/fungible/foreign_coins.proto b/proto/fungible/foreign_coins.proto index d20cad9284..e943d6b574 100644 --- a/proto/fungible/foreign_coins.proto +++ b/proto/fungible/foreign_coins.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.fungible; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/coin/coin.proto"; option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; @@ -14,7 +14,7 @@ message ForeignCoins { uint32 decimals = 5; string name = 6; string symbol = 7; - pkg.CoinType coin_type = 8; + coin.CoinType coin_type = 8; uint64 gas_limit = 9; bool paused = 10; string liquidity_cap = 11 [ diff --git a/proto/fungible/tx.proto b/proto/fungible/tx.proto index 3f9e6e6cf2..9ba063b43a 100644 --- a/proto/fungible/tx.proto +++ b/proto/fungible/tx.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.fungible; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/coin/coin.proto"; option go_package = "github.com/zeta-chain/zetacore/x/fungible/types"; @@ -59,7 +59,7 @@ message MsgDeployFungibleCoinZRC20 { uint32 decimals = 4; string name = 5; string symbol = 6; - pkg.CoinType coin_type = 7; + coin.CoinType coin_type = 7; int64 gas_limit = 8; } diff --git a/proto/observer/chain_nonces.proto b/proto/observer/chain_nonces.proto index 159b51d367..3d4ff65c32 100644 --- a/proto/observer/chain_nonces.proto +++ b/proto/observer/chain_nonces.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; diff --git a/proto/observer/node_account.proto b/proto/observer/node_account.proto index d0556c25cb..ed6141e23e 100644 --- a/proto/observer/node_account.proto +++ b/proto/observer/node_account.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/crypto/crypto.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; @@ -19,6 +19,6 @@ enum NodeStatus { message NodeAccount { string operator = 1; string granteeAddress = 2; - pkg.PubKeySet granteePubkey = 3; + crypto.PubKeySet granteePubkey = 3; NodeStatus nodeStatus = 4; } diff --git a/proto/observer/nonce_to_cctx.proto b/proto/observer/nonce_to_cctx.proto index bd383b7d5b..947e9c6f35 100644 --- a/proto/observer/nonce_to_cctx.proto +++ b/proto/observer/nonce_to_cctx.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; diff --git a/proto/observer/observer.proto b/proto/observer/observer.proto index 0f85902220..575eea04f1 100644 --- a/proto/observer/observer.proto +++ b/proto/observer/observer.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; +import "pkg/chains/chains.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; @@ -24,7 +24,7 @@ enum ObserverUpdateReason { message ObserverMapper { string index = 1; - pkg.Chain observer_chain = 2; + chains.Chain observer_chain = 2; repeated string observer_list = 4; } diff --git a/proto/observer/params.proto b/proto/observer/params.proto index 11cd1d6ae3..8c26206ff6 100644 --- a/proto/observer/params.proto +++ b/proto/observer/params.proto @@ -3,7 +3,7 @@ package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; import "observer/observer.proto"; -import "pkg/pkg.proto"; +import "pkg/chains/chains.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; @@ -36,7 +36,7 @@ message ChainParams { // Deprecated(v13): Use ChainParamsList message ObserverParams { - pkg.Chain chain = 1; + chains.Chain chain = 1; string ballot_threshold = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false diff --git a/proto/observer/pending_nonces.proto b/proto/observer/pending_nonces.proto index 971c9a245d..e733843d01 100644 --- a/proto/observer/pending_nonces.proto +++ b/proto/observer/pending_nonces.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package zetachain.zetacore.observer; import "gogoproto/gogo.proto"; -import "pkg/pkg.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; diff --git a/proto/observer/query.proto b/proto/observer/query.proto index 57bf20400b..0c2cde9644 100644 --- a/proto/observer/query.proto +++ b/proto/observer/query.proto @@ -15,7 +15,8 @@ import "observer/observer.proto"; import "observer/params.proto"; import "observer/pending_nonces.proto"; import "observer/tss.proto"; -import "pkg/pkg.proto"; +import "pkg/chains/chains.proto"; +import "pkg/proofs/proofs.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; @@ -217,7 +218,7 @@ message QueryTssHistoryResponse { message QueryProveRequest { int64 chain_id = 1; string tx_hash = 2; - pkg.Proof proof = 3; + proofs.Proof proof = 3; string block_hash = 4; int64 tx_index = 5; } @@ -267,7 +268,7 @@ message QueryObserverSetResponse { message QuerySupportedChains {} message QuerySupportedChainsResponse { - repeated pkg.Chain chains = 1; + repeated chains.Chain chains = 1; } message QueryGetChainParamsForChainRequest { @@ -350,7 +351,7 @@ message QueryAllBlockHeaderRequest { } message QueryAllBlockHeaderResponse { - repeated pkg.BlockHeader block_headers = 1; + repeated proofs.BlockHeader block_headers = 1; cosmos.base.query.v1beta1.PageResponse pagination = 2; } @@ -359,7 +360,7 @@ message QueryGetBlockHeaderByHashRequest { } message QueryGetBlockHeaderByHashResponse { - pkg.BlockHeader block_header = 1; + proofs.BlockHeader block_header = 1; } message QueryGetBlockHeaderStateRequest { diff --git a/proto/observer/tx.proto b/proto/observer/tx.proto index 8e7e00ff50..8245827f16 100644 --- a/proto/observer/tx.proto +++ b/proto/observer/tx.proto @@ -8,7 +8,7 @@ import "observer/observer.proto"; import "observer/params.proto"; import "observer/pending_nonces.proto"; import "observer/tss.proto"; -import "pkg/pkg.proto"; +import "pkg/proofs/proofs.proto"; option go_package = "github.com/zeta-chain/zetacore/x/observer/types"; @@ -38,7 +38,7 @@ message MsgAddBlockHeader { int64 chain_id = 2; bytes block_hash = 3; int64 height = 4; - pkg.HeaderData header = 5 [(gogoproto.nullable) = false]; + proofs.HeaderData header = 5 [(gogoproto.nullable) = false]; } message MsgAddBlockHeaderResponse {} diff --git a/proto/pkg/chains/chains.proto b/proto/pkg/chains/chains.proto new file mode 100644 index 0000000000..fa9e9e49db --- /dev/null +++ b/proto/pkg/chains/chains.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; +package chains; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/pkg/chains"; + +enum ReceiveStatus { + option (gogoproto.goproto_enum_stringer) = true; + Created = 0; // some observer sees inbound tx + Success = 1; + Failed = 2; +} + +enum ChainName { + option (gogoproto.goproto_enum_stringer) = true; + empty = 0; + + eth_mainnet = 1; + zeta_mainnet = 2; + btc_mainnet = 3; + polygon_mainnet = 4; + bsc_mainnet = 5; + // Testnet + goerli_testnet = 6; + mumbai_testnet = 7; + ganache_testnet = 8; + baobab_testnet = 9; + bsc_testnet = 10; + zeta_testnet = 11; + btc_testnet = 12; + sepolia_testnet = 13; + // LocalNet + // zeta_localnet = 13; + goerli_localnet = 14; + btc_regtest = 15; + // Athens + // zeta_athensnet=15; +} + +message Chain { + ChainName chain_name = 1; + int64 chain_id = 2; +} diff --git a/proto/pkg/coin/coin.proto b/proto/pkg/coin/coin.proto new file mode 100644 index 0000000000..52d2a67967 --- /dev/null +++ b/proto/pkg/coin/coin.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package coin; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/pkg/coin"; + +enum CoinType { + option (gogoproto.goproto_enum_stringer) = true; + Zeta = 0; + Gas = 1; // Ether, BNB, Matic, Klay, BTC, etc + ERC20 = 2; // ERC20 token + Cmd = 3; // not a real coin, rather a command +} diff --git a/proto/pkg/crypto/crypto.proto b/proto/pkg/crypto/crypto.proto new file mode 100644 index 0000000000..f74878f490 --- /dev/null +++ b/proto/pkg/crypto/crypto.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package crypto; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/zeta-chain/zetacore/pkg/crypto"; + +// PubKeySet contains two pub keys , secp256k1 and ed25519 +message PubKeySet { + string secp256k1 = 1 [ + (gogoproto.casttype) = "PubKey", + (gogoproto.customname) = "Secp256k1" + ]; + string ed25519 = 2 [(gogoproto.casttype) = "PubKey"]; +} diff --git a/proto/pkg/pkg.proto b/proto/pkg/pkg.proto deleted file mode 100644 index 5a92b5f031..0000000000 --- a/proto/pkg/pkg.proto +++ /dev/null @@ -1,89 +0,0 @@ -syntax = "proto3"; -package pkg; - -//option (gogoproto.goproto_stringer_all) = false; -//option (gogoproto.stringer_all) = false; -//option (gogoproto.goproto_getters_all) = false; -import "gogoproto/gogo.proto"; -import "pkg/bitcoin/bitcoin.proto"; -import "pkg/ethereum/ethereum.proto"; - -option go_package = "github.com/zeta-chain/zetacore/pkg/proto"; - -// PubKeySet contains two pub keys , secp256k1 and ed25519 -message PubKeySet { - string secp256k1 = 1 [ - (gogoproto.casttype) = "PubKey", - (gogoproto.customname) = "Secp256k1" - ]; - string ed25519 = 2 [(gogoproto.casttype) = "PubKey"]; -} - -enum ReceiveStatus { - option (gogoproto.goproto_enum_stringer) = true; - Created = 0; // some observer sees inbound tx - Success = 1; - Failed = 2; -} - -enum CoinType { - option (gogoproto.goproto_enum_stringer) = true; - Zeta = 0; - Gas = 1; // Ether, BNB, Matic, Klay, BTC, etc - ERC20 = 2; // ERC20 token - Cmd = 3; // not a real coin, rather a command -} - -enum ChainName { - option (gogoproto.goproto_enum_stringer) = true; - empty = 0; - - eth_mainnet = 1; - zeta_mainnet = 2; - btc_mainnet = 3; - polygon_mainnet = 4; - bsc_mainnet = 5; - // Testnet - goerli_testnet = 6; - mumbai_testnet = 7; - ganache_testnet = 8; - baobab_testnet = 9; - bsc_testnet = 10; - zeta_testnet = 11; - btc_testnet = 12; - sepolia_testnet = 13; - // LocalNet - // zeta_localnet = 13; - goerli_localnet = 14; - btc_regtest = 15; - // Athens - // zeta_athensnet=15; -} - -message Chain { - ChainName chain_name = 1; - int64 chain_id = 2; -} - -message BlockHeader { - int64 height = 1; - bytes hash = 2; - bytes parent_hash = 3; - int64 chain_id = 4; - // chain specific header - HeaderData header = 5 [(gogoproto.nullable) = false]; -} - -message HeaderData { - oneof data { - bytes ethereum_header = 1; // binary encoded headers; RLP for ethereum - bytes bitcoin_header = 2; // 80-byte little-endian encoded binary data - } -} - -message Proof { - oneof proof { - ethereum.Proof ethereum_proof = 1; - bitcoin.Proof bitcoin_proof = 2; - } -} diff --git a/proto/pkg/bitcoin/bitcoin.proto b/proto/pkg/proofs/bitcoin/bitcoin.proto similarity index 61% rename from proto/pkg/bitcoin/bitcoin.proto rename to proto/pkg/proofs/bitcoin/bitcoin.proto index 55a4498e0d..7712782ce3 100644 --- a/proto/pkg/bitcoin/bitcoin.proto +++ b/proto/pkg/proofs/bitcoin/bitcoin.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package bitcoin; -option go_package = "github.com/zeta-chain/zetacore/pkg/bitcoin"; +option go_package = "github.com/zeta-chain/zetacore/pkg/proofs/bitcoin"; message Proof { bytes tx_bytes = 1; diff --git a/proto/pkg/ethereum/ethereum.proto b/proto/pkg/proofs/ethereum/ethereum.proto similarity index 60% rename from proto/pkg/ethereum/ethereum.proto rename to proto/pkg/proofs/ethereum/ethereum.proto index e1150bdcee..76d9489292 100644 --- a/proto/pkg/ethereum/ethereum.proto +++ b/proto/pkg/proofs/ethereum/ethereum.proto @@ -1,7 +1,7 @@ syntax = "proto3"; package ethereum; -option go_package = "github.com/zeta-chain/zetacore/pkg/ethereum"; +option go_package = "github.com/zeta-chain/zetacore/pkg/proofs/ethereum"; message Proof { repeated bytes keys = 1; diff --git a/proto/pkg/proofs/proofs.proto b/proto/pkg/proofs/proofs.proto new file mode 100644 index 0000000000..e8360d5cbd --- /dev/null +++ b/proto/pkg/proofs/proofs.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package proofs; + +import "gogoproto/gogo.proto"; +import "pkg/proofs/bitcoin/bitcoin.proto"; +import "pkg/proofs/ethereum/ethereum.proto"; + +option go_package = "github.com/zeta-chain/zetacore/pkg/proofs"; + +message BlockHeader { + int64 height = 1; + bytes hash = 2; + bytes parent_hash = 3; + int64 chain_id = 4; + // chain specific header + HeaderData header = 5 [(gogoproto.nullable) = false]; +} + +message HeaderData { + oneof data { + bytes ethereum_header = 1; // binary encoded headers; RLP for ethereum + bytes bitcoin_header = 2; // 80-byte little-endian encoded binary data + } +} + +message Proof { + oneof proof { + ethereum.Proof ethereum_proof = 1; + bitcoin.Proof bitcoin_proof = 2; + } +} diff --git a/testutil/keeper/mocks/crosschain/fungible.go b/testutil/keeper/mocks/crosschain/fungible.go index 81d7c0f380..54b7e54a03 100644 --- a/testutil/keeper/mocks/crosschain/fungible.go +++ b/testutil/keeper/mocks/crosschain/fungible.go @@ -6,6 +6,8 @@ import ( big "math/big" common "github.com/ethereum/go-ethereum/common" + coin "github.com/zeta-chain/zetacore/pkg/coin" + evmtypes "github.com/evmos/ethermint/x/evm/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" @@ -13,8 +15,6 @@ import ( mock "github.com/stretchr/testify/mock" types "github.com/cosmos/cosmos-sdk/types" - - "github.com/zeta-chain/zetacore/pkg" ) // CrosschainFungibleKeeper is an autogenerated mock type for the CrosschainFungibleKeeper type @@ -119,7 +119,7 @@ func (_m *CrosschainFungibleKeeper) CallZRC20Burn(ctx types.Context, sender comm } // DeployZRC20Contract provides a mock function with given fields: ctx, name, symbol, decimals, chainID, coinType, erc20Contract, gasLimit -func (_m *CrosschainFungibleKeeper) DeployZRC20Contract(ctx types.Context, name string, symbol string, decimals uint8, chainID int64, coinType pkg.CoinType, erc20Contract string, gasLimit *big.Int) (common.Address, error) { +func (_m *CrosschainFungibleKeeper) DeployZRC20Contract(ctx types.Context, name string, symbol string, decimals uint8, chainID int64, coinType coin.CoinType, erc20Contract string, gasLimit *big.Int) (common.Address, error) { ret := _m.Called(ctx, name, symbol, decimals, chainID, coinType, erc20Contract, gasLimit) if len(ret) == 0 { @@ -128,10 +128,10 @@ func (_m *CrosschainFungibleKeeper) DeployZRC20Contract(ctx types.Context, name var r0 common.Address var r1 error - if rf, ok := ret.Get(0).(func(types.Context, string, string, uint8, int64, pkg.CoinType, string, *big.Int) (common.Address, error)); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, string, uint8, int64, coin.CoinType, string, *big.Int) (common.Address, error)); ok { return rf(ctx, name, symbol, decimals, chainID, coinType, erc20Contract, gasLimit) } - if rf, ok := ret.Get(0).(func(types.Context, string, string, uint8, int64, pkg.CoinType, string, *big.Int) common.Address); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, string, uint8, int64, coin.CoinType, string, *big.Int) common.Address); ok { r0 = rf(ctx, name, symbol, decimals, chainID, coinType, erc20Contract, gasLimit) } else { if ret.Get(0) != nil { @@ -139,7 +139,7 @@ func (_m *CrosschainFungibleKeeper) DeployZRC20Contract(ctx types.Context, name } } - if rf, ok := ret.Get(1).(func(types.Context, string, string, uint8, int64, pkg.CoinType, string, *big.Int) error); ok { + if rf, ok := ret.Get(1).(func(types.Context, string, string, uint8, int64, coin.CoinType, string, *big.Int) error); ok { r1 = rf(ctx, name, symbol, decimals, chainID, coinType, erc20Contract, gasLimit) } else { r1 = ret.Error(1) @@ -598,7 +598,7 @@ func (_m *CrosschainFungibleKeeper) WithdrawFromGasStabilityPool(ctx types.Conte } // ZRC20DepositAndCallContract provides a mock function with given fields: ctx, from, to, amount, senderChainID, data, coinType, asset -func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Context, from []byte, to common.Address, amount *big.Int, senderChainID int64, data []byte, coinType pkg.CoinType, asset string) (*evmtypes.MsgEthereumTxResponse, bool, error) { +func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Context, from []byte, to common.Address, amount *big.Int, senderChainID int64, data []byte, coinType coin.CoinType, asset string) (*evmtypes.MsgEthereumTxResponse, bool, error) { ret := _m.Called(ctx, from, to, amount, senderChainID, data, coinType, asset) if len(ret) == 0 { @@ -608,10 +608,10 @@ func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Contex var r0 *evmtypes.MsgEthereumTxResponse var r1 bool var r2 error - if rf, ok := ret.Get(0).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, pkg.CoinType, string) (*evmtypes.MsgEthereumTxResponse, bool, error)); ok { + if rf, ok := ret.Get(0).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, coin.CoinType, string) (*evmtypes.MsgEthereumTxResponse, bool, error)); ok { return rf(ctx, from, to, amount, senderChainID, data, coinType, asset) } - if rf, ok := ret.Get(0).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, pkg.CoinType, string) *evmtypes.MsgEthereumTxResponse); ok { + if rf, ok := ret.Get(0).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, coin.CoinType, string) *evmtypes.MsgEthereumTxResponse); ok { r0 = rf(ctx, from, to, amount, senderChainID, data, coinType, asset) } else { if ret.Get(0) != nil { @@ -619,13 +619,13 @@ func (_m *CrosschainFungibleKeeper) ZRC20DepositAndCallContract(ctx types.Contex } } - if rf, ok := ret.Get(1).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, pkg.CoinType, string) bool); ok { + if rf, ok := ret.Get(1).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, coin.CoinType, string) bool); ok { r1 = rf(ctx, from, to, amount, senderChainID, data, coinType, asset) } else { r1 = ret.Get(1).(bool) } - if rf, ok := ret.Get(2).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, pkg.CoinType, string) error); ok { + if rf, ok := ret.Get(2).(func(types.Context, []byte, common.Address, *big.Int, int64, []byte, coin.CoinType, string) error); ok { r2 = rf(ctx, from, to, amount, senderChainID, data, coinType, asset) } else { r2 = ret.Error(2) diff --git a/testutil/keeper/mocks/crosschain/observer.go b/testutil/keeper/mocks/crosschain/observer.go index 3cf01ecf0f..84590ca702 100644 --- a/testutil/keeper/mocks/crosschain/observer.go +++ b/testutil/keeper/mocks/crosschain/observer.go @@ -3,14 +3,17 @@ package mocks import ( - context "context" + chains "github.com/zeta-chain/zetacore/pkg/chains" + coin "github.com/zeta-chain/zetacore/pkg/coin" - "github.com/zeta-chain/zetacore/pkg" + context "context" mock "github.com/stretchr/testify/mock" observertypes "github.com/zeta-chain/zetacore/x/observer/types" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" + types "github.com/cosmos/cosmos-sdk/types" ) @@ -109,7 +112,7 @@ func (_m *CrosschainObserverKeeper) CheckIfTssPubkeyHasBeenGenerated(ctx types.C } // FindBallot provides a mock function with given fields: ctx, index, chain, observationType -func (_m *CrosschainObserverKeeper) FindBallot(ctx types.Context, index string, chain *pkg.Chain, observationType observertypes.ObservationType) (observertypes.Ballot, bool, error) { +func (_m *CrosschainObserverKeeper) FindBallot(ctx types.Context, index string, chain *chains.Chain, observationType observertypes.ObservationType) (observertypes.Ballot, bool, error) { ret := _m.Called(ctx, index, chain, observationType) if len(ret) == 0 { @@ -119,22 +122,22 @@ func (_m *CrosschainObserverKeeper) FindBallot(ctx types.Context, index string, var r0 observertypes.Ballot var r1 bool var r2 error - if rf, ok := ret.Get(0).(func(types.Context, string, *pkg.Chain, observertypes.ObservationType) (observertypes.Ballot, bool, error)); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, *chains.Chain, observertypes.ObservationType) (observertypes.Ballot, bool, error)); ok { return rf(ctx, index, chain, observationType) } - if rf, ok := ret.Get(0).(func(types.Context, string, *pkg.Chain, observertypes.ObservationType) observertypes.Ballot); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, *chains.Chain, observertypes.ObservationType) observertypes.Ballot); ok { r0 = rf(ctx, index, chain, observationType) } else { r0 = ret.Get(0).(observertypes.Ballot) } - if rf, ok := ret.Get(1).(func(types.Context, string, *pkg.Chain, observertypes.ObservationType) bool); ok { + if rf, ok := ret.Get(1).(func(types.Context, string, *chains.Chain, observertypes.ObservationType) bool); ok { r1 = rf(ctx, index, chain, observationType) } else { r1 = ret.Get(1).(bool) } - if rf, ok := ret.Get(2).(func(types.Context, string, *pkg.Chain, observertypes.ObservationType) error); ok { + if rf, ok := ret.Get(2).(func(types.Context, string, *chains.Chain, observertypes.ObservationType) error); ok { r2 = rf(ctx, index, chain, observationType) } else { r2 = ret.Error(2) @@ -302,22 +305,22 @@ func (_m *CrosschainObserverKeeper) GetBallot(ctx types.Context, index string) ( } // GetBlockHeader provides a mock function with given fields: ctx, hash -func (_m *CrosschainObserverKeeper) GetBlockHeader(ctx types.Context, hash []byte) (pkg.BlockHeader, bool) { +func (_m *CrosschainObserverKeeper) GetBlockHeader(ctx types.Context, hash []byte) (proofs.BlockHeader, bool) { ret := _m.Called(ctx, hash) if len(ret) == 0 { panic("no return value specified for GetBlockHeader") } - var r0 pkg.BlockHeader + var r0 proofs.BlockHeader var r1 bool - if rf, ok := ret.Get(0).(func(types.Context, []byte) (pkg.BlockHeader, bool)); ok { + if rf, ok := ret.Get(0).(func(types.Context, []byte) (proofs.BlockHeader, bool)); ok { return rf(ctx, hash) } - if rf, ok := ret.Get(0).(func(types.Context, []byte) pkg.BlockHeader); ok { + if rf, ok := ret.Get(0).(func(types.Context, []byte) proofs.BlockHeader); ok { r0 = rf(ctx, hash) } else { - r0 = ret.Get(0).(pkg.BlockHeader) + r0 = ret.Get(0).(proofs.BlockHeader) } if rf, ok := ret.Get(1).(func(types.Context, []byte) bool); ok { @@ -584,19 +587,19 @@ func (_m *CrosschainObserverKeeper) GetPendingNonces(ctx types.Context, tss stri } // GetSupportedChainFromChainID provides a mock function with given fields: ctx, chainID -func (_m *CrosschainObserverKeeper) GetSupportedChainFromChainID(ctx types.Context, chainID int64) *pkg.Chain { +func (_m *CrosschainObserverKeeper) GetSupportedChainFromChainID(ctx types.Context, chainID int64) *chains.Chain { ret := _m.Called(ctx, chainID) if len(ret) == 0 { panic("no return value specified for GetSupportedChainFromChainID") } - var r0 *pkg.Chain - if rf, ok := ret.Get(0).(func(types.Context, int64) *pkg.Chain); ok { + var r0 *chains.Chain + if rf, ok := ret.Get(0).(func(types.Context, int64) *chains.Chain); ok { r0 = rf(ctx, chainID) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*pkg.Chain) + r0 = ret.Get(0).(*chains.Chain) } } @@ -604,19 +607,19 @@ func (_m *CrosschainObserverKeeper) GetSupportedChainFromChainID(ctx types.Conte } // GetSupportedChains provides a mock function with given fields: ctx -func (_m *CrosschainObserverKeeper) GetSupportedChains(ctx types.Context) []*pkg.Chain { +func (_m *CrosschainObserverKeeper) GetSupportedChains(ctx types.Context) []*chains.Chain { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetSupportedChains") } - var r0 []*pkg.Chain - if rf, ok := ret.Get(0).(func(types.Context) []*pkg.Chain); ok { + var r0 []*chains.Chain + if rf, ok := ret.Get(0).(func(types.Context) []*chains.Chain); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*pkg.Chain) + r0 = ret.Get(0).([]*chains.Chain) } } @@ -783,7 +786,7 @@ func (_m *CrosschainObserverKeeper) SetTssAndUpdateNonce(ctx types.Context, tss } // VoteOnInboundBallot provides a mock function with given fields: ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash -func (_m *CrosschainObserverKeeper) VoteOnInboundBallot(ctx types.Context, senderChainID int64, receiverChainID int64, coinType pkg.CoinType, voter string, ballotIndex string, inTxHash string) (bool, bool, error) { +func (_m *CrosschainObserverKeeper) VoteOnInboundBallot(ctx types.Context, senderChainID int64, receiverChainID int64, coinType coin.CoinType, voter string, ballotIndex string, inTxHash string) (bool, bool, error) { ret := _m.Called(ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash) if len(ret) == 0 { @@ -793,22 +796,22 @@ func (_m *CrosschainObserverKeeper) VoteOnInboundBallot(ctx types.Context, sende var r0 bool var r1 bool var r2 error - if rf, ok := ret.Get(0).(func(types.Context, int64, int64, pkg.CoinType, string, string, string) (bool, bool, error)); ok { + if rf, ok := ret.Get(0).(func(types.Context, int64, int64, coin.CoinType, string, string, string) (bool, bool, error)); ok { return rf(ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash) } - if rf, ok := ret.Get(0).(func(types.Context, int64, int64, pkg.CoinType, string, string, string) bool); ok { + if rf, ok := ret.Get(0).(func(types.Context, int64, int64, coin.CoinType, string, string, string) bool); ok { r0 = rf(ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash) } else { r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(types.Context, int64, int64, pkg.CoinType, string, string, string) bool); ok { + if rf, ok := ret.Get(1).(func(types.Context, int64, int64, coin.CoinType, string, string, string) bool); ok { r1 = rf(ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash) } else { r1 = ret.Get(1).(bool) } - if rf, ok := ret.Get(2).(func(types.Context, int64, int64, pkg.CoinType, string, string, string) error); ok { + if rf, ok := ret.Get(2).(func(types.Context, int64, int64, coin.CoinType, string, string, string) error); ok { r2 = rf(ctx, senderChainID, receiverChainID, coinType, voter, ballotIndex, inTxHash) } else { r2 = ret.Error(2) @@ -818,7 +821,7 @@ func (_m *CrosschainObserverKeeper) VoteOnInboundBallot(ctx types.Context, sende } // VoteOnOutboundBallot provides a mock function with given fields: ctx, ballotIndex, outTxChainID, receiveStatus, voter -func (_m *CrosschainObserverKeeper) VoteOnOutboundBallot(ctx types.Context, ballotIndex string, outTxChainID int64, receiveStatus pkg.ReceiveStatus, voter string) (bool, bool, observertypes.Ballot, string, error) { +func (_m *CrosschainObserverKeeper) VoteOnOutboundBallot(ctx types.Context, ballotIndex string, outTxChainID int64, receiveStatus chains.ReceiveStatus, voter string) (bool, bool, observertypes.Ballot, string, error) { ret := _m.Called(ctx, ballotIndex, outTxChainID, receiveStatus, voter) if len(ret) == 0 { @@ -830,34 +833,34 @@ func (_m *CrosschainObserverKeeper) VoteOnOutboundBallot(ctx types.Context, ball var r2 observertypes.Ballot var r3 string var r4 error - if rf, ok := ret.Get(0).(func(types.Context, string, int64, pkg.ReceiveStatus, string) (bool, bool, observertypes.Ballot, string, error)); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, int64, chains.ReceiveStatus, string) (bool, bool, observertypes.Ballot, string, error)); ok { return rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } - if rf, ok := ret.Get(0).(func(types.Context, string, int64, pkg.ReceiveStatus, string) bool); ok { + if rf, ok := ret.Get(0).(func(types.Context, string, int64, chains.ReceiveStatus, string) bool); ok { r0 = rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } else { r0 = ret.Get(0).(bool) } - if rf, ok := ret.Get(1).(func(types.Context, string, int64, pkg.ReceiveStatus, string) bool); ok { + if rf, ok := ret.Get(1).(func(types.Context, string, int64, chains.ReceiveStatus, string) bool); ok { r1 = rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } else { r1 = ret.Get(1).(bool) } - if rf, ok := ret.Get(2).(func(types.Context, string, int64, pkg.ReceiveStatus, string) observertypes.Ballot); ok { + if rf, ok := ret.Get(2).(func(types.Context, string, int64, chains.ReceiveStatus, string) observertypes.Ballot); ok { r2 = rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } else { r2 = ret.Get(2).(observertypes.Ballot) } - if rf, ok := ret.Get(3).(func(types.Context, string, int64, pkg.ReceiveStatus, string) string); ok { + if rf, ok := ret.Get(3).(func(types.Context, string, int64, chains.ReceiveStatus, string) string); ok { r3 = rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } else { r3 = ret.Get(3).(string) } - if rf, ok := ret.Get(4).(func(types.Context, string, int64, pkg.ReceiveStatus, string) error); ok { + if rf, ok := ret.Get(4).(func(types.Context, string, int64, chains.ReceiveStatus, string) error); ok { r4 = rf(ctx, ballotIndex, outTxChainID, receiveStatus, voter) } else { r4 = ret.Error(4) diff --git a/testutil/keeper/mocks/fungible/observer.go b/testutil/keeper/mocks/fungible/observer.go index ac4d1dea07..bbe76b1afa 100644 --- a/testutil/keeper/mocks/fungible/observer.go +++ b/testutil/keeper/mocks/fungible/observer.go @@ -4,7 +4,7 @@ package mocks import ( mock "github.com/stretchr/testify/mock" - "github.com/zeta-chain/zetacore/pkg" + chains "github.com/zeta-chain/zetacore/pkg/chains" types "github.com/cosmos/cosmos-sdk/types" ) @@ -15,19 +15,19 @@ type FungibleObserverKeeper struct { } // GetSupportedChains provides a mock function with given fields: ctx -func (_m *FungibleObserverKeeper) GetSupportedChains(ctx types.Context) []*pkg.Chain { +func (_m *FungibleObserverKeeper) GetSupportedChains(ctx types.Context) []*chains.Chain { ret := _m.Called(ctx) if len(ret) == 0 { panic("no return value specified for GetSupportedChains") } - var r0 []*pkg.Chain - if rf, ok := ret.Get(0).(func(types.Context) []*pkg.Chain); ok { + var r0 []*chains.Chain + if rf, ok := ret.Get(0).(func(types.Context) []*chains.Chain); ok { r0 = rf(ctx) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]*pkg.Chain) + r0 = ret.Get(0).([]*chains.Chain) } } diff --git a/testutil/network/genesis_state.go b/testutil/network/genesis_state.go index 202fb00c2a..4263ac256b 100644 --- a/testutil/network/genesis_state.go +++ b/testutil/network/genesis_state.go @@ -6,6 +6,8 @@ import ( "strconv" "testing" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "cosmossdk.io/math" @@ -14,7 +16,6 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/require" cmdcfg "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -61,8 +62,8 @@ func SetupZetaGenesisState(t *testing.T, genesisState map[string]json.RawMessage } if setupChainNonces { - chainNonceList := make([]observertypes.ChainNonces, len(pkg.PrivnetChainList())) - for i, chain := range pkg.PrivnetChainList() { + chainNonceList := make([]observertypes.ChainNonces, len(chains.PrivnetChainList())) + for i, chain := range chains.PrivnetChainList() { chainNonceList[i] = observertypes.ChainNonces{ Index: chain.ChainName.String(), ChainId: chain.ChainId, @@ -139,8 +140,8 @@ func AddObserverData(t *testing.T, n int, genesisState map[string]json.RawMessag FinalizedZetaHeight: 1, KeyGenZetaHeight: 1, } - pendingNonces := make([]observertypes.PendingNonces, len(pkg.DefaultChainsList())) - for i, chain := range pkg.DefaultChainsList() { + pendingNonces := make([]observertypes.PendingNonces, len(chains.DefaultChainsList())) + for i, chain := range chains.DefaultChainsList() { pendingNonces[i] = observertypes.PendingNonces{ ChainId: chain.ChainId, NonceLow: 0, @@ -205,7 +206,7 @@ func AddCrosschainData(t *testing.T, n int, genesisState map[string]json.RawMess inTxTracker := types.InTxTracker{ ChainId: 5, TxHash: fmt.Sprintf("txHash-%d", i), - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, } nullify.Fill(&inTxTracker) state.InTxTrackerList = append(state.InTxTrackerList, inTxTracker) diff --git a/testutil/sample/common.go b/testutil/sample/common.go index 0ef7411d15..7549d80ce0 100644 --- a/testutil/sample/common.go +++ b/testutil/sample/common.go @@ -3,22 +3,23 @@ package sample import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/crypto" ) -func Chain(chainID int64) *pkg.Chain { +func Chain(chainID int64) *chains.Chain { r := newRandFromSeed(chainID) - return &pkg.Chain{ - ChainName: pkg.ChainName(r.Intn(4)), + return &chains.Chain{ + ChainName: chains.ChainName(r.Intn(4)), ChainId: chainID, } } -func PubKeySet() *pkg.PubKeySet { - pubKeySet := pkg.PubKeySet{ - Secp256k1: pkg.PubKey(secp256k1.GenPrivKey().PubKey().Bytes()), - Ed25519: pkg.PubKey(ed25519.GenPrivKey().PubKey().String()), +func PubKeySet() *crypto.PubKeySet { + pubKeySet := crypto.PubKeySet{ + Secp256k1: crypto.PubKey(secp256k1.GenPrivKey().PubKey().Bytes()), + Ed25519: crypto.PubKey(ed25519.GenPrivKey().PubKey().String()), } return &pubKeySet } diff --git a/testutil/sample/crosschain.go b/testutil/sample/crosschain.go index eaa015fd90..3fa5d04983 100644 --- a/testutil/sample/crosschain.go +++ b/testutil/sample/crosschain.go @@ -9,7 +9,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -42,7 +42,7 @@ func InboundTxParams(r *rand.Rand) *types.InboundTxParams { Sender: EthAddress().String(), SenderChainId: r.Int63(), TxOrigin: EthAddress().String(), - CoinType: pkg.CoinType(r.Intn(100)), + CoinType: coin.CoinType(r.Intn(100)), Asset: StringRandom(r, 32), Amount: math.NewUint(uint64(r.Int63())), InboundTxObservedHash: StringRandom(r, 32), @@ -56,7 +56,7 @@ func OutboundTxParams(r *rand.Rand) *types.OutboundTxParams { return &types.OutboundTxParams{ Receiver: EthAddress().String(), ReceiverChainId: r.Int63(), - CoinType: pkg.CoinType(r.Intn(100)), + CoinType: coin.CoinType(r.Intn(100)), Amount: math.NewUint(uint64(r.Int63())), OutboundTxTssNonce: r.Uint64(), OutboundTxGasLimit: r.Uint64(), @@ -125,7 +125,7 @@ func ZetaAccounting(t *testing.T, index string) types.ZetaAccounting { } } -func InboundVote(coinType pkg.CoinType, from, to int64) types.MsgVoteOnObservedInboundTx { +func InboundVote(coinType coin.CoinType, from, to int64) types.MsgVoteOnObservedInboundTx { return types.MsgVoteOnObservedInboundTx{ Creator: "", Sender: EthAddress().String(), diff --git a/testutil/sample/fungible.go b/testutil/sample/fungible.go index dd130bf1c2..73fdc2b2e3 100644 --- a/testutil/sample/fungible.go +++ b/testutil/sample/fungible.go @@ -3,7 +3,7 @@ package sample import ( "testing" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -17,7 +17,7 @@ func ForeignCoins(t *testing.T, address string) types.ForeignCoins { Decimals: uint32(r.Uint64()), Name: StringRandom(r, 32), Symbol: StringRandom(r, 32), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, GasLimit: r.Uint64(), } } diff --git a/testutil/sample/observer.go b/testutil/sample/observer.go index 317d24193a..c90036ff07 100644 --- a/testutil/sample/observer.go +++ b/testutil/sample/observer.go @@ -8,8 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/cosmos" + zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -111,7 +112,7 @@ func ChainParamsSupported(chainID int64) *types.ChainParams { } func ChainParamsList() (cpl types.ChainParamsList) { - chainList := pkg.PrivnetChainList() + chainList := chains.PrivnetChainList() for _, chain := range chainList { cpl.ChainParams = append(cpl.ChainParams, ChainParams(chain.ChainId)) @@ -125,7 +126,7 @@ func Tss() types.TSS { if err != nil { panic(err) } - pk, err := pkg.NewPubKey(spk) + pk, err := zetacrypto.NewPubKey(spk) if err != nil { panic(err) } diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 46154096fb..0ac8621411 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -9,7 +9,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -18,6 +17,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/cosmos" + "github.com/zeta-chain/zetacore/pkg/crypto" ) var ErrSample = errors.New("sample error") @@ -86,7 +86,7 @@ func PubKeyString() string { if err != nil { panic(err) } - pubkey, err := pkg.NewPubKey(s) + pubkey, err := crypto.NewPubKey(s) if err != nil { panic(err) } diff --git a/x/crosschain/client/cli/cli_cctx.go b/x/crosschain/client/cli/cli_cctx.go index 66d7a9a828..92fed899d3 100644 --- a/x/crosschain/client/cli/cli_cctx.go +++ b/x/crosschain/client/cli/cli_cctx.go @@ -12,7 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - "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/x/crosschain/types" ) @@ -148,11 +149,11 @@ func CmdCCTXInboundVoter() *cobra.Command { return err } - coinType, ok := pkg.CoinType_value[args[9]] + coinType, ok := coin.CoinType_value[args[9]] if !ok { return fmt.Errorf("wrong coin type %s", args[9]) } - argsCoinType := pkg.CoinType(coinType) + argsCoinType := coin.CoinType(coinType) argsAsset := args[10] @@ -224,11 +225,11 @@ func CmdCCTXOutboundVoter() *cobra.Command { argsMMint := args[6] - var status pkg.ReceiveStatus + var status chains.ReceiveStatus if args[7] == "0" { - status = pkg.ReceiveStatus_Success + status = chains.ReceiveStatus_Success } else if args[7] == "1" { - status = pkg.ReceiveStatus_Failed + status = chains.ReceiveStatus_Failed } else { return fmt.Errorf("wrong status") } @@ -243,11 +244,11 @@ func CmdCCTXOutboundVoter() *cobra.Command { return err } - coinType, ok := pkg.CoinType_value[args[10]] + coinType, ok := coin.CoinType_value[args[10]] if !ok { return fmt.Errorf("wrong coin type %s", args[10]) } - argsCoinType := pkg.CoinType(coinType) + argsCoinType := coin.CoinType(coinType) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/crosschain/client/cli/cli_in_tx_tracker.go b/x/crosschain/client/cli/cli_in_tx_tracker.go index 730e075711..5afcec7ec8 100644 --- a/x/crosschain/client/cli/cli_in_tx_tracker.go +++ b/x/crosschain/client/cli/cli_in_tx_tracker.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -24,7 +24,7 @@ func CmdAddToInTxTracker() *cobra.Command { return err } argTxHash := args[1] - argsCoinType, err := pkg.GetCoinType(args[2]) + argsCoinType, err := coin.GetCoinType(args[2]) if err != nil { return err } diff --git a/x/crosschain/client/cli/cli_tss.go b/x/crosschain/client/cli/cli_tss.go index 298fb01294..7c85ea8b72 100644 --- a/x/crosschain/client/cli/cli_tss.go +++ b/x/crosschain/client/cli/cli_tss.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cast" "github.com/spf13/cobra" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -29,11 +29,11 @@ func CmdCreateTSSVoter() *cobra.Command { if err != nil { return err } - var status pkg.ReceiveStatus + var status chains.ReceiveStatus if args[2] == "0" { - status = pkg.ReceiveStatus_Success + status = chains.ReceiveStatus_Success } else if args[2] == "1" { - status = pkg.ReceiveStatus_Failed + status = chains.ReceiveStatus_Failed } else { return fmt.Errorf("wrong status") } diff --git a/x/crosschain/client/integrationtests/cli_helpers.go b/x/crosschain/client/integrationtests/cli_helpers.go index a0b57d0bf1..9cc05b32d6 100644 --- a/x/crosschain/client/integrationtests/cli_helpers.go +++ b/x/crosschain/client/integrationtests/cli_helpers.go @@ -17,7 +17,8 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" tmcli "github.com/tendermint/tendermint/libs/cli" - "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/testutil/network" "github.com/zeta-chain/zetacore/x/crosschain/client/cli" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -137,11 +138,11 @@ func BuildSignedDeployETHZRC20( } args := append([]string{ "", - strconv.FormatInt(pkg.GoerliLocalnetChain().ChainId, 10), + strconv.FormatInt(chains.GoerliLocalnetChain().ChainId, 10), "18", "ETH", "gETH", - strconv.FormatInt(int64(pkg.CoinType_Gas), 10), + strconv.FormatInt(int64(coin.CoinType_Gas), 10), "1000000", }, txArgs...) out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) @@ -156,7 +157,7 @@ func BuildSignedDeployETHZRC20( func BuildSignedGasPriceVote(t testing.TB, val *network.Validator, denom string, account authtypes.AccountI) *os.File { cmd := cli.CmdGasPriceVoter() inboundVoterArgs := []string{ - strconv.FormatInt(pkg.GoerliLocalnetChain().ChainId, 10), + strconv.FormatInt(chains.GoerliLocalnetChain().ChainId, 10), "10000000000", "100", "100", @@ -225,7 +226,7 @@ func BuildSignedOutboundVote( "0", valueReceived, status, - strconv.FormatInt(pkg.GoerliLocalnetChain().ChainId, 10), + strconv.FormatInt(chains.GoerliLocalnetChain().ChainId, 10), strconv.FormatUint(nonce, 10), "Zeta", } @@ -252,10 +253,10 @@ func BuildSignedInboundVote(t testing.TB, val *network.Validator, denom string, cmd := cli.CmdCCTXInboundVoter() inboundVoterArgs := []string{ "0x96B05C238b99768F349135de0653b687f9c13fEE", - strconv.FormatInt(pkg.GoerliLocalnetChain().ChainId, 10), + strconv.FormatInt(chains.GoerliLocalnetChain().ChainId, 10), "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", "0x96B05C238b99768F349135de0653b687f9c13fEE", - strconv.FormatInt(pkg.GoerliLocalnetChain().ChainId, 10), + strconv.FormatInt(chains.GoerliLocalnetChain().ChainId, 10), "10000000000000000000", message, "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", @@ -286,16 +287,16 @@ func GetBallotIdentifier(message string, eventIndex int) string { msg := types.NewMsgVoteOnObservedInboundTx( "", "0x96B05C238b99768F349135de0653b687f9c13fEE", - pkg.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain().ChainId, "0x3b9Fe88DE29efD13240829A0c18E9EC7A44C3CA7", "0x96B05C238b99768F349135de0653b687f9c13fEE", - pkg.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain().ChainId, sdk.NewUint(10000000000000000000), message, "0x19398991572a825894b34b904ac1e3692720895351466b5c9e6bb7ae1e21d680", 100, 250_000, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, "", // #nosec G701 always positive uint(eventIndex), @@ -314,9 +315,9 @@ func GetBallotIdentifierOutBound(nonce uint64, cctxindex, outtxHash, valueReceiv 0, math.NewUintFromString(valueReceived), 0, - pkg.GoerliLocalnetChain().ChainId, + chains.GoerliLocalnetChain().ChainId, nonce, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ) return msg.Digest() } diff --git a/x/crosschain/keeper/abci.go b/x/crosschain/keeper/abci.go index cf4cee6a24..5a02c53676 100644 --- a/x/crosschain/keeper/abci.go +++ b/x/crosschain/keeper/abci.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/zeta-chain/zetacore/pkg" + zetachains "github.com/zeta-chain/zetacore/pkg/chains" cosmoserrors "cosmossdk.io/errors" "cosmossdk.io/math" @@ -30,7 +30,7 @@ type CheckAndUpdateCctxGasPriceFunc func( // The function returns the number of cctxs updated and the gas price increase flags used func (k Keeper) IterateAndUpdateCctxGasPrice( ctx sdk.Context, - chains []*pkg.Chain, + chains []*zetachains.Chain, updateFunc CheckAndUpdateCctxGasPriceFunc, ) (int, observertypes.GasPriceIncreaseFlags) { // fetch the gas price increase flags or use default @@ -50,7 +50,7 @@ func (k Keeper) IterateAndUpdateCctxGasPrice( IterateChains: for _, chain := range chains { // support only external evm chains - if pkg.IsEVMChain(chain.ChainId) && !pkg.IsZetaChain(chain.ChainId) { + if zetachains.IsEVMChain(chain.ChainId) && !zetachains.IsZetaChain(chain.ChainId) { res, err := k.CctxListPending(sdk.UnwrapSDKContext(ctx), &types.QueryListCctxPendingRequest{ ChainId: chain.ChainId, Limit: gasPriceIncreaseFlags.MaxPendingCctxs, diff --git a/x/crosschain/keeper/abci_test.go b/x/crosschain/keeper/abci_test.go index 0160d45e87..c8ef411f4b 100644 --- a/x/crosschain/keeper/abci_test.go +++ b/x/crosschain/keeper/abci_test.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -42,20 +42,20 @@ func TestKeeper_IterateAndUpdateCctxGasPrice(t *testing.T) { } // add some evm and non-evm chains - supportedChains := []*pkg.Chain{ - {ChainId: pkg.EthChain().ChainId}, - {ChainId: pkg.BtcMainnetChain().ChainId}, - {ChainId: pkg.BscMainnetChain().ChainId}, - {ChainId: pkg.ZetaChainMainnet().ChainId}, + supportedChains := []*chains.Chain{ + {ChainId: chains.EthChain().ChainId}, + {ChainId: chains.BtcMainnetChain().ChainId}, + {ChainId: chains.BscMainnetChain().ChainId}, + {ChainId: chains.ZetaChainMainnet().ChainId}, } // set pending cctx tss := sample.Tss() zk.ObserverKeeper.SetTSS(ctx, tss) - createCctxWithNonceRange(t, ctx, *k, 10, 15, pkg.EthChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 20, 25, pkg.BtcMainnetChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 30, 35, pkg.BscMainnetChain().ChainId, tss, zk) - createCctxWithNonceRange(t, ctx, *k, 40, 45, pkg.ZetaChainMainnet().ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 10, 15, chains.EthChain().ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 20, 25, chains.BtcMainnetChain().ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 30, 35, chains.BscMainnetChain().ChainId, tss, zk) + createCctxWithNonceRange(t, ctx, *k, 40, 45, chains.ZetaChainMainnet().ChainId, tss, zk) // set a cctx where the update function should fail to test that the next cctx are not updated but the next chains are failMap[sample.GetCctxIndexFromString("1-12")] = struct{}{} diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index 7ff21a32f5..c689e0cc00 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -48,7 +48,7 @@ func (k Keeper) SetCctxAndNonceToCctxAndInTxHashToCctx(ctx sdk.Context, cctx typ Tss: tss.TssPubkey, }) } - if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.GetCurrentOutTxParam().CoinType == pkg.CoinType_Zeta { + if cctx.CctxStatus.Status == types.CctxStatus_Aborted && cctx.GetCurrentOutTxParam().CoinType == coin.CoinType_Zeta { k.AddZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) } } diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index 91e9e6cdee..7f51dca642 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -8,6 +8,7 @@ import ( "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -15,7 +16,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -48,7 +48,7 @@ func createNCctx(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.CrossCha SenderChainId: int64(i), TxOrigin: fmt.Sprintf("%d", i), Asset: fmt.Sprintf("%d", i), - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, InboundTxObservedHash: fmt.Sprintf("%d", i), InboundTxObservedExternalHeight: uint64(i), InboundTxFinalizedZetaHeight: uint64(i), diff --git a/x/crosschain/keeper/cctx_utils.go b/x/crosschain/keeper/cctx_utils.go index e313bf528a..0fde2fb2e6 100644 --- a/x/crosschain/keeper/cctx_utils.go +++ b/x/crosschain/keeper/cctx_utils.go @@ -9,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -59,7 +59,7 @@ func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uin return 0, nil } - if cctx.InboundTxParams.CoinType == pkg.CoinType_Gas { + if cctx.InboundTxParams.CoinType == coin.CoinType_Gas { // get the gas limit of the gas token fc, found := k.fungibleKeeper.GetGasCoinForForeignCoin(ctx, cctx.InboundTxParams.SenderChainId) if !found { @@ -70,7 +70,7 @@ func (k Keeper) GetRevertGasLimit(ctx sdk.Context, cctx types.CrossChainTx) (uin return 0, errors.Wrap(fungibletypes.ErrContractCall, err.Error()) } return gasLimit.Uint64(), nil - } else if cctx.InboundTxParams.CoinType == pkg.CoinType_ERC20 { + } else if cctx.InboundTxParams.CoinType == coin.CoinType_ERC20 { // get the gas limit of the associated asset fc, found := k.fungibleKeeper.GetForeignCoinFromAsset(ctx, cctx.InboundTxParams.Asset, cctx.InboundTxParams.SenderChainId) if !found { diff --git a/x/crosschain/keeper/cctx_utils_test.go b/x/crosschain/keeper/cctx_utils_test.go index 5a915836f3..c637cc4cc9 100644 --- a/x/crosschain/keeper/cctx_utils_test.go +++ b/x/crosschain/keeper/cctx_utils_test.go @@ -6,7 +6,7 @@ import ( sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -28,7 +28,7 @@ func TestGetRevertGasLimit(t *testing.T) { gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }}) require.NoError(t, err) require.Equal(t, uint64(0), gasLimit) @@ -47,7 +47,7 @@ func TestGetRevertGasLimit(t *testing.T) { gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, }}) require.NoError(t, err) @@ -77,7 +77,7 @@ func TestGetRevertGasLimit(t *testing.T) { gasLimit, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: chainID, Asset: asset, }}) @@ -90,7 +90,7 @@ func TestGetRevertGasLimit(t *testing.T) { _, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: 999999, }}) require.ErrorIs(t, err, types.ErrForeignCoinNotFound) @@ -105,13 +105,13 @@ func TestGetRevertGasLimit(t *testing.T) { zk.FungibleKeeper.SetForeignCoins(ctx, fungibletypes.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: chainID, - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }) // no contract deployed therefore will fail _, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, }}) require.ErrorIs(t, err, fungibletypes.ErrContractCall) @@ -122,7 +122,7 @@ func TestGetRevertGasLimit(t *testing.T) { _, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: 999999, }}) require.ErrorIs(t, err, types.ErrForeignCoinNotFound) @@ -138,14 +138,14 @@ func TestGetRevertGasLimit(t *testing.T) { zk.FungibleKeeper.SetForeignCoins(ctx, fungibletypes.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: chainID, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Asset: asset, }) // no contract deployed therefore will fail _, err := k.GetRevertGasLimit(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: chainID, Asset: asset, }}) diff --git a/x/crosschain/keeper/events.go b/x/crosschain/keeper/events.go index 2008fc5413..6943d77723 100644 --- a/x/crosschain/keeper/events.go +++ b/x/crosschain/keeper/events.go @@ -3,7 +3,7 @@ package keeper import ( "strconv" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -15,13 +15,13 @@ func EmitEventInboundFinalized(ctx sdk.Context, cctx *types.CrossChainTx) { MsgTypeUrl: sdk.MsgTypeURL(&types.MsgVoteOnObservedInboundTx{}), CctxIndex: cctx.Index, Sender: cctx.InboundTxParams.Sender, - SenderChain: pkg.GetChainFromChainID(cctx.InboundTxParams.SenderChainId).ChainName.String(), + SenderChain: chains.GetChainFromChainID(cctx.InboundTxParams.SenderChainId).ChainName.String(), TxOrgin: cctx.InboundTxParams.TxOrigin, Asset: cctx.InboundTxParams.Asset, InTxHash: cctx.InboundTxParams.InboundTxObservedHash, InBlockHeight: strconv.FormatUint(cctx.InboundTxParams.InboundTxObservedExternalHeight, 10), Receiver: currentOutParam.Receiver, - ReceiverChain: pkg.GetChainFromChainID(currentOutParam.ReceiverChainId).ChainName.String(), + ReceiverChain: chains.GetChainFromChainID(currentOutParam.ReceiverChainId).ChainName.String(), Amount: cctx.InboundTxParams.Amount.String(), RelayedMessage: cctx.RelayedMessage, NewStatus: cctx.CctxStatus.Status.String(), diff --git a/x/crosschain/keeper/evm_deposit.go b/x/crosschain/keeper/evm_deposit.go index 731485c84a..96be91a5d4 100644 --- a/x/crosschain/keeper/evm_deposit.go +++ b/x/crosschain/keeper/evm_deposit.go @@ -10,7 +10,8 @@ import ( "github.com/pkg/errors" 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/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -35,7 +36,7 @@ func (k Keeper) HandleEVMDeposit( cctx.GetCurrentOutTxParam().OutboundTxObservedExternalHeight = uint64(ctx.BlockHeight()) } - if msg.CoinType == pkg.CoinType_Zeta { + if msg.CoinType == coin.CoinType_Zeta { // if coin type is Zeta, this is a deposit ZETA to zEVM cctx. err := k.fungibleKeeper.DepositCoinZeta(ctx, to, msg.Amount.BigInt()) if err != nil { @@ -43,7 +44,7 @@ func (k Keeper) HandleEVMDeposit( } } else { // cointype is Gas or ERC20; then it could be a ZRC20 deposit/depositAndCall cctx. - parsedAddress, data, err := pkg.ParseAddressAndData(msg.Message) + parsedAddress, data, err := chains.ParseAddressAndData(msg.Message) if err != nil { return false, errors.Wrap(types.ErrUnableToParseAddress, err.Error()) } @@ -51,7 +52,7 @@ func (k Keeper) HandleEVMDeposit( to = parsedAddress } - from, err := pkg.DecodeAddressFromChainID(senderChainID, msg.Sender) + from, err := chains.DecodeAddressFromChainID(senderChainID, msg.Sender) if err != nil { return false, fmt.Errorf("HandleEVMDeposit: unable to decode address: %s", err.Error()) } diff --git a/x/crosschain/keeper/evm_deposit_test.go b/x/crosschain/keeper/evm_deposit_test.go index fd294a3fd2..15ca00a62a 100644 --- a/x/crosschain/keeper/evm_deposit_test.go +++ b/x/crosschain/keeper/evm_deposit_test.go @@ -10,7 +10,7 @@ import ( evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -37,7 +37,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { types.MsgVoteOnObservedInboundTx{ Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, 0, ) @@ -66,7 +66,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { types.MsgVoteOnObservedInboundTx{ Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, 0, ) @@ -96,7 +96,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, nil) @@ -108,7 +108,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -141,7 +141,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, errDeposit) @@ -153,7 +153,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -186,7 +186,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{VmError: "reverted"}, false, errDeposit) @@ -198,7 +198,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -230,7 +230,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, fungibletypes.ErrForeignCoinCapReached) @@ -242,7 +242,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -274,7 +274,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, fungibletypes.ErrPausedZRC20) @@ -286,7 +286,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -316,7 +316,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, mock.Anything, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, fungibletypes.ErrCallNonContract) @@ -328,7 +328,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "", Asset: "", }, @@ -352,7 +352,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: sample.EthAddress().String(), Amount: math.NewUint(42), - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, Message: "not_hex", Asset: "", }, @@ -382,7 +382,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, data, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, nil) @@ -393,7 +393,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: sample.EthAddress().String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: receiver.Hex()[2:] + "DEADBEEF", Asset: "", }, @@ -425,7 +425,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { amount, senderChain, data, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, mock.Anything, ).Return(&evmtypes.MsgEthereumTxResponse{}, false, nil) @@ -436,7 +436,7 @@ func TestMsgServer_HandleEVMDeposit(t *testing.T) { Sender: sample.EthAddress().String(), Receiver: receiver.String(), Amount: math.NewUintFromBigInt(amount), - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Message: "DEADBEEF", Asset: "", }, diff --git a/x/crosschain/keeper/evm_hooks.go b/x/crosschain/keeper/evm_hooks.go index f2932451ef..e5d85aba2a 100644 --- a/x/crosschain/keeper/evm_hooks.go +++ b/x/crosschain/keeper/evm_hooks.go @@ -17,7 +17,8 @@ import ( connectorzevm "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/connectorzevm.sol" zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "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/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -137,7 +138,7 @@ func (k Keeper) ProcessZRC20WithdrawalEvent(ctx sdk.Context, event *zrc20.ZRC20W if receiverChain == nil { return errorsmod.Wrapf(observertypes.ErrSupportedChains, "chain with chainID %d not supported", foreignCoin.ForeignChainId) } - senderChain, err := pkg.ZetaChainFromChainID(ctx.ChainID()) + senderChain, err := chains.ZetaChainFromChainID(ctx.ChainID()) if err != nil { return fmt.Errorf("ProcessZRC20WithdrawalEvent: failed to convert chainID: %s", err.Error()) } @@ -224,7 +225,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return types.ErrUnableToSendCoinType } toAddr := "0x" + hex.EncodeToString(event.DestinationAddress) - senderChain, err := pkg.ZetaChainFromChainID(ctx.ChainID()) + senderChain, err := chains.ZetaChainFromChainID(ctx.ChainID()) if err != nil { return fmt.Errorf("ProcessZetaSentEvent: failed to convert chainID: %s", err.Error()) } @@ -242,7 +243,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC event.Raw.TxHash.String(), event.Raw.BlockNumber, 90000, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, "", event.Raw.Index, ) @@ -273,7 +274,7 @@ func (k Keeper) ProcessZetaSentEvent(ctx sdk.Context, event *connectorzevm.ZetaC return k.ProcessCCTX(ctx, cctx, receiverChain) } -func (k Keeper) ProcessCCTX(ctx sdk.Context, cctx types.CrossChainTx, receiverChain *pkg.Chain) error { +func (k Keeper) ProcessCCTX(ctx sdk.Context, cctx types.CrossChainTx, receiverChain *chains.Chain) error { inCctxIndex, ok := ctx.Value("inCctxIndex").(string) if ok { cctx.InboundTxParams.InboundTxObservedHash = inCctxIndex @@ -310,11 +311,11 @@ func ParseZRC20WithdrawalEvent(log ethtypes.Log) (*zrc20.ZRC20Withdrawal, error) func ValidateZrc20WithdrawEvent(event *zrc20.ZRC20Withdrawal, chainID int64) error { // The event was parsed; that means the user has deposited tokens to the contract. - if pkg.IsBitcoinChain(chainID) { + if chains.IsBitcoinChain(chainID) { if event.Value.Cmp(big.NewInt(0)) <= 0 { return fmt.Errorf("ParseZRC20WithdrawalEvent: invalid amount %s", event.Value.String()) } - addr, err := pkg.DecodeBtcAddress(string(event.To), chainID) + addr, err := chains.DecodeBtcAddress(string(event.To), chainID) if err != nil { return fmt.Errorf("ParseZRC20WithdrawalEvent: invalid address %s: %s", event.To, err) } diff --git a/x/crosschain/keeper/evm_hooks_test.go b/x/crosschain/keeper/evm_hooks_test.go index 1c48059861..85676457cf 100644 --- a/x/crosschain/keeper/evm_hooks_test.go +++ b/x/crosschain/keeper/evm_hooks_test.go @@ -13,7 +13,7 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -22,7 +22,7 @@ import ( observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -func SetupStateForProcessLogsZetaSent(t *testing.T, ctx sdk.Context, k *crosschainkeeper.Keeper, zk keepertest.ZetaKeepers, sdkk keepertest.SDKKeepers, chain pkg.Chain) { +func SetupStateForProcessLogsZetaSent(t *testing.T, ctx sdk.Context, k *crosschainkeeper.Keeper, zk keepertest.ZetaKeepers, sdkk keepertest.SDKKeepers, chain chains.Chain) { assetAddress := sample.EthAddress().String() gasZRC20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, chain.ChainId, "ethereum", "ETH") zrc20Addr := deployZRC20( @@ -53,7 +53,7 @@ func SetupStateForProcessLogsZetaSent(t *testing.T, ctx sdk.Context, k *crosscha ) } -func SetupStateForProcessLogs(t *testing.T, ctx sdk.Context, k *crosschainkeeper.Keeper, zk keepertest.ZetaKeepers, sdkk keepertest.SDKKeepers, chain pkg.Chain) { +func SetupStateForProcessLogs(t *testing.T, ctx sdk.Context, k *crosschainkeeper.Keeper, zk keepertest.ZetaKeepers, sdkk keepertest.SDKKeepers, chain chains.Chain) { deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) tss := sample.Tss() @@ -134,7 +134,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { t.Run("successfully validate a valid event", func(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, pkg.BtcMainnetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain().ChainId) require.NoError(t, err) }) @@ -142,14 +142,14 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) btcMainNetWithdrawalEvent.Value = big.NewInt(0) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, pkg.BtcMainnetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcMainnetChain().ChainId) require.ErrorContains(t, err, "ParseZRC20WithdrawalEvent: invalid amount") }) t.Run("unable to validate a event with an invalid chain ID", func(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, pkg.BtcTestNetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcTestNetChain().ChainId) require.ErrorContains(t, err, "address is not for network testnet3") }) @@ -157,7 +157,7 @@ func TestValidateZrc20WithdrawEvent(t *testing.T) { btcMainNetWithdrawalEvent, err := crosschainkeeper.ParseZRC20WithdrawalEvent(*sample.GetValidZRC20WithdrawToBTC(t).Logs[3]) require.NoError(t, err) btcMainNetWithdrawalEvent.To = []byte("1EYVvXLusCxtVuEwoYvWRyN5EZTXwPVvo3") - err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, pkg.BtcTestNetChain().ChainId) + err = crosschainkeeper.ValidateZrc20WithdrawEvent(btcMainNetWithdrawalEvent, chains.BtcTestNetChain().ChainId) require.ErrorContains(t, err, "decode address failed: unknown address type") }) } @@ -167,7 +167,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -193,7 +193,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -219,7 +219,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -240,7 +240,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -261,7 +261,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -284,7 +284,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -310,7 +310,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { fungibleMock := keepertest.GetCrosschainFungibleMock(t, k) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -335,7 +335,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -358,7 +358,7 @@ func TestKeeper_ProcessZRC20WithdrawalEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -393,7 +393,7 @@ func TestKeeper_ParseZetaSentEvent(t *testing.T) { require.Nil(t, event) continue } - require.Equal(t, pkg.EthChain().ChainId, event.DestinationChainId.Int64()) + require.Equal(t, chains.EthChain().ChainId, event.DestinationChainId.Int64()) require.Equal(t, "70000000000000000000", event.ZetaValueAndGas.String()) require.Equal(t, "0x60983881bdf302dcfa96603A58274D15D5966209", event.SourceTxOriginAddress.String()) require.Equal(t, "0xF0a3F93Ed1B126142E61423F9546bf1323Ff82DF", event.ZetaTxSenderAddress.String()) @@ -430,7 +430,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -452,7 +452,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { cctxList := k.GetAllCrossChainTx(ctx) require.Len(t, cctxList, 1) require.Equal(t, strings.Compare("0x60983881bdf302dcfa96603a58274d15d5966209", cctxList[0].GetCurrentOutTxParam().Receiver), 0) - require.Equal(t, pkg.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) + require.Equal(t, chains.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundTxParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundTxParams.TxOrigin) }) @@ -461,7 +461,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -481,7 +481,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) SetupStateForProcessLogsZetaSent(t, ctx, k, zk, sdkk, chain) @@ -503,7 +503,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -528,7 +528,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -551,7 +551,7 @@ func TestKeeper_ProcessZetaSentEvent(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) @@ -583,7 +583,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -609,7 +609,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -633,7 +633,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { cctxList := k.GetAllCrossChainTx(ctx) require.Len(t, cctxList, 1) require.Equal(t, strings.Compare("0x60983881bdf302dcfa96603a58274d15d5966209", cctxList[0].GetCurrentOutTxParam().Receiver), 0) - require.Equal(t, pkg.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) + require.Equal(t, chains.EthChain().ChainId, cctxList[0].GetCurrentOutTxParam().ReceiverChainId) require.Equal(t, emittingContract.Hex(), cctxList[0].InboundTxParams.Sender) require.Equal(t, txOrigin.Hex(), cctxList[0].InboundTxParams.TxOrigin) }) @@ -652,7 +652,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -673,7 +673,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { t.Run("no cctx created for logs containing proper event but not emitted from a known ZRC20 contract", func(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -694,7 +694,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -718,7 +718,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) @@ -739,7 +739,7 @@ func TestKeeper_ProcessLogs(t *testing.T) { k, ctx, sdkk, zk := keepertest.CrosschainKeeper(t) k.GetAuthKeeper().GetModuleAccount(ctx, fungibletypes.ModuleName) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() chainID := chain.ChainId setSupportedChain(ctx, zk, chainID) SetupStateForProcessLogs(t, ctx, k, zk, sdkk, chain) diff --git a/x/crosschain/keeper/gas_payment.go b/x/crosschain/keeper/gas_payment.go index c025bde196..6a9b957f16 100644 --- a/x/crosschain/keeper/gas_payment.go +++ b/x/crosschain/keeper/gas_payment.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -29,11 +29,11 @@ func (k Keeper) PayGasAndUpdateCctx( ) error { // Dispatch to the correct function based on the coin type switch cctx.InboundTxParams.CoinType { - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: return k.PayGasInZetaAndUpdateCctx(ctx, chainID, cctx, inputAmount, noEthereumTxEvent) - case pkg.CoinType_Gas: + case coin.CoinType_Gas: return k.PayGasNativeAndUpdateCctx(ctx, chainID, cctx, inputAmount) - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: return k.PayGasInERC20AndUpdateCctx(ctx, chainID, cctx, inputAmount, noEthereumTxEvent) default: // can't pay gas with coin type @@ -90,7 +90,7 @@ func (k Keeper) PayGasNativeAndUpdateCctx( inputAmount math.Uint, ) error { // preliminary checks - if cctx.InboundTxParams.CoinType != pkg.CoinType_Gas { + if cctx.InboundTxParams.CoinType != coin.CoinType_Gas { return cosmoserrors.Wrapf(types.ErrInvalidCoinType, "can't pay gas in native gas with %s", cctx.InboundTxParams.CoinType.String()) } if chain := k.zetaObserverKeeper.GetSupportedChainFromChainID(ctx, chainID); chain == nil { @@ -137,7 +137,7 @@ func (k Keeper) PayGasInERC20AndUpdateCctx( noEthereumTxEvent bool, ) error { // preliminary checks - if cctx.InboundTxParams.CoinType != pkg.CoinType_ERC20 { + if cctx.InboundTxParams.CoinType != coin.CoinType_ERC20 { return cosmoserrors.Wrapf(types.ErrInvalidCoinType, "can't pay gas in erc20 with %s", cctx.InboundTxParams.CoinType.String()) } @@ -264,7 +264,7 @@ func (k Keeper) PayGasInZetaAndUpdateCctx( noEthereumTxEvent bool, ) error { // preliminary checks - if cctx.InboundTxParams.CoinType != pkg.CoinType_Zeta { + if cctx.InboundTxParams.CoinType != coin.CoinType_Zeta { return cosmoserrors.Wrapf(types.ErrInvalidCoinType, "can't pay gas in zeta with %s", cctx.InboundTxParams.CoinType.String()) } diff --git a/x/crosschain/keeper/gas_payment_test.go b/x/crosschain/keeper/gas_payment_test.go index c667fb3a3b..1ccb31c937 100644 --- a/x/crosschain/keeper/gas_payment_test.go +++ b/x/crosschain/keeper/gas_payment_test.go @@ -4,13 +4,14 @@ import ( "math/big" "testing" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/sample" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/x/crosschain/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" @@ -47,11 +48,11 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -73,7 +74,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { chainID := getValidEthChainID(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, } err := k.PayGasNativeAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount)) @@ -84,7 +85,7 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, } err := k.PayGasNativeAndUpdateCctx(ctx, 999999, &cctx, math.NewUint(inputAmount)) @@ -104,11 +105,11 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -141,11 +142,11 @@ func TestKeeper_PayGasNativeAndUpdateCctx(t *testing.T) { cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -202,12 +203,12 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Asset: assetAddress, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -234,7 +235,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { chainID := getValidEthChainID(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, } err := k.PayGasInERC20AndUpdateCctx(ctx, chainID, &cctx, math.NewUint(inputAmount), false) @@ -245,7 +246,7 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, }, } err := k.PayGasInERC20AndUpdateCctx(ctx, 999999, &cctx, math.NewUint(inputAmount), false) @@ -265,11 +266,11 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -306,12 +307,12 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Asset: assetAddress, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -358,12 +359,12 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Asset: assetAddress, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -416,12 +417,12 @@ func TestKeeper_PayGasInERC20AndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Asset: assetAddress, }, OutboundTxParams: []*types.OutboundTxParams{ { - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }, { ReceiverChainId: chainID, @@ -461,7 +462,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*types.OutboundTxParams{ { @@ -487,7 +488,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { // can call with undefined zeta fees cctx = types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*types.OutboundTxParams{ { @@ -512,7 +513,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { chainID := getValidEthChainID(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, } err := k.PayGasInZetaAndUpdateCctx(ctx, chainID, &cctx, math.NewUint(100000), false) @@ -523,7 +524,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { k, ctx, _, _ := testkeeper.CrosschainKeeper(t) cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, } err := k.PayGasInZetaAndUpdateCctx(ctx, 999999, &cctx, math.NewUint(100000), false) @@ -545,7 +546,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*types.OutboundTxParams{ { @@ -577,7 +578,7 @@ func TestKeeper_PayGasInZetaAndUpdateCctx(t *testing.T) { // create a cctx reverted from zeta cctx := types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*types.OutboundTxParams{ { diff --git a/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go b/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go index 84fe370a84..5cb26ef831 100644 --- a/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go +++ b/x/crosschain/keeper/grpc_query_zeta_conversion_rate.go @@ -6,7 +6,7 @@ import ( "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/crosschain/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" @@ -15,7 +15,7 @@ import ( func (k Keeper) ConvertGasToZeta(context context.Context, request *types.QueryConvertGasToZetaRequest) (*types.QueryConvertGasToZetaResponse, error) { ctx := sdk.UnwrapSDKContext(context) - chain := pkg.GetChainFromChainID(request.ChainId) + chain := chains.GetChainFromChainID(request.ChainId) if chain == nil { return nil, zetaObserverTypes.ErrSupportedChains diff --git a/x/crosschain/keeper/in_tx_tracker_test.go b/x/crosschain/keeper/in_tx_tracker_test.go index 871e472c0a..317f305a82 100644 --- a/x/crosschain/keeper/in_tx_tracker_test.go +++ b/x/crosschain/keeper/in_tx_tracker_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/nullify" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -20,7 +20,7 @@ func createNInTxTracker(keeper *keeper.Keeper, ctx sdk.Context, n int, chainID i for i := range items { items[i].TxHash = fmt.Sprintf("TxHash-%d", i) items[i].ChainId = chainID - items[i].CoinType = pkg.CoinType_Gas + items[i].CoinType = coin.CoinType_Gas keeper.SetInTxTracker(ctx, items[i]) } return items diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker.go index 0cfd77a8e9..960fa3d2c5 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -32,7 +32,7 @@ func (k msgServer) AddToInTxTracker(goCtx context.Context, msg *types.MsgAddToIn return nil, types.ErrProofVerificationFail.Wrapf(err.Error()) } - if pkg.IsEVMChain(msg.ChainId) { + if chains.IsEVMChain(msg.ChainId) { err = k.VerifyEVMInTxBody(ctx, msg, txBytes) if err != nil { return nil, types.ErrTxBodyVerificationFail.Wrapf(err.Error()) diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 0870951850..a43816db66 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -6,7 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/pkg/proofs" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -18,12 +19,12 @@ import ( func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_index int64, chainID int64, header ethtypes.Header, headerRLP []byte, block *ethtypes.Block) { params := zk.ObserverKeeper.GetParamsIfExists(ctx) zk.ObserverKeeper.SetParams(ctx, params) - zk.ObserverKeeper.SetBlockHeader(ctx, pkg.BlockHeader{ + zk.ObserverKeeper.SetBlockHeader(ctx, proofs.BlockHeader{ Height: block.Number().Int64(), Hash: block.Hash().Bytes(), ParentHash: header.ParentHash.Bytes(), ChainId: chainID, - Header: pkg.NewEthereumHeader(headerRLP), + Header: proofs.NewEthereumHeader(headerRLP), }) zk.ObserverKeeper.SetChainParamsList(ctx, observertypes.ChainParamsList{ChainParams: []*observertypes.ChainParams{ { @@ -56,7 +57,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { Creator: sample.AccAddress(), ChainId: chainID, TxHash: tx_hash, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, @@ -85,7 +86,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { Creator: admin, ChainId: chainID, TxHash: tx_hash, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, @@ -114,7 +115,7 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { Creator: admin, ChainId: chainID, TxHash: "Malicious TX HASH", - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, Proof: nil, BlockHash: "", TxIndex: 0, diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go index 926fe66f8d..7f747fbcd7 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker.go @@ -12,7 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" eth "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -116,7 +116,7 @@ func (k msgServer) AddToOutTxTracker(goCtx context.Context, msg *types.MsgAddToO func (k Keeper) VerifyOutTxBody(ctx sdk.Context, msg *types.MsgAddToOutTxTracker, txBytes []byte) error { // get tss address var bitcoinChainID int64 - if pkg.IsBitcoinChain(msg.ChainId) { + if chains.IsBitcoinChain(msg.ChainId) { bitcoinChainID = msg.ChainId } tss, err := k.zetaObserverKeeper.GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ @@ -127,9 +127,9 @@ func (k Keeper) VerifyOutTxBody(ctx sdk.Context, msg *types.MsgAddToOutTxTracker } // verify message against transaction body - if pkg.IsEVMChain(msg.ChainId) { + if chains.IsEVMChain(msg.ChainId) { err = VerifyEVMOutTxBody(msg, txBytes, tss.Eth) - } else if pkg.IsBitcoinChain(msg.ChainId) { + } else if chains.IsBitcoinChain(msg.ChainId) { err = VerifyBTCOutTxBody(msg, txBytes, tss.Btc) } else { return fmt.Errorf("cannot verify outTx body for chain %d", msg.ChainId) @@ -172,7 +172,7 @@ func VerifyEVMOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssEth // VerifyBTCOutTxBody validates the SegWit sender address, nonce and chain id and tx hash // Note: 'msg' may contain fabricated information func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc string) error { - if !pkg.IsBitcoinChain(msg.ChainId) { + if !chains.IsBitcoinChain(msg.ChainId) { return fmt.Errorf("not a Bitcoin chain ID %d", msg.ChainId) } tx, err := btcutil.NewTxFromBytes(txBytes) @@ -187,7 +187,7 @@ func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc if err != nil { return fmt.Errorf("failed to parse public key") } - bitcoinNetParams, err := pkg.BitcoinNetParamsFromChainID(msg.ChainId) + bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(msg.ChainId) if err != nil { return fmt.Errorf("failed to get Bitcoin net params, error %s", err.Error()) } @@ -205,8 +205,8 @@ func VerifyBTCOutTxBody(msg *types.MsgAddToOutTxTracker, txBytes []byte, tssBtc if len(tx.MsgTx().TxOut) < 1 { return fmt.Errorf("outTx should have at least one output") } - if tx.MsgTx().TxOut[0].Value != pkg.NonceMarkAmount(msg.Nonce) { - return fmt.Errorf("want nonce mark %d, got %d", tx.MsgTx().TxOut[0].Value, pkg.NonceMarkAmount(msg.Nonce)) + if tx.MsgTx().TxOut[0].Value != chains.NonceMarkAmount(msg.Nonce) { + return fmt.Errorf("want nonce mark %d, got %d", tx.MsgTx().TxOut[0].Value, chains.NonceMarkAmount(msg.Nonce)) } if tx.MsgTx().TxHash().String() != msg.TxHash { return fmt.Errorf("want tx hash %s, got %s", tx.MsgTx().TxHash(), msg.TxHash) diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds.go b/x/crosschain/keeper/msg_server_migrate_tss_funds.go index 8505637421..a9ad02429f 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds.go @@ -13,6 +13,11 @@ import ( 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" + zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto" + "github.com/zeta-chain/zetacore/pkg/gas" + + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -92,7 +97,7 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s Sender: "", SenderChainId: chainID, TxOrigin: "", - CoinType: pkg.CoinType_Cmd, + CoinType: coin.CoinType_Cmd, Asset: "", Amount: amount, InboundTxObservedHash: tmbytes.HexBytes(tmtypes.Tx(ctx.TxBytes()).Hash()).String(), @@ -103,7 +108,7 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s OutboundTxParams: []*types.OutboundTxParams{{ Receiver: "", ReceiverChainId: chainID, - CoinType: pkg.CoinType_Cmd, + CoinType: coin.CoinType_Cmd, Amount: amount, OutboundTxTssNonce: 0, OutboundTxGasLimit: 1_000_000, @@ -117,21 +122,21 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s TssPubkey: currentTss.TssPubkey, }}} // Set the sender and receiver addresses for EVM chain - if pkg.IsEVMChain(chainID) { - ethAddressOld, err := pkg.GetTssAddrEVM(currentTss.TssPubkey) + if chains.IsEVMChain(chainID) { + ethAddressOld, err := zetacrypto.GetTssAddrEVM(currentTss.TssPubkey) if err != nil { return err } - ethAddressNew, err := pkg.GetTssAddrEVM(newTss.TssPubkey) + ethAddressNew, err := zetacrypto.GetTssAddrEVM(newTss.TssPubkey) if err != nil { return err } cctx.InboundTxParams.Sender = ethAddressOld.String() cctx.GetCurrentOutTxParam().Receiver = ethAddressNew.String() // Tss migration is a send transaction, so the gas limit is set to 21000 - cctx.GetCurrentOutTxParam().OutboundTxGasLimit = pkg.EVMSend + cctx.GetCurrentOutTxParam().OutboundTxGasLimit = gas.EVMSend // Multiple current gas price with standard multiplier to add some buffer - multipliedGasPrice, err := pkg.MultiplyGasPrice(medianGasPrice, types.TssMigrationGasMultiplierEVM) + multipliedGasPrice, err := gas.MultiplyGasPrice(medianGasPrice, types.TssMigrationGasMultiplierEVM) if err != nil { return err } @@ -143,16 +148,16 @@ func (k Keeper) MigrateTSSFundsForChain(ctx sdk.Context, chainID int64, amount s cctx.GetCurrentOutTxParam().Amount = amount.Sub(evmFee) } // Set the sender and receiver addresses for Bitcoin chain - if pkg.IsBitcoinChain(chainID) { - bitcoinNetParams, err := pkg.BitcoinNetParamsFromChainID(chainID) + if chains.IsBitcoinChain(chainID) { + bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(chainID) if err != nil { return err } - btcAddressOld, err := pkg.GetTssAddrBTC(currentTss.TssPubkey, bitcoinNetParams) + btcAddressOld, err := zetacrypto.GetTssAddrBTC(currentTss.TssPubkey, bitcoinNetParams) if err != nil { return err } - btcAddressNew, err := pkg.GetTssAddrBTC(newTss.TssPubkey, bitcoinNetParams) + btcAddressNew, err := zetacrypto.GetTssAddrBTC(newTss.TssPubkey, bitcoinNetParams) if err != nil { return err } diff --git a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go index c4282e4f17..d4a6c5206e 100644 --- a/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go +++ b/x/crosschain/keeper/msg_server_migrate_tss_funds_test.go @@ -7,7 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/gas" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -20,7 +21,7 @@ func setupTssMigrationParams( zk keepertest.ZetaKeepers, k *keeper.Keeper, ctx sdk.Context, - chain pkg.Chain, + chain chains.Chain, amount sdkmath.Uint, setNewTss bool, setCurrentTSS bool, @@ -102,7 +103,7 @@ func TestKeeper_MigrateTSSFundsForChain(t *testing.T) { index := hash.Hex() cctx, found := k.GetCrossChainTx(ctx, index) require.True(t, found) - multipliedValue, err := pkg.MultiplyGasPrice(gp, crosschaintypes.TssMigrationGasMultiplierEVM) + multipliedValue, err := gas.MultiplyGasPrice(gp, crosschaintypes.TssMigrationGasMultiplierEVM) require.NoError(t, err) require.Equal(t, multipliedValue.String(), cctx.GetCurrentOutTxParam().OutboundTxGasPrice) diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx.go b/x/crosschain/keeper/msg_server_refund_aborted_tx.go index c99b406227..2d08296630 100644 --- a/x/crosschain/keeper/msg_server_refund_aborted_tx.go +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -43,7 +43,7 @@ func (k msgServer) RefundAbortedCCTX(goCtx context.Context, msg *types.MsgRefund } // Check if aborted amount is available to maintain zeta accounting - if cctx.InboundTxParams.CoinType == pkg.CoinType_Zeta { + if cctx.InboundTxParams.CoinType == coin.CoinType_Zeta { err := k.RemoveZetaAbortedAmount(ctx, GetAbortedAmount(cctx)) // if the zeta accounting is not found, it means the zeta accounting is not set yet and the refund should not be processed if errors.Is(err, types.ErrUnableToFindZetaAccounting) { diff --git a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go index e822f237f3..5defcd882a 100644 --- a/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go +++ b/x/crosschain/keeper/msg_server_refund_aborted_tx_test.go @@ -7,7 +7,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -55,7 +55,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") @@ -94,7 +94,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta k.SetCrossChainTx(ctx, *cctx) k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.GetCurrentOutTxParam().Amount}) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -133,7 +133,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta cctx.OutboundTxParams = nil k.SetCrossChainTx(ctx, *cctx) k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.GetCurrentOutTxParam().Amount}) @@ -173,7 +173,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta k.SetCrossChainTx(ctx, *cctx) k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -212,7 +212,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.Status = crosschaintypes.CctxStatus_Aborted cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_ERC20 + cctx.InboundTxParams.CoinType = coin.CoinType_ERC20 cctx.InboundTxParams.Asset = asset k.SetCrossChainTx(ctx, *cctx) // deploy zrc20 @@ -262,7 +262,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) zrc20 := setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") @@ -301,7 +301,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta k.SetCrossChainTx(ctx, *cctx) k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -332,7 +332,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta k.SetCrossChainTx(ctx, *cctx) k.SetZetaAccounting(ctx, crosschaintypes.ZetaAccounting{AbortedZetaAmount: cctx.InboundTxParams.Amount}) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -363,7 +363,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -396,7 +396,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) _, err := msgServer.RefundAbortedCCTX(ctx, &crosschaintypes.MsgRefundAbortedCCTX{ @@ -425,7 +425,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") @@ -456,7 +456,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Zeta + cctx.InboundTxParams.CoinType = coin.CoinType_Zeta k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) @@ -486,7 +486,7 @@ func TestMsgServer_RefundAbortedCCTX(t *testing.T) { cctx.CctxStatus.IsAbortRefunded = false cctx.InboundTxParams.TxOrigin = cctx.InboundTxParams.Sender cctx.InboundTxParams.SenderChainId = chainID - cctx.InboundTxParams.CoinType = pkg.CoinType_Gas + cctx.InboundTxParams.CoinType = coin.CoinType_Gas k.SetCrossChainTx(ctx, *cctx) deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) _ = setupGasCoin(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper, cctx.InboundTxParams.SenderChainId, "foobar", "foobar") diff --git a/x/crosschain/keeper/msg_server_tss_voter.go b/x/crosschain/keeper/msg_server_tss_voter.go index 0bca8c6028..a3782729b1 100644 --- a/x/crosschain/keeper/msg_server_tss_voter.go +++ b/x/crosschain/keeper/msg_server_tss_voter.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" math2 "github.com/ethereum/go-ethereum/common/math" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/observer/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -65,12 +65,12 @@ func (k msgServer) CreateTSSVoter(goCtx context.Context, msg *types.MsgCreateTSS k.zetaObserverKeeper.AddBallotToList(ctx, ballot) } var err error - if msg.Status == pkg.ReceiveStatus_Success { + if msg.Status == chains.ReceiveStatus_Success { ballot, err = k.zetaObserverKeeper.AddVoteToBallot(ctx, ballot, msg.Creator, observertypes.VoteType_SuccessObservation) if err != nil { return &types.MsgCreateTSSVoterResponse{}, err } - } else if msg.Status == pkg.ReceiveStatus_Failed { + } else if msg.Status == chains.ReceiveStatus_Failed { ballot, err = k.zetaObserverKeeper.AddVoteToBallot(ctx, ballot, msg.Creator, observertypes.VoteType_FailureObservation) if err != nil { return &types.MsgCreateTSSVoterResponse{}, err diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx.go b/x/crosschain/keeper/msg_server_vote_inbound_tx.go index d1459b4cba..4fee3a2c9d 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx.go @@ -6,7 +6,7 @@ import ( cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -121,7 +121,7 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg // FinalizeInbound updates CCTX Prices and Nonce // Aborts is any of the updates fail - if pkg.IsZetaChain(msg.ReceiverChain) { + if chains.IsZetaChain(msg.ReceiverChain) { tmpCtx, commit := ctx.CacheContext() isContractReverted, err := k.HandleEVMDeposit(tmpCtx, &cctx, *msg, msg.SenderChainId) diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 24f77f4579..fa51c66bfa 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -7,7 +7,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -42,12 +42,12 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) validatorList := setObservers(t, k, ctx, zk) to, from := int64(1337), int64(101) - chains := zk.ObserverKeeper.GetSupportedChains(ctx) - for _, chain := range chains { - if pkg.IsEVMChain(chain.ChainId) { + supportedChains := zk.ObserverKeeper.GetSupportedChains(ctx) + for _, chain := range supportedChains { + if chains.IsEVMChain(chain.ChainId) { from = chain.ChainId } - if pkg.IsZetaChain(chain.ChainId) { + if chains.IsZetaChain(chain.ChainId) { to = chain.ChainId } } diff --git a/x/crosschain/keeper/msg_server_vote_outbound_tx.go b/x/crosschain/keeper/msg_server_vote_outbound_tx.go index 81331024f4..9286f0865a 100644 --- a/x/crosschain/keeper/msg_server_vote_outbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_outbound_tx.go @@ -12,7 +12,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/rs/zerolog/log" - "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/x/crosschain/types" observerkeeper "github.com/zeta-chain/zetacore/x/observer/keeper" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -142,7 +143,7 @@ func (k msgServer) VoteOnObservedOutboundTx(goCtx context.Context, msg *types.Ms newStatus := cctx.CctxStatus.Status.String() EmitOutboundSuccess(tmpCtx, msg, oldStatus.String(), newStatus, cctx) case observertypes.BallotStatus_BallotFinalized_FailureObservation: - if msg.CoinType == pkg.CoinType_Cmd || pkg.IsZetaChain(cctx.InboundTxParams.SenderChainId) { + if msg.CoinType == coin.CoinType_Cmd || chains.IsZetaChain(cctx.InboundTxParams.SenderChainId) { // if the cctx is of coin type cmd or the sender chain is zeta chain, then we do not revert, the cctx is aborted cctx.CctxStatus.ChangeStatus(types.CctxStatus_Aborted, "") } else { diff --git a/x/crosschain/keeper/msg_server_whitelist_erc20.go b/x/crosschain/keeper/msg_server_whitelist_erc20.go index f845c53a52..9bc6aba87d 100644 --- a/x/crosschain/keeper/msg_server_whitelist_erc20.go +++ b/x/crosschain/keeper/msg_server_whitelist_erc20.go @@ -5,6 +5,7 @@ import ( "fmt" "math/big" + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" errorsmod "cosmossdk.io/errors" @@ -72,7 +73,7 @@ func (k msgServer) WhitelistERC20(goCtx context.Context, msg *types.MsgWhitelist // #nosec G701 always in range uint8(msg.Decimals), chain.ChainId, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, msg.Erc20Address, big.NewInt(msg.GasLimit), ) @@ -125,7 +126,7 @@ func (k msgServer) WhitelistERC20(goCtx context.Context, msg *types.MsgWhitelist Sender: "", SenderChainId: 0, TxOrigin: "", - CoinType: pkg.CoinType_Cmd, + CoinType: coin.CoinType_Cmd, Asset: "", Amount: math.Uint{}, InboundTxObservedHash: hash.String(), // all Upper case Cosmos TX HEX, with no 0x prefix @@ -137,7 +138,7 @@ func (k msgServer) WhitelistERC20(goCtx context.Context, msg *types.MsgWhitelist { Receiver: param.Erc20CustodyContractAddress, ReceiverChainId: msg.ChainId, - CoinType: pkg.CoinType_Cmd, + CoinType: coin.CoinType_Cmd, Amount: math.NewUint(0), OutboundTxTssNonce: 0, OutboundTxGasLimit: 100_000, @@ -162,7 +163,7 @@ func (k msgServer) WhitelistERC20(goCtx context.Context, msg *types.MsgWhitelist Decimals: msg.Decimals, Name: msg.Name, Symbol: msg.Symbol, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, // #nosec G701 always positive GasLimit: uint64(msg.GasLimit), } diff --git a/x/crosschain/keeper/refund.go b/x/crosschain/keeper/refund.go index 36638bd1be..1781264c1c 100644 --- a/x/crosschain/keeper/refund.go +++ b/x/crosschain/keeper/refund.go @@ -7,18 +7,19 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" - "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/x/crosschain/types" ) func (k Keeper) RefundAbortedAmountOnZetaChain(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { coinType := cctx.InboundTxParams.CoinType switch coinType { - case pkg.CoinType_Gas: + case coin.CoinType_Gas: return k.RefundAmountOnZetaChainGas(ctx, cctx, refundAddress) - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: return k.RefundAmountOnZetaChainZeta(ctx, cctx, refundAddress) - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: return k.RefundAmountOnZetaChainERC20(ctx, cctx, refundAddress) default: return errors.New("unsupported coin type for refund on ZetaChain") @@ -56,7 +57,7 @@ func (k Keeper) RefundAmountOnZetaChainZeta(ctx sdk.Context, cctx types.CrossCha refundAmount := GetAbortedAmount(cctx) chainID := cctx.InboundTxParams.SenderChainId // check if chain is an EVM chain - if !pkg.IsEVMChain(chainID) { + if !chains.IsEVMChain(chainID) { return errors.New("only EVM chains are supported for refund when coin type is Zeta") } if cctx.InboundTxParams.Amount.IsNil() || cctx.InboundTxParams.Amount.IsZero() { @@ -75,10 +76,10 @@ func (k Keeper) RefundAmountOnZetaChainZeta(ctx sdk.Context, cctx types.CrossCha func (k Keeper) RefundAmountOnZetaChainERC20(ctx sdk.Context, cctx types.CrossChainTx, refundAddress ethcommon.Address) error { refundAmount := GetAbortedAmount(cctx) // preliminary checks - if cctx.InboundTxParams.CoinType != pkg.CoinType_ERC20 { + if cctx.InboundTxParams.CoinType != coin.CoinType_ERC20 { return errors.New("unsupported coin type for refund on ZetaChain") } - if !pkg.IsEVMChain(cctx.InboundTxParams.SenderChainId) { + if !chains.IsEVMChain(cctx.InboundTxParams.SenderChainId) { return errors.New("only EVM chains are supported for refund on ZetaChain") } diff --git a/x/crosschain/keeper/refund_test.go b/x/crosschain/keeper/refund_test.go index ba339ceed9..933359008f 100644 --- a/x/crosschain/keeper/refund_test.go +++ b/x/crosschain/keeper/refund_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -26,7 +26,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -53,7 +53,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -75,7 +75,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { deploySystemContracts(t, ctx, zk.FungibleKeeper, sdkk.EvmKeeper) err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -100,7 +100,7 @@ func TestKeeper_RefundAmountOnZetaChainGas(t *testing.T) { err := k.RefundAmountOnZetaChainGas(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -126,7 +126,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -151,7 +151,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -172,7 +172,7 @@ func TestKeeper_RefundAmountOnZetaChainZeta(t *testing.T) { err := k.RefundAmountOnZetaChainZeta(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, SenderChainId: chainID, Sender: sender.String(), TxOrigin: sender.String(), @@ -211,7 +211,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err := k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: chainID, Sender: sender.String(), Asset: asset, @@ -233,7 +233,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { // can refund again err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: chainID, Sender: sender.String(), Asset: asset, @@ -252,7 +252,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err := k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, Amount: math.NewUint(42), }}, sample.EthAddress(), @@ -261,7 +261,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }}, sample.EthAddress(), ) @@ -269,7 +269,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: 999999, Amount: math.NewUint(42), }}, @@ -279,7 +279,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: getValidEthChainID(t), Sender: sample.EthAddress().String(), Amount: math.Uint{}, @@ -290,7 +290,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: getValidEthChainID(t), Sender: sample.EthAddress().String(), Amount: math.ZeroUint(), @@ -302,7 +302,7 @@ func TestKeeper_RefundAmountOnZetaChainERC20(t *testing.T) { // the foreign coin has not been set err = k.RefundAmountOnZetaChainERC20(ctx, types.CrossChainTx{ InboundTxParams: &types.InboundTxParams{ - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, SenderChainId: getValidEthChainID(t), Sender: sample.EthAddress().String(), Asset: sample.EthAddress().String(), diff --git a/x/crosschain/keeper/utils_test.go b/x/crosschain/keeper/utils_test.go index 4dd56e67b4..732ec5d0bd 100644 --- a/x/crosschain/keeper/utils_test.go +++ b/x/crosschain/keeper/utils_test.go @@ -5,7 +5,7 @@ import ( "math/big" "testing" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -27,13 +27,13 @@ func getValidEthChainID(t *testing.T) int64 { } // getValidEthChain get a valid eth chain -func getValidEthChain(_ *testing.T) *pkg.Chain { - goerli := pkg.GoerliLocalnetChain() +func getValidEthChain(_ *testing.T) *chains.Chain { + goerli := chains.GoerliLocalnetChain() return &goerli } -func getValidBTCChain() *pkg.Chain { - btcRegNet := pkg.BtcRegtestChain() +func getValidBTCChain() *chains.Chain { + btcRegNet := chains.BtcRegtestChain() return &btcRegNet } @@ -45,9 +45,9 @@ func getValidBtcChainID() int64 { func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { case 0: - return pkg.GoerliLocalnetChain().ChainId + return chains.GoerliLocalnetChain().ChainId case 1: - return pkg.GoerliChain().ChainId + return chains.GoerliChain().ChainId default: require.Fail(t, "invalid index") } diff --git a/x/crosschain/keeper/verify_proof.go b/x/crosschain/keeper/verify_proof.go index 7df158457d..5c58c98b10 100644 --- a/x/crosschain/keeper/verify_proof.go +++ b/x/crosschain/keeper/verify_proof.go @@ -7,12 +7,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" eth "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" - "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/proofs" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) -func (k Keeper) VerifyProof(ctx sdk.Context, proof *pkg.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { +func (k Keeper) VerifyProof(ctx sdk.Context, proof *proofs.Proof, chainID int64, blockHash string, txIndex int64) ([]byte, error) { // header-based merkle proof verification must be enabled crosschainFlags, found := k.zetaObserverKeeper.GetCrosschainFlags(ctx) if !found { @@ -21,15 +23,15 @@ func (k Keeper) VerifyProof(ctx sdk.Context, proof *pkg.Proof, chainID int64, bl if crosschainFlags.BlockHeaderVerificationFlags == nil { return nil, fmt.Errorf("block header verification flags not found") } - if pkg.IsBitcoinChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { + if chains.IsBitcoinChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { return nil, fmt.Errorf("proof verification not enabled for bitcoin chain") } - if pkg.IsEVMChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { + if chains.IsEVMChain(chainID) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { return nil, fmt.Errorf("proof verification not enabled for evm chain") } // chain must support header-based merkle proof verification - senderChain := pkg.GetChainFromChainID(chainID) + senderChain := chains.GetChainFromChainID(chainID) if senderChain == nil { return nil, types.ErrUnsupportedChain } @@ -38,7 +40,7 @@ func (k Keeper) VerifyProof(ctx sdk.Context, proof *pkg.Proof, chainID int64, bl } // get block header from the store - hashBytes, err := pkg.StringToHash(chainID, blockHash) + hashBytes, err := chains.StringToHash(chainID, blockHash) if err != nil { return nil, fmt.Errorf("block hash %s conversion failed %s", blockHash, err) } @@ -68,7 +70,7 @@ func (k Keeper) VerifyEVMInTxBody(ctx sdk.Context, msg *types.MsgAddToInTxTracke return fmt.Errorf("want evm chain id %d, got %d", txx.ChainId(), msg.ChainId) } switch msg.CoinType { - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: chainParams, found := k.zetaObserverKeeper.GetChainParamsByChainID(ctx, msg.ChainId) if !found { return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId) @@ -77,7 +79,7 @@ func (k Keeper) VerifyEVMInTxBody(ctx sdk.Context, msg *types.MsgAddToInTxTracke return fmt.Errorf("receiver is not connector contract for coin type %s", msg.CoinType) } return nil - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: chainParams, found := k.zetaObserverKeeper.GetChainParamsByChainID(ctx, msg.ChainId) if !found { return types.ErrUnsupportedChain.Wrapf("chain params not found for chain %d", msg.ChainId) @@ -86,7 +88,7 @@ func (k Keeper) VerifyEVMInTxBody(ctx sdk.Context, msg *types.MsgAddToInTxTracke return fmt.Errorf("receiver is not erc20Custory contract for coin type %s", msg.CoinType) } return nil - case pkg.CoinType_Gas: + case coin.CoinType_Gas: tss, err := k.zetaObserverKeeper.GetTssAddress(ctx, &observertypes.QueryGetTssAddressRequest{ BitcoinChainId: msg.ChainId, }) diff --git a/x/crosschain/migrations/v4/migrate.go b/x/crosschain/migrations/v4/migrate.go index 4b29169263..da289e062e 100644 --- a/x/crosschain/migrations/v4/migrate.go +++ b/x/crosschain/migrations/v4/migrate.go @@ -8,7 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "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/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -54,7 +55,7 @@ func SetZetaAccounting( for ; iterator.Valid(); iterator.Next() { var val types.CrossChainTx cdc.MustUnmarshal(iterator.Value(), &val) - if val.CctxStatus.Status == types.CctxStatus_Aborted && val.GetCurrentOutTxParam().CoinType == pkg.CoinType_Zeta { + if val.CctxStatus.Status == types.CctxStatus_Aborted && val.GetCurrentOutTxParam().CoinType == coin.CoinType_Zeta { abortedAmountZeta = abortedAmountZeta.Add(val.GetCurrentOutTxParam().Amount) } } @@ -176,7 +177,7 @@ func SetBitcoinFinalizedInbound(ctx sdk.Context, crosschainKeeper crosschainKeep for _, cctx := range crosschainKeeper.GetAllCrossChainTx(ctx) { if cctx.InboundTxParams != nil { // check if bitcoin inbound - if pkg.IsBitcoinChain(cctx.InboundTxParams.SenderChainId) { + if chains.IsBitcoinChain(cctx.InboundTxParams.SenderChainId) { // add finalized inbound crosschainKeeper.AddFinalizedInbound( ctx, diff --git a/x/crosschain/migrations/v4/migrate_test.go b/x/crosschain/migrations/v4/migrate_test.go index 14d6b88cbb..c4c68d93a5 100644 --- a/x/crosschain/migrations/v4/migrate_test.go +++ b/x/crosschain/migrations/v4/migrate_test.go @@ -10,7 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "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" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -96,49 +97,49 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "0", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.GoerliChain().ChainId, + SenderChainId: chains.GoerliChain().ChainId, InboundTxObservedHash: "0xaaa", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "1", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.BtcMainnetChain().ChainId, + SenderChainId: chains.BtcMainnetChain().ChainId, InboundTxObservedHash: "0x111", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "2", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.EthChain().ChainId, + SenderChainId: chains.EthChain().ChainId, InboundTxObservedHash: "0xbbb", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "3", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.BtcTestNetChain().ChainId, + SenderChainId: chains.BtcTestNetChain().ChainId, InboundTxObservedHash: "0x222", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "4", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.BtcTestNetChain().ChainId, + SenderChainId: chains.BtcTestNetChain().ChainId, InboundTxObservedHash: "0x333", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "5", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.MumbaiChain().ChainId, + SenderChainId: chains.MumbaiChain().ChainId, InboundTxObservedHash: "0xccc", }, }) k.SetCrossChainTx(ctx, types.CrossChainTx{ Index: "6", InboundTxParams: &types.InboundTxParams{ - SenderChainId: pkg.BtcRegtestChain().ChainId, + SenderChainId: chains.BtcRegtestChain().ChainId, InboundTxObservedHash: "0x444", }, }) @@ -147,13 +148,13 @@ func TestSetBitcoinFinalizedInbound(t *testing.T) { v4.SetBitcoinFinalizedInbound(ctx, k) // check finalized inbound - require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", pkg.GoerliChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", pkg.EthChain().ChainId, 0)) - require.False(t, k.IsFinalizedInbound(ctx, "0xccc", pkg.MumbaiChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x111", pkg.BtcMainnetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x222", pkg.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x333", pkg.BtcTestNetChain().ChainId, 0)) - require.True(t, k.IsFinalizedInbound(ctx, "0x444", pkg.BtcRegtestChain().ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xaaa", chains.GoerliChain().ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xbbb", chains.EthChain().ChainId, 0)) + require.False(t, k.IsFinalizedInbound(ctx, "0xccc", chains.MumbaiChain().ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x111", chains.BtcMainnetChain().ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x222", chains.BtcTestNetChain().ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x333", chains.BtcTestNetChain().ChainId, 0)) + require.True(t, k.IsFinalizedInbound(ctx, "0x444", chains.BtcRegtestChain().ChainId, 0)) }) } @@ -170,7 +171,7 @@ func SetRandomCctx(ctx sdk.Context, k keeper.Keeper) sdkmath.Uint { CctxStatus: &types.Status{Status: types.CctxStatus_Aborted}, OutboundTxParams: []*types.OutboundTxParams{{ Amount: amount, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }}, }) totalZeta = totalZeta.Add(amount) diff --git a/x/crosschain/migrations/v5/migrate.go b/x/crosschain/migrations/v5/migrate.go index 8e6567f156..98fee02256 100644 --- a/x/crosschain/migrations/v5/migrate.go +++ b/x/crosschain/migrations/v5/migrate.go @@ -7,7 +7,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "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/x/crosschain/types" ) @@ -69,17 +70,17 @@ func ResetTestnetNonce( } type TestnetNonce struct { - chain pkg.Chain + chain chains.Chain nonceHigh uint64 nonceLow uint64 } func CurrentTestnetChains() []TestnetNonce { return []TestnetNonce{ - {chain: pkg.GoerliChain(), nonceHigh: 226841, nonceLow: 226841}, - {chain: pkg.MumbaiChain(), nonceHigh: 200599, nonceLow: 200599}, - {chain: pkg.BscTestnetChain(), nonceHigh: 110454, nonceLow: 110454}, - {chain: pkg.BtcTestNetChain(), nonceHigh: 4881, nonceLow: 4881}, + {chain: chains.GoerliChain(), nonceHigh: 226841, nonceLow: 226841}, + {chain: chains.MumbaiChain(), nonceHigh: 200599, nonceLow: 200599}, + {chain: chains.BscTestnetChain(), nonceHigh: 110454, nonceLow: 110454}, + {chain: chains.BtcTestNetChain(), nonceHigh: 4881, nonceLow: 4881}, } } @@ -94,7 +95,7 @@ func SetZetaAccounting( if cctx.CctxStatus.Status == types.CctxStatus_Aborted { switch cctx.InboundTxParams.CoinType { - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: { receiverChain := observerKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) if receiverChain == nil { @@ -110,7 +111,7 @@ func SetZetaAccounting( cctx.CctxStatus.IsAbortRefunded = false } } - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: { // add the required amount into the zeta accounting. // GetAbortedAmount replaces using Outbound Amount directly, to make sure we refund the amount deposited by the user if the outbound is never created and the cctx is aborted. @@ -120,7 +121,7 @@ func SetZetaAccounting( cctx.CctxStatus.IsAbortRefunded = false } - case pkg.CoinType_Gas: + case coin.CoinType_Gas: { // CointType gas can be processed as normal and we can issue the refund using the admin refund tx . cctx.CctxStatus.IsAbortRefunded = false diff --git a/x/crosschain/migrations/v5/migrate_test.go b/x/crosschain/migrations/v5/migrate_test.go index 010c9000a4..3e9e535fda 100644 --- a/x/crosschain/migrations/v5/migrate_test.go +++ b/x/crosschain/migrations/v5/migrate_test.go @@ -7,7 +7,8 @@ import ( "cosmossdk.io/math" "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" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" crosschainkeeper "github.com/zeta-chain/zetacore/x/crosschain/keeper" @@ -24,7 +25,7 @@ func TestMigrateStore(t *testing.T) { v4ZetaAccountingAmount := math.ZeroUint() for _, cctx := range cctxList { k.SetCrossChainTx(ctx, cctx) - if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Aborted || cctx.GetCurrentOutTxParam().CoinType != pkg.CoinType_Zeta { + if cctx.CctxStatus.Status != crosschaintypes.CctxStatus_Aborted || cctx.GetCurrentOutTxParam().CoinType != coin.CoinType_Zeta { continue } v5ZetaAccountingAmount = v5ZetaAccountingAmount.Add(crosschainkeeper.GetAbortedAmount(cctx)) @@ -45,7 +46,7 @@ func TestMigrateStore(t *testing.T) { // Check refund status of the cctx for _, cctx := range cctxListUpdated { switch cctx.InboundTxParams.CoinType { - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: receiverChain := zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, cctx.GetCurrentOutTxParam().ReceiverChainId) require.NotNil(t, receiverChain) if receiverChain.IsZetaChain() { @@ -53,9 +54,9 @@ func TestMigrateStore(t *testing.T) { } else { require.False(t, cctx.CctxStatus.IsAbortRefunded) } - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: require.False(t, cctx.CctxStatus.IsAbortRefunded) - case pkg.CoinType_Gas: + case coin.CoinType_Gas: require.False(t, cctx.CctxStatus.IsAbortRefunded) } } @@ -66,8 +67,8 @@ func TestMigrateStore(t *testing.T) { func TestResetTestnetNonce(t *testing.T) { t.Run("reset only testnet nonce without changing mainnet chains", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - testnetChains := []pkg.Chain{pkg.GoerliChain(), pkg.MumbaiChain(), pkg.BscTestnetChain(), pkg.BtcTestNetChain()} - mainnetChains := []pkg.Chain{pkg.EthChain(), pkg.BscMainnetChain(), pkg.BtcMainnetChain()} + testnetChains := []chains.Chain{chains.GoerliChain(), chains.MumbaiChain(), chains.BscTestnetChain(), chains.BtcTestNetChain()} + mainnetChains := []chains.Chain{chains.EthChain(), chains.BscMainnetChain(), chains.BtcMainnetChain()} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() @@ -100,11 +101,11 @@ func TestResetTestnetNonce(t *testing.T) { } err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) require.NoError(t, err) - assertValues := map[pkg.Chain]int64{ - pkg.GoerliChain(): 226841, - pkg.MumbaiChain(): 200599, - pkg.BscTestnetChain(): 110454, - pkg.BtcTestNetChain(): 4881, + assertValues := map[chains.Chain]int64{ + chains.GoerliChain(): 226841, + chains.MumbaiChain(): 200599, + chains.BscTestnetChain(): 110454, + chains.BtcTestNetChain(): 4881, } for _, chain := range testnetChains { @@ -129,7 +130,7 @@ func TestResetTestnetNonce(t *testing.T) { t.Run("reset nonce even if some chain values are missing", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) - testnetChains := []pkg.Chain{pkg.GoerliChain()} + testnetChains := []chains.Chain{chains.GoerliChain()} nonceLow := int64(1) nonceHigh := int64(10) tss := sample.Tss() @@ -149,10 +150,10 @@ func TestResetTestnetNonce(t *testing.T) { } err := v5.MigrateStore(ctx, k, zk.ObserverKeeper) require.NoError(t, err) - assertValuesSet := map[pkg.Chain]int64{ - pkg.GoerliChain(): 226841, + assertValuesSet := map[chains.Chain]int64{ + chains.GoerliChain(): 226841, } - assertValuesNotSet := []pkg.Chain{pkg.MumbaiChain(), pkg.BscTestnetChain(), pkg.BtcTestNetChain()} + assertValuesNotSet := []chains.Chain{chains.MumbaiChain(), chains.BscTestnetChain(), chains.BtcTestNetChain()} for _, chain := range testnetChains { pn, found := zk.ObserverKeeper.GetPendingNonces(ctx, tss.TssPubkey, chain.ChainId) @@ -183,11 +184,11 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, InboundTxParams: &crosschaintypes.InboundTxParams{ Amount: amount.Add(math.NewUint(uint64(r.Uint32()))), - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: amount, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }}, } for ; i < count; i++ { @@ -197,11 +198,11 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, InboundTxParams: &crosschaintypes.InboundTxParams{ Amount: amount, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }, OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: math.ZeroUint(), - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, }}, } } @@ -212,12 +213,12 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, InboundTxParams: &crosschaintypes.InboundTxParams{ Amount: amount, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, }, OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: math.ZeroUint(), - CoinType: pkg.CoinType_ERC20, - ReceiverChainId: pkg.ZetaPrivnetChain().ChainId, + CoinType: coin.CoinType_ERC20, + ReceiverChainId: chains.ZetaPrivnetChain().ChainId, }}, } } @@ -228,12 +229,12 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, InboundTxParams: &crosschaintypes.InboundTxParams{ Amount: amount, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, }, OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: math.ZeroUint(), - CoinType: pkg.CoinType_ERC20, - ReceiverChainId: pkg.GoerliLocalnetChain().ChainId, + CoinType: coin.CoinType_ERC20, + ReceiverChainId: chains.GoerliLocalnetChain().ChainId, }}, } } @@ -244,11 +245,11 @@ func CrossChainTxList(count int) []crosschaintypes.CrossChainTx { CctxStatus: &crosschaintypes.Status{Status: crosschaintypes.CctxStatus_Aborted}, InboundTxParams: &crosschaintypes.InboundTxParams{ Amount: amount, - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }, OutboundTxParams: []*crosschaintypes.OutboundTxParams{{ Amount: amount, - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, }}, } } diff --git a/x/crosschain/types/cross_chain_tx.pb.go b/x/crosschain/types/cross_chain_tx.pb.go index 17ba755231..665a7958b6 100644 --- a/x/crosschain/types/cross_chain_tx.pb.go +++ b/x/crosschain/types/cross_chain_tx.pb.go @@ -12,7 +12,7 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + coin "github.com/zeta-chain/zetacore/pkg/coin" ) // Reference imports to suppress errors if they are not otherwise used. @@ -95,7 +95,7 @@ type InboundTxParams struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` SenderChainId int64 `protobuf:"varint,2,opt,name=sender_chain_id,json=senderChainId,proto3" json:"sender_chain_id,omitempty"` TxOrigin string `protobuf:"bytes,3,opt,name=tx_origin,json=txOrigin,proto3" json:"tx_origin,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,4,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` + CoinType coin.CoinType `protobuf:"varint,4,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` Asset string `protobuf:"bytes,5,opt,name=asset,proto3" json:"asset,omitempty"` Amount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,6,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"` InboundTxObservedHash string `protobuf:"bytes,7,opt,name=inbound_tx_observed_hash,json=inboundTxObservedHash,proto3" json:"inbound_tx_observed_hash,omitempty"` @@ -159,11 +159,11 @@ func (m *InboundTxParams) GetTxOrigin() string { return "" } -func (m *InboundTxParams) GetCoinType() proto1.CoinType { +func (m *InboundTxParams) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *InboundTxParams) GetAsset() string { @@ -249,7 +249,7 @@ var xxx_messageInfo_ZetaAccounting proto.InternalMessageInfo type OutboundTxParams struct { Receiver string `protobuf:"bytes,1,opt,name=receiver,proto3" json:"receiver,omitempty"` ReceiverChainId int64 `protobuf:"varint,2,opt,name=receiver_chainId,json=receiverChainId,proto3" json:"receiver_chainId,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` + CoinType coin.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` Amount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,4,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"` OutboundTxTssNonce uint64 `protobuf:"varint,5,opt,name=outbound_tx_tss_nonce,json=outboundTxTssNonce,proto3" json:"outbound_tx_tss_nonce,omitempty"` OutboundTxGasLimit uint64 `protobuf:"varint,6,opt,name=outbound_tx_gas_limit,json=outboundTxGasLimit,proto3" json:"outbound_tx_gas_limit,omitempty"` @@ -313,11 +313,11 @@ func (m *OutboundTxParams) GetReceiverChainId() int64 { return 0 } -func (m *OutboundTxParams) GetCoinType() proto1.CoinType { +func (m *OutboundTxParams) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *OutboundTxParams) GetOutboundTxTssNonce() uint64 { @@ -556,78 +556,78 @@ func init() { func init() { proto.RegisterFile("crosschain/cross_chain_tx.proto", fileDescriptor_af3a0ad055343c21) } var fileDescriptor_af3a0ad055343c21 = []byte{ - // 1121 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xdd, 0x4e, 0x1b, 0x47, - 0x14, 0xf6, 0xc6, 0x8e, 0xb1, 0x8f, 0x31, 0x5e, 0x06, 0x43, 0x57, 0xa4, 0xb1, 0x2d, 0xb7, 0x49, - 0x1c, 0xa4, 0xd8, 0x82, 0xa8, 0x8a, 0xd4, 0x3b, 0xa0, 0x90, 0xa0, 0x24, 0x80, 0xb6, 0x70, 0x83, - 0x54, 0x6d, 0xc7, 0xbb, 0x83, 0x3d, 0xc2, 0xde, 0x71, 0x77, 0xc6, 0xc8, 0x44, 0x7d, 0x88, 0xf6, - 0x1d, 0x7a, 0xd1, 0x47, 0xc9, 0x45, 0xa5, 0xe6, 0xb2, 0xea, 0x05, 0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 0x3c, 0x7a, 0x4b, 0x43, 0x12, - 0xd8, 0x69, 0xe9, 0x32, 0xeb, 0x5c, 0x72, 0x4a, 0x22, 0x61, 0x67, 0xd0, 0x2c, 0xe4, 0xb4, 0x4d, - 0x02, 0xfb, 0x3e, 0x2a, 0xc0, 0xcc, 0xba, 0x7e, 0xb4, 0xec, 0xec, 0x72, 0xe6, 0xc7, 0x1f, 0x2a, - 0xd6, 0xca, 0x6b, 0x28, 0x5f, 0xd7, 0x4c, 0xc8, 0x86, 0xd9, 0x5d, 0x26, 0xc6, 0x4f, 0xb8, 0x9d, - 0x42, 0x45, 0xc8, 0x4f, 0x86, 0x96, 0x64, 0xde, 0x1a, 0x11, 0x7f, 0x28, 0xc9, 0xee, 0x69, 0xb2, - 0x8d, 0xd7, 0xef, 0x2f, 0x2a, 0xd6, 0x87, 0x8b, 0x8a, 0xf5, 0xdb, 0x45, 0xc5, 0xfa, 0xee, 0xb2, - 0x92, 0xfa, 0x70, 0x59, 0x49, 0xfd, 0x72, 0x59, 0x49, 0x1d, 0xad, 0x26, 0x74, 0x25, 0xcf, 0xe9, - 0x99, 0xfe, 0xd3, 0x8c, 0x8f, 0xac, 0x35, 0x6a, 0x25, 0xfe, 0x3f, 0x95, 0xcc, 0xda, 0x59, 0xf5, - 0xcf, 0xf8, 0xfc, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xfb, 0xe0, 0xd3, 0xd8, 0x9a, 0x0a, 0x00, - 0x00, + // 1125 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5d, 0x4f, 0x1b, 0x47, + 0x17, 0xf6, 0xc6, 0xc6, 0xd8, 0xc7, 0x60, 0x2f, 0x83, 0xe1, 0x5d, 0x91, 0x37, 0xb6, 0xe5, 0x36, + 0x89, 0x93, 0x2a, 0xb6, 0x20, 0xaa, 0x22, 0xf5, 0x0e, 0x28, 0x24, 0x28,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0x77, 0x90, 0x4f, 0x5f, 0x07, 0xae, + 0xcd, 0xa6, 0x3c, 0x4f, 0xbf, 0x01, 0x98, 0x08, 0x0d, 0x21, 0x28, 0xee, 0x93, 0x30, 0xa0, 0x61, + 0xc7, 0xe4, 0x65, 0xa7, 0xd0, 0x22, 0x94, 0x8c, 0x2f, 0xa6, 0xb3, 0x2d, 0xb4, 0x00, 0xf3, 0xf1, + 0xe8, 0x2d, 0x0d, 0x49, 0x60, 0xa7, 0xa5, 0xcb, 0xac, 0x73, 0xc9, 0x29, 0x89, 0x84, 0x9d, 0x41, + 0x73, 0x90, 0xd3, 0x36, 0x09, 0xec, 0x19, 0x54, 0x80, 0xd9, 0x75, 0x7d, 0x6b, 0xd9, 0xd9, 0x95, + 0xcc, 0x0f, 0xdf, 0x57, 0xac, 0xa7, 0xaf, 0xa1, 0x7c, 0x5d, 0x33, 0x21, 0x1b, 0xe6, 0x76, 0x99, + 0x18, 0xdf, 0xe1, 0x76, 0x0a, 0xcd, 0x43, 0x7e, 0x32, 0xb4, 0x24, 0xf3, 0xd6, 0x88, 0xf8, 0x43, + 0x49, 0x76, 0x4f, 0x93, 0x6d, 0xbc, 0x7e, 0x7f, 0x51, 0xb1, 0x3e, 0x5c, 0x54, 0xac, 0x5f, 0x2f, + 0x2a, 0xd6, 0xb7, 0x97, 0x95, 0xd4, 0x87, 0xcb, 0x4a, 0xea, 0xe7, 0xcb, 0x4a, 0xea, 0x68, 0x35, + 0xa1, 0x2b, 0xb9, 0x4f, 0xcf, 0xf4, 0x8b, 0x33, 0xde, 0xb2, 0xd6, 0xa8, 0x95, 0x78, 0x87, 0x2a, + 0x99, 0xb5, 0xb3, 0xea, 0xd5, 0xf8, 0xfc, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xec, 0x1d, 0x5c, + 0x64, 0xa2, 0x0a, 0x00, 0x00, } func (m *InboundTxParams) Marshal() (dAtA []byte, err error) { @@ -1338,7 +1338,7 @@ func (m *InboundTxParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } @@ -1729,7 +1729,7 @@ func (m *OutboundTxParams) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/crosschain/types/events.pb.go b/x/crosschain/types/events.pb.go index 2f2b5aa604..39d521d4a7 100644 --- a/x/crosschain/types/events.pb.go +++ b/x/crosschain/types/events.pb.go @@ -11,7 +11,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/zeta-chain/zetacore/pkg/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -581,48 +580,47 @@ func init() { func init() { proto.RegisterFile("crosschain/events.proto", fileDescriptor_7398db8b12b87b9e) } var fileDescriptor_7398db8b12b87b9e = []byte{ - // 651 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0xdf, 0x4e, 0x13, 0x4f, - 0x14, 0xc7, 0x59, 0x68, 0x4b, 0x3b, 0xd0, 0xf2, 0xcb, 0x86, 0x9f, 0x8c, 0x8d, 0x34, 0x48, 0xe2, - 0x9f, 0x0b, 0x6d, 0x63, 0x7c, 0x03, 0x1a, 0x11, 0x62, 0x0c, 0x06, 0x30, 0x1a, 0x6e, 0x26, 0xd3, - 0xdd, 0xe3, 0xec, 0x84, 0xed, 0x4c, 0x33, 0x33, 0x0b, 0x0b, 0x4f, 0x61, 0x7c, 0x0f, 0x13, 0x1f, - 0xc0, 0x07, 0xf0, 0x92, 0x0b, 0x2f, 0xbc, 0x34, 0xf0, 0x22, 0x66, 0x66, 0x76, 0x85, 0x2e, 0x46, - 0x2f, 0x8c, 0x26, 0xde, 0xcd, 0xf9, 0x9e, 0x33, 0x87, 0xcf, 0x7c, 0xcf, 0xd2, 0x83, 0x56, 0x22, - 0x25, 0xb5, 0x8e, 0x12, 0xca, 0xc5, 0x00, 0x8e, 0x40, 0x18, 0xdd, 0x9f, 0x28, 0x69, 0x64, 0xb8, - 0x7a, 0x0a, 0x86, 0x3a, 0xbd, 0xef, 0x4e, 0x52, 0x41, 0xff, 0xb2, 0xb6, 0xbb, 0xcc, 0x24, 0x93, - 0xae, 0x72, 0x60, 0x4f, 0xfe, 0x52, 0xb7, 0x3d, 0x39, 0x64, 0x83, 0xc9, 0x21, 0xf3, 0xe1, 0xfa, - 0xe7, 0x39, 0xf4, 0xff, 0x13, 0xdb, 0x74, 0x5b, 0x8c, 0x64, 0x26, 0xe2, 0x4d, 0x2e, 0x68, 0xca, - 0x4f, 0x21, 0x0e, 0xd7, 0xd0, 0xe2, 0x58, 0x33, 0x62, 0x4e, 0x26, 0x40, 0x32, 0x95, 0xe2, 0x60, - 0x2d, 0xb8, 0xdf, 0xda, 0x45, 0x63, 0xcd, 0xf6, 0x4f, 0x26, 0xf0, 0x52, 0xa5, 0xe1, 0x2a, 0x42, - 0x51, 0x64, 0x72, 0xc2, 0x45, 0x0c, 0x39, 0x9e, 0x75, 0xf9, 0x96, 0x55, 0xb6, 0xad, 0x10, 0xde, - 0x40, 0x0d, 0x0d, 0x22, 0x06, 0x85, 0xe7, 0x5c, 0xaa, 0x88, 0xc2, 0x9b, 0xa8, 0x69, 0x72, 0x22, - 0x15, 0xe3, 0x02, 0xd7, 0x5c, 0x66, 0xde, 0xe4, 0x3b, 0x36, 0x0c, 0x97, 0x51, 0x9d, 0x6a, 0x0d, - 0x06, 0xd7, 0x9d, 0xee, 0x83, 0xf0, 0x16, 0x42, 0x5c, 0x10, 0x93, 0x93, 0x84, 0xea, 0x04, 0x37, - 0x5c, 0xaa, 0xc9, 0xc5, 0x7e, 0xbe, 0x45, 0x75, 0x12, 0xde, 0x45, 0x4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a3, 0x86, 0x5b, 0x10, 0x8f, 0xbf, 0x05, 0x00, - 0x00, 0xff, 0xff, 0xdd, 0x9e, 0xb3, 0xe1, 0x7f, 0x06, 0x00, 0x00, + // 640 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x95, 0xdf, 0x4e, 0x14, 0x31, + 0x14, 0xc6, 0x19, 0xd8, 0x5d, 0x76, 0x0b, 0x2c, 0x66, 0x82, 0x52, 0x89, 0x4c, 0x90, 0xc4, 0x3f, + 0x17, 0xba, 0x1b, 0xe3, 0x1b, 0xb0, 0x11, 0x21, 0xc6, 0x60, 0x00, 0xa3, 0xe1, 0xa6, 0xe9, 0x4e, + 0x8f, 0x33, 0x8d, 0xb3, 0xed, 0xa6, 0xed, 0xc0, 0xc0, 0x53, 0x18, 0xdf, 0xc3, 0xc4, 0x07, 0xf0, + 0x01, 0xbc, 0xe4, 0xc2, 0x0b, 0x2f, 0x0d, 0xbc, 0x88, 0x69, 0x3b, 0x23, 0xec, 0x60, 0xf4, 0xc2, + 0x68, 0xe2, 0x5d, 0xcf, 0x77, 0x4e, 0x0f, 0xbf, 0x7e, 0x67, 0xd8, 0x83, 0x96, 0x63, 0x25, 0xb5, + 0x8e, 0x53, 0xca, 0x45, 0x1f, 0x0e, 0x41, 0x18, 0xdd, 0x1b, 0x2b, 0x69, 0x64, 0xb8, 0x7a, 0x02, + 0x86, 0x3a, 0xbd, 0xe7, 0x4e, 0x52, 0x41, 0xef, 0xa2, 0x76, 0x65, 0x29, 0x91, 0x89, 0x74, 0x95, + 0x7d, 0x7b, 0xf2, 0x97, 0xd6, 0xbf, 0xcc, 0xa0, 0xeb, 0x4f, 0x6c, 0x97, 0x6d, 0x31, 0x94, 0xb9, + 0x60, 0x9b, 0x5c, 0xd0, 0x8c, 0x9f, 0x00, 0x0b, 0xd7, 0xd0, 0xfc, 0x48, 0x27, 0xc4, 0x1c, 0x8f,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 0xc0, 0x11, 0xd1, 0x86, 0x9a, 0x5c, 0xe3, 0x79, 0xef, 0x98, 0x80, 0xa3, + 0x3d, 0x27, 0x58, 0x0c, 0x9f, 0xfa, 0xd1, 0x66, 0xc1, 0x63, 0x78, 0xb5, 0xea, 0x72, 0x1b, 0xcd, + 0x7b, 0x2b, 0x4b, 0xd6, 0xae, 0x2b, 0x9a, 0xf3, 0x9a, 0x23, 0x5d, 0xff, 0x30, 0x8d, 0x96, 0xdd, + 0x58, 0x0f, 0x54, 0xfc, 0x8a, 0x9b, 0x94, 0x29, 0x7a, 0x34, 0x50, 0x40, 0xcd, 0xdf, 0x1c, 0x6c, + 0x9d, 0xab, 0x71, 0x85, 0xab, 0x36, 0xca, 0x66, 0x6d, 0x94, 0x97, 0x47, 0xd4, 0xfa, 0xed, 0x88, + 0x66, 0x7f, 0x3d, 0xa2, 0xf6, 0xc4, 0x88, 0x26, 0x9d, 0xef, 0xd4, 0x9c, 0x5f, 0xff, 0x18, 0x20, + 0xec, 0xfd, 0x02, 0x43, 0xff, 0x99, 0x61, 0x93, 0x6e, 0x34, 0x6a, 0x6e, 0x4c, 0x22, 0x37, 0xeb, + 0xc8, 0x9f, 0x02, 0xb4, 0xe4, 0x90, 0x77, 0x72, 0xe3, 0xff, 0x75, 0x29, 0xcf, 0x72, 0x05, 0x7f, + 0x8e, 0xbb, 0x8a, 0x90, 0xcc, 0x58, 0xf5, 0x87, 0x3d, 0x72, 0x47, 0x66, 0xac, 0xfc, 0x4a, 0x27, + 0xb9, 0x1a, 0x3f, 0xf9, 0x88, 0x0f, 0x69, 0x96, 0x03, 0x29, 0x07, 0xc3, 0x4a, 0xf4, 0x05, 0xa7, + 0xee, 0x96, 0xe2, 0x55, 0xfc, 0xbd, 0x3c, 0x8e, 0x41, 0xeb, 0xff, 0x04, 0xff, 0x7d, 0x80, 0x56, + 0x1c, 0xfe, 0x60, 0xb0, 0xff, 0xfa, 0x29, 0xd5, 0x2f, 0x14, 0x8f, 0x61, 0x5b, 0xc4, 0x0a, 0xa8, + 0x06, 0x56, 0x43, 0x0c, 0xea, 0x88, 0x0f, 0x50, 0x98, 0x50, 0x4d, 0xc6, 0xf6, 0x12, 0xe1, 0xe5, + 0xad, 0xf2, 0x25, 0xd7, 0x92, 0x5a, 0x37, 0xfb, 0xf3, 0x42, 0x19, 0xe3, 0x86, 0x4b, 0x41, 0x33, + 0xf2, 0x06, 0xa0, 0x7a, 0x55, 0xf7, 0x42, 0xde, 0x04, 0xd0, 0x1b, 0xcf, 0x3e, 0x9f, 0x45, 0xc1, + 0xe9, 0x59, 0x14, 0x7c, 0x3b, 0x8b, 0x82, 0x77, 0xe7, 0xd1, 0xd4, 0xe9, 0x79, 0x34, 0xf5, 0xf5, + 0x3c, 0x9a, 0x3a, 0x78, 0x94, 0x70, 0x93, 0xe6, 0xc3, 0x5e, 0x2c, 0x47, 0x7d, 0xbb, 0x1c, 0x1e, + 0xfa, 0xfd, 0x51, 0xed, 0x89, 0x7e, 0xd1, 0xbf, 0xb4, 0x55, 0xac, 0xf5, 0x7a, 0xd8, 0x72, 0x0b, + 0xe2, 0xf1, 0xf7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xf3, 0x4a, 0xbd, 0x70, 0x06, 0x00, 0x00, } func (m *EventInboundFinalized) Marshal() (dAtA []byte, err error) { diff --git a/x/crosschain/types/expected_keepers.go b/x/crosschain/types/expected_keepers.go index e8a11b2d44..eb291938c4 100644 --- a/x/crosschain/types/expected_keepers.go +++ b/x/crosschain/types/expected_keepers.go @@ -9,7 +9,9 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" eth "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" - "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/proofs" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" fungibletypes "github.com/zeta-chain/zetacore/x/fungible/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -46,9 +48,9 @@ type ObserverKeeper interface { AddVoteToBallot(ctx sdk.Context, ballot observertypes.Ballot, address string, observationType observertypes.VoteType) (observertypes.Ballot, error) CheckIfFinalizingVote(ctx sdk.Context, ballot observertypes.Ballot) (observertypes.Ballot, bool) IsAuthorized(ctx sdk.Context, address string) bool - FindBallot(ctx sdk.Context, index string, chain *pkg.Chain, observationType observertypes.ObservationType) (ballot observertypes.Ballot, isNew bool, err error) + FindBallot(ctx sdk.Context, index string, chain *chains.Chain, observationType observertypes.ObservationType) (ballot observertypes.Ballot, isNew bool, err error) AddBallotToList(ctx sdk.Context, ballot observertypes.Ballot) - GetBlockHeader(ctx sdk.Context, hash []byte) (val pkg.BlockHeader, found bool) + GetBlockHeader(ctx sdk.Context, hash []byte) (val proofs.BlockHeader, found bool) CheckIfTssPubkeyHasBeenGenerated(ctx sdk.Context, tssPubkey string) (observertypes.TSS, bool) GetAllTSS(ctx sdk.Context) (list []observertypes.TSS) GetTSS(ctx sdk.Context) (val observertypes.TSS, found bool) @@ -75,7 +77,7 @@ type ObserverKeeper interface { ctx sdk.Context, senderChainID int64, receiverChainID int64, - coinType pkg.CoinType, + coinType coin.CoinType, voter string, ballotIndex string, inTxHash string, @@ -84,11 +86,11 @@ type ObserverKeeper interface { ctx sdk.Context, ballotIndex string, outTxChainID int64, - receiveStatus pkg.ReceiveStatus, + receiveStatus chains.ReceiveStatus, voter string, ) (bool, bool, observertypes.Ballot, string, error) - GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *pkg.Chain - GetSupportedChains(ctx sdk.Context) []*pkg.Chain + GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *chains.Chain + GetSupportedChains(ctx sdk.Context) []*chains.Chain } type FungibleKeeper interface { @@ -120,7 +122,7 @@ type FungibleKeeper interface { amount *big.Int, senderChainID int64, data []byte, - coinType pkg.CoinType, + coinType coin.CoinType, asset string, ) (*evmtypes.MsgEthereumTxResponse, bool, error) CallUniswapV2RouterSwapExactTokensForTokens( @@ -154,7 +156,7 @@ type FungibleKeeper interface { name, symbol string, decimals uint8, chainID int64, - coinType pkg.CoinType, + coinType coin.CoinType, erc20Contract string, gasLimit *big.Int, ) (eth.Address, error) diff --git a/x/crosschain/types/in_tx_tracker.pb.go b/x/crosschain/types/in_tx_tracker.pb.go index 41df88abf9..244ec7aec3 100644 --- a/x/crosschain/types/in_tx_tracker.pb.go +++ b/x/crosschain/types/in_tx_tracker.pb.go @@ -10,7 +10,7 @@ import ( math_bits "math/bits" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + coin "github.com/zeta-chain/zetacore/pkg/coin" ) // Reference imports to suppress errors if they are not otherwise used. @@ -25,9 +25,9 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type InTxTracker struct { - ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - TxHash string `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` + ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + TxHash string `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + CoinType coin.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` } func (m *InTxTracker) Reset() { *m = InTxTracker{} } @@ -77,11 +77,11 @@ func (m *InTxTracker) GetTxHash() string { return "" } -func (m *InTxTracker) GetCoinType() proto1.CoinType { +func (m *InTxTracker) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func init() { @@ -91,22 +91,22 @@ func init() { func init() { proto.RegisterFile("crosschain/in_tx_tracker.proto", fileDescriptor_799b411f065af0ce) } var fileDescriptor_799b411f065af0ce = []byte{ - // 238 bytes of a gzipped FileDescriptorProto + // 240 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4b, 0x2e, 0xca, 0x2f, 0x2e, 0x4e, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0xcf, 0xcc, 0x8b, 0x2f, 0xa9, 0x88, 0x2f, 0x29, 0x4a, 0x4c, 0xce, 0x4e, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xad, 0x4a, 0x2d, 0x49, - 0x04, 0x4b, 0xeb, 0x81, 0x59, 0xf9, 0x45, 0xa9, 0x7a, 0x08, 0x2d, 0x52, 0xbc, 0x05, 0xd9, 0xe9, - 0xfa, 0x05, 0xd9, 0xe9, 0x10, 0xd5, 0x4a, 0xb9, 0x5c, 0xdc, 0x9e, 0x79, 0x21, 0x15, 0x21, 0x10, - 0x23, 0x84, 0x24, 0xb9, 0x38, 0xc0, 0xca, 0xe2, 0x33, 0x53, 0x24, 0x18, 0x15, 0x18, 0x35, 0x98, - 0x83, 0xd8, 0xc1, 0x7c, 0xcf, 0x14, 0x21, 0x71, 0x2e, 0xf6, 0x92, 0x8a, 0xf8, 0x8c, 0xc4, 0xe2, - 0x0c, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, 0xb6, 0x92, 0x0a, 0x8f, 0xc4, 0xe2, 0x0c, 0x21, - 0x2d, 0x2e, 0xce, 0xe4, 0x7c, 0x90, 0x4b, 0x2a, 0x0b, 0x52, 0x25, 0x98, 0x15, 0x18, 0x35, 0xf8, - 0x8c, 0x78, 0xf5, 0x40, 0x36, 0x38, 0xe7, 0x67, 0xe6, 0x85, 0x54, 0x16, 0xa4, 0x06, 0x71, 0x24, - 0x43, 0x59, 0x4e, 0xde, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, - 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x65, 0x98, - 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x0f, 0x72, 0xb7, 0x2e, 0xc4, 0x87, - 0x30, 0x2f, 0xe8, 0x57, 0xe8, 0x23, 0xf9, 0x1b, 0x64, 0x55, 0x71, 0x12, 0x1b, 0xd8, 0x0b, 0xc6, - 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa9, 0xce, 0xc2, 0x70, 0x12, 0x01, 0x00, 0x00, + 0x04, 0x4b, 0xeb, 0x81, 0x59, 0xf9, 0x45, 0xa9, 0x7a, 0x08, 0x2d, 0x52, 0xc2, 0x05, 0xd9, 0xe9, + 0xfa, 0xc9, 0xf9, 0x99, 0x79, 0x60, 0x02, 0xa2, 0x47, 0x29, 0x8f, 0x8b, 0xdb, 0x33, 0x2f, 0xa4, + 0x22, 0x04, 0x62, 0x90, 0x90, 0x24, 0x17, 0x07, 0x58, 0x71, 0x7c, 0x66, 0x8a, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0x73, 0x10, 0x3b, 0x98, 0xef, 0x99, 0x22, 0x24, 0xce, 0xc5, 0x5e, 0x52, 0x11, 0x9f, + 0x91, 0x58, 0x9c, 0x21, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x19, 0xc4, 0x56, 0x52, 0xe1, 0x91, 0x58, + 0x9c, 0x21, 0xa4, 0xcd, 0xc5, 0x09, 0x32, 0x30, 0xbe, 0xa4, 0xb2, 0x20, 0x55, 0x82, 0x59, 0x81, + 0x51, 0x83, 0xcf, 0x88, 0x4f, 0x0f, 0x6c, 0x85, 0x73, 0x7e, 0x66, 0x5e, 0x48, 0x65, 0x41, 0x6a, + 0x10, 0x47, 0x32, 0x94, 0xe5, 0xe4, 0x7d, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, + 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, + 0x51, 0x86, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x20, 0xe7, 0xeb, + 0x42, 0x3c, 0x0a, 0xf3, 0x89, 0x7e, 0x85, 0x3e, 0x92, 0xf7, 0x41, 0x76, 0x15, 0x27, 0xb1, 0x81, + 0xfd, 0x60, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xba, 0x1e, 0xbf, 0xb5, 0x19, 0x01, 0x00, 0x00, } func (m *InTxTracker) Marshal() (dAtA []byte, err error) { @@ -279,7 +279,7 @@ func (m *InTxTracker) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/crosschain/types/message_add_to_in_tx_tracker.go b/x/crosschain/types/message_add_to_in_tx_tracker.go index f48f250663..66498192a7 100644 --- a/x/crosschain/types/message_add_to_in_tx_tracker.go +++ b/x/crosschain/types/message_add_to_in_tx_tracker.go @@ -4,14 +4,15 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" ) const TypeMsgAddToInTxTracker = "AddToInTxTracker" var _ sdk.Msg = &MsgAddToInTxTracker{} -func NewMsgAddToInTxTracker(creator string, chain int64, coinType pkg.CoinType, txHash string) *MsgAddToInTxTracker { +func NewMsgAddToInTxTracker(creator string, chain int64, coinType coin.CoinType, txHash string) *MsgAddToInTxTracker { return &MsgAddToInTxTracker{ Creator: creator, ChainId: chain, @@ -46,14 +47,14 @@ func (msg *MsgAddToInTxTracker) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - chain := pkg.GetChainFromChainID(msg.ChainId) + chain := chains.GetChainFromChainID(msg.ChainId) if chain == nil { return errorsmod.Wrapf(ErrInvalidChainID, "chain id (%d)", msg.ChainId) } if msg.Proof != nil && !chain.SupportMerkleProof() { return errorsmod.Wrapf(ErrProofVerificationFail, "chain id %d does not support proof-based trackers", msg.ChainId) } - _, ok := pkg.CoinType_value[msg.CoinType.String()] + _, ok := coin.CoinType_value[msg.CoinType.String()] if !ok { return errorsmod.Wrapf(ErrProofVerificationFail, "coin-type not supported") } diff --git a/x/crosschain/types/message_add_to_in_tx_tracker_test.go b/x/crosschain/types/message_add_to_in_tx_tracker_test.go index 1884a8e14d..b145737eaa 100644 --- a/x/crosschain/types/message_add_to_in_tx_tracker_test.go +++ b/x/crosschain/types/message_add_to_in_tx_tracker_test.go @@ -7,7 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "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/proofs" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -22,8 +24,8 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "invalid address", msg: types.NewMsgAddToInTxTracker( "invalid_address", - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ), err: sdkerrors.ErrInvalidAddress, @@ -33,7 +35,7 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { msg: types.NewMsgAddToInTxTracker( sample.AccAddress(), 42, - pkg.CoinType_Gas, + coin.CoinType_Gas, "hash", ), err: errorsmod.Wrapf(types.ErrInvalidChainID, "chain id (%d)", 42), @@ -42,17 +44,17 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "invalid proof", msg: &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), - ChainId: pkg.ZetaTestnetChain().ChainId, - CoinType: pkg.CoinType_Gas, - Proof: &pkg.Proof{}, + ChainId: chains.ZetaTestnetChain().ChainId, + CoinType: coin.CoinType_Gas, + Proof: &proofs.Proof{}, }, - err: errorsmod.Wrapf(types.ErrProofVerificationFail, "chain id %d does not support proof-based trackers", pkg.ZetaTestnetChain().ChainId), + err: errorsmod.Wrapf(types.ErrProofVerificationFail, "chain id %d does not support proof-based trackers", chains.ZetaTestnetChain().ChainId), }, { name: "invalid coin type", msg: &types.MsgAddToInTxTracker{ Creator: sample.AccAddress(), - ChainId: pkg.ZetaTestnetChain().ChainId, + ChainId: chains.ZetaTestnetChain().ChainId, CoinType: 5, }, err: errorsmod.Wrapf(types.ErrProofVerificationFail, "coin-type not supported"), @@ -61,8 +63,8 @@ func TestMsgAddToInTxTracker_ValidateBasic(t *testing.T) { name: "valid", msg: types.NewMsgAddToInTxTracker( sample.AccAddress(), - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ), err: nil, @@ -91,8 +93,8 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { name: "valid signer", msg: types.NewMsgAddToInTxTracker( signer, - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ), panics: false, @@ -101,8 +103,8 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { name: "invalid signer", msg: types.NewMsgAddToInTxTracker( "invalid_address", - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ), panics: true, @@ -126,8 +128,8 @@ func TestMsgAddToInTxTracker_GetSigners(t *testing.T) { func TestMsgAddToInTxTracker_Type(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ) require.Equal(t, types.TypeMsgAddToInTxTracker, msg.Type()) @@ -136,8 +138,8 @@ func TestMsgAddToInTxTracker_Type(t *testing.T) { func TestMsgAddToInTxTracker_Route(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ) require.Equal(t, types.RouterKey, msg.Route()) @@ -146,8 +148,8 @@ func TestMsgAddToInTxTracker_Route(t *testing.T) { func TestMsgAddToInTxTracker_GetSignBytes(t *testing.T) { msg := types.NewMsgAddToInTxTracker( sample.AccAddress(), - pkg.GoerliChain().ChainId, - pkg.CoinType_Gas, + chains.GoerliChain().ChainId, + coin.CoinType_Gas, "hash", ) require.NotPanics(t, func() { diff --git a/x/crosschain/types/message_add_to_out_tx_tracker.go b/x/crosschain/types/message_add_to_out_tx_tracker.go index 71f2c312b2..4e1900bb65 100644 --- a/x/crosschain/types/message_add_to_out_tx_tracker.go +++ b/x/crosschain/types/message_add_to_out_tx_tracker.go @@ -4,7 +4,7 @@ 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/pkg" + "github.com/zeta-chain/zetacore/pkg/proofs" ) const TypeMsgAddToOutTxTracker = "AddToTracker" @@ -16,7 +16,7 @@ func NewMsgAddToOutTxTracker( chain int64, nonce uint64, txHash string, - proof *pkg.Proof, + proof *proofs.Proof, blockHash string, txIndex int64, ) *MsgAddToOutTxTracker { diff --git a/x/crosschain/types/message_gas_price_voter.go b/x/crosschain/types/message_gas_price_voter.go index 954cc54f9d..89dc8030c4 100644 --- a/x/crosschain/types/message_gas_price_voter.go +++ b/x/crosschain/types/message_gas_price_voter.go @@ -4,7 +4,7 @@ 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/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" ) var _ sdk.Msg = &MsgGasPriceVoter{} @@ -24,7 +24,7 @@ func (msg *MsgGasPriceVoter) Route() string { } func (msg *MsgGasPriceVoter) Type() string { - return pkg.GasPriceVoter.String() + return authz.GasPriceVoter.String() } func (msg *MsgGasPriceVoter) GetSigners() []sdk.AccAddress { diff --git a/x/crosschain/types/message_gas_price_voter_test.go b/x/crosschain/types/message_gas_price_voter_test.go index d0cf868333..10ce98a1bd 100644 --- a/x/crosschain/types/message_gas_price_voter_test.go +++ b/x/crosschain/types/message_gas_price_voter_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -103,7 +103,7 @@ func TestMsgGasPriceVoter_Type(t *testing.T) { msg := types.MsgGasPriceVoter{ Creator: sample.AccAddress(), } - require.Equal(t, pkg.GasPriceVoter.String(), msg.Type()) + require.Equal(t, authz.GasPriceVoter.String(), msg.Type()) } func TestMsgGasPriceVoter_Route(t *testing.T) { diff --git a/x/crosschain/types/message_migrate_tss_funds.go b/x/crosschain/types/message_migrate_tss_funds.go index 818fe907e0..cb78371d43 100644 --- a/x/crosschain/types/message_migrate_tss_funds.go +++ b/x/crosschain/types/message_migrate_tss_funds.go @@ -5,7 +5,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) const TypeMsgMigrateTssFunds = "MigrateTssFunds" @@ -46,7 +46,7 @@ func (msg *MsgMigrateTssFunds) ValidateBasic() error { if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if pkg.GetChainFromChainID(msg.ChainId) == nil { + if chains.GetChainFromChainID(msg.ChainId) == nil { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid chain id (%d)", msg.ChainId) } if msg.Amount.IsZero() { diff --git a/x/crosschain/types/message_migrate_tss_funds_test.go b/x/crosschain/types/message_migrate_tss_funds_test.go index 6b6ca5126a..f882cf90fa 100644 --- a/x/crosschain/types/message_migrate_tss_funds_test.go +++ b/x/crosschain/types/message_migrate_tss_funds_test.go @@ -6,7 +6,7 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -23,7 +23,7 @@ func TestNewMsgMigrateTssFunds_ValidateBasic(t *testing.T) { name: "invalid creator", msg: types.NewMsgMigrateTssFunds( "invalid address", - pkg.DefaultChainsList()[0].ChainId, + chains.DefaultChainsList()[0].ChainId, sdkmath.NewUintFromString("100000"), ), error: true, @@ -41,7 +41,7 @@ func TestNewMsgMigrateTssFunds_ValidateBasic(t *testing.T) { name: "invalid amount", msg: types.NewMsgMigrateTssFunds( sample.AccAddress(), - pkg.DefaultChainsList()[0].ChainId, + chains.DefaultChainsList()[0].ChainId, sdkmath.NewUintFromString("0"), ), error: true, @@ -50,7 +50,7 @@ func TestNewMsgMigrateTssFunds_ValidateBasic(t *testing.T) { name: "valid msg", msg: types.NewMsgMigrateTssFunds( sample.AccAddress(), - pkg.DefaultChainsList()[0].ChainId, + chains.DefaultChainsList()[0].ChainId, sdkmath.NewUintFromString("100000"), ), error: false, @@ -80,7 +80,7 @@ func TestNewMsgMigrateTssFunds_GetSigners(t *testing.T) { name: "valid signer", msg: types.MsgMigrateTssFunds{ Creator: signer, - ChainId: pkg.DefaultChainsList()[0].ChainId, + ChainId: chains.DefaultChainsList()[0].ChainId, Amount: sdkmath.NewUintFromString("100000"), }, panics: false, @@ -89,7 +89,7 @@ func TestNewMsgMigrateTssFunds_GetSigners(t *testing.T) { name: "invalid signer", msg: types.MsgMigrateTssFunds{ Creator: "invalid_address", - ChainId: pkg.DefaultChainsList()[0].ChainId, + ChainId: chains.DefaultChainsList()[0].ChainId, Amount: sdkmath.NewUintFromString("100000"), }, panics: true, @@ -113,7 +113,7 @@ func TestNewMsgMigrateTssFunds_GetSigners(t *testing.T) { func TestNewMsgMigrateTssFunds_Type(t *testing.T) { msg := types.MsgMigrateTssFunds{ Creator: sample.AccAddress(), - ChainId: pkg.DefaultChainsList()[0].ChainId, + ChainId: chains.DefaultChainsList()[0].ChainId, Amount: sdkmath.NewUintFromString("100000"), } require.Equal(t, types.TypeMsgMigrateTssFunds, msg.Type()) @@ -122,7 +122,7 @@ func TestNewMsgMigrateTssFunds_Type(t *testing.T) { func TestNewMsgMigrateTssFunds_Route(t *testing.T) { msg := types.MsgMigrateTssFunds{ Creator: sample.AccAddress(), - ChainId: pkg.DefaultChainsList()[0].ChainId, + ChainId: chains.DefaultChainsList()[0].ChainId, Amount: sdkmath.NewUintFromString("100000"), } require.Equal(t, types.RouterKey, msg.Route()) @@ -131,7 +131,7 @@ func TestNewMsgMigrateTssFunds_Route(t *testing.T) { func TestNewMsgMigrateTssFunds_GetSignBytes(t *testing.T) { msg := types.MsgMigrateTssFunds{ Creator: sample.AccAddress(), - ChainId: pkg.DefaultChainsList()[0].ChainId, + ChainId: chains.DefaultChainsList()[0].ChainId, Amount: sdkmath.NewUintFromString("100000"), } require.NotPanics(t, func() { diff --git a/x/crosschain/types/message_tss_voter.go b/x/crosschain/types/message_tss_voter.go index 86fcd836b9..dc9abc4ccb 100644 --- a/x/crosschain/types/message_tss_voter.go +++ b/x/crosschain/types/message_tss_voter.go @@ -6,14 +6,14 @@ 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/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) const TypeMsgCreateTSSVoter = "CreateTSSVoter" var _ sdk.Msg = &MsgCreateTSSVoter{} -func NewMsgCreateTSSVoter(creator string, pubkey string, keygenZetaHeight int64, status pkg.ReceiveStatus) *MsgCreateTSSVoter { +func NewMsgCreateTSSVoter(creator string, pubkey string, keygenZetaHeight int64, status chains.ReceiveStatus) *MsgCreateTSSVoter { return &MsgCreateTSSVoter{ Creator: creator, TssPubkey: pubkey, diff --git a/x/crosschain/types/message_tss_voter_test.go b/x/crosschain/types/message_tss_voter_test.go index 6f8df9f43a..8c87c0e552 100644 --- a/x/crosschain/types/message_tss_voter_test.go +++ b/x/crosschain/types/message_tss_voter_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -20,11 +20,11 @@ func TestMsgCreateTSSVoter_ValidateBasic(t *testing.T) { }{ { name: "valid message", - msg: types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, pkg.ReceiveStatus_Created), + msg: types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created), }, { name: "invalid creator address", - msg: types.NewMsgCreateTSSVoter("invalid", "pubkey", 1, pkg.ReceiveStatus_Created), + msg: types.NewMsgCreateTSSVoter("invalid", "pubkey", 1, chains.ReceiveStatus_Created), err: sdkerrors.ErrInvalidAddress, }, } @@ -50,12 +50,12 @@ func TestMsgCreateTSSVoter_GetSigners(t *testing.T) { }{ { name: "valid signer", - msg: types.NewMsgCreateTSSVoter(signer, "pubkey", 1, pkg.ReceiveStatus_Created), + msg: types.NewMsgCreateTSSVoter(signer, "pubkey", 1, chains.ReceiveStatus_Created), panics: false, }, { name: "invalid signer", - msg: types.NewMsgCreateTSSVoter("invalid", "pubkey", 1, pkg.ReceiveStatus_Created), + msg: types.NewMsgCreateTSSVoter("invalid", "pubkey", 1, chains.ReceiveStatus_Created), panics: true, }, } @@ -75,23 +75,23 @@ func TestMsgCreateTSSVoter_GetSigners(t *testing.T) { } func TestMsgCreateTSSVoter_Type(t *testing.T) { - msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, pkg.ReceiveStatus_Created) + msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created) require.Equal(t, types.TypeMsgCreateTSSVoter, msg.Type()) } func TestMsgCreateTSSVoter_Route(t *testing.T) { - msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, pkg.ReceiveStatus_Created) + msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created) require.Equal(t, types.RouterKey, msg.Route()) } func TestMsgCreateTSSVoter_GetSignBytes(t *testing.T) { - msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, pkg.ReceiveStatus_Created) + msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created) require.NotPanics(t, func() { msg.GetSignBytes() }) } func TestMsgCreateTSSVoter_Digest(t *testing.T) { - msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, pkg.ReceiveStatus_Created) + msg := types.NewMsgCreateTSSVoter(sample.AccAddress(), "pubkey", 1, chains.ReceiveStatus_Created) require.Equal(t, "1-tss-keygen", msg.Digest()) } diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx.go b/x/crosschain/types/message_vote_on_observed_inbound_tx.go index 31dec381d8..aeb8305f57 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx.go @@ -6,7 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" + "github.com/zeta-chain/zetacore/pkg/coin" ) // MaxMessageLength is the maximum length of a message in a cctx @@ -29,7 +30,7 @@ func NewMsgVoteOnObservedInboundTx( inTxHash string, inBlockHeight, gasLimit uint64, - coinType pkg.CoinType, + coinType coin.CoinType, asset string, eventIndex uint, ) *MsgVoteOnObservedInboundTx { @@ -56,7 +57,7 @@ func (msg *MsgVoteOnObservedInboundTx) Route() string { } func (msg *MsgVoteOnObservedInboundTx) Type() string { - return pkg.InboundVoter.String() + return authz.InboundVoter.String() } func (msg *MsgVoteOnObservedInboundTx) GetSigners() []sdk.AccAddress { diff --git a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go index 06d4340443..a62a3e2b62 100644 --- a/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_inbound_tx_test.go @@ -9,7 +9,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -36,7 +37,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { sample.String(), 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, sample.String(), 42, ), @@ -55,7 +56,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { sample.String(), 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, sample.String(), 42, ), @@ -75,7 +76,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { sample.String(), 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, sample.String(), 42, ), @@ -95,7 +96,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { sample.String(), 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, sample.String(), 42, ), @@ -115,7 +116,7 @@ func TestMsgVoteOnObservedInboundTx_ValidateBasic(t *testing.T) { sample.String(), 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, sample.String(), 42, ), @@ -149,7 +150,7 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { InTxHash: sample.String(), InBlockHeight: 42, GasLimit: 42, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, Asset: sample.String(), EventIndex: 42, } @@ -224,7 +225,7 @@ func TestMsgVoteOnObservedInboundTx_Digest(t *testing.T) { // coin type used msg2 = msg - msg2.CoinType = pkg.CoinType_ERC20 + msg2.CoinType = coin.CoinType_ERC20 hash2 = msg2.Digest() require.NotEqual(t, hash, hash2, "coin type should change hash") @@ -282,7 +283,7 @@ func TestMsgVoteOnObservedInboundTx_Type(t *testing.T) { msg := types.MsgVoteOnObservedInboundTx{ Creator: sample.AccAddress(), } - require.Equal(t, pkg.InboundVoter.String(), msg.Type()) + require.Equal(t, authz.InboundVoter.String(), msg.Type()) } func TestMsgVoteOnObservedInboundTx_Route(t *testing.T) { diff --git a/x/crosschain/types/message_vote_on_observed_outbound_tx.go b/x/crosschain/types/message_vote_on_observed_outbound_tx.go index 570f98648b..360038c6f4 100644 --- a/x/crosschain/types/message_vote_on_observed_outbound_tx.go +++ b/x/crosschain/types/message_vote_on_observed_outbound_tx.go @@ -6,7 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" ) var _ sdk.Msg = &MsgVoteOnObservedOutboundTx{} @@ -20,10 +22,10 @@ func NewMsgVoteOnObservedOutboundTx( outTxEffectiveGasPrice math.Int, outTxEffectiveGasLimit uint64, valueReceived math.Uint, - status pkg.ReceiveStatus, + status chains.ReceiveStatus, chain int64, nonce uint64, - coinType pkg.CoinType, + coinType coin.CoinType, ) *MsgVoteOnObservedOutboundTx { return &MsgVoteOnObservedOutboundTx{ Creator: creator, @@ -46,7 +48,7 @@ func (msg *MsgVoteOnObservedOutboundTx) Route() string { } func (msg *MsgVoteOnObservedOutboundTx) Type() string { - return pkg.OutboundVoter.String() + return authz.OutboundVoter.String() } func (msg *MsgVoteOnObservedOutboundTx) GetSigners() []sdk.AccAddress { @@ -79,7 +81,7 @@ func (msg *MsgVoteOnObservedOutboundTx) Digest() string { m.Creator = "" // Set status to ReceiveStatus_Created to make sure both successful and failed votes are added to the same ballot - m.Status = pkg.ReceiveStatus_Created + m.Status = chains.ReceiveStatus_Created // Outbound and reverted txs have different digest as ObservedOutTxHash is different so they are stored in different ballots hash := crypto.Keccak256Hash([]byte(m.String())) diff --git a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go index 27b0a701f8..d9e3f6a3ca 100644 --- a/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go +++ b/x/crosschain/types/message_vote_on_observed_outbound_tx_test.go @@ -8,7 +8,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -30,10 +32,10 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - pkg.ReceiveStatus_Created, + chains.ReceiveStatus_Created, 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ), }, { @@ -47,10 +49,10 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - pkg.ReceiveStatus_Created, + chains.ReceiveStatus_Created, 42, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ), err: sdkerrors.ErrInvalidAddress, }, @@ -65,10 +67,10 @@ func TestMsgVoteOnObservedOutboundTx_ValidateBasic(t *testing.T) { math.NewInt(42), 42, math.NewUint(42), - pkg.ReceiveStatus_Created, + chains.ReceiveStatus_Created, -1, 42, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ), err: types.ErrInvalidChainID, }, @@ -97,10 +99,10 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { ObservedOutTxEffectiveGasPrice: math.NewInt(42), ObservedOutTxEffectiveGasLimit: 42, ValueReceived: math.NewUint(42), - Status: pkg.ReceiveStatus_Created, + Status: chains.ReceiveStatus_Created, OutTxChain: 42, OutTxTssNonce: 42, - CoinType: pkg.CoinType_Zeta, + CoinType: coin.CoinType_Zeta, } hash := msg.Digest() require.NotEmpty(t, hash, "hash should not be empty") @@ -113,7 +115,7 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { // status not used msg2 = msg - msg2.Status = pkg.ReceiveStatus_Failed + msg2.Status = chains.ReceiveStatus_Failed hash2 = msg2.Digest() require.Equal(t, hash, hash2, "status should not change hash") @@ -173,7 +175,7 @@ func TestMsgVoteOnObservedOutboundTx_Digest(t *testing.T) { // coin type used msg2 = msg - msg2.CoinType = pkg.CoinType_ERC20 + msg2.CoinType = coin.CoinType_ERC20 hash2 = msg2.Digest() require.NotEqual(t, hash, hash2, "coin type should change hash") } @@ -219,7 +221,7 @@ func TestMsgVoteOnObservedOutboundTx_Type(t *testing.T) { msg := types.MsgVoteOnObservedOutboundTx{ Creator: sample.AccAddress(), } - require.Equal(t, pkg.OutboundVoter.String(), msg.Type()) + require.Equal(t, authz.OutboundVoter.String(), msg.Type()) } func TestMsgVoteOnObservedOutboundTx_Route(t *testing.T) { diff --git a/x/crosschain/types/tx.pb.go b/x/crosschain/types/tx.pb.go index 8e7e7fffe1..c8338b386b 100644 --- a/x/crosschain/types/tx.pb.go +++ b/x/crosschain/types/tx.pb.go @@ -14,7 +14,9 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + chains "github.com/zeta-chain/zetacore/pkg/chains" + coin "github.com/zeta-chain/zetacore/pkg/coin" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -35,7 +37,7 @@ type MsgCreateTSSVoter struct { Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` TssPubkey string `protobuf:"bytes,2,opt,name=tss_pubkey,json=tssPubkey,proto3" json:"tss_pubkey,omitempty"` KeyGenZetaHeight int64 `protobuf:"varint,3,opt,name=keyGenZetaHeight,proto3" json:"keyGenZetaHeight,omitempty"` - Status proto1.ReceiveStatus `protobuf:"varint,4,opt,name=status,proto3,enum=pkg.ReceiveStatus" json:"status,omitempty"` + Status chains.ReceiveStatus `protobuf:"varint,4,opt,name=status,proto3,enum=chains.ReceiveStatus" json:"status,omitempty"` } func (m *MsgCreateTSSVoter) Reset() { *m = MsgCreateTSSVoter{} } @@ -92,11 +94,11 @@ func (m *MsgCreateTSSVoter) GetKeyGenZetaHeight() int64 { return 0 } -func (m *MsgCreateTSSVoter) GetStatus() proto1.ReceiveStatus { +func (m *MsgCreateTSSVoter) GetStatus() chains.ReceiveStatus { if m != nil { return m.Status } - return proto1.ReceiveStatus_Created + return chains.ReceiveStatus_Created } type MsgCreateTSSVoterResponse struct { @@ -313,13 +315,13 @@ func (m *MsgUpdateTssAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateTssAddressResponse proto.InternalMessageInfo type MsgAddToInTxTracker struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - TxHash string `protobuf:"bytes,3,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,4,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` - Proof *proto1.Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` - BlockHash string `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` - TxIndex int64 `protobuf:"varint,7,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + TxHash string `protobuf:"bytes,3,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` + CoinType coin.CoinType `protobuf:"varint,4,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` + Proof *proofs.Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` + BlockHash string `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` + TxIndex int64 `protobuf:"varint,7,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` } func (m *MsgAddToInTxTracker) Reset() { *m = MsgAddToInTxTracker{} } @@ -376,14 +378,14 @@ func (m *MsgAddToInTxTracker) GetTxHash() string { return "" } -func (m *MsgAddToInTxTracker) GetCoinType() proto1.CoinType { +func (m *MsgAddToInTxTracker) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } -func (m *MsgAddToInTxTracker) GetProof() *proto1.Proof { +func (m *MsgAddToInTxTracker) GetProof() *proofs.Proof { if m != nil { return m.Proof } @@ -589,7 +591,7 @@ type MsgAddToOutTxTracker struct { ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` Nonce uint64 `protobuf:"varint,3,opt,name=nonce,proto3" json:"nonce,omitempty"` TxHash string `protobuf:"bytes,4,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` - Proof *proto1.Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` + Proof *proofs.Proof `protobuf:"bytes,5,opt,name=proof,proto3" json:"proof,omitempty"` BlockHash string `protobuf:"bytes,6,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` TxIndex int64 `protobuf:"varint,7,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` } @@ -655,7 +657,7 @@ func (m *MsgAddToOutTxTracker) GetTxHash() string { return "" } -func (m *MsgAddToOutTxTracker) GetProof() *proto1.Proof { +func (m *MsgAddToOutTxTracker) GetProof() *proofs.Proof { if m != nil { return m.Proof } @@ -937,10 +939,10 @@ type MsgVoteOnObservedOutboundTx struct { ObservedOutTxEffectiveGasPrice github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=observed_outTx_effective_gas_price,json=observedOutTxEffectiveGasPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"observed_outTx_effective_gas_price"` ObservedOutTxEffectiveGasLimit uint64 `protobuf:"varint,12,opt,name=observed_outTx_effective_gas_limit,json=observedOutTxEffectiveGasLimit,proto3" json:"observed_outTx_effective_gas_limit,omitempty"` ValueReceived github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,5,opt,name=value_received,json=valueReceived,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"value_received" yaml:"value_received"` - Status proto1.ReceiveStatus `protobuf:"varint,6,opt,name=status,proto3,enum=pkg.ReceiveStatus" json:"status,omitempty"` + Status chains.ReceiveStatus `protobuf:"varint,6,opt,name=status,proto3,enum=chains.ReceiveStatus" json:"status,omitempty"` OutTxChain int64 `protobuf:"varint,7,opt,name=outTx_chain,json=outTxChain,proto3" json:"outTx_chain,omitempty"` OutTxTssNonce uint64 `protobuf:"varint,8,opt,name=outTx_tss_nonce,json=outTxTssNonce,proto3" json:"outTx_tss_nonce,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,9,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` + CoinType coin.CoinType `protobuf:"varint,9,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` } func (m *MsgVoteOnObservedOutboundTx) Reset() { *m = MsgVoteOnObservedOutboundTx{} } @@ -1018,11 +1020,11 @@ func (m *MsgVoteOnObservedOutboundTx) GetObservedOutTxEffectiveGasLimit() uint64 return 0 } -func (m *MsgVoteOnObservedOutboundTx) GetStatus() proto1.ReceiveStatus { +func (m *MsgVoteOnObservedOutboundTx) GetStatus() chains.ReceiveStatus { if m != nil { return m.Status } - return proto1.ReceiveStatus_Created + return chains.ReceiveStatus_Created } func (m *MsgVoteOnObservedOutboundTx) GetOutTxChain() int64 { @@ -1039,11 +1041,11 @@ func (m *MsgVoteOnObservedOutboundTx) GetOutTxTssNonce() uint64 { return 0 } -func (m *MsgVoteOnObservedOutboundTx) GetCoinType() proto1.CoinType { +func (m *MsgVoteOnObservedOutboundTx) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } type MsgVoteOnObservedOutboundTxResponse struct { @@ -1091,13 +1093,13 @@ type MsgVoteOnObservedInboundTx struct { // string zeta_burnt = 6; Amount github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,6,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"` // string mMint = 7; - Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` - InTxHash string `protobuf:"bytes,9,opt,name=in_tx_hash,json=inTxHash,proto3" json:"in_tx_hash,omitempty"` - InBlockHeight uint64 `protobuf:"varint,10,opt,name=in_block_height,json=inBlockHeight,proto3" json:"in_block_height,omitempty"` - GasLimit uint64 `protobuf:"varint,11,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,12,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` - TxOrigin string `protobuf:"bytes,13,opt,name=tx_origin,json=txOrigin,proto3" json:"tx_origin,omitempty"` - Asset string `protobuf:"bytes,14,opt,name=asset,proto3" json:"asset,omitempty"` + Message string `protobuf:"bytes,8,opt,name=message,proto3" json:"message,omitempty"` + InTxHash string `protobuf:"bytes,9,opt,name=in_tx_hash,json=inTxHash,proto3" json:"in_tx_hash,omitempty"` + InBlockHeight uint64 `protobuf:"varint,10,opt,name=in_block_height,json=inBlockHeight,proto3" json:"in_block_height,omitempty"` + GasLimit uint64 `protobuf:"varint,11,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + CoinType coin.CoinType `protobuf:"varint,12,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` + TxOrigin string `protobuf:"bytes,13,opt,name=tx_origin,json=txOrigin,proto3" json:"tx_origin,omitempty"` + Asset string `protobuf:"bytes,14,opt,name=asset,proto3" json:"asset,omitempty"` // event index of the sent asset in the observed tx EventIndex uint64 `protobuf:"varint,15,opt,name=event_index,json=eventIndex,proto3" json:"event_index,omitempty"` } @@ -1198,11 +1200,11 @@ func (m *MsgVoteOnObservedInboundTx) GetGasLimit() uint64 { return 0 } -func (m *MsgVoteOnObservedInboundTx) GetCoinType() proto1.CoinType { +func (m *MsgVoteOnObservedInboundTx) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *MsgVoteOnObservedInboundTx) GetTxOrigin() string { @@ -1476,101 +1478,102 @@ func init() { func init() { proto.RegisterFile("crosschain/tx.proto", fileDescriptor_81d6d611190b7635) } var fileDescriptor_81d6d611190b7635 = []byte{ - // 1501 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xdd, 0x6b, 0xdb, 0x56, - 0x1b, 0x8f, 0xde, 0x24, 0x8e, 0xfd, 0x24, 0x4e, 0x5a, 0x35, 0x6f, 0xeb, 0x2a, 0x8d, 0x93, 0xaa, - 0x6f, 0xfb, 0x86, 0x42, 0xed, 0x36, 0x65, 0xac, 0xed, 0x36, 0x58, 0x12, 0xda, 0x34, 0x5b, 0xd3, - 0x14, 0xc5, 0xdd, 0x46, 0x6f, 0x84, 0x2c, 0x9d, 0xc8, 0xc2, 0xb6, 0x8e, 0xd1, 0x39, 0x32, 0x76, - 0x18, 0x0c, 0x06, 0xbb, 0x1f, 0x63, 0xb0, 0xb1, 0xeb, 0xfd, 0x31, 0xbd, 0x2c, 0x1b, 0x8c, 0xb1, - 0x8b, 0x32, 0x9a, 0xcb, 0xdd, 0xed,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 0xa0, 0xf4, 0x20, 0x37, 0xbd, 0xaa, 0xac, 0xcd, 0xae, 0x03, 0x9e, 0x7b, 0x26, 0x38, - 0x86, 0x7c, 0x21, 0x22, 0x2e, 0xd7, 0xa8, 0x5d, 0x95, 0x96, 0x52, 0x32, 0x62, 0xe4, 0xa0, 0xb1, - 0xcb, 0x90, 0xe6, 0x2d, 0xd3, 0xf3, 0x1d, 0xd2, 0xca, 0xcd, 0x48, 0x07, 0x79, 0x6b, 0x47, 0x90, - 0x11, 0x18, 0xbd, 0xc1, 0xc6, 0x60, 0xfc, 0x22, 0x53, 0xfe, 0xf3, 0x8a, 0xc7, 0x49, 0xcd, 0x63, - 0xfc, 0xa1, 0xb1, 0xb5, 0x7e, 0x7b, 0x08, 0x14, 0xd7, 0x20, 0x4b, 0x02, 0x7b, 0xfd, 0xb6, 0x69, - 0x49, 0x54, 0x23, 0xf4, 0xe7, 0x90, 0xd9, 0xb9, 0xb9, 0x6e, 0xbc, 0x26, 0x93, 0x78, 0xa9, 0x30, - 0xe5, 0x5b, 0x75, 0x89, 0x48, 0xc6, 0xc0, 0x67, 0xf5, 0x22, 0xa4, 0x58, 0xbb, 0x5e, 0xa6, 0x35, - 0x8c, 0x3f, 0x63, 0x44, 0x94, 0xaa, 0x41, 0xda, 0x21, 0xb6, 0x57, 0xb7, 0x6a, 0x0c, 0x43, 0xce, - 0x1a, 0x31, 0xad, 0x2e, 0x41, 0xc6, 0xb5, 0x98, 0x59, 0xf3, 0xea, 0x1e, 0x8f, 0x42, 0x4e, 0xbb, - 0x16, 0x7b, 0x22, 0x68, 0xdd, 0xc4, 0x02, 0x49, 0xc6, 0xd4, 0x89, 0x58, 0x44, 0x70, 0x98, 0x88, - 0x40, 0x46, 0x38, 0x77, 0xd8, 0x1d, 0xc1, 0x32, 0x80, 0x6d, 0xc7, 0x90, 0x46, 0x19, 0x26, 0x38, - 0x12, 0xd4, 0xdf, 0x14, 0x58, 0xec, 0xa0, 0xba, 0x17, 0xf2, 0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, - 0x3c, 0x46, 0x2d, 0xf5, 0xca, 0x8c, 0x53, 0x4b, 0x83, 0xfe, 0x27, 0xab, 0x5f, 0xc1, 0x42, 0xef, - 0x57, 0x84, 0x3b, 0xa3, 0xd5, 0xf5, 0x88, 0x68, 0xf7, 0x4f, 0x2d, 0xd2, 0x7d, 0x07, 0x3d, 0x9f, - 0x62, 0xc6, 0xb8, 0x83, 0xa4, 0xc4, 0x38, 0x77, 0x70, 0xf2, 0x87, 0x14, 0x61, 0xbd, 0x67, 0xbe, - 0x8c, 0x61, 0x3d, 0x29, 0x31, 0x8e, 0xf5, 0x93, 0xa7, 0x0e, 0x76, 0xf5, 0xfe, 0x99, 0x73, 0x77, - 0x9c, 0x4e, 0xd4, 0x23, 0x34, 0x4e, 0x57, 0x1f, 0x38, 0x65, 0x36, 0x3f, 0x7d, 0xf9, 0x26, 0xaf, - 0xbc, 0x7a, 0x93, 0x57, 0xfe, 0x7c, 0x93, 0x57, 0xbe, 0x3d, 0xca, 0x4f, 0xbc, 0x3a, 0xca, 0x4f, - 0xfc, 0x7e, 0x94, 0x9f, 0x78, 0x71, 0xa7, 0x6b, 0xad, 0x11, 0x6a, 0x6f, 0xc9, 0x0f, 0x72, 0x1d, - 0x0b, 0xc5, 0x56, 0xb1, 0xfb, 0x33, 0x9d, 0xd8, 0x72, 0xca, 0x29, 0xfc, 0xcc, 0x76, 0xf7, 0xdf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xb7, 0xf7, 0x9f, 0xc3, 0xc1, 0x13, 0x00, 0x00, + // 1517 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x18, 0xdd, 0x4e, 0x1b, 0x47, + 0x97, 0xfd, 0x00, 0x63, 0x1f, 0x30, 0x24, 0x0b, 0x09, 0xce, 0x12, 0x0c, 0x59, 0xbe, 0xa4, 0xa8, + 0x55, 0xec, 0x84, 0xa8, 0x6a, 0x92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6b, 0x9f, 0x58, 0x73, 0x4a, 0x09, 0xfc, 0xea, 0x76, 0xe7, 0xbf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x08, 0xaa, 0x5d, 0x39, 0x08, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3678,7 +3681,7 @@ func (m *MsgCreateTSSVoter) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= proto1.ReceiveStatus(b&0x7F) << shift + m.Status |= chains.ReceiveStatus(b&0x7F) << shift if b < 0x80 { break } @@ -4229,7 +4232,7 @@ func (m *MsgAddToInTxTracker) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } @@ -4264,7 +4267,7 @@ func (m *MsgAddToInTxTracker) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Proof == nil { - m.Proof = &proto1.Proof{} + m.Proof = &proofs.Proof{} } if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4902,7 +4905,7 @@ func (m *MsgAddToOutTxTracker) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Proof == nil { - m.Proof = &proto1.Proof{} + m.Proof = &proofs.Proof{} } if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -5633,7 +5636,7 @@ func (m *MsgVoteOnObservedOutboundTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= proto1.ReceiveStatus(b&0x7F) << shift + m.Status |= chains.ReceiveStatus(b&0x7F) << shift if b < 0x80 { break } @@ -5690,7 +5693,7 @@ func (m *MsgVoteOnObservedOutboundTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } @@ -6151,7 +6154,7 @@ func (m *MsgVoteOnObservedInboundTx) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/emissions/abci_test.go b/x/emissions/abci_test.go index d75cfe92e5..65153b377a 100644 --- a/x/emissions/abci_test.go +++ b/x/emissions/abci_test.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" emissionsModule "github.com/zeta-chain/zetacore/x/emissions" @@ -88,7 +88,7 @@ func TestBeginBlocker(t *testing.T) { }) // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := pkg.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) + totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) require.NoError(t, err) // Fund the emission pool to start the emission process @@ -246,7 +246,7 @@ func TestDistributeObserverRewards(t *testing.T) { zk.ObserverKeeper.SetObserverSet(ctx, observerSet) // Total block rewards is the fixed amount of rewards that are distributed - totalBlockRewards, err := pkg.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) + totalBlockRewards, err := coin.GetAzetaDecFromAmountInZeta(emissionstypes.BlockRewardsInZeta) totalRewardCoins := sdk.NewCoins(sdk.NewCoin(config.BaseDenom, totalBlockRewards.TruncateInt())) require.NoError(t, err) diff --git a/x/emissions/keeper/block_rewards_components.go b/x/emissions/keeper/block_rewards_components.go index b51ae9a96e..e1eadf66ad 100644 --- a/x/emissions/keeper/block_rewards_components.go +++ b/x/emissions/keeper/block_rewards_components.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/emissions/types" ) @@ -66,7 +66,7 @@ func (k Keeper) GetFixedBlockRewards() (sdk.Dec, error) { } func CalculateFixedValidatorRewards(avgBlockTimeString string) (sdk.Dec, error) { - azetaAmountTotalRewards, err := pkg.GetAzetaDecFromAmountInZeta(types.BlockRewardsInZeta) + azetaAmountTotalRewards, err := coin.GetAzetaDecFromAmountInZeta(types.BlockRewardsInZeta) if err != nil { return sdk.ZeroDec(), err } diff --git a/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go b/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go index 06f3cca2dd..703b57fd1e 100644 --- a/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go +++ b/x/fungible/client/cli/tx_deploy_fungible_coin_zrc_4.go @@ -3,7 +3,7 @@ package cli import ( "strconv" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" @@ -50,7 +50,7 @@ func CmdDeployFungibleCoinZRC4() *cobra.Command { uint32(argDecimals), argName, argSymbol, - pkg.CoinType(argCoinType), + coin.CoinType(argCoinType), argGasLimit, ) diff --git a/x/fungible/keeper/deposits.go b/x/fungible/keeper/deposits.go index e5410ec578..c7d786db18 100644 --- a/x/fungible/keeper/deposits.go +++ b/x/fungible/keeper/deposits.go @@ -7,7 +7,7 @@ import ( eth "github.com/ethereum/go-ethereum/common" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -28,35 +28,35 @@ func (k Keeper) ZRC20DepositAndCallContract( amount *big.Int, senderChainID int64, data []byte, - coinType pkg.CoinType, + coinType coin.CoinType, asset string, ) (*evmtypes.MsgEthereumTxResponse, bool, error) { var ZRC20Contract eth.Address - var coin types.ForeignCoins + var foreignCoin types.ForeignCoins var found bool // get foreign coin - if coinType == pkg.CoinType_Gas { - coin, found = k.GetGasCoinForForeignCoin(ctx, senderChainID) + if coinType == coin.CoinType_Gas { + foreignCoin, found = k.GetGasCoinForForeignCoin(ctx, senderChainID) if !found { return nil, false, crosschaintypes.ErrGasCoinNotFound } } else { - coin, found = k.GetForeignCoinFromAsset(ctx, asset, senderChainID) + foreignCoin, found = k.GetForeignCoinFromAsset(ctx, asset, senderChainID) if !found { return nil, false, crosschaintypes.ErrForeignCoinNotFound } } - ZRC20Contract = eth.HexToAddress(coin.Zrc20ContractAddress) + ZRC20Contract = eth.HexToAddress(foreignCoin.Zrc20ContractAddress) // check if foreign coin is paused - if coin.Paused { + if foreignCoin.Paused { return nil, false, types.ErrPausedZRC20 } // check foreign coins cap if it has a cap - if !coin.LiquidityCap.IsNil() && !coin.LiquidityCap.IsZero() { - liquidityCap := coin.LiquidityCap.BigInt() + if !foreignCoin.LiquidityCap.IsNil() && !foreignCoin.LiquidityCap.IsZero() { + liquidityCap := foreignCoin.LiquidityCap.BigInt() totalSupply, err := k.TotalSupplyZRC4(ctx, ZRC20Contract) if err != nil { return nil, false, err diff --git a/x/fungible/keeper/deposits_test.go b/x/fungible/keeper/deposits_test.go index e84acb5e2d..858a8130ce 100644 --- a/x/fungible/keeper/deposits_test.go +++ b/x/fungible/keeper/deposits_test.go @@ -7,7 +7,8 @@ import ( "cosmossdk.io/math" "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/testutil/contracts" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -21,7 +22,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -37,7 +38,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.NoError(t, err) @@ -52,7 +53,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId assetAddress := sample.EthAddress().String() @@ -69,7 +70,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, assetAddress, ) require.NoError(t, err) @@ -84,7 +85,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId assetAddress := sample.EthAddress().String() @@ -101,7 +102,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte("DEADBEEF"), - pkg.CoinType_ERC20, + coin.CoinType_ERC20, assetAddress, ) require.ErrorIs(t, err, types.ErrCallNonContract) @@ -112,7 +113,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -124,10 +125,10 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { require.NoError(t, err) // set a liquidity cap - coin, found := k.GetForeignCoins(ctx, zrc20.String()) + foreignCoin, found := k.GetForeignCoins(ctx, zrc20.String()) require.True(t, found) - coin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) - k.SetForeignCoins(ctx, coin) + foreignCoin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) + k.SetForeignCoins(ctx, foreignCoin) // increase total supply _, err = k.DepositZRC20(ctx, zrc20, sample.EthAddress(), big.NewInt(500)) @@ -142,7 +143,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(500), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.NoError(t, err) @@ -158,7 +159,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -166,10 +167,10 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { zrc20 := setupGasCoin(t, ctx, k, sdkk.EvmKeeper, chain, "foobar", "foobar") // pause the coin - coin, found := k.GetForeignCoins(ctx, zrc20.String()) + foreignCoin, found := k.GetForeignCoins(ctx, zrc20.String()) require.True(t, found) - coin.Paused = true - k.SetForeignCoins(ctx, coin) + foreignCoin.Paused = true + k.SetForeignCoins(ctx, foreignCoin) to := sample.EthAddress() _, _, err := k.ZRC20DepositAndCallContract( @@ -179,7 +180,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.ErrorIs(t, err, types.ErrPausedZRC20) @@ -190,7 +191,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -202,10 +203,10 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { require.NoError(t, err) // set a liquidity cap - coin, found := k.GetForeignCoins(ctx, zrc20.String()) + foreignCoin, found := k.GetForeignCoins(ctx, zrc20.String()) require.True(t, found) - coin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) - k.SetForeignCoins(ctx, coin) + foreignCoin.LiquidityCap = math.NewUint(initialTotalSupply.Uint64() + 1000) + k.SetForeignCoins(ctx, foreignCoin) // increase total supply _, err = k.DepositZRC20(ctx, zrc20, sample.EthAddress(), big.NewInt(500)) @@ -220,7 +221,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(501), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.ErrorIs(t, err, types.ErrForeignCoinCapReached) @@ -231,7 +232,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -246,7 +247,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.ErrorIs(t, err, crosschaintypes.ErrGasCoinNotFound) @@ -256,7 +257,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId assetAddress := sample.EthAddress().String() @@ -272,7 +273,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, assetAddress, ) require.ErrorIs(t, err, crosschaintypes.ErrForeignCoinNotFound) @@ -283,7 +284,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -302,7 +303,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.NoError(t, err) @@ -321,7 +322,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { k, ctx, sdkk, _ := testkeeper.FungibleKeeper(t) _ = k.GetAuthKeeper().GetModuleAccount(ctx, types.ModuleName) - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() chain := chainList[0].ChainId // deploy the system contracts @@ -340,7 +341,7 @@ func TestKeeper_ZRC20DepositAndCallContract(t *testing.T) { big.NewInt(42), chain, []byte{}, - pkg.CoinType_Gas, + coin.CoinType_Gas, sample.EthAddress().String(), ) require.Error(t, err) diff --git a/x/fungible/keeper/evm.go b/x/fungible/keeper/evm.go index 5fe96e88b0..313a1301aa 100644 --- a/x/fungible/keeper/evm.go +++ b/x/fungible/keeper/evm.go @@ -26,7 +26,8 @@ import ( zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" uniswapv2factory "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-core/contracts/uniswapv2factory.sol" uniswapv2router02 "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.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/server/config" "github.com/zeta-chain/zetacore/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -89,11 +90,11 @@ func (k Keeper) DeployZRC20Contract( name, symbol string, decimals uint8, chainID int64, - coinType pkg.CoinType, + coinType coin.CoinType, erc20Contract string, gasLimit *big.Int, ) (common.Address, error) { - chain := pkg.GetChainFromChainID(chainID) + chain := chains.GetChainFromChainID(chainID) if chain == nil { return common.Address{}, cosmoserrors.Wrapf(zetaObserverTypes.ErrSupportedChains, "chain %d not found", chainID) } diff --git a/x/fungible/keeper/evm_test.go b/x/fungible/keeper/evm_test.go index 433ffed083..8d52742c0c 100644 --- a/x/fungible/keeper/evm_test.go +++ b/x/fungible/keeper/evm_test.go @@ -12,7 +12,8 @@ import ( "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.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/server/config" "github.com/zeta-chain/zetacore/testutil/contracts" testkeeper "github.com/zeta-chain/zetacore/testutil/keeper" @@ -23,7 +24,7 @@ import ( // get a valid chain id independently of the build flag func getValidChainID(t *testing.T) int64 { - list := pkg.DefaultChainsList() + list := chains.DefaultChainsList() require.NotEmpty(t, list) require.NotNil(t, list[0]) @@ -181,7 +182,7 @@ func TestKeeper_DeployZRC20Contract(t *testing.T) { "bar", 8, chainID, - pkg.CoinType_Gas, + coin.CoinType_Gas, "foobar", big.NewInt(1000), ) @@ -196,7 +197,7 @@ func TestKeeper_DeployZRC20Contract(t *testing.T) { require.Equal(t, uint32(8), foreignCoins.Decimals) require.Equal(t, "foo", foreignCoins.Name) require.Equal(t, "bar", foreignCoins.Symbol) - require.Equal(t, pkg.CoinType_Gas, foreignCoins.CoinType) + require.Equal(t, coin.CoinType_Gas, foreignCoins.CoinType) require.Equal(t, uint64(1000), foreignCoins.GasLimit) // can get the zrc20 data diff --git a/x/fungible/keeper/foreign_coins.go b/x/fungible/keeper/foreign_coins.go index f995daee29..ee424e92c1 100644 --- a/x/fungible/keeper/foreign_coins.go +++ b/x/fungible/keeper/foreign_coins.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -82,9 +82,9 @@ func (k Keeper) GetAllForeignCoins(ctx sdk.Context) (list []types.ForeignCoins) // GetGasCoinForForeignCoin returns the gas coin for a given chain func (k Keeper) GetGasCoinForForeignCoin(ctx sdk.Context, chainID int64) (types.ForeignCoins, bool) { foreignCoinList := k.GetAllForeignCoinsForChain(ctx, chainID) - for _, coin := range foreignCoinList { - if coin.CoinType == pkg.CoinType_Gas { - return coin, true + for _, c := range foreignCoinList { + if c.CoinType == coin.CoinType_Gas { + return c, true } } return types.ForeignCoins{}, false diff --git a/x/fungible/keeper/foreign_coins_test.go b/x/fungible/keeper/foreign_coins_test.go index dc4c722c2f..d9a98a4031 100644 --- a/x/fungible/keeper/foreign_coins_test.go +++ b/x/fungible/keeper/foreign_coins_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" @@ -38,31 +38,31 @@ func TestKeeper_GetGasCoinForForeignCoin(t *testing.T) { types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: 1, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: 1, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: 1, - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, Name: "bar", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: 2, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), ForeignChainId: 2, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, ) @@ -88,35 +88,35 @@ func TestKeeperGetForeignCoinFromAsset(t *testing.T) { Zrc20ContractAddress: sample.EthAddress().String(), Asset: sample.EthAddress().String(), ForeignChainId: 1, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), Asset: gasAsset, ForeignChainId: 1, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "bar", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), Asset: sample.EthAddress().String(), ForeignChainId: 1, - CoinType: pkg.CoinType_Gas, + CoinType: coin.CoinType_Gas, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), Asset: sample.EthAddress().String(), ForeignChainId: 2, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, types.ForeignCoins{ Zrc20ContractAddress: sample.EthAddress().String(), Asset: sample.EthAddress().String(), ForeignChainId: 2, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, ) @@ -142,7 +142,7 @@ func TestKeeperGetForeignCoinFromAsset(t *testing.T) { Zrc20ContractAddress: sample.EthAddress().String(), Asset: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", ForeignChainId: 1, - CoinType: pkg.CoinType_ERC20, + CoinType: coin.CoinType_ERC20, Name: "foo", }, ) diff --git a/x/fungible/keeper/gas_coin_and_pool.go b/x/fungible/keeper/gas_coin_and_pool.go index 7c4c82f5ff..6b06cd8cec 100644 --- a/x/fungible/keeper/gas_coin_and_pool.go +++ b/x/fungible/keeper/gas_coin_and_pool.go @@ -10,7 +10,8 @@ import ( systemcontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" uniswapv2router02 "github.com/zeta-chain/protocol-contracts/pkg/uniswap/v2-periphery/contracts/uniswapv2router02.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/x/fungible/types" zetaObserverTypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -26,7 +27,7 @@ func (k Keeper) SetupChainGasCoinAndPool( decimals uint8, gasLimit *big.Int, ) (ethcommon.Address, error) { - chain := pkg.GetChainFromChainID(chainID) + chain := chains.GetChainFromChainID(chainID) if chain == nil { return ethcommon.Address{}, zetaObserverTypes.ErrSupportedChains } @@ -43,12 +44,12 @@ func (k Keeper) SetupChainGasCoinAndPool( // default values if transferGasLimit == nil { transferGasLimit = big.NewInt(21_000) - if pkg.IsBitcoinChain(chain.ChainId) { + if chains.IsBitcoinChain(chain.ChainId) { transferGasLimit = big.NewInt(100) // 100B for a typical tx } } - zrc20Addr, err := k.DeployZRC20Contract(ctx, name, symbol, decimals, chain.ChainId, pkg.CoinType_Gas, "", transferGasLimit) + zrc20Addr, err := k.DeployZRC20Contract(ctx, name, symbol, decimals, chain.ChainId, coin.CoinType_Gas, "", transferGasLimit) if err != nil { return ethcommon.Address{}, cosmoserrors.Wrapf(err, "failed to DeployZRC20Contract") } diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go index 2d38dd8820..27b31aab29 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -45,7 +45,7 @@ func (k msgServer) DeployFungibleCoinZRC20(goCtx context.Context, msg *types.Msg return nil, cosmoserrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") } - if msg.CoinType == pkg.CoinType_Gas { + if msg.CoinType == coin.CoinType_Gas { // #nosec G701 always in range address, err = k.SetupChainGasCoinAndPool(ctx, msg.ForeignChainId, msg.Name, msg.Symbol, uint8(msg.Decimals), big.NewInt(msg.GasLimit)) if err != nil { diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go index 709b38fe00..75ec3f4d08 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go @@ -7,7 +7,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/coin" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -39,7 +39,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 8, "foo", "foo", - pkg.CoinType_Gas, + coin.CoinType_Gas, 1000000, )) require.NoError(t, err) @@ -49,7 +49,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { // can retrieve the gas coin foreignCoin, found := k.GetForeignCoins(ctx, gasAddress) require.True(t, found) - require.Equal(t, foreignCoin.CoinType, pkg.CoinType_Gas) + require.Equal(t, foreignCoin.CoinType, coin.CoinType_Gas) require.Contains(t, foreignCoin.Name, "foo") // check gas limit @@ -71,7 +71,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 8, "bar", "bar", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, 2000000, )) require.NoError(t, err) @@ -79,7 +79,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { foreignCoin, found = k.GetForeignCoins(ctx, res.Address) require.True(t, found) - require.Equal(t, foreignCoin.CoinType, pkg.CoinType_ERC20) + require.Equal(t, foreignCoin.CoinType, coin.CoinType_ERC20) require.Contains(t, foreignCoin.Name, "bar") // check gas limit @@ -115,7 +115,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 8, "foo", "foo", - pkg.CoinType_Gas, + coin.CoinType_Gas, 1000000, )) require.Error(t, err) @@ -142,7 +142,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 78, "foo", "foo", - pkg.CoinType_Gas, + coin.CoinType_Gas, 1000000, )) require.Error(t, err) @@ -169,7 +169,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 8, "foo", "foo", - pkg.CoinType_Gas, + coin.CoinType_Gas, 1000000, )) require.Error(t, err) @@ -196,7 +196,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { 8, "foo", "foo", - pkg.CoinType_Gas, + coin.CoinType_Gas, 1000000, ) @@ -213,7 +213,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { require.ErrorIs(t, err, types.ErrForeignCoinAlreadyExist) // Similar to above, redeploying existing erc20 should also fail - deployMsg.CoinType = pkg.CoinType_ERC20 + deployMsg.CoinType = coin.CoinType_ERC20 keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) _, err = keeper.NewMsgServerImpl(*k).DeployFungibleCoinZRC20(ctx, deployMsg) diff --git a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go index 2c40ecdbd7..48f7db6b6c 100644 --- a/x/fungible/keeper/msg_server_update_contract_bytecode_test.go +++ b/x/fungible/keeper/msg_server_update_contract_bytecode_test.go @@ -11,7 +11,8 @@ import ( "github.com/evmos/ethermint/x/evm/statedb" "github.com/stretchr/testify/mock" "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" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -39,7 +40,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { authorityMock := keepertest.GetFungibleAuthorityMock(t, k) // sample chainIDs and addresses - chainList := pkg.DefaultChainsList() + chainList := chains.DefaultChainsList() require.True(t, len(chainList) > 1) require.NotNil(t, chainList[0]) require.NotNil(t, chainList[1]) @@ -86,7 +87,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { "BETA", 18, chainID2, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, "beta", big.NewInt(90_000), ) @@ -132,7 +133,7 @@ func TestKeeper_UpdateContractBytecode(t *testing.T) { "GAMMA", 18, chainID1, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, "gamma", big.NewInt(90_000), ) diff --git a/x/fungible/keeper/msg_server_update_system_contract.go b/x/fungible/keeper/msg_server_update_system_contract.go index c0d776c811..bda5373c3c 100644 --- a/x/fungible/keeper/msg_server_update_system_contract.go +++ b/x/fungible/keeper/msg_server_update_system_contract.go @@ -10,7 +10,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -47,7 +47,7 @@ func (k msgServer) UpdateSystemContract(goCtx context.Context, msg *types.MsgUpd if err != nil { return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to call zrc20 contract method updateSystemContractAddress (%s)", err.Error()) } - if fcoin.CoinType == pkg.CoinType_Gas { + if fcoin.CoinType == coin.CoinType_Gas { _, err = k.CallEVM(tmpCtx, *sysABI, types.ModuleAddressEVM, newSystemContractAddr, BigIntZero, nil, true, false, "setGasCoinZRC20", big.NewInt(fcoin.ForeignChainId), zrc20Addr) if err != nil { return nil, cosmoserrors.Wrapf(types.ErrContractCall, "failed to call system contract method setGasCoinZRC20 (%s)", err.Error()) diff --git a/x/fungible/keeper/msg_server_update_system_contract_test.go b/x/fungible/keeper/msg_server_update_system_contract_test.go index 147e65af81..f66ccd1643 100644 --- a/x/fungible/keeper/msg_server_update_system_contract_test.go +++ b/x/fungible/keeper/msg_server_update_system_contract_test.go @@ -10,7 +10,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" zrc20 "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/zrc20.sol" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -43,7 +43,7 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { return address.Hex() } - chains := pkg.DefaultChainsList() + chains := chains.DefaultChainsList() require.True(t, len(chains) > 1) require.NotNil(t, chains[0]) require.NotNil(t, chains[1]) @@ -193,7 +193,7 @@ func TestKeeper_UpdateSystemContract(t *testing.T) { admin := sample.AccAddress() authorityMock := keepertest.GetFungibleAuthorityMock(t, k) - chains := pkg.DefaultChainsList() + chains := chains.DefaultChainsList() require.True(t, len(chains) > 1) require.NotNil(t, chains[0]) chainID1 := chains[0].ChainId diff --git a/x/fungible/types/events.pb.go b/x/fungible/types/events.pb.go index 6e616e2403..b6e51845c2 100644 --- a/x/fungible/types/events.pb.go +++ b/x/fungible/types/events.pb.go @@ -11,7 +11,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + coin "github.com/zeta-chain/zetacore/pkg/coin" ) // Reference imports to suppress errors if they are not otherwise used. @@ -94,15 +94,15 @@ func (m *EventSystemContractUpdated) GetSigner() string { } type EventZRC20Deployed struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - Contract string `protobuf:"bytes,3,opt,name=contract,proto3" json:"contract,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` - Symbol string `protobuf:"bytes,5,opt,name=symbol,proto3" json:"symbol,omitempty"` - Decimals int64 `protobuf:"varint,6,opt,name=decimals,proto3" json:"decimals,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,7,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` - Erc20 string `protobuf:"bytes,8,opt,name=erc20,proto3" json:"erc20,omitempty"` - GasLimit int64 `protobuf:"varint,9,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Contract string `protobuf:"bytes,3,opt,name=contract,proto3" json:"contract,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,5,opt,name=symbol,proto3" json:"symbol,omitempty"` + Decimals int64 `protobuf:"varint,6,opt,name=decimals,proto3" json:"decimals,omitempty"` + CoinType coin.CoinType `protobuf:"varint,7,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` + Erc20 string `protobuf:"bytes,8,opt,name=erc20,proto3" json:"erc20,omitempty"` + GasLimit int64 `protobuf:"varint,9,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` } func (m *EventZRC20Deployed) Reset() { *m = EventZRC20Deployed{} } @@ -180,11 +180,11 @@ func (m *EventZRC20Deployed) GetDecimals() int64 { return 0 } -func (m *EventZRC20Deployed) GetCoinType() proto1.CoinType { +func (m *EventZRC20Deployed) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *EventZRC20Deployed) GetErc20() string { @@ -202,15 +202,15 @@ func (m *EventZRC20Deployed) GetGasLimit() int64 { } type EventZRC20WithdrawFeeUpdated struct { - MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` - ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` - Zrc20Address string `protobuf:"bytes,4,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` - OldWithdrawFee string `protobuf:"bytes,5,opt,name=old_withdraw_fee,json=oldWithdrawFee,proto3" json:"old_withdraw_fee,omitempty"` - NewWithdrawFee string `protobuf:"bytes,6,opt,name=new_withdraw_fee,json=newWithdrawFee,proto3" json:"new_withdraw_fee,omitempty"` - Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` - OldGasLimit string `protobuf:"bytes,8,opt,name=old_gas_limit,json=oldGasLimit,proto3" json:"old_gas_limit,omitempty"` - NewGasLimit string `protobuf:"bytes,9,opt,name=new_gas_limit,json=newGasLimit,proto3" json:"new_gas_limit,omitempty"` + MsgTypeUrl string `protobuf:"bytes,1,opt,name=msg_type_url,json=msgTypeUrl,proto3" json:"msg_type_url,omitempty"` + ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + CoinType coin.CoinType `protobuf:"varint,3,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` + Zrc20Address string `protobuf:"bytes,4,opt,name=zrc20_address,json=zrc20Address,proto3" json:"zrc20_address,omitempty"` + OldWithdrawFee string `protobuf:"bytes,5,opt,name=old_withdraw_fee,json=oldWithdrawFee,proto3" json:"old_withdraw_fee,omitempty"` + NewWithdrawFee string `protobuf:"bytes,6,opt,name=new_withdraw_fee,json=newWithdrawFee,proto3" json:"new_withdraw_fee,omitempty"` + Signer string `protobuf:"bytes,7,opt,name=signer,proto3" json:"signer,omitempty"` + OldGasLimit string `protobuf:"bytes,8,opt,name=old_gas_limit,json=oldGasLimit,proto3" json:"old_gas_limit,omitempty"` + NewGasLimit string `protobuf:"bytes,9,opt,name=new_gas_limit,json=newGasLimit,proto3" json:"new_gas_limit,omitempty"` } func (m *EventZRC20WithdrawFeeUpdated) Reset() { *m = EventZRC20WithdrawFeeUpdated{} } @@ -260,11 +260,11 @@ func (m *EventZRC20WithdrawFeeUpdated) GetChainId() int64 { return 0 } -func (m *EventZRC20WithdrawFeeUpdated) GetCoinType() proto1.CoinType { +func (m *EventZRC20WithdrawFeeUpdated) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *EventZRC20WithdrawFeeUpdated) GetZrc20Address() string { @@ -557,55 +557,55 @@ func init() { func init() { proto.RegisterFile("fungible/events.proto", fileDescriptor_858e6494730deffd) } var fileDescriptor_858e6494730deffd = []byte{ - // 756 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xc1, 0x4e, 0xdb, 0x4a, - 0x14, 0xc5, 0x04, 0x02, 0x19, 0x08, 0x81, 0x51, 0xde, 0x93, 0x5f, 0x78, 0x2f, 0x42, 0x79, 0xaa, - 0x4a, 0x51, 0x1b, 0xa3, 0x54, 0xfd, 0x00, 0xa0, 0xa5, 0x45, 0x6a, 0xa5, 0x2a, 0x94, 0x56, 0x62, - 0x63, 0x4d, 0xec, 0x8b, 0x63, 0x61, 0xcf, 0x58, 0x9e, 0x49, 0x8c, 0xf9, 0x8a, 0x2e, 0xba, 0xe8, - 0xb7, 0xf4, 0x0b, 0xba, 0xa4, 0xea, 0xa6, 0x4b, 0x04, 0x3f, 0x52, 0xcd, 0x78, 0xec, 0xc4, 0x54, - 0x20, 0xd8, 0xcd, 0x1d, 0x9f, 0x7b, 0xef, 0x99, 0x33, 0x67, 0xae, 0xd1, 0x5f, 0x27, 0x23, 0xea, - 0xf9, 0x83, 0x00, 0x2c, 0x18, 0x03, 0x15, 0xbc, 0x1b, 0xc5, 0x4c, 0x30, 0xbc, 0x7e, 0x0e, 0x82, - 0x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, 0x34, 0x28, 0x24, 0x79, 0xef, 0x37, 0x84, 0x0f, 0x25, 0x56, 0x1a, - 0xb9, 0x8c, 0xd5, 0x2a, 0xb1, 0xc0, 0x2d, 0x61, 0x27, 0xa7, 0x9a, 0x9f, 0x3e, 0xd5, 0xee, 0xc1, - 0xf7, 0xab, 0xb6, 0x71, 0x71, 0xd5, 0x36, 0x2e, 0xaf, 0xda, 0xc6, 0xe7, 0xeb, 0xf6, 0xcc, 0xc5, - 0x75, 0x7b, 0xe6, 0xd7, 0x75, 0x7b, 0xe6, 0xd8, 0xf2, 0x7c, 0x31, 0x1c, 0x0d, 0xba, 0x0e, 0x0b, - 0x2d, 0x79, 0x29, 0xcf, 0x94, 0xd9, 0xac, 0xdc, 0x6c, 0xd6, 0x99, 0x35, 0xf9, 0xdd, 0xa4, 0x11, - 0xf0, 0x41, 0x55, 0xfd, 0x4d, 0x9e, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x34, 0xb2, 0xd9, 0x08, - 0xbb, 0x06, 0x00, 0x00, + // 761 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xd1, 0x4e, 0xdb, 0x48, + 0x14, 0xc5, 0x04, 0x02, 0x19, 0x20, 0x81, 0xd9, 0xec, 0xca, 0x1b, 0x76, 0x23, 0x94, 0xd5, 0x6a, + 0x59, 0xda, 0xc6, 0x28, 0x55, 0x3f, 0x00, 0x68, 0x69, 0x91, 0x5a, 0xa9, 0x0a, 0xa5, 0x95, 0x78, + 0xb1, 0x26, 0xf6, 0xc5, 0xb1, 0x6a, 0xcf, 0x58, 0x9e, 0x49, 0x8c, 0xf9, 0x8a, 0xbe, 0x54, 0xea, + 0xb7, 0xf4, 0x0b, 0xfa, 0x48, 0xd5, 0x97, 0x3e, 0xb6, 0xf0, 0x23, 0xd5, 0x8c, 0xc7, 0x4e, 0x4c, + 0x05, 0x85, 0x97, 0x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0xd3, 0xf9, 0x62, 0xa0, 0xa6, 0x92, 0x66, 0x37, 0x15, 0xe0, 0x30, 0xf7, + 0x0e, 0x4f, 0xe9, 0x7f, 0xb4, 0x7a, 0xcd, 0x74, 0x6c, 0x38, 0x57, 0x06, 0xdd, 0x16, 0x5a, 0x93, + 0xc6, 0x1b, 0xe8, 0x1e, 0xf6, 0x90, 0xf0, 0xa1, 0xd6, 0xa6, 0x41, 0x21, 0xc9, 0x7b, 0x3f, 0x23, + 0x7c, 0x28, 0xb1, 0xd2, 0xc8, 0x65, 0xac, 0x56, 0x89, 0x05, 0x6e, 0x09, 0x3b, 0x39, 0xd5, 0xfc, + 0xf4, 0xa9, 0x76, 0x0f, 0x3e, 0x5d, 0xb4, 0x8d, 0xf3, 0x8b, 0xb6, 0xf1, 0xed, 0xa2, 0x6d, 0xbc, + 0xbb, 0x6c, 0xcf, 0x9c, 0x5f, 0xb6, 0x67, 0xbe, 0x5e, 0xb6, 0x67, 0x8e, 0x2d, 0xcf, 0x17, 0xc3, + 0xd1, 0xa0, 0xeb, 0xb0, 0xd0, 0x92, 0x97, 0xf2, 0x40, 0x99, 0xcd, 0xca, 0xcd, 0x66, 0x9d, 0x5a, + 0x93, 0xcf, 0x4e, 0x1a, 0x01, 0x1f, 0x54, 0xd5, 0xf7, 0xe4, 0xe1, 0x8f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xbf, 0x18, 0x8d, 0x7b, 0xc3, 0x06, 0x00, 0x00, } func (m *EventSystemContractUpdated) Marshal() (dAtA []byte, err error) { @@ -1605,7 +1605,7 @@ func (m *EventZRC20Deployed) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } @@ -1776,7 +1776,7 @@ func (m *EventZRC20WithdrawFeeUpdated) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/fungible/types/expected_keepers.go b/x/fungible/types/expected_keepers.go index 3ca676ae6f..f1064b0476 100644 --- a/x/fungible/types/expected_keepers.go +++ b/x/fungible/types/expected_keepers.go @@ -11,7 +11,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/evmos/ethermint/x/evm/statedb" evmtypes "github.com/evmos/ethermint/x/evm/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" ) @@ -31,7 +31,7 @@ type BankKeeper interface { } type ObserverKeeper interface { - GetSupportedChains(ctx sdk.Context) []*pkg.Chain + GetSupportedChains(ctx sdk.Context) []*chains.Chain } type EVMKeeper interface { diff --git a/x/fungible/types/foreign_coins.pb.go b/x/fungible/types/foreign_coins.pb.go index 78f90e0d9d..05a014fa47 100644 --- a/x/fungible/types/foreign_coins.pb.go +++ b/x/fungible/types/foreign_coins.pb.go @@ -12,7 +12,7 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + coin "github.com/zeta-chain/zetacore/pkg/coin" ) // Reference imports to suppress errors if they are not otherwise used. @@ -27,14 +27,14 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ForeignCoins struct { - // string index = 1; + // string index = 1; Zrc20ContractAddress string `protobuf:"bytes,2,opt,name=zrc20_contract_address,json=zrc20ContractAddress,proto3" json:"zrc20_contract_address,omitempty"` Asset string `protobuf:"bytes,3,opt,name=asset,proto3" json:"asset,omitempty"` ForeignChainId int64 `protobuf:"varint,4,opt,name=foreign_chain_id,json=foreignChainId,proto3" json:"foreign_chain_id,omitempty"` Decimals uint32 `protobuf:"varint,5,opt,name=decimals,proto3" json:"decimals,omitempty"` Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` Symbol string `protobuf:"bytes,7,opt,name=symbol,proto3" json:"symbol,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,8,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` + CoinType coin.CoinType `protobuf:"varint,8,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` GasLimit uint64 `protobuf:"varint,9,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` Paused bool `protobuf:"varint,10,opt,name=paused,proto3" json:"paused,omitempty"` LiquidityCap github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,11,opt,name=liquidity_cap,json=liquidityCap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"liquidity_cap"` @@ -115,11 +115,11 @@ func (m *ForeignCoins) GetSymbol() string { return "" } -func (m *ForeignCoins) GetCoinType() proto1.CoinType { +func (m *ForeignCoins) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *ForeignCoins) GetGasLimit() uint64 { @@ -143,33 +143,34 @@ func init() { func init() { proto.RegisterFile("fungible/foreign_coins.proto", fileDescriptor_5285bb476cecbbf8) } var fileDescriptor_5285bb476cecbbf8 = []byte{ - // 415 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x52, 0xcf, 0x6a, 0xdb, 0x30, - 0x1c, 0x8e, 0x96, 0x34, 0x73, 0xb4, 0xa6, 0x0c, 0x11, 0x8a, 0x48, 0x87, 0x6b, 0x76, 0x99, 0x19, - 0xd4, 0x1a, 0xdd, 0x5e, 0x60, 0x0d, 0x0c, 0x0a, 0x3b, 0x99, 0xee, 0xb2, 0x8b, 0x51, 0x24, 0x55, - 0x15, 0xb1, 0x2d, 0xcd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+ // 418 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x52, 0xc1, 0x6a, 0xdc, 0x30, + 0x14, 0x5c, 0x75, 0x37, 0x5b, 0xaf, 0x9a, 0x2c, 0x45, 0x5d, 0x82, 0xd8, 0x14, 0xc7, 0xf4, 0x52, + 0x43, 0x89, 0x55, 0xd2, 0xfe, 0x40, 0x63, 0x28, 0x04, 0x7a, 0x32, 0xe9, 0xa5, 0x17, 0x23, 0x4b, + 0x8a, 0x22, 0x62, 0x5b, 0xae, 0x25, 0x43, 0x9d, 0x73, 0x3f, 0xa0, 0x9f, 0x95, 0x63, 0x8e, 0xa5, + 0x87, 0x50, 0x76, 0x7f, 0xa4, 0x48, 0x76, 0x4c, 0x2f, 0xf6, 0xcc, 0x3c, 0xbd, 0xf1, 0x3c, 0x3f, + 0xc1, 0xd7, 0xd7, 0x5d, 0x2d, 0x55, 0x51, 0x0a, 0x72, 0xad, 0x5b, 0xa1, 0x64, 0x9d, 0x33, 0xad, + 0x6a, 0x93, 0x34, 0xad, 0xb6, 0x1a, 0x9d, 0xdc, 0x09, 0x4b, 0xd9, 0x0d, 0x55, 0x75, 0xe2, 0x91, + 0x6e, 0x45, 0xf2, 0xd4, 0xb0, 0xdd, 0x48, 0x2d, 0xb5, 0x3f, 0x47, 0x1c, 0x1a, 0x5a, 0xb6, 0xaf, + 0x9a, 0x5b, 0x49, 0x9c, 0x87, 0x7f, 0x0c, 0xe2, 0x9b, 0x9f, 0x73, 0x78, 0xf8, 0x79, 0xf0, 0x4f, + 0x9d, 0x3d, 0xfa, 0x08, 0x8f, 0xef, 0x5a, 0x76, 0xfe, 0x3e, 0x67, 0xba, 0xb6, 0x2d, 0x65, 0x36, + 0xa7, 0x9c, 0xb7, 0xc2, 0x18, 0xfc, 0x2c, 0x02, 0xf1, 0x2a, 0xdb, 0xf8, 0x6a, 0x3a, 0x16, 0x3f, + 0x0d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x17, 0x97, 0xf7, 0xbb, 0x10, 0x3c, 0xec, 0x42, 0xf0, 0x77, + 0x17, 0x82, 0x5f, 0xfb, 0x70, 0xf6, 0xb0, 0x0f, 0x67, 0xbf, 0xf7, 0xe1, 0xec, 0x1b, 0xf9, 0xcf, + 0xd0, 0x6d, 0xfa, 0xcc, 0xff, 0x49, 0xf2, 0xb4, 0x74, 0xf2, 0x83, 0x4c, 0xf7, 0xc4, 0xbb, 0x17, + 0x4b, 0xbf, 0xd8, 0x0f, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x6a, 0xca, 0x24, 0xbf, 0x40, 0x02, + 0x00, 0x00, } func (m *ForeignCoins) Marshal() (dAtA []byte, err error) { @@ -531,7 +532,7 @@ func (m *ForeignCoins) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/fungible/types/message_deploy_fungible_coin_zrc20.go b/x/fungible/types/message_deploy_fungible_coin_zrc20.go index cdba98fded..6103b6ef35 100644 --- a/x/fungible/types/message_deploy_fungible_coin_zrc20.go +++ b/x/fungible/types/message_deploy_fungible_coin_zrc20.go @@ -4,14 +4,14 @@ 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/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" ) const TypeMsgDeployFungibleCoinZRC20 = "deploy_fungible_coin_zrc_20" var _ sdk.Msg = &MsgDeployFungibleCoinZRC20{} -func NewMsgDeployFungibleCoinZRC20(creator string, ERC20 string, foreignChainID int64, decimals uint32, name string, symbol string, coinType pkg.CoinType, gasLimit int64) *MsgDeployFungibleCoinZRC20 { +func NewMsgDeployFungibleCoinZRC20(creator string, ERC20 string, foreignChainID int64, decimals uint32, name string, symbol string, coinType coin.CoinType, gasLimit int64) *MsgDeployFungibleCoinZRC20 { return &MsgDeployFungibleCoinZRC20{ Creator: creator, ERC20: ERC20, diff --git a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go index bd9dbbe884..99b7ea9886 100644 --- a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/fungible/types" ) @@ -27,7 +27,7 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { 6, "test", "test", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, 10, ), err: sdkerrors.ErrInvalidAddress, @@ -41,7 +41,7 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { 6, "test", "test", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, -1, ), err: sdkerrors.ErrInvalidGasLimit, @@ -55,7 +55,7 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { 78, "test", "test", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, 10, ), err: cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "decimals must be less than 78"), @@ -69,7 +69,7 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { 6, "test", "test", - pkg.CoinType_ERC20, + coin.CoinType_ERC20, 10, ), }, diff --git a/x/fungible/types/tx.pb.go b/x/fungible/types/tx.pb.go index fcc5774138..a4db855245 100644 --- a/x/fungible/types/tx.pb.go +++ b/x/fungible/types/tx.pb.go @@ -14,7 +14,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + coin "github.com/zeta-chain/zetacore/pkg/coin" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -355,14 +355,14 @@ func (m *MsgUpdateSystemContractResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateSystemContractResponse proto.InternalMessageInfo type MsgDeployFungibleCoinZRC20 struct { - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - ERC20 string `protobuf:"bytes,2,opt,name=ERC20,proto3" json:"ERC20,omitempty"` - ForeignChainId int64 `protobuf:"varint,3,opt,name=foreign_chain_id,json=foreignChainId,proto3" json:"foreign_chain_id,omitempty"` - Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` - Symbol string `protobuf:"bytes,6,opt,name=symbol,proto3" json:"symbol,omitempty"` - CoinType proto1.CoinType `protobuf:"varint,7,opt,name=coin_type,json=coinType,proto3,enum=pkg.CoinType" json:"coin_type,omitempty"` - GasLimit int64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + ERC20 string `protobuf:"bytes,2,opt,name=ERC20,proto3" json:"ERC20,omitempty"` + ForeignChainId int64 `protobuf:"varint,3,opt,name=foreign_chain_id,json=foreignChainId,proto3" json:"foreign_chain_id,omitempty"` + Decimals uint32 `protobuf:"varint,4,opt,name=decimals,proto3" json:"decimals,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Symbol string `protobuf:"bytes,6,opt,name=symbol,proto3" json:"symbol,omitempty"` + CoinType coin.CoinType `protobuf:"varint,7,opt,name=coin_type,json=coinType,proto3,enum=coin.CoinType" json:"coin_type,omitempty"` + GasLimit int64 `protobuf:"varint,8,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` } func (m *MsgDeployFungibleCoinZRC20) Reset() { *m = MsgDeployFungibleCoinZRC20{} } @@ -440,11 +440,11 @@ func (m *MsgDeployFungibleCoinZRC20) GetSymbol() string { return "" } -func (m *MsgDeployFungibleCoinZRC20) GetCoinType() proto1.CoinType { +func (m *MsgDeployFungibleCoinZRC20) GetCoinType() coin.CoinType { if m != nil { return m.CoinType } - return proto1.CoinType_Zeta + return coin.CoinType_Zeta } func (m *MsgDeployFungibleCoinZRC20) GetGasLimit() int64 { @@ -890,70 +890,70 @@ func init() { func init() { proto.RegisterFile("fungible/tx.proto", fileDescriptor_197fdedece277fa0) } var fileDescriptor_197fdedece277fa0 = []byte{ - // 999 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x5d, 0x6b, 0x1b, 0x47, - 0x14, 0xd5, 0xda, 0xf1, 0x87, 0x6e, 0x22, 0x59, 0x19, 0xd4, 0x64, 0x2b, 0x17, 0x39, 0xd9, 0x84, - 0xc6, 0x35, 0x44, 0x9b, 0xaa, 0x69, 0x43, 0xa1, 0x49, 0xb1, 0x15, 0xbb, 0x0d, 0x44, 0x25, 0xac, - 0xe3, 0x94, 0xfa, 0x65, 0x19, 0xef, 0x8e, 0x57, 0x8b, 0xa5, 0x9d, 0xed, 0xce, 0xa8, 0x8a, 0xf2, - 0x56, 0x28, 0x14, 0x02, 0x2d, 0x81, 0xfe, 0x8f, 0x42, 0xff, 0x45, 0x1e, 0xf3, 0x58, 0x4a, 0x31, - 0xc5, 0xfe, 0x23, 0x65, 0x66, 0x3f, 0xbc, 0xfa, 0x58, 0xd9, 0x52, 0x9e, 0x3c, 0x33, 0xbe, 0xe7, - 0xec, 0xb9, 0x77, 0xee, 0x3d, 0xab, 0x85, 0xab, 0x87, 0x5d, 0xcf, 0x71, 0x0f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59, 0x81, 0xab, 0xa3, 0x16, 0xf1, 0xe9, 0x79, - 0xb4, 0x23, 0x90, 0xca, 0x97, 0x53, 0x43, 0x12, 0x0d, 0xaf, 0x15, 0x28, 0x8f, 0x7d, 0x0f, 0xdd, - 0x3f, 0x8f, 0x73, 0x1c, 0xaa, 0xf2, 0xd5, 0x2c, 0xa8, 0x44, 0xcc, 0x1b, 0x05, 0xae, 0x65, 0x98, - 0xd9, 0x17, 0x17, 0x23, 0x1e, 0xc6, 0x55, 0x1e, 0xcd, 0x86, 0x1b, 0x23, 0x69, 0xe4, 0x87, 0xcd, - 0x05, 0x25, 0x0d, 0xe3, 0x2e, 0x2a, 0x29, 0xeb, 0xc7, 0x83, 0x6c, 0xe6, 0x2c, 0x1b, 0x7d, 0x30, - 0x05, 0x77, 0x1a, 0x78, 0x7e, 0x33, 0x9f, 0x63, 0x84, 0xc3, 0xaa, 0x06, 0x5c, 0x70, 0x1a, 0x55, - 0x69, 0xe0, 0x54, 0xaa, 0xc6, 0x99, 0xd8, 0xd6, 0x93, 0xb7, 0x27, 0x55, 0xe5, 0xdd, 0x49, 0x55, - 0xf9, 0xef, 0xa4, 0xaa, 0xbc, 0x39, 0xad, 0xe6, 0xde, 0x9d, 0x56, 0x73, 0x7f, 0x9f, 0x56, 0x73, - 0xfb, 0x7a, 0xca, 0x3b, 0x05, 0xf5, 0x5d, 0xf9, 0x14, 0x3d, 0x7e, 0x8a, 0xfe, 0x52, 0x3f, 0xfb, - 0x7e, 0x10, 0x46, 0x7a, 0xb0, 0x28, 0xbf, 0x00, 0x3e, 0xfb, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x7f, - 0xff, 0xad, 0xf0, 0x58, 0x0c, 0x00, 0x00, + // 1001 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xae, 0xdb, 0xf5, 0x23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 0x22, 0xb6, 0xf5, 0xf0, 0xf5, 0x51, 0x55, 0x79, 0x73, 0x54, + 0x55, 0xfe, 0x3b, 0xaa, 0x2a, 0xaf, 0x8e, 0xab, 0x73, 0x6f, 0x8e, 0xab, 0x73, 0x7f, 0x1f, 0x57, + 0xe7, 0xf6, 0x8d, 0x8c, 0x76, 0x0a, 0xe8, 0x5b, 0xf2, 0x29, 0x46, 0xf2, 0x14, 0xe3, 0xb9, 0x71, + 0xf2, 0x33, 0x42, 0x08, 0xe9, 0xc1, 0x92, 0xfc, 0x09, 0xf0, 0xd9, 0xff, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x72, 0x83, 0xf4, 0x62, 0x5f, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -3058,7 +3058,7 @@ func (m *MsgDeployFungibleCoinZRC20) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.CoinType |= proto1.CoinType(b&0x7F) << shift + m.CoinType |= coin.CoinType(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/observer/genesis.go b/x/observer/genesis.go index 61236567a3..7e3ff44311 100644 --- a/x/observer/genesis.go +++ b/x/observer/genesis.go @@ -2,7 +2,7 @@ package observer import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/observer/keeper" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -106,7 +106,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetPendingNonces(ctx, pendingNonce) } } else { - for _, chain := range pkg.DefaultChainsList() { + for _, chain := range chains.DefaultChainsList() { if genState.Tss != nil { k.SetPendingNonces(ctx, types.PendingNonces{ NonceLow: 0, diff --git a/x/observer/keeper/block_header.go b/x/observer/keeper/block_header.go index 1ed54c9edd..aaf06bca4b 100644 --- a/x/observer/keeper/block_header.go +++ b/x/observer/keeper/block_header.go @@ -5,19 +5,19 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/x/observer/types" ) // SetBlockHeader set a specific block header in the store from its index -func (k Keeper) SetBlockHeader(ctx sdk.Context, header pkg.BlockHeader) { +func (k Keeper) SetBlockHeader(ctx sdk.Context, header proofs.BlockHeader) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) b := k.cdc.MustMarshal(&header) store.Set(header.Hash, b) } // GetBlockHeader returns a block header from its hash -func (k Keeper) GetBlockHeader(ctx sdk.Context, hash []byte) (val pkg.BlockHeader, found bool) { +func (k Keeper) GetBlockHeader(ctx sdk.Context, hash []byte) (val proofs.BlockHeader, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.BlockHeaderKey)) b := store.Get(hash) diff --git a/x/observer/keeper/chain_params.go b/x/observer/keeper/chain_params.go index f0db89368f..7b5e0a246e 100644 --- a/x/observer/keeper/chain_params.go +++ b/x/observer/keeper/chain_params.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -42,7 +42,7 @@ func (k Keeper) GetChainParamsByChainID(ctx sdk.Context, chainID int64) (*types. // GetSupportedChainFromChainID returns the chain from the chain id // it returns nil if the chain doesn't exist or is not supported -func (k Keeper) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *pkg.Chain { +func (k Keeper) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *chains.Chain { cpl, found := k.GetChainParamsList(ctx) if !found { return nil @@ -50,24 +50,24 @@ func (k Keeper) GetSupportedChainFromChainID(ctx sdk.Context, chainID int64) *pk for _, cp := range cpl.ChainParams { if cp.ChainId == chainID && cp.IsSupported { - return pkg.GetChainFromChainID(chainID) + return chains.GetChainFromChainID(chainID) } } return nil } // GetSupportedChains returns the list of supported chains -func (k Keeper) GetSupportedChains(ctx sdk.Context) []*pkg.Chain { +func (k Keeper) GetSupportedChains(ctx sdk.Context) []*chains.Chain { cpl, found := k.GetChainParamsList(ctx) if !found { - return []*pkg.Chain{} + return []*chains.Chain{} } - var chains []*pkg.Chain + var c []*chains.Chain for _, cp := range cpl.ChainParams { if cp.IsSupported { - chains = append(chains, pkg.GetChainFromChainID(cp.ChainId)) + c = append(c, chains.GetChainFromChainID(cp.ChainId)) } } - return chains + return c } diff --git a/x/observer/keeper/chain_params_test.go b/x/observer/keeper/chain_params_test.go index 0818ec2a71..3464c950fa 100644 --- a/x/observer/keeper/chain_params_test.go +++ b/x/observer/keeper/chain_params_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -49,12 +49,12 @@ func TestKeeper_GetSupportedChains(t *testing.T) { t.Run("return list containing supported chains", func(t *testing.T) { k, ctx, _, _ := keepertest.ObserverKeeper(t) - require.Greater(t, len(pkg.ExternalChainList()), 5) - supported1 := pkg.ExternalChainList()[0] - supported2 := pkg.ExternalChainList()[1] - unsupported := pkg.ExternalChainList()[2] - supported3 := pkg.ExternalChainList()[3] - supported4 := pkg.ExternalChainList()[4] + require.Greater(t, len(chains.ExternalChainList()), 5) + supported1 := chains.ExternalChainList()[0] + supported2 := chains.ExternalChainList()[1] + unsupported := chains.ExternalChainList()[2] + supported3 := chains.ExternalChainList()[3] + supported4 := chains.ExternalChainList()[4] var chainParamsList []*types.ChainParams chainParamsList = append(chainParamsList, sample.ChainParamsSupported(supported1.ChainId)) diff --git a/x/observer/keeper/grpc_query_block_header.go b/x/observer/keeper/grpc_query_block_header.go index 7ae2d72662..18e9c955c6 100644 --- a/x/observer/keeper/grpc_query_block_header.go +++ b/x/observer/keeper/grpc_query_block_header.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -22,9 +22,9 @@ func (k Keeper) GetAllBlockHeaders(c context.Context, req *types.QueryAllBlockHe store := ctx.KVStore(k.storeKey) blockHeaderStore := prefix.NewStore(store, types.KeyPrefix(types.BlockHeaderKey)) - var blockHeaders []*pkg.BlockHeader + var blockHeaders []*proofs.BlockHeader pageRes, err := query.Paginate(blockHeaderStore, req.Pagination, func(key []byte, value []byte) error { - var blockHeader pkg.BlockHeader + var blockHeader proofs.BlockHeader if err := k.cdc.Unmarshal(value, &blockHeader); err != nil { return err } diff --git a/x/observer/keeper/grpc_query_prove.go b/x/observer/keeper/grpc_query_prove.go index 219d77ba61..edfd0588e5 100644 --- a/x/observer/keeper/grpc_query_prove.go +++ b/x/observer/keeper/grpc_query_prove.go @@ -5,7 +5,8 @@ import ( "fmt" "github.com/btcsuite/btcutil" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" sdk "github.com/cosmos/cosmos-sdk/types" ethtypes "github.com/ethereum/go-ethereum/core/types" @@ -23,7 +24,7 @@ func (k Keeper) Prove(c context.Context, req *types.QueryProveRequest) (*types.Q } ctx := sdk.UnwrapSDKContext(c) - blockHash, err := pkg.StringToHash(req.ChainId, req.BlockHash) + blockHash, err := chains.StringToHash(req.ChainId, req.BlockHash) if err != nil { return nil, status.Error(codes.InvalidArgument, err.Error()) } @@ -35,11 +36,11 @@ func (k Keeper) Prove(c context.Context, req *types.QueryProveRequest) (*types.Q proven := false txBytes, err := req.Proof.Verify(res.Header, int(req.TxIndex)) - if err != nil && !pkg.IsErrorInvalidProof(err) { + if err != nil && !proofs.IsErrorInvalidProof(err) { return nil, status.Error(codes.Internal, err.Error()) } if err == nil { - if pkg.IsEVMChain(req.ChainId) { + if chains.IsEVMChain(req.ChainId) { var txx ethtypes.Transaction err = txx.UnmarshalBinary(txBytes) if err != nil { @@ -49,7 +50,7 @@ func (k Keeper) Prove(c context.Context, req *types.QueryProveRequest) (*types.Q return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("tx hash mismatch: %s != %s", txx.Hash().Hex(), req.TxHash)) } proven = true - } else if pkg.IsBitcoinChain(req.ChainId) { + } else if chains.IsBitcoinChain(req.ChainId) { tx, err := btcutil.NewTxFromBytes(txBytes) if err != nil { return nil, status.Error(codes.Internal, fmt.Sprintf("failed to unmarshal btc transaction: %s", err)) diff --git a/x/observer/keeper/grpc_query_tss.go b/x/observer/keeper/grpc_query_tss.go index 3be419e3ab..48485f0112 100644 --- a/x/observer/keeper/grpc_query_tss.go +++ b/x/observer/keeper/grpc_query_tss.go @@ -5,7 +5,8 @@ import ( "sort" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/crypto" "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -45,18 +46,18 @@ func (k Keeper) GetTssAddress(goCtx context.Context, req *types.QueryGetTssAddre if !found { return nil, status.Error(codes.NotFound, "current tss not set") } - ethAddress, err := pkg.GetTssAddrEVM(tss.TssPubkey) + ethAddress, err := crypto.GetTssAddrEVM(tss.TssPubkey) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - bitcoinParams := pkg.BitcoinRegnetParams + bitcoinParams := chains.BitcoinRegnetParams if req.BitcoinChainId != 0 { - bitcoinParams, err = pkg.BitcoinNetParamsFromChainID(req.BitcoinChainId) + bitcoinParams, err = chains.BitcoinNetParamsFromChainID(req.BitcoinChainId) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } } - btcAddress, err := pkg.GetTssAddrBTC(tss.TssPubkey, bitcoinParams) + btcAddress, err := crypto.GetTssAddrBTC(tss.TssPubkey, bitcoinParams) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -76,18 +77,18 @@ func (k Keeper) GetTssAddressByFinalizedHeight(goCtx context.Context, req *types if !found { return nil, status.Error(codes.NotFound, "tss not found") } - ethAddress, err := pkg.GetTssAddrEVM(tss.TssPubkey) + ethAddress, err := crypto.GetTssAddrEVM(tss.TssPubkey) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } - bitcoinParams := pkg.BitcoinRegnetParams + bitcoinParams := chains.BitcoinRegnetParams if req.BitcoinChainId != 0 { - bitcoinParams, err = pkg.BitcoinNetParamsFromChainID(req.BitcoinChainId) + bitcoinParams, err = chains.BitcoinNetParamsFromChainID(req.BitcoinChainId) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } } - btcAddress, err := pkg.GetTssAddrBTC(tss.TssPubkey, bitcoinParams) + btcAddress, err := crypto.GetTssAddrBTC(tss.TssPubkey, bitcoinParams) if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/observer/keeper/msg_server_add_block_header.go b/x/observer/keeper/msg_server_add_block_header.go index 11a80923de..427ab53175 100644 --- a/x/observer/keeper/msg_server_add_block_header.go +++ b/x/observer/keeper/msg_server_add_block_header.go @@ -6,7 +6,8 @@ import ( cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -31,10 +32,10 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH if crosschainFlags.BlockHeaderVerificationFlags == nil { return nil, fmt.Errorf("block header verification flags not found") } - if pkg.IsBitcoinChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { + if chains.IsBitcoinChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsBtcTypeChainEnabled { return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for bitcoin ,chain id: %d", msg.ChainId) } - if pkg.IsEVMChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { + if chains.IsEVMChain(msg.ChainId) && !crosschainFlags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled { return nil, cosmoserrors.Wrapf(types.ErrBlockHeaderVerificationDisabled, "proof verification not enabled for evm ,chain id: %d", msg.ChainId) } @@ -111,7 +112,7 @@ func (k msgServer) AddBlockHeader(goCtx context.Context, msg *types.MsgAddBlockH } k.Keeper.SetBlockHeaderState(ctx, bhs) - bh := pkg.BlockHeader{ + bh := proofs.BlockHeader{ Header: msg.Header, Height: msg.Height, Hash: msg.BlockHash, diff --git a/x/observer/keeper/msg_server_add_block_header_test.go b/x/observer/keeper/msg_server_add_block_header_test.go index 7d9cf3ce94..f5fc68f55a 100644 --- a/x/observer/keeper/msg_server_add_block_header_test.go +++ b/x/observer/keeper/msg_server_add_block_header_test.go @@ -11,7 +11,8 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/ethereum/go-ethereum/rlp" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/keeper" @@ -45,10 +46,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { name: "success submit eth header", msg: &types.MsgAddBlockHeader{ Creator: observerAddress.String(), - ChainId: pkg.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, - Header: pkg.NewEthereumHeader(header1RLP), + Header: proofs.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, @@ -59,10 +60,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { name: "failure submit eth header eth disabled", msg: &types.MsgAddBlockHeader{ Creator: observerAddress.String(), - ChainId: pkg.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, - Header: pkg.NewEthereumHeader(header1RLP), + Header: proofs.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, @@ -75,10 +76,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { name: "failure submit eth header eth disabled", msg: &types.MsgAddBlockHeader{ Creator: sample.AccAddress(), - ChainId: pkg.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain().ChainId, BlockHash: header.Hash().Bytes(), Height: 1, - Header: pkg.NewEthereumHeader(header1RLP), + Header: proofs.NewEthereumHeader(header1RLP), }, IsEthTypeChainEnabled: false, IsBtcTypeChainEnabled: true, @@ -91,10 +92,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { name: "should succeed if block header parent does exist", msg: &types.MsgAddBlockHeader{ Creator: observerAddress.String(), - ChainId: pkg.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain().ChainId, BlockHash: header2.Hash().Bytes(), Height: 2, - Header: pkg.NewEthereumHeader(header2RLP), + Header: proofs.NewEthereumHeader(header2RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, @@ -109,10 +110,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { // name: "should fail if block header parent does not exist", // msg: &types.MsgAddBlockHeader{ // Creator: observerAddress.String(), - // ChainId: pkg.GoerliLocalnetChain().ChainId, + // ChainId: chains.GoerliLocalnetChain().ChainId, // BlockHash: header3.Hash().Bytes(), // Height: 3, - // Header: pkg.NewEthereumHeader(header3RLP), + // Header: chains.NewEthereumHeader(header3RLP), // }, // IsEthTypeChainEnabled: true, // IsBtcTypeChainEnabled: true, @@ -125,10 +126,10 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { // name: "should succeed to post 3rd header if 2nd header is posted", // msg: &types.MsgAddBlockHeader{ // Creator: observerAddress.String(), - // ChainId: pkg.GoerliLocalnetChain().ChainId, + // ChainId: chains.GoerliLocalnetChain().ChainId, // BlockHash: header3.Hash().Bytes(), // Height: 3, - // Header: pkg.NewEthereumHeader(header3RLP), + // Header: chains.NewEthereumHeader(header3RLP), // }, // IsEthTypeChainEnabled: true, // IsBtcTypeChainEnabled: true, @@ -144,7 +145,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { ChainId: 9999, BlockHash: header3.Hash().Bytes(), Height: 3, - Header: pkg.NewEthereumHeader(header3RLP), + Header: proofs.NewEthereumHeader(header3RLP), }, IsEthTypeChainEnabled: true, IsBtcTypeChainEnabled: true, @@ -172,7 +173,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) { }, }) - setSupportedChain(ctx, *k, pkg.GoerliLocalnetChain().ChainId) + setSupportedChain(ctx, *k, chains.GoerliLocalnetChain().ChainId) _, err := srv.AddBlockHeader(ctx, tc.msg) tc.wantErr(t, err) diff --git a/x/observer/keeper/msg_server_add_observer.go b/x/observer/keeper/msg_server_add_observer.go index cf15b3fa2a..7ea31c9ed2 100644 --- a/x/observer/keeper/msg_server_add_observer.go +++ b/x/observer/keeper/msg_server_add_observer.go @@ -4,12 +4,12 @@ import ( "context" "math" + "github.com/zeta-chain/zetacore/pkg/crypto" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -22,11 +22,11 @@ func (k msgServer) AddObserver(goCtx context.Context, msg *types.MsgAddObserver) return &types.MsgAddObserverResponse{}, types.ErrNotAuthorizedPolicy } - pubkey, err := pkg.NewPubKey(msg.ZetaclientGranteePubkey) + pubkey, err := crypto.NewPubKey(msg.ZetaclientGranteePubkey) if err != nil { return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) } - granteeAddress, err := pkg.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) + granteeAddress, err := crypto.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) if err != nil { return &types.MsgAddObserverResponse{}, cosmoserrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) } @@ -38,7 +38,7 @@ func (k msgServer) AddObserver(goCtx context.Context, msg *types.MsgAddObserver) // False: adds observer to the observer list, and not the node account list // Inbound is disabled in both cases and needs to be enabled manually using an admin TX if msg.AddNodeAccountOnly { - pubkeySet := pkg.PubKeySet{Secp256k1: pubkey, Ed25519: ""} + pubkeySet := crypto.PubKeySet{Secp256k1: pubkey, Ed25519: ""} k.SetNodeAccount(ctx, types.NodeAccount{ Operator: msg.ObserverAddress, GranteeAddress: granteeAddress.String(), diff --git a/x/observer/keeper/msg_server_remove_chain_params_test.go b/x/observer/keeper/msg_server_remove_chain_params_test.go index f85e4e3af8..6faaa0325a 100644 --- a/x/observer/keeper/msg_server_remove_chain_params_test.go +++ b/x/observer/keeper/msg_server_remove_chain_params_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -23,9 +23,9 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { // mock the authority keeper for authorization authorityMock := keepertest.GetObserverAuthorityMock(t, k) - chain1 := pkg.ExternalChainList()[0].ChainId - chain2 := pkg.ExternalChainList()[1].ChainId - chain3 := pkg.ExternalChainList()[2].ChainId + chain1 := chains.ExternalChainList()[0].ChainId + chain2 := chains.ExternalChainList()[1].ChainId + chain3 := chains.ExternalChainList()[2].ChainId // set admin admin := sample.AccAddress() @@ -97,7 +97,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { _, err := srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, }) require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }) @@ -119,16 +119,16 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { _, err := srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, }) require.ErrorIs(t, err, types.ErrChainParamsNotFound) // add chain params k.SetChainParamsList(ctx, types.ChainParamsList{ ChainParams: []*types.ChainParams{ - sample.ChainParams(pkg.ExternalChainList()[0].ChainId), - sample.ChainParams(pkg.ExternalChainList()[1].ChainId), - sample.ChainParams(pkg.ExternalChainList()[2].ChainId), + sample.ChainParams(chains.ExternalChainList()[0].ChainId), + sample.ChainParams(chains.ExternalChainList()[1].ChainId), + sample.ChainParams(chains.ExternalChainList()[2].ChainId), }, }) @@ -137,7 +137,7 @@ func TestMsgServer_RemoveChainParams(t *testing.T) { // not found if chain ID not in list _, err = srv.RemoveChainParams(sdk.WrapSDKContext(ctx), &types.MsgRemoveChainParams{ Creator: admin, - ChainId: pkg.ExternalChainList()[3].ChainId, + ChainId: chains.ExternalChainList()[3].ChainId, }) require.ErrorIs(t, err, types.ErrChainParamsNotFound) }) diff --git a/x/observer/keeper/msg_server_reset_chain_nonces.go b/x/observer/keeper/msg_server_reset_chain_nonces.go index feb23b58c4..211b4dee8c 100644 --- a/x/observer/keeper/msg_server_reset_chain_nonces.go +++ b/x/observer/keeper/msg_server_reset_chain_nonces.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -22,7 +22,7 @@ func (k msgServer) ResetChainNonces(goCtx context.Context, msg *types.MsgResetCh return nil, types.ErrTssNotFound } - chain := pkg.GetChainFromChainID(msg.ChainId) + chain := chains.GetChainFromChainID(msg.ChainId) if chain == nil { return nil, types.ErrSupportedChains } diff --git a/x/observer/keeper/msg_server_reset_chain_nonces_test.go b/x/observer/keeper/msg_server_reset_chain_nonces_test.go index 0b1e60e4c6..58f673c3ba 100644 --- a/x/observer/keeper/msg_server_reset_chain_nonces_test.go +++ b/x/observer/keeper/msg_server_reset_chain_nonces_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -19,7 +19,7 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { UseAuthorityMock: true, }) srv := keeper.NewMsgServerImpl(*k) - chainId := pkg.GoerliLocalnetChain().ChainId + chainId := chains.GoerliLocalnetChain().ChainId admin := sample.AccAddress() authorityMock := keepertest.GetObserverAuthorityMock(t, k) @@ -44,7 +44,7 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { authorityMock := keepertest.GetObserverAuthorityMock(t, k) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) - chainId := pkg.GoerliLocalnetChain().ChainId + chainId := chains.GoerliLocalnetChain().ChainId _, err := srv.ResetChainNonces(sdk.WrapSDKContext(ctx), &types.MsgResetChainNonces{ Creator: admin, ChainId: chainId, @@ -88,8 +88,8 @@ func TestMsgServer_ResetChainNonces(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupAdmin, true) - chainId := pkg.GoerliLocalnetChain().ChainId - index := pkg.GoerliLocalnetChain().ChainName.String() + chainId := chains.GoerliLocalnetChain().ChainId + index := chains.GoerliLocalnetChain().ChainName.String() // check existing chain nonces _, found := k.GetChainNonces(ctx, index) diff --git a/x/observer/keeper/msg_server_update_chain_params_test.go b/x/observer/keeper/msg_server_update_chain_params_test.go index 917f27b8db..274730a4bf 100644 --- a/x/observer/keeper/msg_server_update_chain_params_test.go +++ b/x/observer/keeper/msg_server_update_chain_params_test.go @@ -3,11 +3,11 @@ package keeper_test import ( "testing" + "github.com/zeta-chain/zetacore/pkg/chains" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/keeper" @@ -21,9 +21,9 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { }) srv := keeper.NewMsgServerImpl(*k) - chain1 := pkg.ExternalChainList()[0].ChainId - chain2 := pkg.ExternalChainList()[1].ChainId - chain3 := pkg.ExternalChainList()[2].ChainId + chain1 := chains.ExternalChainList()[0].ChainId + chain2 := chains.ExternalChainList()[1].ChainId + chain3 := chains.ExternalChainList()[2].ChainId // set admin admin := sample.AccAddress() @@ -115,7 +115,7 @@ func TestMsgServer_UpdateChainParams(t *testing.T) { _, err := srv.UpdateChainParams(sdk.WrapSDKContext(ctx), &types.MsgUpdateChainParams{ Creator: admin, - ChainParams: sample.ChainParams(pkg.ExternalChainList()[0].ChainId), + ChainParams: sample.ChainParams(chains.ExternalChainList()[0].ChainId), }) require.ErrorIs(t, err, types.ErrNotAuthorizedPolicy) }) diff --git a/x/observer/keeper/utils.go b/x/observer/keeper/utils.go index 77270fa561..95787cf1a1 100644 --- a/x/observer/keeper/utils.go +++ b/x/observer/keeper/utils.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -48,7 +48,7 @@ func (k Keeper) IsAuthorized(ctx sdk.Context, address string) bool { func (k Keeper) FindBallot( ctx sdk.Context, index string, - chain *pkg.Chain, + chain *chains.Chain, observationType types.ObservationType, ) (ballot types.Ballot, isNew bool, err error) { isNew = false diff --git a/x/observer/keeper/utils_test.go b/x/observer/keeper/utils_test.go index 16edfeeda8..8a59bfe310 100644 --- a/x/observer/keeper/utils_test.go +++ b/x/observer/keeper/utils_test.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/keeper" @@ -32,9 +32,9 @@ func setSupportedChain(ctx sdk.Context, observerKeeper keeper.Keeper, chainIDs . func getValidEthChainIDWithIndex(t *testing.T, index int) int64 { switch index { case 0: - return pkg.GoerliLocalnetChain().ChainId + return chains.GoerliLocalnetChain().ChainId case 1: - return pkg.GoerliChain().ChainId + return chains.GoerliChain().ChainId default: require.Fail(t, "invalid index") } diff --git a/x/observer/keeper/vote_inbound.go b/x/observer/keeper/vote_inbound.go index 0903fdc3e5..31b56912e5 100644 --- a/x/observer/keeper/vote_inbound.go +++ b/x/observer/keeper/vote_inbound.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -16,7 +16,7 @@ func (k Keeper) VoteOnInboundBallot( ctx sdk.Context, senderChainID int64, receiverChainID int64, - coinType pkg.CoinType, + coinType coin.CoinType, voter string, ballotIndex string, inTxHash string, @@ -58,7 +58,7 @@ func (k Keeper) VoteOnInboundBallot( if !found { return false, false, types.ErrChainParamsNotFound } - if coreParams.ZetaTokenContractAddress == "" && coinType == pkg.CoinType_Zeta { + if coreParams.ZetaTokenContractAddress == "" && coinType == coin.CoinType_Zeta { return false, false, types.ErrInvalidZetaCoinTypes } } diff --git a/x/observer/keeper/vote_inbound_test.go b/x/observer/keeper/vote_inbound_test.go index 0197892216..41a3999b75 100644 --- a/x/observer/keeper/vote_inbound_test.go +++ b/x/observer/keeper/vote_inbound_test.go @@ -5,7 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "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" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -23,8 +24,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, sample.AccAddress(), "index", "inTxHash", @@ -45,8 +46,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, sample.AccAddress(), "index", "inTxHash", @@ -67,8 +68,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, sample.AccAddress(), "index", "inTxHash", @@ -96,8 +97,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, sample.AccAddress(), "index", "inTxHash", @@ -133,8 +134,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err := k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, observer, "index", "inTxHash", @@ -150,7 +151,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { IsSupported: true, }, { - ChainId: pkg.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain().ChainId, IsSupported: false, }, }, @@ -161,8 +162,8 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { _, _, err = k.VoteOnInboundBallot( ctx, getValidEthChainIDWithIndex(t, 0), - pkg.ZetaPrivnetChain().ChainId, - pkg.CoinType_ERC20, + chains.ZetaPrivnetChain().ChainId, + coin.CoinType_ERC20, observer, "index", "inTxHash", @@ -204,7 +205,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { ctx, getValidEthChainIDWithIndex(t, 0), getValidEthChainIDWithIndex(t, 1), - pkg.CoinType_Zeta, + coin.CoinType_Zeta, observer, "index", "inTxHash", @@ -245,7 +246,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { ctx, getValidEthChainIDWithIndex(t, 0), getValidEthChainIDWithIndex(t, 1), - pkg.CoinType_ERC20, + coin.CoinType_ERC20, observer, "index", "inTxHash", @@ -298,7 +299,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { ctx, getValidEthChainIDWithIndex(t, 0), getValidEthChainIDWithIndex(t, 1), - pkg.CoinType_ERC20, + coin.CoinType_ERC20, observer, "index", "inTxHash", @@ -362,7 +363,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { ctx, getValidEthChainIDWithIndex(t, 0), getValidEthChainIDWithIndex(t, 1), - pkg.CoinType_ERC20, + coin.CoinType_ERC20, observer, "index", "inTxHash", @@ -424,7 +425,7 @@ func TestKeeper_VoteOnInboundBallot(t *testing.T) { ctx, getValidEthChainIDWithIndex(t, 0), getValidEthChainIDWithIndex(t, 1), - pkg.CoinType_ERC20, + coin.CoinType_ERC20, observer, "index", "inTxHash", diff --git a/x/observer/keeper/vote_outbound.go b/x/observer/keeper/vote_outbound.go index b118298bb7..34f3c73fc0 100644 --- a/x/observer/keeper/vote_outbound.go +++ b/x/observer/keeper/vote_outbound.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -15,7 +15,7 @@ func (k Keeper) VoteOnOutboundBallot( ctx sdk.Context, ballotIndex string, outTxChainID int64, - receiveStatus pkg.ReceiveStatus, + receiveStatus chains.ReceiveStatus, voter string, ) (isFinalized bool, isNew bool, ballot observertypes.Ballot, observationChainName string, err error) { // Observer Chain already checked then inbound is created diff --git a/x/observer/keeper/vote_outbound_test.go b/x/observer/keeper/vote_outbound_test.go index fb9ba8dc67..fa34a11ca6 100644 --- a/x/observer/keeper/vote_outbound_test.go +++ b/x/observer/keeper/vote_outbound_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -21,7 +21,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, sample.AccAddress(), ) require.Error(t, err) @@ -41,7 +41,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, sample.AccAddress(), ) require.Error(t, err) @@ -64,7 +64,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus(1000), + chains.ReceiveStatus(1000), sample.AccAddress(), ) require.Error(t, err) @@ -88,7 +88,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, sample.AccAddress(), ) require.Error(t, err) @@ -120,7 +120,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, observer, ) require.NoError(t, err) @@ -166,7 +166,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, observer, ) require.NoError(t, err) @@ -224,7 +224,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, observer, ) require.NoError(t, err) @@ -280,7 +280,7 @@ func TestKeeper_VoteOnOutboundBallot(t *testing.T) { ctx, "index", getValidEthChainIDWithIndex(t, 0), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, observer, ) require.NoError(t, err) diff --git a/x/observer/migrations/v5/migrate_test.go b/x/observer/migrations/v5/migrate_test.go index 78479d69cb..40d072230d 100644 --- a/x/observer/migrations/v5/migrate_test.go +++ b/x/observer/migrations/v5/migrate_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" v5 "github.com/zeta-chain/zetacore/x/observer/migrations/v5" @@ -68,13 +68,13 @@ func TestMigrateObserverParams(t *testing.T) { params := types.Params{ ObserverParams: []*types.ObserverParams{ { - Chain: &pkg.Chain{ChainId: 2}, + Chain: &chains.Chain{ChainId: 2}, BallotThreshold: dec42, MinObserverDelegation: dec1000, IsSupported: true, }, { - Chain: &pkg.Chain{ChainId: 3}, + Chain: &chains.Chain{ChainId: 3}, BallotThreshold: dec43, MinObserverDelegation: dec1001, IsSupported: true, diff --git a/x/observer/types/chain_nonces.pb.go b/x/observer/types/chain_nonces.pb.go index 6edb1c1d64..18090e8ec5 100644 --- a/x/observer/types/chain_nonces.pb.go +++ b/x/observer/types/chain_nonces.pb.go @@ -11,7 +11,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/zeta-chain/zetacore/pkg/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -116,25 +115,24 @@ func init() { func init() { proto.RegisterFile("observer/chain_nonces.proto", fileDescriptor_a4a180ef3ffea001) } var fileDescriptor_a4a180ef3ffea001 = []byte{ - // 275 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3d, 0x4e, 0xc4, 0x30, - 0x10, 0x85, 0x63, 0xb2, 0x3f, 0x60, 0x84, 0x90, 0xa2, 0x2d, 0xcc, 0xae, 0x64, 0x45, 0x54, 0x69, - 0x88, 0x0b, 0x6e, 0x00, 0x0d, 0xdb, 0x50, 0xa4, 0xa4, 0x41, 0xf9, 0x19, 0x1c, 0x6b, 0xc1, 0x8e, - 0x1c, 0x83, 0x96, 0x3d, 0x05, 0x67, 0xe1, 0x14, 0x94, 0x5b, 0x52, 0xa2, 0xe4, 0x22, 0xc8, 0x13, - 0x42, 0xb1, 0xdd, 0x7c, 0x4f, 0xf3, 0x66, 0x9e, 0x1e, 0x5d, 0x99, 0xa2, 0x05, 0xfb, 0x06, 0x56, - 0x94, 0x75, 0xae, 0xf4, 0xa3, 0x36, 0xba, 0x84, 0x36, 0x6d, 0xac, 0x71, 0x26, 0x5a, 0xed, 0xc0, - 0xe5, 0xa8, 0xa7, 0x38, 0x19, 0x0b, 0xe9, 0xb8, 0xbf, 0x5c, 0x48, 0x23, 0x0d, 0xee, 0x09, 0x3f, - 0x0d, 0x96, 0xe5, 0x59, 0xb3, 0x91, 0xa2, 0xd9, 0xc8, 0x01, 0x2f, 0x3f, 0x09, 0x3d, 0xbd, 0xf5, - 0x07, 0xee, 0xf1, 0x6e, 0xc4, 0xe8, 0xbc, 0xb4, 0x90, 0x3b, 0x63, 0x19, 0x89, 0x49, 0x72, 0x92, - 0x8d, 0x18, 0x2d, 0xe8, 0x54, 0xe9, 0x0a, 0xb6, 0xec, 0x08, 0xf5, 0x01, 0xa2, 0x0b, 0x7a, 0x3c, - 0xe4, 0x52, 0x15, 0x0b, 0x63, 0x92, 0x84, 0xd9, 0x1c, 0x79, 0x5d, 0x79, 0x03, 0x86, 0x65, 0x93, - 0x98, 0x24, 0x93, 0x6c, 0x00, 0xff, 0xa0, 0x55, 0x52, 0x83, 0x6d, 0xd9, 0x34, 0x0e, 0xfd, 0x83, - 0x3f, 0x8c, 0x12, 0x7a, 0xfe, 0xa4, 0x74, 0xfe, 0xac, 0x76, 0x50, 0xdd, 0x81, 0x92, 0xb5, 0x63, - 0x33, 0x74, 0x1e, 0xca, 0x37, 0xeb, 0xaf, 0x8e, 0x93, 0x7d, 0xc7, 0xc9, 0x4f, 0xc7, 0xc9, 0x47, - 0xcf, 0x83, 0x7d, 0xcf, 0x83, 0xef, 0x9e, 0x07, 0x0f, 0x42, 0x2a, 0x57, 0xbf, 0x16, 0x69, 0x69, - 0x5e, 0x84, 0x6f, 0xe4, 0x0a, 0xc3, 0x88, 0xb1, 0x1c, 0xb1, 0x15, 0xff, 0x75, 0xba, 0xf7, 0x06, - 0xda, 0x62, 0x86, 0x35, 0x5c, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x30, 0x18, 0x60, 0x85, 0x67, - 0x01, 0x00, 0x00, + // 267 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0x3d, 0x4e, 0xfc, 0x30, + 0x10, 0xc5, 0xe3, 0x7f, 0xf6, 0xe3, 0x8f, 0x29, 0x90, 0xac, 0x2d, 0x0c, 0x2b, 0x59, 0x11, 0x55, + 0x1a, 0xe2, 0x82, 0x1b, 0x40, 0xc3, 0x36, 0x14, 0x29, 0x69, 0x50, 0x3e, 0x06, 0xc7, 0x12, 0xd8, + 0x2b, 0xdb, 0xa0, 0x65, 0x4f, 0xc1, 0x59, 0x38, 0x05, 0xe5, 0x96, 0x94, 0x28, 0xb9, 0x08, 0xf2, + 0x84, 0x50, 0xd0, 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, 0x2f, 0xb0, 0x86, 0xcb, 0xef, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xfa, 0xab, 0xcc, 0x63, 0x58, 0x01, 0x00, 0x00, } func (m *ChainNonces) Marshal() (dAtA []byte, err error) { diff --git a/x/observer/types/chain_params.go b/x/observer/types/chain_params.go index c2d49cde7b..e32ee9e597 100644 --- a/x/observer/types/chain_params.go +++ b/x/observer/types/chain_params.go @@ -8,8 +8,8 @@ import ( errorsmod "cosmossdk.io/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ethpkg "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + ethchains "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/pkg/chains" ) const ( @@ -27,7 +27,7 @@ func (cpl ChainParamsList) Validate() error { chainMap := make(map[int64]struct{}) existingChainMap := make(map[int64]struct{}) - externalChainList := pkg.DefaultChainsList() + externalChainList := chains.DefaultChainsList() for _, chain := range externalChainList { chainMap[chain.ChainId] = struct{}{} } @@ -54,7 +54,7 @@ func ValidateChainParams(params *ChainParams) error { if params == nil { return fmt.Errorf("chain params cannot be nil") } - chain := pkg.GetChainFromChainID(params.ChainId) + chain := chains.GetChainFromChainID(params.ChainId) if chain == nil { return fmt.Errorf("ChainId %d not supported", params.ChainId) } @@ -83,12 +83,12 @@ func ValidateChainParams(params *ChainParams) error { } // chain type specific checks - if pkg.IsBitcoinChain(params.ChainId) { + if chains.IsBitcoinChain(params.ChainId) { if params.WatchUtxoTicker == 0 || params.WatchUtxoTicker > 300 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "WatchUtxoTicker %d out of range", params.WatchUtxoTicker) } } - if pkg.IsEVMChain(params.ChainId) { + if chains.IsEVMChain(params.ChainId) { if !validChainContractAddress(params.ZetaTokenContractAddress) { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid ZetaTokenContractAddress %s", params.ZetaTokenContractAddress) } @@ -115,7 +115,7 @@ func validChainContractAddress(address string) bool { if !strings.HasPrefix(address, "0x") { return false } - return ethpkg.IsHexAddress(address) + return ethchains.IsHexAddress(address) } // GetDefaultChainParams returns a list of default chain params @@ -140,7 +140,7 @@ func GetDefaultChainParams() ChainParamsList { func GetDefaultEthMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.EthChain().ChainId, + ChainId: chains.EthChain().ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -158,7 +158,7 @@ func GetDefaultEthMainnetChainParams() *ChainParams { } func GetDefaultBscMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.BscMainnetChain().ChainId, + ChainId: chains.BscMainnetChain().ChainId, ConfirmationCount: 14, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -176,7 +176,7 @@ func GetDefaultBscMainnetChainParams() *ChainParams { } func GetDefaultBtcMainnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.BtcMainnetChain().ChainId, + ChainId: chains.BtcMainnetChain().ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -194,7 +194,7 @@ func GetDefaultBtcMainnetChainParams() *ChainParams { } func GetDefaultGoerliTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.GoerliChain().ChainId, + ChainId: chains.GoerliChain().ChainId, ConfirmationCount: 6, // This is the actual Zeta token Goerli testnet, we need to specify this address for the integration tests to pass ZetaTokenContractAddress: "0x0000c304d2934c00db1d51995b9f6996affd17c0", @@ -213,7 +213,7 @@ func GetDefaultGoerliTestnetChainParams() *ChainParams { } func GetDefaultBscTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.BscTestnetChain().ChainId, + ChainId: chains.BscTestnetChain().ChainId, ConfirmationCount: 6, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -231,7 +231,7 @@ func GetDefaultBscTestnetChainParams() *ChainParams { } func GetDefaultMumbaiTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.MumbaiChain().ChainId, + ChainId: chains.MumbaiChain().ChainId, ConfirmationCount: 12, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -249,7 +249,7 @@ func GetDefaultMumbaiTestnetChainParams() *ChainParams { } func GetDefaultBtcTestnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.BtcTestNetChain().ChainId, + ChainId: chains.BtcTestNetChain().ChainId, ConfirmationCount: 2, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -267,7 +267,7 @@ func GetDefaultBtcTestnetChainParams() *ChainParams { } func GetDefaultBtcRegtestChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.BtcRegtestChain().ChainId, + ChainId: chains.BtcRegtestChain().ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, @@ -285,7 +285,7 @@ func GetDefaultBtcRegtestChainParams() *ChainParams { } func GetDefaultGoerliLocalnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.GoerliLocalnetChain().ChainId, + ChainId: chains.GoerliLocalnetChain().ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: "0x733aB8b06DDDEf27Eaa72294B0d7c9cEF7f12db9", ConnectorContractAddress: "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca", @@ -303,7 +303,7 @@ func GetDefaultGoerliLocalnetChainParams() *ChainParams { } func GetDefaultZetaPrivnetChainParams() *ChainParams { return &ChainParams{ - ChainId: pkg.ZetaPrivnetChain().ChainId, + ChainId: chains.ZetaPrivnetChain().ChainId, ConfirmationCount: 1, ZetaTokenContractAddress: zeroAddress, ConnectorContractAddress: zeroAddress, diff --git a/x/observer/types/message_add_blame_vote.go b/x/observer/types/message_add_blame_vote.go index c82aeb18fa..5a93f0cafe 100644 --- a/x/observer/types/message_add_blame_vote.go +++ b/x/observer/types/message_add_blame_vote.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) const TypeMsgAddBlameVote = "add_blame_vote" @@ -33,7 +33,7 @@ func (m *MsgAddBlameVote) ValidateBasic() error { if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - if pkg.GetChainFromChainID(m.ChainId) == nil { + if chains.GetChainFromChainID(m.ChainId) == nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidChainID, "chain id (%d)", m.ChainId) } return nil diff --git a/x/observer/types/message_add_block_header.go b/x/observer/types/message_add_block_header.go index 3570777a63..58be17f079 100644 --- a/x/observer/types/message_add_block_header.go +++ b/x/observer/types/message_add_block_header.go @@ -6,7 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" ) var _ sdk.Msg = &MsgAddBlockHeader{} @@ -15,7 +16,7 @@ const ( TypeMsgAddBlockHeader = "add_block_header" ) -func NewMsgAddBlockHeader(creator string, chainID int64, blockHash []byte, height int64, header pkg.HeaderData) *MsgAddBlockHeader { +func NewMsgAddBlockHeader(creator string, chainID int64, blockHash []byte, height int64, header proofs.HeaderData) *MsgAddBlockHeader { return &MsgAddBlockHeader{ Creator: creator, ChainId: chainID, @@ -52,7 +53,7 @@ func (msg *MsgAddBlockHeader) ValidateBasic() error { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, err.Error()) } - if pkg.IsHeaderSupportedEvmChain(msg.ChainId) || pkg.IsBitcoinChain(msg.ChainId) { + if chains.IsHeaderSupportedEvmChain(msg.ChainId) || chains.IsBitcoinChain(msg.ChainId) { if len(msg.BlockHash) != 32 { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "invalid block hash length (%d)", len(msg.BlockHash)) } diff --git a/x/observer/types/message_add_block_header_test.go b/x/observer/types/message_add_block_header_test.go index 86fb2d3058..9f53590dde 100644 --- a/x/observer/types/message_add_block_header_test.go +++ b/x/observer/types/message_add_block_header_test.go @@ -9,7 +9,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" @@ -29,7 +29,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { var buffer bytes.Buffer err = header.EncodeRLP(&buffer) require.NoError(t, err) - headerData := pkg.NewEthereumHeader(buffer.Bytes()) + headerData := proofs.NewEthereumHeader(buffer.Bytes()) tests := []struct { name string msg *types.MsgAddBlockHeader @@ -42,7 +42,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { 1, []byte{}, 6, - pkg.HeaderData{}, + proofs.HeaderData{}, ), error: true, }, @@ -53,7 +53,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { -1, []byte{}, 6, - pkg.HeaderData{}, + proofs.HeaderData{}, ), error: true, }, @@ -64,7 +64,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { 5, sample.Hash().Bytes(), 6, - pkg.HeaderData{}, + proofs.HeaderData{}, ), error: true, }, @@ -75,7 +75,7 @@ func TestMsgAddBlockHeader_ValidateBasic(t *testing.T) { 5, sample.Hash().Bytes()[:31], 6, - pkg.HeaderData{}, + proofs.HeaderData{}, ), error: true, }, diff --git a/x/observer/types/message_add_observer.go b/x/observer/types/message_add_observer.go index 80b75ba86b..087636b10a 100644 --- a/x/observer/types/message_add_observer.go +++ b/x/observer/types/message_add_observer.go @@ -4,7 +4,7 @@ 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/pkg" + "github.com/zeta-chain/zetacore/pkg/crypto" ) const TypeMsgAddObserver = "add_observer" @@ -50,11 +50,11 @@ func (msg *MsgAddObserver) ValidateBasic() error { if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid observer address (%s)", err) } - _, err = pkg.NewPubKey(msg.ZetaclientGranteePubkey) + _, err = crypto.NewPubKey(msg.ZetaclientGranteePubkey) if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) } - _, err = pkg.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) + _, err = crypto.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) if err != nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) } diff --git a/x/observer/types/message_remove_chain_params.go b/x/observer/types/message_remove_chain_params.go index 02fdb1803c..5b333c4bc1 100644 --- a/x/observer/types/message_remove_chain_params.go +++ b/x/observer/types/message_remove_chain_params.go @@ -2,7 +2,7 @@ package types import ( cosmoserrors "cosmossdk.io/errors" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -47,7 +47,7 @@ func (msg *MsgRemoveChainParams) ValidateBasic() error { } // Check if chain exists - chain := pkg.GetChainFromChainID(msg.ChainId) + chain := chains.GetChainFromChainID(msg.ChainId) if chain == nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidChainID, "invalid chain id (%d)", msg.ChainId) } diff --git a/x/observer/types/message_remove_chain_params_test.go b/x/observer/types/message_remove_chain_params_test.go index 48b862f214..bd46dfe692 100644 --- a/x/observer/types/message_remove_chain_params_test.go +++ b/x/observer/types/message_remove_chain_params_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -21,14 +21,14 @@ func TestMsgRemoveChainParams_ValidateBasic(t *testing.T) { name: "valid message", msg: types.NewMsgRemoveChainParams( sample.AccAddress(), - pkg.ExternalChainList()[0].ChainId, + chains.ExternalChainList()[0].ChainId, ), }, { name: "invalid address", msg: types.NewMsgRemoveChainParams( "invalid_address", - pkg.ExternalChainList()[0].ChainId, + chains.ExternalChainList()[0].ChainId, ), err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/observer/types/message_reset_chain_nonces.go b/x/observer/types/message_reset_chain_nonces.go index b14cb75df1..c7bb615040 100644 --- a/x/observer/types/message_reset_chain_nonces.go +++ b/x/observer/types/message_reset_chain_nonces.go @@ -4,7 +4,7 @@ import ( "errors" cosmoserrors "cosmossdk.io/errors" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -51,7 +51,7 @@ func (msg *MsgResetChainNonces) ValidateBasic() error { } // Check if chain exists - chain := pkg.GetChainFromChainID(msg.ChainId) + chain := chains.GetChainFromChainID(msg.ChainId) if chain == nil { return cosmoserrors.Wrapf(sdkerrors.ErrInvalidChainID, "invalid chain id (%d)", msg.ChainId) } diff --git a/x/observer/types/message_reset_chain_nonces_test.go b/x/observer/types/message_reset_chain_nonces_test.go index 3b8f1788f4..4f37b359bb 100644 --- a/x/observer/types/message_reset_chain_nonces_test.go +++ b/x/observer/types/message_reset_chain_nonces_test.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -20,7 +20,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "valid message chain nonce high greater than nonce low", msg: types.MsgResetChainNonces{ Creator: sample.AccAddress(), - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, ChainNonceLow: 1, ChainNonceHigh: 5, }, @@ -30,7 +30,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "valid message chain nonce high same as nonce low", msg: types.MsgResetChainNonces{ Creator: sample.AccAddress(), - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, ChainNonceLow: 1, ChainNonceHigh: 1, }, @@ -40,7 +40,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "invalid address", msg: types.MsgResetChainNonces{ Creator: "invalid_address", - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, }, wantErr: true, }, @@ -56,7 +56,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "invalid chain nonce low", msg: types.MsgResetChainNonces{ Creator: sample.AccAddress(), - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, ChainNonceLow: -1, }, wantErr: true, @@ -65,7 +65,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "invalid chain nonce high", msg: types.MsgResetChainNonces{ Creator: sample.AccAddress(), - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, ChainNonceLow: 1, ChainNonceHigh: -1, }, @@ -75,7 +75,7 @@ func TestMsgResetChainNonces_ValidateBasic(t *testing.T) { name: "invalid chain nonce low greater than chain nonce high", msg: types.MsgResetChainNonces{ Creator: sample.AccAddress(), - ChainId: pkg.ExternalChainList()[0].ChainId, + ChainId: chains.ExternalChainList()[0].ChainId, ChainNonceLow: 1, ChainNonceHigh: 0, }, diff --git a/x/observer/types/message_update_chain_params_test.go b/x/observer/types/message_update_chain_params_test.go index 2e714f0b07..1e909ea783 100644 --- a/x/observer/types/message_update_chain_params_test.go +++ b/x/observer/types/message_update_chain_params_test.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -21,14 +21,14 @@ func TestMsgUpdateChainParams_ValidateBasic(t *testing.T) { name: "valid message", msg: types.NewMsgUpdateChainParams( sample.AccAddress(), - sample.ChainParams(pkg.ExternalChainList()[0].ChainId), + sample.ChainParams(chains.ExternalChainList()[0].ChainId), ), }, { name: "invalid address", msg: types.NewMsgUpdateChainParams( "invalid_address", - sample.ChainParams(pkg.ExternalChainList()[0].ChainId), + sample.ChainParams(chains.ExternalChainList()[0].ChainId), ), err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/observer/types/node_account.pb.go b/x/observer/types/node_account.pb.go index d231c89ffc..a127e290e6 100644 --- a/x/observer/types/node_account.pb.go +++ b/x/observer/types/node_account.pb.go @@ -11,7 +11,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + crypto "github.com/zeta-chain/zetacore/pkg/crypto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -65,7 +65,7 @@ func (NodeStatus) EnumDescriptor() ([]byte, []int) { type NodeAccount struct { Operator string `protobuf:"bytes,1,opt,name=operator,proto3" json:"operator,omitempty"` GranteeAddress string `protobuf:"bytes,2,opt,name=granteeAddress,proto3" json:"granteeAddress,omitempty"` - GranteePubkey *proto1.PubKeySet `protobuf:"bytes,3,opt,name=granteePubkey,proto3" json:"granteePubkey,omitempty"` + GranteePubkey *crypto.PubKeySet `protobuf:"bytes,3,opt,name=granteePubkey,proto3" json:"granteePubkey,omitempty"` NodeStatus NodeStatus `protobuf:"varint,4,opt,name=nodeStatus,proto3,enum=zetachain.zetacore.observer.NodeStatus" json:"nodeStatus,omitempty"` } @@ -116,7 +116,7 @@ func (m *NodeAccount) GetGranteeAddress() string { return "" } -func (m *NodeAccount) GetGranteePubkey() *proto1.PubKeySet { +func (m *NodeAccount) GetGranteePubkey() *crypto.PubKeySet { if m != nil { return m.GranteePubkey } @@ -138,30 +138,31 @@ func init() { func init() { proto.RegisterFile("observer/node_account.proto", fileDescriptor_6f54e38f9d1a9953) } var fileDescriptor_6f54e38f9d1a9953 = []byte{ - // 363 bytes of a gzipped FileDescriptorProto + // 370 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x91, 0xcb, 0x6a, 0xdb, 0x40, - 0x14, 0x86, 0x35, 0xbe, 0xd5, 0x1e, 0xd5, 0xae, 0x18, 0xba, 0x10, 0x32, 0x08, 0xd3, 0x45, 0x6b, - 0x0a, 0xd5, 0x80, 0xdb, 0x17, 0x70, 0x29, 0x94, 0x52, 0x30, 0x46, 0xa6, 0x14, 0xb2, 0x09, 0x33, - 0x9a, 0x83, 0x2c, 0xe4, 0xcc, 0x88, 0xd1, 0xc8, 0x89, 0xf2, 0x14, 0x79, 0x88, 0x2c, 0xf2, 0x28, - 0x59, 0x7a, 0x99, 0x65, 0xb0, 0x5f, 0x24, 0x48, 0x8e, 0x9d, 0xcb, 0x22, 0xbb, 0x73, 0xf9, 0xce, - 0xcc, 0xff, 0xf3, 0xe3, 0xa1, 0xe2, 0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34, 0xc8, 0x5b, 0xdc, 0xfe, 0x9d, 0x64, 0x8c, 0x2f, 0x40, 0x38, 0x4d, 0xaf, 0x71, 0x7d, 0xe5, + 0xa3, 0x5f, 0x7f, 0x6f, 0xd6, 0x3e, 0x5a, 0xad, 0x7d, 0x74, 0xbf, 0xf6, 0xd1, 0xe5, 0xc6, 0xb7, + 0x56, 0x1b, 0xdf, 0xba, 0xdb, 0xf8, 0xd6, 0x31, 0x8d, 0x13, 0x33, 0xcb, 0x79, 0x10, 0xa9, 0x53, + 0x5a, 0x5a, 0xfe, 0x5e, 0xb9, 0xa7, 0x7b, 0xf7, 0xf4, 0x9c, 0x1e, 0xd2, 0x35, 0x45, 0x0a, 0x19, + 0x6f, 0x55, 0x59, 0xfc, 0x78, 0x08, 0x00, 0x00, 0xff, 0xff, 0x94, 0xd1, 0x0e, 0xdf, 0xf6, 0x01, + 0x00, 0x00, } func (m *NodeAccount) Marshal() (dAtA []byte, err error) { @@ -382,7 +383,7 @@ func (m *NodeAccount) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.GranteePubkey == nil { - m.GranteePubkey = &proto1.PubKeySet{} + m.GranteePubkey = &crypto.PubKeySet{} } if err := m.GranteePubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/observer/types/nonce_to_cctx.pb.go b/x/observer/types/nonce_to_cctx.pb.go index 8eb228d133..0e7e05e98c 100644 --- a/x/observer/types/nonce_to_cctx.pb.go +++ b/x/observer/types/nonce_to_cctx.pb.go @@ -11,7 +11,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/zeta-chain/zetacore/pkg/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -101,23 +100,22 @@ func init() { func init() { proto.RegisterFile("observer/nonce_to_cctx.proto", fileDescriptor_6f9bbe8a689fa6e4) } var fileDescriptor_6f9bbe8a689fa6e4 = []byte{ - // 241 bytes of a gzipped FileDescriptorProto + // 230 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xc9, 0x4f, 0x2a, 0x4e, 0x2d, 0x2a, 0x4b, 0x2d, 0xd2, 0xcf, 0xcb, 0xcf, 0x4b, 0x4e, 0x8d, 0x2f, 0xc9, 0x8f, 0x4f, 0x4e, 0x2e, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xae, 0x4a, 0x2d, 0x49, 0x4c, 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x60, 0x1a, 0xa4, 0x44, 0xd2, 0xf3, - 0xd3, 0xf3, 0xc1, 0xea, 0xf4, 0x41, 0x2c, 0x88, 0x16, 0x29, 0xde, 0x82, 0xec, 0x74, 0xfd, 0x82, - 0xec, 0x74, 0x08, 0x57, 0x29, 0x8f, 0x8b, 0xdb, 0x0f, 0x64, 0x70, 0x48, 0xbe, 0x73, 0x72, 0x49, - 0x85, 0x90, 0x24, 0x17, 0x07, 0xd8, 0xb8, 0xf8, 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xe6, - 0x20, 0x76, 0x30, 0xdf, 0x33, 0x45, 0x48, 0x84, 0x8b, 0x15, 0xec, 0x04, 0x09, 0x26, 0xb0, 0x38, - 0x84, 0x23, 0x24, 0xc3, 0xc5, 0x09, 0x72, 0x8f, 0x67, 0x5e, 0x4a, 0x6a, 0x85, 0x04, 0xb3, 0x02, - 0xa3, 0x06, 0x67, 0x10, 0x42, 0x40, 0x48, 0x80, 0x8b, 0xb9, 0xa4, 0xb8, 0x58, 0x82, 0x05, 0x2c, - 0x0e, 0x62, 0x3a, 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, - 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x7e, - 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x33, 0xba, 0x60, 0x8b, - 0xf5, 0x61, 0xfe, 0xd2, 0xaf, 0xd0, 0x87, 0x07, 0x45, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, - 0xd8, 0x07, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xef, 0xd8, 0x84, 0x2f, 0x23, 0x01, 0x00, - 0x00, + 0xd3, 0xf3, 0xc1, 0xea, 0xf4, 0x41, 0x2c, 0x88, 0x16, 0xa5, 0x3c, 0x2e, 0x6e, 0x3f, 0x90, 0x49, + 0x21, 0xf9, 0xce, 0xc9, 0x25, 0x15, 0x42, 0x92, 0x5c, 0x1c, 0x60, 0xfd, 0xf1, 0x99, 0x29, 0x12, + 0x8c, 0x0a, 0x8c, 0x1a, 0xcc, 0x41, 0xec, 0x60, 0xbe, 0x67, 0x8a, 0x90, 0x08, 0x17, 0x2b, 0xd8, + 0x4e, 0x09, 0x26, 0xb0, 0x38, 0x84, 0x23, 0x24, 0xc3, 0xc5, 0x09, 0x72, 0x80, 0x67, 0x5e, 0x4a, + 0x6a, 0x85, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x42, 0x40, 0x48, 0x80, 0x8b, 0xb9, 0xa4, + 0xb8, 0x58, 0x82, 0x05, 0x2c, 0x0e, 0x62, 0x3a, 0x79, 0x9e, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, + 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, + 0xb1, 0x1c, 0x43, 0x94, 0x7e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, + 0xc8, 0xf5, 0xba, 0x60, 0x8b, 0xf5, 0x61, 0x1e, 0xd1, 0xaf, 0xd0, 0x87, 0xfb, 0xbd, 0xa4, 0xb2, + 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xec, 0x03, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0xf7, + 0xb7, 0x20, 0x14, 0x01, 0x00, 0x00, } func (m *NonceToCctx) Marshal() (dAtA []byte, err error) { diff --git a/x/observer/types/observer.pb.go b/x/observer/types/observer.pb.go index 639caac692..ede9e119a5 100644 --- a/x/observer/types/observer.pb.go +++ b/x/observer/types/observer.pb.go @@ -11,7 +11,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + chains "github.com/zeta-chain/zetacore/pkg/chains" ) // Reference imports to suppress errors if they are not otherwise used. @@ -89,7 +89,7 @@ func (ObserverUpdateReason) EnumDescriptor() ([]byte, []int) { type ObserverMapper struct { Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - ObserverChain *proto1.Chain `protobuf:"bytes,2,opt,name=observer_chain,json=observerChain,proto3" json:"observer_chain,omitempty"` + ObserverChain *chains.Chain `protobuf:"bytes,2,opt,name=observer_chain,json=observerChain,proto3" json:"observer_chain,omitempty"` ObserverList []string `protobuf:"bytes,4,rep,name=observer_list,json=observerList,proto3" json:"observer_list,omitempty"` } @@ -133,7 +133,7 @@ func (m *ObserverMapper) GetIndex() string { return "" } -func (m *ObserverMapper) GetObserverChain() *proto1.Chain { +func (m *ObserverMapper) GetObserverChain() *chains.Chain { if m != nil { return m.ObserverChain } @@ -254,34 +254,34 @@ func init() { func init() { proto.RegisterFile("observer/observer.proto", fileDescriptor_3004233a4a5969ce) } var fileDescriptor_3004233a4a5969ce = []byte{ - // 426 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0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, 0x7d, 0x3f, 0x44, 0xc1, 0xdd, 0x21, 0x0a, 0x7e, 0x1f, 0xa2, 0xe0, 0x53, 0x52, 0x08, - 0x5a, 0x6e, 0xe6, 0xf1, 0x42, 0xad, 0x13, 0x73, 0x25, 0x2f, 0xec, 0xff, 0x25, 0xfe, 0x60, 0x92, - 0xed, 0xf1, 0xaa, 0x12, 0xda, 0x69, 0xac, 0xe6, 0x0f, 0xed, 0x69, 0xbc, 0xfa, 0x1b, 0x00, 0x00, - 0xff, 0xff, 0x9b, 0x82, 0x5d, 0x57, 0x77, 0x02, 0x00, 0x00, + // 429 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xc1, 0x8a, 0x13, 0x41, + 0x10, 0x9d, 0x4e, 0xa2, 0x90, 0x8e, 0xc9, 0xce, 0x36, 0x91, 0x0d, 0x11, 0x86, 0xb0, 0x5e, 0xc2, + 0xa2, 0x33, 0xb0, 0xfa, 0x03, 0x6e, 0x10, 0x5d, 0x8c, 0x2c, 0x4c, 0xb2, 0x08, 0x5e, 0x42, 0x27, + 0x53, 0x4e, 0x1a, 0x93, 0xee, 0x66, 0xba, 0x22, 0x89, 0x37, 0xff, 0xc0, 0x8f, 0xf0, 0xe0, 0xa7, + 0x78, 0xdc, 0xa3, 0x47, 0x49, 0x7e, 0x44, 0xba, 0x3b, 0xbd, 0x17, 0x3d, 0x75, 0xbd, 0x7a, 0xf5, + 0x5e, 0x3d, 0xe8, 0xa2, 0x67, 0x6a, 0x6e, 0xa0, 0xfa, 0x02, 0x55, 0x16, 0x8a, 0x54, 0x57, 0x0a, + 0x15, 0x7b, 0xf2, 0x15, 0x90, 0x2f, 0x96, 0x5c, 0xc8, 0xd4, 0x55, 0xaa, 0x82, 0x34, 0x8c, 0xf4, + 0xbb, 0xa5, 0x2a, 0x95, 0x9b, 0xcb, 0x6c, 0xe5, 0x25, 0xfd, 0x33, 0x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e3, 0xba, 0xa5, 0x3d, 0x9c, 0x88, 0x52, 0xc6, 0x8d, 0x7e, 0xe3, 0xe7, 0x8f, 0x84, 0x5c, + 0x8c, 0x69, 0x37, 0xb8, 0xde, 0xea, 0x82, 0x23, 0xe4, 0xc0, 0x8d, 0x92, 0x56, 0x7c, 0x2b, 0x0b, + 0xf8, 0x24, 0x24, 0x14, 0x71, 0xe4, 0xc4, 0x6a, 0x3d, 0x37, 0xa8, 0x2c, 0x26, 0xec, 0x84, 0xb6, + 0x5e, 0x15, 0x6b, 0x21, 0xbd, 0x26, 0xae, 0x79, 0xb7, 0xab, 0xeb, 0x5f, 0xfb, 0x84, 0xdc, 0xed, + 0x13, 0xf2, 0x67, 0x9f, 0x90, 0xef, 0x87, 0x24, 0xba, 0x3b, 0x24, 0xd1, 0xef, 0x43, 0x12, 0x7d, + 0xcc, 0x4a, 0x81, 0xcb, 0xcd, 0x3c, 0x5d, 0xa8, 0x75, 0x66, 0x6f, 0xe6, 0xb9, 0xfb, 0xb4, 0x2c, + 0x9c, 0x4f, 0xb6, 0xbd, 0xbf, 0xb1, 0x0c, 0x77, 0x1a, 0xcc, 0xfc, 0xa1, 0x3b, 0x8f, 0x17, 0x7f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x91, 0x8a, 0xa2, 0x49, 0x85, 0x02, 0x00, 0x00, } func (m *ObserverMapper) Marshal() (dAtA []byte, err error) { @@ -561,7 +561,7 @@ func (m *ObserverMapper) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.ObserverChain == nil { - m.ObserverChain = &proto1.Chain{} + m.ObserverChain = &chains.Chain{} } if err := m.ObserverChain.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/observer/types/observer_set.go b/x/observer/types/observer_set.go index 252f3cce8e..483f28592c 100644 --- a/x/observer/types/observer_set.go +++ b/x/observer/types/observer_set.go @@ -2,7 +2,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) func (m *ObserverSet) Len() int { @@ -24,11 +24,11 @@ func (m *ObserverSet) Validate() error { return nil } -func CheckReceiveStatus(status pkg.ReceiveStatus) error { +func CheckReceiveStatus(status chains.ReceiveStatus) error { switch status { - case pkg.ReceiveStatus_Success: + case chains.ReceiveStatus_Success: return nil - case pkg.ReceiveStatus_Failed: + case chains.ReceiveStatus_Failed: return nil default: return ErrInvalidStatus diff --git a/x/observer/types/params.go b/x/observer/types/params.go index 6f8b262c25..7fc72c1e89 100644 --- a/x/observer/types/params.go +++ b/x/observer/types/params.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "gopkg.in/yaml.v2" ) @@ -28,7 +28,7 @@ func NewParams(observerParams []*ObserverParams, adminParams []*Admin_Policy, ba // privnet chains are supported by default for testing purposes // custom params must be provided in genesis for other networks func DefaultParams() Params { - chains := pkg.PrivnetChainList() + chains := chains.PrivnetChainList() observerParams := make([]*ObserverParams, len(chains)) for i, chain := range chains { observerParams[i] = &ObserverParams{ diff --git a/x/observer/types/params.pb.go b/x/observer/types/params.pb.go index 28cd9b2623..8e223d5571 100644 --- a/x/observer/types/params.pb.go +++ b/x/observer/types/params.pb.go @@ -12,7 +12,7 @@ import ( github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + chains "github.com/zeta-chain/zetacore/pkg/chains" ) // Reference imports to suppress errors if they are not otherwise used. @@ -232,7 +232,7 @@ func (m *ChainParams) GetIsSupported() bool { // Deprecated(v13): Use ChainParamsList type ObserverParams struct { - Chain *proto1.Chain `protobuf:"bytes,1,opt,name=chain,proto3" json:"chain,omitempty"` + Chain *chains.Chain `protobuf:"bytes,1,opt,name=chain,proto3" json:"chain,omitempty"` BallotThreshold github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=ballot_threshold,json=ballotThreshold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"ballot_threshold"` MinObserverDelegation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=min_observer_delegation,json=minObserverDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_observer_delegation"` IsSupported bool `protobuf:"varint,5,opt,name=is_supported,json=isSupported,proto3" json:"is_supported,omitempty"` @@ -271,7 +271,7 @@ func (m *ObserverParams) XXX_DiscardUnknown() { var xxx_messageInfo_ObserverParams proto.InternalMessageInfo -func (m *ObserverParams) GetChain() *proto1.Chain { +func (m *ObserverParams) GetChain() *chains.Chain { if m != nil { return m.Chain } @@ -412,58 +412,58 @@ func init() { func init() { proto.RegisterFile("observer/params.proto", fileDescriptor_4542fa62877488a1) } var fileDescriptor_4542fa62877488a1 = []byte{ - // 804 bytes of a gzipped FileDescriptorProto + // 805 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x41, 0x6f, 0xe3, 0x44, - 0x14, 0xc7, 0xe3, 0x24, 0xcd, 0x76, 0x9f, 0xd3, 0x24, 0x6b, 0xed, 0xb2, 0x26, 0x15, 0x6e, 0xc8, - 0x01, 0x85, 0x5d, 0xd5, 0x86, 0xc0, 0x09, 0xc1, 0xa1, 0xcd, 0x5e, 0x22, 0x8a, 0xa8, 0xbc, 0xe1, - 0x00, 0x07, 0x46, 0x93, 0xf1, 0xac, 0x33, 0x8a, 0xe3, 0xb1, 0x66, 0xc6, 0x4b, 0xc2, 0xa7, 0xe0, - 0xd8, 0x23, 0x12, 0x1c, 0xf8, 0x28, 0x3d, 0xf6, 0x88, 0x38, 0x54, 0xa8, 0xbd, 0xf0, 0x31, 0x90, - 0xc7, 0x76, 0x48, 0x9b, 0xaa, 0x48, 0x2b, 0xf5, 0x94, 0x37, 0xf3, 0x7e, 0xef, 0x3f, 0x6f, 0xde, - 0xbc, 0x17, 0xc3, 0x33, 0x3e, 0x95, 0x54, 0xbc, 0xa5, 0xc2, 0x4b, 0xb0, 0xc0, 0x0b, 0xe9, 0x26, - 0x82, 0x2b, 0x6e, 0xed, 0xff, 0x4c, 0x15, 0x26, 0x33, 0xcc, 0x62, 0x57, 0x5b, 0x5c, 0x50, 0xb7, - 0x24, 0xbb, 0x4f, 0x43, 0x1e, 0x72, 0xcd, 0x79, 0x99, 0x95, 0x87, 0x74, 0x9f, 0xaf, 0x95, 0x4a, - 0xa3, 0x70, 0xec, 0x25, 0xf3, 0xd0, 0x4b, 0xe6, 0x61, 0xbe, 0xec, 0xff, 0x08, 0xed, 0x51, 0x26, - 0x7c, 0xaa, 0xcf, 0x3b, 0x61, 0x52, 0x59, 0x5f, 0x43, 0x53, 0x9f, 0x85, 0xf2, 0x1c, 0x6c, 0xa3, - 0x57, 0x1b, 0x98, 0xc3, 0x81, 0x7b, 0x4f, 0x12, 0xee, 0x86, 0x86, 0x6f, 0x92, 0xff, 0x16, 0xfd, - 0xdf, 0x1a, 0x60, 0x6e, 0x38, 0xad, 0xf7, 0x61, 0x37, 0x17, 0x67, 0x81, 0x6d, 0xf6, 0x8c, 0x41, - 0xcd, 0x7f, 0xa4, 0xd7, 0xe3, 0xc0, 0x3a, 0x04, 0x8b, 0xf0, 0xf8, 0x0d, 0x13, 0x0b, 0xac, 0x18, - 0x8f, 0x11, 0xe1, 0x69, 0xac, 0x6c, 0xa3, 0x67, 0x0c, 0xea, 0xfe, 0x93, 0x4d, 0xcf, 0x28, 0x73, - 0x58, 0x03, 0xe8, 0x84, 0x58, 0xa2, 0x44, 0x30, 0x42, 0x91, 0x62, 0x64, 0x4e, 0x85, 0x5d, 0xd5, - 0x70, 0x2b, 0xc4, 0xf2, 0x34, 0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f8, 0xfc, 0xca, 0x31, 0x2e, 0xae, 0x1c, 0xe3, + 0xaf, 0x2b, 0xc7, 0xf8, 0xf1, 0xda, 0xa9, 0x5c, 0x5c, 0x3b, 0x95, 0x3f, 0xae, 0x9d, 0xca, 0xb7, + 0xde, 0x46, 0x23, 0x64, 0xa9, 0x1f, 0xea, 0x53, 0x78, 0xe5, 0x29, 0xbc, 0xe5, 0xfa, 0xa7, 0x94, + 0x77, 0xc5, 0xb4, 0xa1, 0x7f, 0x41, 0x1f, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x70, 0xbf, 0xfa, + 0xb7, 0x00, 0x07, 0x00, 0x00, } func (m *ChainParamsList) Marshal() (dAtA []byte, err error) { @@ -1448,7 +1448,7 @@ func (m *ObserverParams) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Chain == nil { - m.Chain = &proto1.Chain{} + m.Chain = &chains.Chain{} } if err := m.Chain.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/observer/types/parsers.go b/x/observer/types/parsers.go index 9cfad1c182..ad7537e18e 100644 --- a/x/observer/types/parsers.go +++ b/x/observer/types/parsers.go @@ -2,14 +2,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) -func ConvertReceiveStatusToVoteType(status pkg.ReceiveStatus) VoteType { +func ConvertReceiveStatusToVoteType(status chains.ReceiveStatus) VoteType { switch status { - case pkg.ReceiveStatus_Success: + case chains.ReceiveStatus_Success: return VoteType_SuccessObservation - case pkg.ReceiveStatus_Failed: + case chains.ReceiveStatus_Failed: return VoteType_FailureObservation default: return VoteType_NotYetVoted diff --git a/x/observer/types/pending_nonces.pb.go b/x/observer/types/pending_nonces.pb.go index c36c912c1b..2769d17d76 100644 --- a/x/observer/types/pending_nonces.pb.go +++ b/x/observer/types/pending_nonces.pb.go @@ -11,7 +11,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/gogo/protobuf/proto" - _ "github.com/zeta-chain/zetacore/pkg/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -101,23 +100,22 @@ func init() { func init() { proto.RegisterFile("observer/pending_nonces.proto", fileDescriptor_dd001e4838750ecf) } var fileDescriptor_dd001e4838750ecf = []byte{ - // 249 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x50, 0xbf, 0x4a, 0x03, 0x31, - 0x1c, 0xbe, 0x78, 0xa2, 0x6d, 0xa0, 0x20, 0xc1, 0xe1, 0x6c, 0x69, 0x28, 0x4e, 0x5d, 0xbc, 0x0c, - 0xbe, 0x81, 0x93, 0x05, 0x11, 0xe9, 0xe8, 0x72, 0xf4, 0xee, 0x42, 0x12, 0xaa, 0xf9, 0x85, 0x24, - 0xda, 0xea, 0x53, 0xf8, 0x58, 0x8e, 0x1d, 0x1d, 0xe5, 0xee, 0x45, 0xe4, 0x7e, 0xa1, 0x6e, 0xdf, - 0x97, 0xef, 0x4f, 0xf2, 0x85, 0xce, 0xa1, 0x0e, 0xd2, 0xbf, 0x4b, 0x2f, 0x9c, 0xb4, 0xad, 0xb1, - 0xaa, 0xb2, 0x60, 0x1b, 0x19, 0x4a, 0xe7, 0x21, 0x02, 0x9b, 0x7d, 0xca, 0xb8, 0x69, 0xf4, 0xc6, - 0xd8, 0x12, 0x11, 0x78, 0x59, 0x1e, 0x13, 0xd3, 0x4b, 0x05, 0x0a, 0xd0, 0x27, 0x06, 0x94, 0x22, - 0xd3, 0x89, 0xdb, 0x2a, 0xe1, 0xb6, 0x2a, 0xd1, 0xeb, 0x3d, 0x9d, 0x3c, 0xa5, 0xe6, 0x47, 0x2c, - 0x66, 0x33, 0x3a, 0xc6, 0x2b, 0xaa, 0x17, 0xd8, 0x15, 0x64, 0x41, 0x96, 0xf9, 0x7a, 0x84, 0x07, - 0x0f, 0xb0, 0x63, 0x73, 0x4a, 0x93, 0xa8, 0x8d, 0xd2, 0xc5, 0x09, 0xaa, 0xc9, 0x7e, 0x6f, 0x94, - 0x66, 0x57, 0x74, 0x84, 0x8f, 0xa9, 0x4c, 0x5b, 0xe4, 0x28, 0x9e, 0x23, 0x5f, 0xb5, 0xec, 0x82, - 0xe6, 0x31, 0x84, 0xe2, 0x74, 0x41, 0x96, 0xe3, 0xf5, 0x00, 0xef, 0x56, 0xdf, 0x1d, 0x27, 0x87, - 0x8e, 0x93, 0xdf, 0x8e, 0x93, 0xaf, 0x9e, 0x67, 0x87, 0x9e, 0x67, 0x3f, 0x3d, 0xcf, 0x9e, 0x85, - 0x32, 0x51, 0xbf, 0xd5, 0x65, 0x03, 0xaf, 0x62, 0x98, 0x75, 0x83, 0x25, 0xe2, 0xb8, 0x50, 0xec, - 0xc5, 0xff, 0xaf, 0xc4, 0x0f, 0x27, 0x43, 0x7d, 0x86, 0x5b, 0x6e, 0xff, 0x02, 0x00, 0x00, 0xff, - 0xff, 0x24, 0x1e, 0x5b, 0xda, 0x2e, 0x01, 0x00, 0x00, + // 239 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcd, 0x4f, 0x2a, 0x4e, + 0x2d, 0x2a, 0x4b, 0x2d, 0xd2, 0x2f, 0x48, 0xcd, 0x4b, 0xc9, 0xcc, 0x4b, 0x8f, 0xcf, 0xcb, 0xcf, + 0x4b, 0x4e, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0xae, 0x4a, 0x2d, 0x49, 0x4c, + 0xce, 0x48, 0xcc, 0xcc, 0xd3, 0x03, 0xb3, 0xf2, 0x8b, 0x52, 0xf5, 0x60, 0x3a, 0xa4, 0x44, 0xd2, + 0xf3, 0xd3, 0xf3, 0xc1, 0xea, 0xf4, 0x41, 0x2c, 0x88, 0x16, 0xa5, 0x0a, 0x2e, 0xde, 0x00, 0x88, + 0x51, 0x7e, 0x60, 0x93, 0x84, 0xa4, 0xb9, 0x38, 0xc1, 0x66, 0xc6, 0xe7, 0xe4, 0x97, 0x4b, 0x30, + 0x2a, 0x30, 0x6a, 0x30, 0x07, 0x71, 0x80, 0x05, 0x7c, 0xf2, 0xcb, 0x85, 0x64, 0xb9, 0xb8, 0x20, + 0x92, 0x19, 0x99, 0xe9, 0x19, 0x12, 0x4c, 0x60, 0x59, 0x88, 0x72, 0x8f, 0xcc, 0xf4, 0x0c, 0x21, + 0x49, 0x2e, 0x0e, 0xb0, 0xed, 0xf1, 0x99, 0x29, 0x12, 0xcc, 0x60, 0x49, 0x76, 0x30, 0xdf, 0x33, + 0x45, 0x48, 0x80, 0x8b, 0xb9, 0xa4, 0xb8, 0x58, 0x82, 0x45, 0x81, 0x51, 0x83, 0x33, 0x08, 0xc4, + 0x74, 0xf2, 0x3c, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, + 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xfd, 0xf4, 0xcc, + 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0x7d, 0x90, 0x3f, 0x74, 0xc1, 0x86, 0xe8, 0xc3, + 0xbc, 0xa4, 0x5f, 0xa1, 0x0f, 0x0f, 0x86, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x5f, + 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x1d, 0x35, 0x4c, 0x1f, 0x01, 0x00, 0x00, } func (m *PendingNonces) Marshal() (dAtA []byte, err error) { diff --git a/x/observer/types/query.pb.go b/x/observer/types/query.pb.go index f8c16dc42c..4c2dc1375c 100644 --- a/x/observer/types/query.pb.go +++ b/x/observer/types/query.pb.go @@ -14,7 +14,8 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + chains "github.com/zeta-chain/zetacore/pkg/chains" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -787,7 +788,7 @@ func (m *QueryTssHistoryResponse) GetPagination() *query.PageResponse { type QueryProveRequest struct { ChainId int64 `protobuf:"varint,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` TxHash string `protobuf:"bytes,2,opt,name=tx_hash,json=txHash,proto3" json:"tx_hash,omitempty"` - Proof *proto1.Proof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + Proof *proofs.Proof `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` BlockHash string `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` TxIndex int64 `protobuf:"varint,5,opt,name=tx_index,json=txIndex,proto3" json:"tx_index,omitempty"` } @@ -839,7 +840,7 @@ func (m *QueryProveRequest) GetTxHash() string { return "" } -func (m *QueryProveRequest) GetProof() *proto1.Proof { +func (m *QueryProveRequest) GetProof() *proofs.Proof { if m != nil { return m.Proof } @@ -1363,7 +1364,7 @@ func (m *QuerySupportedChains) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySupportedChains proto.InternalMessageInfo type QuerySupportedChainsResponse struct { - Chains []*proto1.Chain `protobuf:"bytes,1,rep,name=chains,proto3" json:"chains,omitempty"` + Chains []*chains.Chain `protobuf:"bytes,1,rep,name=chains,proto3" json:"chains,omitempty"` } func (m *QuerySupportedChainsResponse) Reset() { *m = QuerySupportedChainsResponse{} } @@ -1399,7 +1400,7 @@ func (m *QuerySupportedChainsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QuerySupportedChainsResponse proto.InternalMessageInfo -func (m *QuerySupportedChainsResponse) GetChains() []*proto1.Chain { +func (m *QuerySupportedChainsResponse) GetChains() []*chains.Chain { if m != nil { return m.Chains } @@ -2323,7 +2324,7 @@ func (m *QueryAllBlockHeaderRequest) GetPagination() *query.PageRequest { } type QueryAllBlockHeaderResponse struct { - BlockHeaders []*proto1.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` + BlockHeaders []*proofs.BlockHeader `protobuf:"bytes,1,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -2360,7 +2361,7 @@ func (m *QueryAllBlockHeaderResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllBlockHeaderResponse proto.InternalMessageInfo -func (m *QueryAllBlockHeaderResponse) GetBlockHeaders() []*proto1.BlockHeader { +func (m *QueryAllBlockHeaderResponse) GetBlockHeaders() []*proofs.BlockHeader { if m != nil { return m.BlockHeaders } @@ -2419,7 +2420,7 @@ func (m *QueryGetBlockHeaderByHashRequest) GetBlockHash() []byte { } type QueryGetBlockHeaderByHashResponse struct { - BlockHeader *proto1.BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` + BlockHeader *proofs.BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` } func (m *QueryGetBlockHeaderByHashResponse) Reset() { *m = QueryGetBlockHeaderByHashResponse{} } @@ -2455,7 +2456,7 @@ func (m *QueryGetBlockHeaderByHashResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryGetBlockHeaderByHashResponse proto.InternalMessageInfo -func (m *QueryGetBlockHeaderByHashResponse) GetBlockHeader() *proto1.BlockHeader { +func (m *QueryGetBlockHeaderByHashResponse) GetBlockHeader() *proofs.BlockHeader { if m != nil { return m.BlockHeader } @@ -2611,163 +2612,164 @@ func init() { func init() { proto.RegisterFile("observer/query.proto", fileDescriptor_dcb801e455adaee4) } var fileDescriptor_dcb801e455adaee4 = []byte{ - // 2493 bytes of a gzipped FileDescriptorProto + // 2504 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0xcd, 0x6f, 0x1b, 0xc7, - 0x15, 0xf7, 0x5a, 0x91, 0x2c, 0x3d, 0x7d, 0x58, 0x1e, 0xcb, 0x5f, 0x6b, 0x5b, 0x96, 0xd7, 0x49, - 0x2c, 0x2b, 0x36, 0x19, 0xcb, 0x71, 0xfd, 0x1d, 0x5b, 0x74, 0x63, 0xc9, 0x4e, 0x6a, 0x3b, 0xa4, - 0xdb, 0x04, 0xee, 0x07, 0xbb, 0x24, 0x47, 0xe4, 0xd6, 0xf4, 0x2e, 0xb3, 0x3b, 0x52, 0xc4, 0xa8, - 0x42, 0x8b, 0x1e, 0x83, 0x1e, 0x02, 0x14, 0x68, 0x4f, 0x2d, 0x0a, 0x04, 0x3d, 0x16, 0x28, 0x02, - 0x14, 0x2d, 0x50, 0xf4, 0x90, 0x53, 0x73, 0xe8, 0x21, 0x45, 0x81, 0xa2, 0xbd, 0xb4, 0x81, 0xdd, - 0xfe, 0x1f, 0xc5, 0xbe, 0x7d, 0xcb, 0x9d, 0x5d, 0x2e, 0x97, 0x43, 0x45, 0xb9, 0x71, 0x67, 0xe6, - 0xbd, 0xf9, 0xfd, 0xde, 0xbc, 0x99, 0x37, 0x3f, 0xee, 0xc2, 0x8c, 0x53, 0xf1, 0xb8, 0xbb, 0xce, - 0xdd, 0xfc, 0x7b, 0x6b, 0xdc, 0x6d, 0xe7, 0x5a, 0xae, 0x23, 0x1c, 0x76, 0xf4, 0x03, 0x2e, 0xcc, - 0x6a, 0xc3, 0xb4, 0xec, 0x1c, 0xfe, 0x72, 0x5c, 0x9e, 0x0b, 0x07, 0xea, 0x0b, 0x55, 0x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0xf1, 0x18, 0x8c, 0x85, 0x6e, 0x83, - 0x4b, 0xc4, 0x58, 0x31, 0x6a, 0x30, 0x0e, 0x52, 0xb2, 0x97, 0xd6, 0x5a, 0x2d, 0xc7, 0x15, 0xbc, - 0x86, 0x87, 0xb4, 0x67, 0x14, 0xe8, 0x26, 0x94, 0x68, 0xef, 0x78, 0x35, 0x60, 0x04, 0xb1, 0x87, - 0xf7, 0x92, 0xe0, 0x74, 0x08, 0xaa, 0x37, 0xf5, 0x18, 0x37, 0xc1, 0x88, 0xdd, 0x6f, 0x83, 0xdd, - 0x76, 0xc7, 0x71, 0x55, 0xef, 0x08, 0x2e, 0x9c, 0xca, 0x74, 0x40, 0x58, 0xde, 0x84, 0x89, 0xc0, - 0x43, 0x6c, 0xe7, 0x2b, 0xdc, 0x28, 0xe9, 0xec, 0x18, 0xaf, 0x46, 0x0f, 0xc6, 0xb1, 0xc4, 0x45, - 0x3e, 0x7e, 0xea, 0xd8, 0x89, 0x2b, 0x7b, 0xe2, 0xf4, 0x79, 0x90, 0x8a, 0xe4, 0xac, 0x2a, 0x12, - 0x4c, 0xc8, 0x18, 0x1a, 0x49, 0x56, 0xdc, 0x77, 0x6a, 0x7c, 0x29, 0x50, 0x39, 0xd9, 0xb2, 0xe2, - 0x07, 0x11, 0xc6, 0x98, 0x4d, 0x14, 0x2d, 0x59, 0x31, 0x29, 0x45, 0x4b, 0xf6, 0x33, 0x6e, 0x47, - 0x0f, 0xb2, 0xa2, 0x48, 0xc1, 0xb7, 0x53, 0xb5, 0xf7, 0x13, 0x49, 0x51, 0xa4, 0x51, 0xba, 0x07, - 0xe3, 0x52, 0xb3, 0x92, 0xa2, 0x88, 0x31, 0x92, 0x1e, 0x76, 0xae, 0x10, 0xcf, 0xd1, 0x31, 0xed, - 0xa7, 0x4a, 0x47, 0xd9, 0xde, 0xf1, 0x85, 0x6d, 0x98, 0x4c, 0x3f, 0xd6, 0xe8, 0x0c, 0x4c, 0x1b, - 0x42, 0xd4, 0x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xd9, 0x35, 0x14, 0x81, 0x0a, 0x57, 0xe3, 0x19, - 0x18, 0x46, 0xd9, 0x49, 0x3a, 0x26, 0x78, 0x30, 0x56, 0x49, 0xb9, 0xa6, 0x3b, 0xed, 0xb1, 0xac, - 0x43, 0x83, 0x2f, 0xab, 0x74, 0xb6, 0x16, 0xf0, 0x4e, 0x8d, 0xff, 0xa9, 0xed, 0xf4, 0xaa, 0xfe, - 0x52, 0x93, 0xb3, 0x47, 0x9a, 0x86, 0x88, 0x5c, 0x84, 0x49, 0xf9, 0x2f, 0xbd, 0xb0, 0xde, 0x4f, - 0x63, 0xbd, 0x97, 0x0d, 0x26, 0x2a, 0xd1, 0xc3, 0x0e, 0xfe, 0xcd, 0xb0, 0x44, 0x4b, 0xb8, 0xcc, - 0x85, 0x34, 0x5b, 0xc1, 0xbf, 0x33, 0x37, 0xc2, 0x58, 0xc4, 0x75, 0x88, 0x1f, 0x8b, 0x09, 0x49, - 0x87, 0x18, 0xef, 0xd2, 0x82, 0xa5, 0xbb, 0x20, 0x9e, 0x17, 0x60, 0x42, 0xe6, 0x49, 0x11, 0xed, - 0xa6, 0x39, 0x2e, 0xd1, 0x34, 0xae, 0x47, 0x07, 0xb8, 0x34, 0xc6, 0xbf, 0xa8, 0x29, 0xa4, 0x97, - 0xf1, 0xa3, 0x54, 0x6a, 0x64, 0x4d, 0xb0, 0xbe, 0x0d, 0x4c, 0x86, 0x85, 0x77, 0x48, 0x4e, 0xe0, - 0xce, 0xf5, 0xc9, 0xa7, 0x84, 0xcb, 0xe9, 0x4a, 0xa2, 0x65, 0xf1, 0xe3, 0x79, 0x18, 0x46, 0x04, - 0xec, 0x23, 0x0d, 0x46, 0x82, 0x2b, 0x07, 0xcb, 0x67, 0x7a, 0xed, 0x56, 0x62, 0xfa, 0xab, 0xea, - 0x06, 0x01, 0x29, 0xe3, 0xd4, 0x4f, 0xfe, 0xfe, 0xdf, 0x9f, 0xed, 0x3e, 0xce, 0x8e, 0xe6, 0xfd, - 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, 0xff, 0x14, 0x45, 0x1f, 0x39, 0x01, 0x80, 0x45, 0x81, + 0xef, 0xe0, 0x05, 0xee, 0x60, 0x8c, 0xb7, 0x70, 0x1f, 0x47, 0x61, 0x94, 0x6d, 0x95, 0xc5, 0xdd, + 0x37, 0x2c, 0xe6, 0x65, 0x5b, 0xf7, 0xf8, 0xed, 0xb7, 0x88, 0x5b, 0x10, 0x71, 0x62, 0x28, 0x67, + 0x60, 0x78, 0xd3, 0x6c, 0x22, 0xca, 0xd1, 0xa2, 0x78, 0x08, 0xb7, 0xeb, 0x23, 0x7e, 0xaf, 0x07, + 0xdb, 0xf5, 0x5b, 0xb8, 0x5d, 0x83, 0xd6, 0x70, 0x35, 0x46, 0xc4, 0xfd, 0x8f, 0xab, 0x3d, 0x9f, + 0x7d, 0x58, 0xf0, 0xa1, 0xb8, 0x1c, 0x68, 0x68, 0x34, 0x60, 0x86, 0x7b, 0x5e, 0x35, 0xbd, 0x6f, + 0x3a, 0x8c, 0xd6, 0x82, 0x30, 0xbe, 0x02, 0xfb, 0x45, 0xbd, 0x54, 0xb6, 0x6a, 0xd4, 0x66, 0xd6, + 0x9a, 0x45, 0x5d, 0x4c, 0xcc, 0x69, 0xd1, 0x71, 0x2f, 0x6c, 0x27, 0xf3, 0x30, 0xb9, 0xe9, 0x30, + 0xea, 0x96, 0x4d, 0x91, 0xe1, 0x18, 0xde, 0x09, 0xde, 0x88, 0x59, 0x6f, 0xbc, 0x06, 0x07, 0x13, + 0x33, 0x21, 0x8b, 0x63, 0x30, 0xd6, 0x30, 0xbd, 0xb2, 0x3f, 0x38, 0x08, 0xc6, 0x68, 0x03, 0x07, + 0x19, 0x5f, 0x87, 0x59, 0x6e, 0x55, 0xe0, 0x73, 0x16, 0xda, 0xd1, 0xac, 0xbb, 0x41, 0x6a, 0x30, + 0x18, 0xf3, 0xfd, 0xba, 0x3c, 0x13, 0x3b, 0x60, 0x6b, 0x9d, 0xb0, 0x49, 0x01, 0xc6, 0xfc, 0xe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3, 0x00, 0xff, 0xdf, 0xb0, 0x8c, 0xab, 0xb8, 0x42, 0x99, 0x34, 0x5b, 0xc1, 0xaf, 0x9c, + 0x1b, 0x41, 0x38, 0xe2, 0x6a, 0xc4, 0x0f, 0xc7, 0x84, 0xa4, 0x46, 0x8c, 0xf7, 0x70, 0xcd, 0xd2, + 0x5d, 0x20, 0xd5, 0x37, 0x60, 0x42, 0xa6, 0x8a, 0x41, 0x4d, 0x65, 0x3a, 0x2e, 0x31, 0x35, 0xae, + 0x47, 0xc7, 0xb8, 0x34, 0xc6, 0xaf, 0xd8, 0x14, 0x92, 0xcc, 0xf8, 0x61, 0x2a, 0x3b, 0xb4, 0x46, + 0x64, 0xef, 0x01, 0x91, 0x91, 0xf1, 0x62, 0x92, 0x22, 0xbe, 0xf3, 0x3d, 0xb2, 0x2a, 0xe1, 0x72, + 0xba, 0x92, 0x68, 0x59, 0xfa, 0xe5, 0x02, 0x0c, 0x73, 0x04, 0xe4, 0x63, 0x0d, 0x46, 0x44, 0xe1, + 0x41, 0xf2, 0x99, 0x5e, 0x3b, 0x25, 0x99, 0xfe, 0xaa, 0xba, 0x81, 0x20, 0x65, 0xcc, 0xff, 0xf8, + 0x6f, 0xff, 0xf9, 0xe9, 0xde, 0x13, 0xe4, 0x58, 0xde, 0x1f, 0x7f, 0x9e, 0x9b, 0xe6, 0x13, 0xff, + 0xc8, 0x25, 0x7f, 0xd2, 0x60, 0x34, 0x50, 0x48, 0xe4, 0x42, 0xef, 0x39, 0x12, 0xba, 0x4d, 0x5f, + 0xea, 0xc7, 0x04, 0x81, 0xdd, 0xe7, 0xc0, 0xbe, 0x46, 0x0a, 0xa9, 0xc0, 0x42, 0x6d, 0x96, 0xdf, + 0xee, 0x10, 0x28, 0x3b, 0xf9, 0xed, 0x98, 0x82, 0xda, 0x21, 0x7f, 0xd7, 0x80, 0x74, 0xaa, 0x1c, + 0x72, 0xad, 0x37, 0xac, 0xae, 0x0a, 0x4f, 0xbf, 0xbe, 0x3b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 0x9a, 0xe4, 0x49, 0x5d, 0xa2, 0xed, 0x0e, 0x77, 0xfa, 0x17, 0x79, + 0x3d, 0x24, 0x9a, 0x84, 0xbb, 0x70, 0xef, 0xf3, 0x67, 0xb3, 0xda, 0x17, 0xcf, 0x66, 0xb5, 0x2f, + 0x9f, 0xcd, 0x6a, 0x1f, 0x3f, 0x9f, 0xdd, 0xf3, 0xc5, 0xf3, 0xd9, 0x3d, 0xff, 0x78, 0x3e, 0xbb, + 0xe7, 0x49, 0xbe, 0x6e, 0xb1, 0xc6, 0x46, 0x25, 0x57, 0x75, 0xd6, 0x53, 0x0b, 0xfb, 0x2d, 0x69, + 0xef, 0xb4, 0x5b, 0xd4, 0xab, 0x8c, 0xf0, 0x0f, 0x27, 0x2f, 0xfe, 0x2f, 0x00, 0x00, 0xff, 0xff, + 0xcd, 0x82, 0xdb, 0xae, 0x1e, 0x2b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -8048,7 +8050,7 @@ func (m *QueryProveRequest) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Proof == nil { - m.Proof = &proto1.Proof{} + m.Proof = &proofs.Proof{} } if err := m.Proof.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -9090,7 +9092,7 @@ func (m *QuerySupportedChainsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Chains = append(m.Chains, &proto1.Chain{}) + m.Chains = append(m.Chains, &chains.Chain{}) if err := m.Chains[len(m.Chains)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -10876,7 +10878,7 @@ func (m *QueryAllBlockHeaderResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.BlockHeaders = append(m.BlockHeaders, &proto1.BlockHeader{}) + m.BlockHeaders = append(m.BlockHeaders, &proofs.BlockHeader{}) if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -11081,7 +11083,7 @@ func (m *QueryGetBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.BlockHeader == nil { - m.BlockHeader = &proto1.BlockHeader{} + m.BlockHeader = &proofs.BlockHeader{} } if err := m.BlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/observer/types/tx.pb.go b/x/observer/types/tx.pb.go index 354ea8a244..fef0e1ec4a 100644 --- a/x/observer/types/tx.pb.go +++ b/x/observer/types/tx.pb.go @@ -13,7 +13,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" - proto1 "github.com/zeta-chain/zetacore/pkg/proto" + proofs "github.com/zeta-chain/zetacore/pkg/proofs" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -139,7 +139,7 @@ type MsgAddBlockHeader struct { ChainId int64 `protobuf:"varint,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` BlockHash []byte `protobuf:"bytes,3,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` Height int64 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` - Header proto1.HeaderData `protobuf:"bytes,5,opt,name=header,proto3" json:"header"` + Header proofs.HeaderData `protobuf:"bytes,5,opt,name=header,proto3" json:"header"` } func (m *MsgAddBlockHeader) Reset() { *m = MsgAddBlockHeader{} } @@ -203,11 +203,11 @@ func (m *MsgAddBlockHeader) GetHeight() int64 { return 0 } -func (m *MsgAddBlockHeader) GetHeader() proto1.HeaderData { +func (m *MsgAddBlockHeader) GetHeader() proofs.HeaderData { if m != nil { return m.Header } - return proto1.HeaderData{} + return proofs.HeaderData{} } type MsgAddBlockHeaderResponse struct { @@ -950,71 +950,71 @@ func init() { func init() { proto.RegisterFile("observer/tx.proto", fileDescriptor_1bcd40fa296a2b1d) } var fileDescriptor_1bcd40fa296a2b1d = []byte{ - // 1020 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x35, 0xa3, 0xc4, 0xb1, 0xaf, 0xfc, 0x9c, 0xca, 0xb1, 0x2c, 0xc7, 0x8a, 0xc1, 0x45, 0xa1, - 0xb6, 0x8e, 0x14, 0x2b, 0x6d, 0xd1, 0x14, 0xe8, 0xc2, 0xee, 0xc3, 0x56, 0xd3, 0xc4, 0x06, 0x81, - 0x7a, 0xd1, 0x0d, 0x31, 0xe2, 0x8c, 0x49, 0xc2, 0xd4, 0x8c, 0xc0, 0xa1, 0x62, 0xab, 0x68, 0x0b, - 0xf4, 0x03, 0x8a, 0xf6, 0x03, 0xfa, 0x0d, 0xfd, 0x8a, 0x2e, 0xb2, 0xcc, 0xb2, 0xab, 0xa2, 0xb0, - 0x57, 0xed, 0x0f, 0x74, 0x1b, 0x70, 0x48, 0x8e, 0x44, 0x3d, 0x28, 0xc9, 0x3b, 0xce, 0xdc, 0x73, - 0xcf, 0x7d, 0xcc, 0x99, 0x3b, 0x84, 0x75, 0xde, 0x14, 0xd4, 0x7f, 0x45, 0xfd, 0x5a, 0x70, 0x55, - 0x6d, 0xfb, 0x3c, 0xe0, 0x68, 0xfb, 0x7b, 0x1a, 0x60, 0xcb, 0xc1, 0x2e, 0xab, 0xca, 0x2f, 0xee, - 0xd3, 0x6a, 0x82, 0x2a, 0x15, 0x6c, 0x6e, 0x73, 0x89, 0xab, 0x85, 0x5f, 0x91, 0x4b, 0xa9, 0xa0, - 0x58, 0x9a, 0x1e, 0x6e, 0xd1, 0x78, 0xf7, 0x91, 0xda, 0xb5, 0x7c, 0x2e, 0x84, 0xa4, 0x34, 0xcf, - 0x3d, 0x6c, 0x8b, 0x18, 0xb0, 0xa9, 0x00, 0xc9, 0x47, 0x6c, 0xd8, 0x50, 0x86, 0x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xd4, 0x5c, 0xd8, 0x9b, 0x8e, 0x2e, 0x42, 0x4f, 0xee, 0xc1, - 0xa8, 0x81, 0x11, 0x2a, 0x7f, 0xe0, 0x7f, 0xac, 0x3a, 0x55, 0x2f, 0x15, 0x7e, 0xb2, 0xf2, 0x47, - 0xff, 0x3f, 0xa1, 0x9f, 0x60, 0x6d, 0x68, 0x4c, 0x3d, 0x99, 0x2c, 0xa0, 0xb4, 0x47, 0xe9, 0x93, - 0x59, 0x3d, 0x92, 0xf8, 0x87, 0x8d, 0xd7, 0xd7, 0x65, 0xed, 0xcd, 0x75, 0x59, 0xfb, 0xe7, 0xba, - 0xac, 0xfd, 0x76, 0x53, 0x9e, 0x7b, 0x73, 0x53, 0x9e, 0xfb, 0xeb, 0xa6, 0x3c, 0xf7, 0x5d, 0xcd, - 0x76, 0x03, 0xa7, 0xd3, 0xac, 0x5a, 0xbc, 0x55, 0x0b, 0x39, 0x1f, 0x4b, 0xfa, 0x5a, 0x42, 0x5f, - 0xbb, 0xaa, 0xf5, 0x7e, 0xfa, 0xbb, 0x6d, 0x2a, 0x9a, 0xf3, 0xf2, 0x47, 0xff, 0xe9, 0xdb, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x8d, 0xcb, 0xc0, 0x5e, 0xd9, 0x0c, 0x00, 0x00, + // 1024 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xae, 0x37, 0xfb, 0xd1, 0xbe, 0xe9, 0xf6, 0x63, 0x48, 0xb7, 0x69, 0xba, 0xcd, 0x56, 0x3e, + 0xa0, 0x00, 0x25, 0x69, 0xb3, 0x80, 0x58, 0x24, 0x0e, 0x2d, 0x1f, 0x6d, 0x58, 0x76, 0x5b, 0x59, + 0xa2, 0x07, 0x2e, 0xd6, 0xc4, 0x33, 0xb1, 0xad, 0x3a, 0x33, 0x91, 0x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+ 0x28, 0x70, 0x8f, 0x98, 0x49, 0x08, 0x13, 0x13, 0xe2, 0x53, 0x21, 0x8a, 0x77, 0x24, 0x0c, 0x71, + 0x8f, 0x24, 0x24, 0x87, 0x91, 0x25, 0xf4, 0x60, 0xf4, 0x72, 0xd4, 0x23, 0x17, 0x79, 0x30, 0x7a, + 0x39, 0xec, 0x71, 0x0e, 0x0f, 0xbb, 0x32, 0x1f, 0xd3, 0xa7, 0x58, 0x70, 0x56, 0xbc, 0xbb, 0xab, + 0x55, 0x56, 0xea, 0x07, 0xd5, 0x8c, 0x13, 0xa9, 0x26, 0x24, 0x51, 0x25, 0x86, 0x74, 0x34, 0x96, + 0xbb, 0x03, 0x2b, 0x7d, 0x1b, 0xb6, 0x46, 0x4a, 0x35, 0xa8, 0xe8, 0x70, 0x26, 0xa8, 0xfe, 0x7b, + 0xd4, 0x88, 0x43, 0x42, 0x8e, 0x3c, 0x6e, 0x5d, 0x9c, 0x50, 0x4c, 0x32, 0x1b, 0xb1, 0x05, 0x8b, + 0xd1, 0x49, 0xba, 0x44, 0x16, 0x9f, 0x33, 0x1e, 0xc8, 0x75, 0x83, 0xa0, 0x1d, 0x80, 0x66, 0xc8, + 0x61, 0x3a, 0x58, 0x38, 0xb2, 0xce, 0x65, 0x63, 0x49, 0xee, 0x9c, 0x60, 0xe1, 0xa0, 0x47, 0x70, + 0xdf, 0xa1, 0xae, 0xed, 0x04, 0xb2, 0xae, 0x9c, 0x11, 0xaf, 0xd0, 0x7e, 0xb8, 0x1f, 0x46, 0x2d, + 0xde, 0xdb, 0xd5, 0x2a, 0xf9, 0x3a, 0xaa, 0xc6, 0x27, 0x15, 0xe5, 0xf2, 0x39, 0x0e, 0xf0, 0xd1, + 0xdd, 0xd7, 0x7f, 0x3d, 0x59, 0x30, 0x62, 0x5c, 0x5c, 0x50, 0x3a, 0x65, 0x55, 0xd0, 0xf7, 0x50, + 0x50, 0xd5, 0x7e, 0x16, 0x66, 0x76, 0x26, 0x35, 0x94, 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f2, 0xc2, 0x9b, 0x9b, 0xf2, 0xc2, 0x9f, 0x37, 0xe5, + 0x85, 0x6f, 0x6b, 0xb6, 0x1b, 0x38, 0xdd, 0x66, 0xd5, 0xe2, 0xed, 0x5a, 0xc8, 0xf9, 0xbe, 0xa4, + 0xaf, 0x25, 0xf4, 0xb5, 0xab, 0x5a, 0xff, 0x3f, 0x80, 0x5e, 0x87, 0x8a, 0xe6, 0x7d, 0xf9, 0xad, + 0xff, 0xf4, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0xc5, 0x1a, 0xf7, 0xc9, 0xe6, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/zetaclient/app_context/app_context.go b/zetaclient/app_context/app_context.go index 537b830e7a..ba4cafbace 100644 --- a/zetaclient/app_context/app_context.go +++ b/zetaclient/app_context/app_context.go @@ -1,7 +1,7 @@ package appcontext import ( - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/zetaclient/config" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" ) @@ -32,12 +32,12 @@ func (a AppContext) ZetaCoreContext() *corecontext.ZetaCoreContext { } // GetBTCChainAndConfig returns btc chain and config if enabled -func (a AppContext) GetBTCChainAndConfig() (pkg.Chain, config.BTCConfig, bool) { +func (a AppContext) GetBTCChainAndConfig() (chains.Chain, config.BTCConfig, bool) { btcConfig, configEnabled := a.Config().GetBTCConfig() btcChain, _, paramsEnabled := a.ZetaCoreContext().GetBTCChainParams() if !configEnabled || !paramsEnabled { - return pkg.Chain{}, config.BTCConfig{}, false + return chains.Chain{}, config.BTCConfig{}, false } return btcChain, btcConfig, true diff --git a/zetaclient/authz/authz_signer.go b/zetaclient/authz/authz_signer.go index c17f5c5704..42f9cea92a 100644 --- a/zetaclient/authz/authz_signer.go +++ b/zetaclient/authz/authz_signer.go @@ -2,12 +2,12 @@ package authz import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/authz" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" ) type Signer struct { - KeyType pkg.KeyType + KeyType authz.KeyType GranterAddress string GranteeAddress sdk.AccAddress } @@ -21,7 +21,7 @@ var signers map[string]Signer func init() { signersList := make(map[string]Signer) for _, tx := range crosschaintypes.GetAllAuthzZetaclientTxTypes() { - signersList[tx] = Signer{KeyType: pkg.ZetaClientGranteeKey} + signersList[tx] = Signer{KeyType: authz.ZetaClientGranteeKey} } signers = signersList } diff --git a/zetaclient/bitcoin/bitcoin_client.go b/zetaclient/bitcoin/bitcoin_client.go index 4bc9477890..60f1f83d85 100644 --- a/zetaclient/bitcoin/bitcoin_client.go +++ b/zetaclient/bitcoin/bitcoin_client.go @@ -13,6 +13,10 @@ 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/proofs" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" @@ -34,7 +38,6 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/pkg/errors" "github.com/rs/zerolog" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" clienttypes "github.com/zeta-chain/zetacore/zetaclient/types" @@ -62,7 +65,7 @@ type BTCLog struct { // BTCChainClient represents a chain configuration for Bitcoin // Filled with above constants depending on chain type BTCChainClient struct { - chain pkg.Chain + chain chains.Chain netParams *chaincfg.Params rpcClient interfaces.BTCRPCClient zetaClient interfaces.ZetaCoreBridger @@ -118,7 +121,7 @@ func (ob *BTCChainClient) WithBtcClient(client *rpcclient.Client) { ob.rpcClient = client } -func (ob *BTCChainClient) WithChain(chain pkg.Chain) { +func (ob *BTCChainClient) WithChain(chain chains.Chain) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.chain = chain @@ -139,7 +142,7 @@ func (ob *BTCChainClient) GetChainParams() observertypes.ChainParams { // NewBitcoinClient returns a new configuration based on supplied target chain func NewBitcoinClient( appcontext *appcontext.AppContext, - chain pkg.Chain, + chain chains.Chain, bridge interfaces.ZetaCoreBridger, tss interfaces.TSSSigner, dbpath string, @@ -152,7 +155,7 @@ func NewBitcoinClient( } ob.stop = make(chan struct{}) ob.chain = chain - netParams, err := pkg.BitcoinNetParamsFromChainID(ob.chain.ChainId) + netParams, err := chains.BitcoinNetParamsFromChainID(ob.chain.ChainId) if err != nil { return nil, fmt.Errorf("error getting net params for chain %d: %s", ob.chain.ChainId, err) } @@ -370,7 +373,7 @@ func (ob *BTCChainClient) postBlockHeader(tip int64) error { ob.chain.ChainId, blockHash[:], res2.Block.Height, - pkg.NewBitcoinHeader(headerBuf.Bytes()), + proofs.NewBitcoinHeader(headerBuf.Bytes()), ) ob.logger.WatchInTx.Info().Msgf("posted block header %d: %s", bn, blockHash) if err != nil { // error shouldn't block the process @@ -559,10 +562,10 @@ func (ob *BTCChainClient) IsSendOutTxProcessed(cctx *types.CrossChainTx, logger nil, // gas price not used with Bitcoin 0, // gas limit not used with Bitcoin amountInSat, - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, ob.chain, nonce, - pkg.CoinType_Gas, + coin.CoinType_Gas, ) if err != nil { logger.Error().Err(err).Msgf("IsSendOutTxProcessed: error confirming bitcoin outTx %s, nonce %d ballot %s", res.TxID, nonce, ballot) @@ -699,7 +702,7 @@ func (ob *BTCChainClient) GetInboundVoteMessageFromBtcEvent(inTx *BTCInTxEvnet) inTx.TxHash, inTx.BlockNumber, 0, - pkg.CoinType_Gas, + coin.CoinType_Gas, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), 0, @@ -709,7 +712,7 @@ func (ob *BTCChainClient) GetInboundVoteMessageFromBtcEvent(inTx *BTCInTxEvnet) // IsInTxRestricted returns true if the inTx contains restricted addresses func (ob *BTCChainClient) IsInTxRestricted(inTx *BTCInTxEvnet) bool { receiver := "" - parsedAddress, _, err := pkg.ParseAddressAndData(hex.EncodeToString(inTx.MemoBytes)) + parsedAddress, _, err := chains.ParseAddressAndData(hex.EncodeToString(inTx.MemoBytes)) if err == nil && parsedAddress != (ethcommon.Address{}) { receiver = parsedAddress.Hex() } @@ -852,7 +855,7 @@ func (ob *BTCChainClient) FetchUTXOS() error { // List all unspent UTXOs (160ms) tssAddr := ob.Tss.BTCAddress() - address, err := pkg.DecodeBtcAddress(tssAddr, ob.chain.ChainId) + address, err := chains.DecodeBtcAddress(tssAddr, ob.chain.ChainId) if err != nil { return fmt.Errorf("btc: error decoding wallet address (%s) : %s", tssAddr, err.Error()) } @@ -967,7 +970,7 @@ func (ob *BTCChainClient) getOutTxidByNonce(nonce uint64, test bool) (string, er func (ob *BTCChainClient) findNonceMarkUTXO(nonce uint64, txid string) (int, error) { tssAddress := ob.Tss.BTCAddressWitnessPubkeyHash().EncodeAddress() - amount := pkg.NonceMarkAmount(nonce) + amount := chains.NonceMarkAmount(nonce) for i, utxo := range ob.utxos { sats, err := GetSatoshis(utxo.Amount) if err != nil { @@ -1340,8 +1343,8 @@ func (ob *BTCChainClient) checkTSSVout(params *types.OutboundTxParams, vouts []b if recvAddress != tssAddress { return fmt.Errorf("checkTSSVout: nonce-mark address %s not match TSS address %s", recvAddress, tssAddress) } - if amount != pkg.NonceMarkAmount(nonce) { - return fmt.Errorf("checkTSSVout: nonce-mark amount %d not match nonce-mark amount %d", amount, pkg.NonceMarkAmount(nonce)) + if amount != chains.NonceMarkAmount(nonce) { + return fmt.Errorf("checkTSSVout: nonce-mark amount %d not match nonce-mark amount %d", amount, chains.NonceMarkAmount(nonce)) } } // 2nd vout: payment to recipient @@ -1385,8 +1388,8 @@ func (ob *BTCChainClient) checkTSSVoutCancelled(params *types.OutboundTxParams, if recvAddress != tssAddress { return fmt.Errorf("checkTSSVoutCancelled: nonce-mark address %s not match TSS address %s", recvAddress, tssAddress) } - if amount != pkg.NonceMarkAmount(nonce) { - return fmt.Errorf("checkTSSVoutCancelled: nonce-mark amount %d not match nonce-mark amount %d", amount, pkg.NonceMarkAmount(nonce)) + if amount != chains.NonceMarkAmount(nonce) { + return fmt.Errorf("checkTSSVoutCancelled: nonce-mark amount %d not match nonce-mark amount %d", amount, chains.NonceMarkAmount(nonce)) } } // 2nd vout: change to TSS (optional) diff --git a/zetaclient/bitcoin/bitcoin_client_rpc_test.go b/zetaclient/bitcoin/bitcoin_client_rpc_test.go index f5f7e43efe..d4f65ed84a 100644 --- a/zetaclient/bitcoin/bitcoin_client_rpc_test.go +++ b/zetaclient/bitcoin/bitcoin_client_rpc_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -47,7 +47,7 @@ func (suite *BitcoinClientTestSuite) SetupTest() { PrivKey: privateKey, } appContext := appcontext.NewAppContext(&corecontext.ZetaCoreContext{}, config.Config{}) - client, err := NewBitcoinClient(appContext, pkg.BtcRegtestChain(), nil, tss, tempSQLiteDbPath, + client, err := NewBitcoinClient(appContext, chains.BtcRegtestChain(), nil, tss, tempSQLiteDbPath, clientcommon.DefaultLoggers(), config.BTCConfig{}, nil) suite.Require().NoError(err) suite.BitcoinChainClient = client diff --git a/zetaclient/bitcoin/bitcoin_client_test.go b/zetaclient/bitcoin/bitcoin_client_test.go index 28c1ef60ce..fa7a84b02f 100644 --- a/zetaclient/bitcoin/bitcoin_client_test.go +++ b/zetaclient/bitcoin/bitcoin_client_test.go @@ -15,7 +15,7 @@ import ( "github.com/btcsuite/btcutil" "github.com/rs/zerolog/log" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" observertypes "github.com/zeta-chain/zetacore/x/observer/types" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" @@ -32,7 +32,7 @@ func MockBTCClientMainnet() *BTCChainClient { coreContext := corecontext.NewZetaCoreContext(cfg) return &BTCChainClient{ - chain: pkg.BtcMainnetChain(), + chain: chains.BtcMainnetChain(), zetaClient: stub.NewMockZetaCoreBridge(), Tss: stub.NewTSSMainnet(), coreContext: coreContext, @@ -44,7 +44,7 @@ func TestNewBitcoinClient(t *testing.T) { cfg := config.NewConfig() coreContext := corecontext.NewZetaCoreContext(cfg) appContext := appcontext.NewAppContext(coreContext, cfg) - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() bridge := stub.NewMockZetaCoreBridge() tss := stub.NewMockTSS(sample.EthAddress().String(), "") loggers := clientcommon.ClientLogger{} diff --git a/zetaclient/bitcoin/bitcoin_signer.go b/zetaclient/bitcoin/bitcoin_signer.go index 8ceb8fea19..747649be06 100644 --- a/zetaclient/bitcoin/bitcoin_signer.go +++ b/zetaclient/bitcoin/bitcoin_signer.go @@ -8,6 +8,8 @@ import ( "math/rand" "time" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" ethcommon "github.com/ethereum/go-ethereum/common" @@ -25,7 +27,6 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/rs/zerolog" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -106,11 +107,11 @@ func (signer *BTCSigner) SignWithdrawTx( btcClient *BTCChainClient, height uint64, nonce uint64, - chain *pkg.Chain, + chain *chains.Chain, cancelTx bool, ) (*wire.MsgTx, error) { estimateFee := float64(gasPrice.Uint64()*outTxBytesMax) / 1e8 - nonceMark := pkg.NonceMarkAmount(nonce) + nonceMark := chains.NonceMarkAmount(nonce) // refresh unspent UTXOs and continue with keysign regardless of error err := btcClient.FetchUTXOS() @@ -285,7 +286,7 @@ func (signer *BTCSigner) TryProcessOutTx( Logger() params := cctx.GetCurrentOutTxParam() - if params.CoinType == pkg.CoinType_Zeta || params.CoinType == pkg.CoinType_ERC20 { + if params.CoinType == coin.CoinType_Zeta || params.CoinType == coin.CoinType_ERC20 { logger.Error().Msgf("BTC TryProcessOutTx: can only send BTC to a BTC network") return } @@ -312,12 +313,12 @@ func (signer *BTCSigner) TryProcessOutTx( } // Check receiver P2WPKH address - bitcoinNetParams, err := pkg.BitcoinNetParamsFromChainID(params.ReceiverChainId) + bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(params.ReceiverChainId) if err != nil { logger.Error().Err(err).Msgf("cannot get bitcoin net params%v", err) return } - addr, err := pkg.DecodeBtcAddress(params.Receiver, params.ReceiverChainId) + addr, err := chains.DecodeBtcAddress(params.Receiver, params.ReceiverChainId) if err != nil { logger.Error().Err(err).Msgf("cannot decode address %s ", params.Receiver) return diff --git a/zetaclient/bitcoin/bitcoin_signer_test.go b/zetaclient/bitcoin/bitcoin_signer_test.go index a464395ee9..26e79ed8d6 100644 --- a/zetaclient/bitcoin/bitcoin_signer_test.go +++ b/zetaclient/bitcoin/bitcoin_signer_test.go @@ -19,7 +19,7 @@ import ( "github.com/btcsuite/btcutil" "github.com/ethereum/go-ethereum/crypto" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" "github.com/zeta-chain/zetacore/zetaclient/config" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" @@ -458,7 +458,7 @@ func mineTxNSetNonceMark(ob *BTCChainClient, nonce uint64, txid string, preMarkI // Set nonce mark tssAddress := ob.Tss.BTCAddressWitnessPubkeyHash().EncodeAddress() - nonceMark := btcjson.ListUnspentResult{TxID: txid, Address: tssAddress, Amount: float64(pkg.NonceMarkAmount(nonce)) * 1e-8} + nonceMark := btcjson.ListUnspentResult{TxID: txid, Address: tssAddress, Amount: float64(chains.NonceMarkAmount(nonce)) * 1e-8} if preMarkIndex >= 0 { // replace nonce-mark utxo ob.utxos[preMarkIndex] = nonceMark diff --git a/zetaclient/bitcoin/bitcoin_test.go b/zetaclient/bitcoin/bitcoin_test.go index ffb0f19d44..12e9e29136 100644 --- a/zetaclient/bitcoin/bitcoin_test.go +++ b/zetaclient/bitcoin/bitcoin_test.go @@ -7,6 +7,7 @@ import ( "math/big" "testing" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/btcsuite/btcd/btcec" @@ -16,7 +17,6 @@ import ( "github.com/btcsuite/btcd/wire" "github.com/btcsuite/btcutil" "github.com/stretchr/testify/suite" - "github.com/zeta-chain/zetacore/pkg" "gorm.io/driver/sqlite" "gorm.io/gorm" ) @@ -145,7 +145,7 @@ func getTSSTX(tss *interfaces.TestSigner, tx *wire.MsgTx, sigHashes *txscript.Tx return "", err } - sig65B, err := tss.Sign(witnessHash, 10, 10, &pkg.Chain{}, "") + sig65B, err := tss.Sign(witnessHash, 10, 10, &chains.Chain{}, "") R := big.NewInt(0).SetBytes(sig65B[:32]) S := big.NewInt(0).SetBytes(sig65B[32:64]) sig := btcec.Signature{ diff --git a/zetaclient/bitcoin/inbound_tracker.go b/zetaclient/bitcoin/inbound_tracker.go index c1e4851be3..2a6b80c124 100644 --- a/zetaclient/bitcoin/inbound_tracker.go +++ b/zetaclient/bitcoin/inbound_tracker.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/zetaclient/types" "github.com/zeta-chain/zetacore/zetaclient/zetabridge" ) @@ -44,7 +44,7 @@ func (ob *BTCChainClient) ObserveTrackerSuggestions() error { if err != nil { return err } - ob.logger.WatchInTx.Info().Msgf("Vote submitted for inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, pkg.CoinType_Gas.String()) + ob.logger.WatchInTx.Info().Msgf("Vote submitted for inbound Tracker,Chain : %s,Ballot Identifier : %s, coin-type %s", ob.chain.ChainName, ballotIdentifier, coin.CoinType_Gas.String()) } return nil } diff --git a/zetaclient/bitcoin/utils.go b/zetaclient/bitcoin/utils.go index 98c9ebc73e..12d24a5880 100644 --- a/zetaclient/bitcoin/utils.go +++ b/zetaclient/bitcoin/utils.go @@ -12,7 +12,7 @@ import ( "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcutil" "github.com/rs/zerolog" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" "github.com/btcsuite/btcd/txscript" @@ -172,11 +172,11 @@ func CalcDepositorFee(blockVb *btcjson.GetBlockVerboseTxResult, chainID int64, n dynamicFee := true // use default fee for regnet - if pkg.IsBitcoinRegnet(chainID) { + if chains.IsBitcoinRegnet(chainID) { dynamicFee = false } // mainnet dynamic fee takes effect only after a planned upgrade height - if pkg.IsBitcoinMainnet(chainID) && blockVb.Height < DynamicDepositorFeeHeight { + if chains.IsBitcoinMainnet(chainID) && blockVb.Height < DynamicDepositorFeeHeight { dynamicFee = false } if !dynamicFee { @@ -227,7 +227,7 @@ func PayToWitnessPubKeyHashScript(pubKeyHash []byte) ([]byte, error) { } // DecodeP2WPKHVout decodes receiver and amount from P2WPKH output -func DecodeP2WPKHVout(vout btcjson.Vout, chain pkg.Chain) (string, int64, error) { +func DecodeP2WPKHVout(vout btcjson.Vout, chain chains.Chain) (string, int64, error) { amount, err := GetSatoshis(vout.Value) if err != nil { return "", 0, errors.Wrap(err, "error getting satoshis") diff --git a/zetaclient/bitcoin/utils_test.go b/zetaclient/bitcoin/utils_test.go index 48ae850c6b..7196460cd8 100644 --- a/zetaclient/bitcoin/utils_test.go +++ b/zetaclient/bitcoin/utils_test.go @@ -6,14 +6,14 @@ import ( "github.com/btcsuite/btcd/btcjson" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/zetaclient/testutils" ) func TestDecodeP2WPKHVout(t *testing.T) { // load archived outtx raw result // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() nonce := uint64(148) nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCOuttx(chain.ChainId, nonce)) @@ -26,7 +26,7 @@ func TestDecodeP2WPKHVout(t *testing.T) { receiver, amount, err := DecodeP2WPKHVout(rawResult.Vout[0], chain) require.NoError(t, err) require.Equal(t, testutils.TSSAddressBTCMainnet, receiver) - require.Equal(t, pkg.NonceMarkAmount(nonce), amount) + require.Equal(t, chains.NonceMarkAmount(nonce), amount) // decode vout 1, payment 0.00012000 BTC receiver, amount, err = DecodeP2WPKHVout(rawResult.Vout[1], chain) @@ -44,7 +44,7 @@ func TestDecodeP2WPKHVout(t *testing.T) { func TestDecodeP2WPKHVoutErrors(t *testing.T) { // load archived outtx raw result // https://blockstream.info/tx/030cd813443f7b70cc6d8a544d320c6d8465e4528fc0f3410b599dc0b26753a0 - chain := pkg.BtcMainnetChain() + chain := chains.BtcMainnetChain() nonce := uint64(148) nameTx := path.Join("../", testutils.TestDataPathBTC, testutils.FileNameBTCOuttx(chain.ChainId, nonce)) diff --git a/zetaclient/config/config_chain.go b/zetaclient/config/config_chain.go index 1f541f5ecb..869d9111ea 100644 --- a/zetaclient/config/config_chain.go +++ b/zetaclient/config/config_chain.go @@ -1,8 +1,6 @@ package config -import ( - "github.com/zeta-chain/zetacore/pkg" -) +import "github.com/zeta-chain/zetacore/pkg/chains" const ( BtcConfirmationCount = 1 @@ -46,26 +44,26 @@ var bitcoinConfigRegnet = BTCConfig{ } var evmChainsConfigs = map[int64]EVMConfig{ - pkg.EthChain().ChainId: { - Chain: pkg.EthChain(), + chains.EthChain().ChainId: { + Chain: chains.EthChain(), }, - pkg.BscMainnetChain().ChainId: { - Chain: pkg.BscMainnetChain(), + chains.BscMainnetChain().ChainId: { + Chain: chains.BscMainnetChain(), }, - pkg.GoerliChain().ChainId: { - Chain: pkg.GoerliChain(), + chains.GoerliChain().ChainId: { + Chain: chains.GoerliChain(), Endpoint: "", }, - pkg.BscTestnetChain().ChainId: { - Chain: pkg.BscTestnetChain(), + chains.BscTestnetChain().ChainId: { + Chain: chains.BscTestnetChain(), Endpoint: "", }, - pkg.MumbaiChain().ChainId: { - Chain: pkg.MumbaiChain(), + chains.MumbaiChain().ChainId: { + Chain: chains.MumbaiChain(), Endpoint: "", }, - pkg.GoerliLocalnetChain().ChainId: { - Chain: pkg.GoerliLocalnetChain(), + chains.GoerliLocalnetChain().ChainId: { + Chain: chains.GoerliLocalnetChain(), Endpoint: "http://eth:8545", }, } diff --git a/zetaclient/config/types.go b/zetaclient/config/types.go index f92eb1518d..ea861d46bb 100644 --- a/zetaclient/config/types.go +++ b/zetaclient/config/types.go @@ -5,7 +5,7 @@ import ( "strings" "sync" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" ) // KeyringBackend is the type of keyring backend to use for the hotkey @@ -27,7 +27,7 @@ type ClientConfiguration struct { } type EVMConfig struct { - Chain pkg.Chain + Chain chains.Chain Endpoint string } diff --git a/zetaclient/core_context/zeta_core_context.go b/zetaclient/core_context/zeta_core_context.go index 2402b99a8c..d35c502c86 100644 --- a/zetaclient/core_context/zeta_core_context.go +++ b/zetaclient/core_context/zeta_core_context.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/rs/zerolog" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" ) @@ -16,7 +16,7 @@ import ( type ZetaCoreContext struct { coreContextLock *sync.RWMutex keygen observertypes.Keygen - chainsEnabled []pkg.Chain + chainsEnabled []chains.Chain evmChainParams map[int64]*observertypes.ChainParams bitcoinChainParams *observertypes.ChainParams currentTssPubkey string @@ -37,7 +37,7 @@ func NewZetaCoreContext(cfg config.Config) *ZetaCoreContext { } return &ZetaCoreContext{ coreContextLock: new(sync.RWMutex), - chainsEnabled: []pkg.Chain{}, + chainsEnabled: []chains.Chain{}, evmChainParams: evmChainParams, bitcoinChainParams: bitcoinChainParams, crossChainFlags: observertypes.CrosschainFlags{}, @@ -66,10 +66,10 @@ func (c *ZetaCoreContext) GetCurrentTssPubkey() string { return c.currentTssPubkey } -func (c *ZetaCoreContext) GetEnabledChains() []pkg.Chain { +func (c *ZetaCoreContext) GetEnabledChains() []chains.Chain { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() - copiedChains := make([]pkg.Chain, len(c.chainsEnabled)) + copiedChains := make([]chains.Chain, len(c.chainsEnabled)) copy(copiedChains, c.chainsEnabled) return copiedChains } @@ -94,14 +94,14 @@ func (c *ZetaCoreContext) GetAllEVMChainParams() map[int64]*observertypes.ChainP return copied } -func (c *ZetaCoreContext) GetBTCChainParams() (pkg.Chain, *observertypes.ChainParams, bool) { +func (c *ZetaCoreContext) GetBTCChainParams() (chains.Chain, *observertypes.ChainParams, bool) { c.coreContextLock.RLock() defer c.coreContextLock.RUnlock() if c.bitcoinChainParams == nil { // bitcoin is not enabled - return pkg.Chain{}, &observertypes.ChainParams{}, false + return chains.Chain{}, &observertypes.ChainParams{}, false } - chain := pkg.GetChainFromChainID(c.bitcoinChainParams.ChainId) + chain := chains.GetChainFromChainID(c.bitcoinChainParams.ChainId) if chain == nil { panic(fmt.Sprintf("BTCChain is missing for chainID %d", c.bitcoinChainParams.ChainId)) } @@ -118,7 +118,7 @@ func (c *ZetaCoreContext) GetCrossChainFlags() observertypes.CrosschainFlags { // this must be the ONLY function that writes to core context func (c *ZetaCoreContext) Update( keygen *observertypes.Keygen, - newChains []pkg.Chain, + newChains []chains.Chain, evmChainParams map[int64]*observertypes.ChainParams, btcChainParams *observertypes.ChainParams, tssPubKey string, diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index a6e285f7a6..14f36a1cc2 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" observertypes "github.com/zeta-chain/zetacore/x/observer/types" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" @@ -31,7 +31,7 @@ func TestNewZetaCoreContext(t *testing.T) { // assert btc chain params chain, btcChainParams, btcChainParamsFound := zetaContext.GetBTCChainParams() - require.Equal(t, pkg.Chain{}, chain) + require.Equal(t, chains.Chain{}, chain) require.False(t, btcChainParamsFound) require.Equal(t, &observertypes.ChainParams{}, btcChainParams) @@ -44,13 +44,13 @@ func TestNewZetaCoreContext(t *testing.T) { testCfg := config.NewConfig() testCfg.EVMChainConfigs = map[int64]config.EVMConfig{ 1: { - Chain: pkg.Chain{ + Chain: chains.Chain{ ChainName: 1, ChainId: 1, }, }, 2: { - Chain: pkg.Chain{ + Chain: chains.Chain{ ChainName: 2, ChainId: 2, }, @@ -103,7 +103,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { Status: observertypes.KeygenStatus_KeyGenSuccess, GranteePubkeys: []string{"testpubkey1"}, } - enabledChainsToUpdate := []pkg.Chain{ + enabledChainsToUpdate := []chains.Chain{ { ChainName: 1, ChainId: 1, @@ -151,7 +151,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { // assert btc chain params still empty because they were not specified in config chain, btcChainParams, btcChainParamsFound := zetaContext.GetBTCChainParams() - require.Equal(t, pkg.Chain{}, chain) + require.Equal(t, chains.Chain{}, chain) require.False(t, btcChainParamsFound) require.Equal(t, &observertypes.ChainParams{}, btcChainParams) @@ -167,13 +167,13 @@ func TestUpdateZetaCoreContext(t *testing.T) { testCfg := config.NewConfig() testCfg.EVMChainConfigs = map[int64]config.EVMConfig{ 1: { - Chain: pkg.Chain{ + Chain: chains.Chain{ ChainName: 1, ChainId: 1, }, }, 2: { - Chain: pkg.Chain{ + Chain: chains.Chain{ ChainName: 2, ChainId: 2, }, @@ -193,7 +193,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { Status: observertypes.KeygenStatus_KeyGenSuccess, GranteePubkeys: []string{"testpubkey1"}, } - enabledChainsToUpdate := []pkg.Chain{ + enabledChainsToUpdate := []chains.Chain{ { ChainName: 1, ChainId: 1, @@ -212,7 +212,7 @@ func TestUpdateZetaCoreContext(t *testing.T) { }, } - testBtcChain := pkg.BtcTestNetChain() + testBtcChain := chains.BtcTestNetChain() btcChainParamsToUpdate := &observertypes.ChainParams{ ChainId: testBtcChain.ChainId, } diff --git a/zetaclient/evm/evm_client.go b/zetaclient/evm/evm_client.go index 91626bb7c8..a70401365e 100644 --- a/zetaclient/evm/evm_client.go +++ b/zetaclient/evm/evm_client.go @@ -13,6 +13,9 @@ import ( "sync/atomic" "time" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/pkg/proofs" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" @@ -36,7 +39,6 @@ import ( "github.com/rs/zerolog/log" "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/pkg" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" @@ -70,7 +72,7 @@ var _ interfaces.ChainClient = &ChainClient{} // ChainClient represents the chain configuration for an EVM chain // Filled with above constants depending on chain type ChainClient struct { - chain pkg.Chain + chain chains.Chain evmClient interfaces.EVMRPCClient evmJSONRPC interfaces.EVMJSONRPCClient zetaClient interfaces.ZetaCoreBridger @@ -161,7 +163,7 @@ func NewEVMChainClient( return &ob, nil } -func (ob *ChainClient) WithChain(chain pkg.Chain) { +func (ob *ChainClient) WithChain(chain chains.Chain) { ob.Mu.Lock() defer ob.Mu.Unlock() ob.chain = chain @@ -332,9 +334,9 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, // compliance check, special handling the cancelled cctx if compliance.IsCctxRestricted(cctx) { - recvStatus := pkg.ReceiveStatus_Failed + recvStatus := chains.ReceiveStatus_Failed if receipt.Status == 1 { - recvStatus = pkg.ReceiveStatus_Success + recvStatus = chains.ReceiveStatus_Success } zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( sendHash, @@ -348,7 +350,7 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, recvStatus, ob.chain, nonce, - pkg.CoinType_Cmd, + coin.CoinType_Cmd, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -358,10 +360,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, return true, true, nil } - if cointype == pkg.CoinType_Cmd { - recvStatus := pkg.ReceiveStatus_Failed + if cointype == coin.CoinType_Cmd { + recvStatus := chains.ReceiveStatus_Failed if receipt.Status == 1 { - recvStatus = pkg.ReceiveStatus_Success + recvStatus = chains.ReceiveStatus_Success } zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( sendHash, @@ -374,7 +376,7 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, recvStatus, ob.chain, nonce, - pkg.CoinType_Cmd, + coin.CoinType_Cmd, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -383,7 +385,7 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, } return true, true, nil - } else if cointype == pkg.CoinType_Gas { // the outbound is a regular Ether/BNB/Matic transfer; no need to check events + } else if cointype == coin.CoinType_Gas { // the outbound is a regular Ether/BNB/Matic transfer; no need to check events if receipt.Status == 1 { zetaTxHash, ballot, err := ob.zetaClient.PostVoteOutbound( sendHash, @@ -393,10 +395,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), transaction.Value(), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, ob.chain, nonce, - pkg.CoinType_Gas, + coin.CoinType_Gas, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -414,10 +416,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), big.NewInt(0), - pkg.ReceiveStatus_Failed, + chains.ReceiveStatus_Failed, ob.chain, nonce, - pkg.CoinType_Gas, + coin.CoinType_Gas, ) if err != nil { logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s cctx %s nonce %d", zetaTxHash, sendHash, nonce) @@ -426,7 +428,7 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, } return true, true, nil } - } else if cointype == pkg.CoinType_Zeta { // the outbound is a Zeta transfer; need to check events ZetaReceived + } else if cointype == coin.CoinType_Zeta { // the outbound is a Zeta transfer; need to check events ZetaReceived if receipt.Status == 1 { logs := receipt.Logs for _, vLog := range logs { @@ -458,10 +460,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), mMint, - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, ob.chain, nonce, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -495,10 +497,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), mMint, - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, ob.chain, nonce, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ) if err != nil { logger.Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -523,10 +525,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), big.NewInt(0), - pkg.ReceiveStatus_Failed, + chains.ReceiveStatus_Failed, ob.chain, nonce, - pkg.CoinType_Zeta, + coin.CoinType_Zeta, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -535,7 +537,7 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, } return true, true, nil } - } else if cointype == pkg.CoinType_ERC20 { + } else if cointype == coin.CoinType_ERC20 { if receipt.Status == 1 { logs := receipt.Logs addrCustody, ERC20Custody, err := ob.GetERC20CustodyContract() @@ -563,10 +565,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), event.Amount, - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, ob.chain, nonce, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, ) if err != nil { logger.Error().Err(err).Msgf("error posting confirmation to meta core for cctx %s nonce %d", sendHash, nonce) @@ -590,10 +592,10 @@ func (ob *ChainClient) IsSendOutTxProcessed(cctx *crosschaintypes.CrossChainTx, transaction.GasPrice(), transaction.Gas(), big.NewInt(0), - pkg.ReceiveStatus_Failed, + chains.ReceiveStatus_Failed, ob.chain, nonce, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, ) if err != nil { logger.Error().Err(err).Msgf("PostVoteOutbound error in WatchTxHashWithTimeout; zeta tx hash %s", zetaTxHash) @@ -897,7 +899,7 @@ func (ob *ChainClient) postBlockHeader(tip uint64) error { ob.chain.ChainId, header.Hash().Bytes(), header.Number.Int64(), - pkg.NewEthereumHeader(headerRLP), + proofs.NewEthereumHeader(headerRLP), ) if err != nil { ob.logger.ExternalChainWatcher.Error().Err(err).Msgf("postBlockHeader: error posting block header: %d", bn) @@ -1035,7 +1037,7 @@ func (ob *ChainClient) ObserveZetaSent(startBlock, toBlock uint64) uint64 { msg := ob.BuildInboundVoteMsgForZetaSentEvent(event) if msg != nil { - _, err = ob.PostVoteInbound(msg, pkg.CoinType_Zeta, zetabridge.PostVoteInboundMessagePassingExecutionGasLimit) + _, err = ob.PostVoteInbound(msg, coin.CoinType_Zeta, zetabridge.PostVoteInboundMessagePassingExecutionGasLimit) if err != nil { return beingScanned - 1 // we have to re-scan from this block next time } @@ -1115,7 +1117,7 @@ func (ob *ChainClient) ObserveERC20Deposited(startBlock, toBlock uint64) uint64 msg := ob.BuildInboundVoteMsgForDepositedEvent(event, sender) if msg != nil { - _, err = ob.PostVoteInbound(msg, pkg.CoinType_ERC20, zetabridge.PostVoteInboundExecutionGasLimit) + _, err = ob.PostVoteInbound(msg, coin.CoinType_ERC20, zetabridge.PostVoteInboundExecutionGasLimit) if err != nil { return beingScanned - 1 // we have to re-scan from this block next time } @@ -1138,7 +1140,7 @@ func (ob *ChainClient) ObserverTSSReceive(startBlock, toBlock uint64, flags obse // TODO: consider having a independent ticker(from TSS scaning) for posting block headers if flags.BlockHeaderVerificationFlags != nil && flags.BlockHeaderVerificationFlags.IsEthTypeChainEnabled && - pkg.IsHeaderSupportedEvmChain(ob.chain.ChainId) { // post block header for supported chains + chains.IsHeaderSupportedEvmChain(ob.chain.ChainId) { // post block header for supported chains err := ob.postBlockHeader(toBlock) if err != nil { ob.logger.ExternalChainWatcher.Error().Err(err).Msg("error posting block header") @@ -1280,7 +1282,7 @@ func (ob *ChainClient) BuildReceiptsMap() error { } // LoadDB open sql database and load data into EVMChainClient -func (ob *ChainClient) LoadDB(dbPath string, chain pkg.Chain) error { +func (ob *ChainClient) LoadDB(dbPath string, chain chains.Chain) error { if dbPath != "" { if _, err := os.Stat(dbPath); os.IsNotExist(err) { err := os.MkdirAll(dbPath, os.ModePerm) diff --git a/zetaclient/evm/evm_client_test.go b/zetaclient/evm/evm_client_test.go index 80a4d0634c..7596931f3e 100644 --- a/zetaclient/evm/evm_client_test.go +++ b/zetaclient/evm/evm_client_test.go @@ -8,7 +8,8 @@ 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/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/evm" "github.com/zeta-chain/zetacore/zetaclient/testutils" @@ -45,7 +46,7 @@ func TestEVM_CheckTxInclusion(t *testing.T) { // load archived evm outtx Gas // https://etherscan.io/tx/0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3 chainID := int64(1) - coinType := pkg.CoinType_Gas + coinType := coin.CoinType_Gas outtxHash := "0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3" tx, receipt := testutils.LoadEVMOuttxNReceipt(t, chainID, outtxHash, coinType) @@ -96,7 +97,7 @@ func TestEVM_VoteOutboundBallot(t *testing.T) { // load archived evm outtx Gas // https://etherscan.io/tx/0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3 chainID := int64(1) - coinType := pkg.CoinType_Gas + coinType := coin.CoinType_Gas outtxHash := "0xd13b593eb62b5500a00e288cc2fb2c8af1339025c0e6bc6183b8bef2ebbed0d3" tx, receipt := testutils.LoadEVMOuttxNReceipt(t, chainID, outtxHash, coinType) @@ -113,7 +114,7 @@ func TestEVM_VoteOutboundBallot(t *testing.T) { math.NewIntFromBigInt(tx.GasPrice()), tx.Gas(), math.NewUintFromBigInt(tx.Value()), - pkg.ReceiveStatus_Success, + chains.ReceiveStatus_Success, chainID, tx.Nonce(), coinType, diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index a7b840f659..a3a492e4b6 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -21,6 +21,8 @@ import ( "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" 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" @@ -37,7 +39,7 @@ import ( // Signer deals with the signing EVM transactions and implements the ChainSigner interface type Signer struct { client interfaces.EVMRPCClient - chain *pkg.Chain + chain *chains.Chain tssSigner interfaces.TSSSigner ethSigner ethtypes.Signer logger clientcommon.ClientLogger @@ -56,7 +58,7 @@ type Signer struct { var _ interfaces.ChainSigner = &Signer{} func NewEVMSigner( - chain pkg.Chain, + chain chains.Chain, endpoint string, tssSigner interfaces.TSSSigner, zetaConnectorABI string, @@ -343,7 +345,7 @@ func (signer *Signer) TryProcessOutTx( } // Get destination chain for logging - toChain := pkg.GetChainFromChainID(txData.toChainID.Int64()) + toChain := chains.GetChainFromChainID(txData.toChainID.Int64()) // Get cross-chain flags crossChainflags := signer.coreContext.GetCrossChainFlags() @@ -358,7 +360,7 @@ func (signer *Signer) TryProcessOutTx( logger.Warn().Err(err).Msg(SignerErrorMsg(cctx)) return } - } else if cctx.GetCurrentOutTxParam().CoinType == pkg.CoinType_Cmd { // admin command + } else if cctx.GetCurrentOutTxParam().CoinType == coin.CoinType_Cmd { // admin command to := ethcommon.HexToAddress(cctx.GetCurrentOutTxParam().Receiver) if to == (ethcommon.Address{}) { logger.Error().Msgf("invalid receiver %s", cctx.GetCurrentOutTxParam().Receiver) @@ -370,7 +372,7 @@ func (signer *Signer) TryProcessOutTx( return } // cmd field is used to determine whether to execute ERC20 whitelist or migrate TSS funds given that the coin type - // from the cctx is pkg.CoinType_Cmd + // from the cctx is coin.CoinType_Cmd cmd := msg[0] // params field is used to pass input parameters for command requests, currently it is used to pass the ERC20 // contract address when a whitelist command is requested @@ -382,13 +384,13 @@ func (signer *Signer) TryProcessOutTx( } } else if IsSenderZetaChain(cctx, zetaBridge, &crossChainflags) { switch cctx.GetCurrentOutTxParam().CoinType { - case pkg.CoinType_Gas: + case coin.CoinType_Gas: logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignWithdrawTx(txData) - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: logger.Info().Msgf("SignERC20WithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignERC20WithdrawTx(txData) - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: logger.Info().Msgf("SignOutboundTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignOutboundTx(txData) } @@ -398,10 +400,10 @@ func (signer *Signer) TryProcessOutTx( } } else if cctx.CctxStatus.Status == types.CctxStatus_PendingRevert && cctx.OutboundTxParams[0].ReceiverChainId == zetaBridge.ZetaChain().ChainId { switch cctx.GetCurrentOutTxParam().CoinType { - case pkg.CoinType_Gas: + case coin.CoinType_Gas: logger.Info().Msgf("SignWithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignWithdrawTx(txData) - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: logger.Info().Msgf("SignERC20WithdrawTx: %d => %s, nonce %d, gasPrice %d", cctx.InboundTxParams.SenderChainId, toChain, cctx.GetCurrentOutTxParam().OutboundTxTssNonce, txData.gasPrice) tx, err = signer.SignERC20WithdrawTx(txData) } @@ -443,7 +445,7 @@ func (signer *Signer) BroadcastOutTx( zetaBridge interfaces.ZetaCoreBridger, txData *OutBoundTransactionData) { // Get destination chain for logging - toChain := pkg.GetChainFromChainID(txData.toChainID.Int64()) + toChain := chains.GetChainFromChainID(txData.toChainID.Int64()) // Try to broadcast transaction if tx != nil { @@ -642,7 +644,7 @@ func (signer *Signer) EvmSigner() ethtypes.Signer { // getEVMRPC is a helper function to set up the client and signer, also initializes a mock client for unit tests func getEVMRPC(endpoint string) (interfaces.EVMRPCClient, ethtypes.Signer, error) { if endpoint == stub.EVMRPCEnabled { - chainID := big.NewInt(pkg.BscMainnetChain().ChainId) + chainID := big.NewInt(chains.BscMainnetChain().ChainId) ethSigner := ethtypes.NewEIP155Signer(chainID) client := &stub.MockEvmClient{} return client, ethSigner, nil diff --git a/zetaclient/evm/evm_signer_test.go b/zetaclient/evm/evm_signer_test.go index df897adb74..5f82d9bf91 100644 --- a/zetaclient/evm/evm_signer_test.go +++ b/zetaclient/evm/evm_signer_test.go @@ -9,6 +9,7 @@ import ( "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/testutil/sample" "github.com/zeta-chain/zetacore/x/crosschain/types" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -35,7 +36,7 @@ func getNewEvmSigner() (*Signer, error) { ts := &metrics.TelemetryServer{} cfg := config.NewConfig() return NewEVMSigner( - pkg.BscMainnetChain(), + chains.BscMainnetChain(), stub.EVMRPCEnabled, stub.NewTSSMainnet(), config.GetConnectorABI(), @@ -53,8 +54,8 @@ func getNewEvmChainClient() (*ChainClient, error) { cfg := config.NewConfig() tss := stub.NewTSSMainnet() - evmcfg := config.EVMConfig{Chain: pkg.BscMainnetChain(), Endpoint: "http://localhost:8545"} - cfg.EVMChainConfigs[pkg.BscMainnetChain().ChainId] = evmcfg + evmcfg := config.EVMConfig{Chain: chains.BscMainnetChain(), Endpoint: "http://localhost:8545"} + cfg.EVMChainConfigs[chains.BscMainnetChain().ChainId] = evmcfg coreCTX := corecontext.NewZetaCoreContext(cfg) appCTX := appcontext.NewAppContext(coreCTX, cfg) diff --git a/zetaclient/evm/inbounds.go b/zetaclient/evm/inbounds.go index 27610f96bf..a8dee66c11 100644 --- a/zetaclient/evm/inbounds.go +++ b/zetaclient/evm/inbounds.go @@ -13,6 +13,8 @@ import ( "github.com/pkg/errors" "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/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/zetaclient/compliance" "github.com/zeta-chain/zetacore/zetaclient/config" clienttypes "github.com/zeta-chain/zetacore/zetaclient/types" @@ -73,11 +75,11 @@ func (ob *ChainClient) ObserveIntxTrackers() error { // check and vote on inbound tx switch tracker.CoinType { - case pkg.CoinType_Zeta: + case coin.CoinType_Zeta: _, err = ob.CheckAndVoteInboundTokenZeta(tx, receipt, true) - case pkg.CoinType_ERC20: + case coin.CoinType_ERC20: _, err = ob.CheckAndVoteInboundTokenERC20(tx, receipt, true) - case pkg.CoinType_Gas: + case coin.CoinType_Gas: _, err = ob.CheckAndVoteInboundTokenGas(tx, receipt, true) default: return fmt.Errorf("unknown coin type %s for intx %s chain %d", tracker.CoinType, tx.Hash, ob.chain.ChainId) @@ -123,7 +125,7 @@ func (ob *ChainClient) CheckAndVoteInboundTokenZeta(tx *ethrpc.Transaction, rece return "", nil } if vote { - return ob.PostVoteInbound(msg, pkg.CoinType_Zeta, zetabridge.PostVoteInboundMessagePassingExecutionGasLimit) + return ob.PostVoteInbound(msg, coin.CoinType_Zeta, zetabridge.PostVoteInboundMessagePassingExecutionGasLimit) } return msg.Digest(), nil } @@ -164,7 +166,7 @@ func (ob *ChainClient) CheckAndVoteInboundTokenERC20(tx *ethrpc.Transaction, rec return "", nil } if vote { - return ob.PostVoteInbound(msg, pkg.CoinType_ERC20, zetabridge.PostVoteInboundExecutionGasLimit) + return ob.PostVoteInbound(msg, coin.CoinType_ERC20, zetabridge.PostVoteInboundExecutionGasLimit) } return msg.Digest(), nil } @@ -192,13 +194,13 @@ func (ob *ChainClient) CheckAndVoteInboundTokenGas(tx *ethrpc.Transaction, recei return "", nil } if vote { - return ob.PostVoteInbound(msg, pkg.CoinType_Gas, zetabridge.PostVoteInboundExecutionGasLimit) + return ob.PostVoteInbound(msg, coin.CoinType_Gas, zetabridge.PostVoteInboundExecutionGasLimit) } return msg.Digest(), nil } // PostVoteInbound posts a vote for the given vote message -func (ob *ChainClient) PostVoteInbound(msg *types.MsgVoteOnObservedInboundTx, coinType pkg.CoinType, retryGasLimit uint64) (string, error) { +func (ob *ChainClient) PostVoteInbound(msg *types.MsgVoteOnObservedInboundTx, coinType coin.CoinType, retryGasLimit uint64) (string, error) { txHash := msg.InTxHash chainID := ob.chain.ChainId zetaHash, ballot, err := ob.zetaClient.PostVoteInbound(zetabridge.PostVoteInboundGasLimit, retryGasLimit, msg) @@ -223,7 +225,7 @@ func (ob *ChainClient) HasEnoughConfirmations(receipt *ethtypes.Receipt, lastHei func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody.ERC20CustodyDeposited, sender ethcommon.Address) *types.MsgVoteOnObservedInboundTx { // compliance check maybeReceiver := "" - parsedAddress, _, err := pkg.ParseAddressAndData(hex.EncodeToString(event.Message)) + parsedAddress, _, err := chains.ParseAddressAndData(hex.EncodeToString(event.Message)) if err == nil && parsedAddress != (ethcommon.Address{}) { maybeReceiver = parsedAddress.Hex() } @@ -253,7 +255,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody. event.Raw.TxHash.Hex(), event.Raw.BlockNumber, 1_500_000, - pkg.CoinType_ERC20, + coin.CoinType_ERC20, event.Asset.String(), ob.zetaClient.GetKeys().GetOperatorAddress().String(), event.Raw.Index, @@ -262,7 +264,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForDepositedEvent(event *erc20custody. // BuildInboundVoteMsgForZetaSentEvent builds a inbound vote message for a ZetaSent event func (ob *ChainClient) BuildInboundVoteMsgForZetaSentEvent(event *zetaconnector.ZetaConnectorNonEthZetaSent) *types.MsgVoteOnObservedInboundTx { - destChain := pkg.GetChainFromChainID(event.DestinationChainId.Int64()) + destChain := chains.GetChainFromChainID(event.DestinationChainId.Int64()) if destChain == nil { ob.logger.ExternalChainWatcher.Warn().Msgf("chain id not supported %d", event.DestinationChainId.Int64()) return nil @@ -304,7 +306,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForZetaSentEvent(event *zetaconnector. event.Raw.TxHash.Hex(), event.Raw.BlockNumber, event.DestinationGasLimit.Uint64(), - pkg.CoinType_Zeta, + coin.CoinType_Zeta, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), event.Raw.Index, @@ -317,7 +319,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transacti // compliance check maybeReceiver := "" - parsedAddress, _, err := pkg.ParseAddressAndData(message) + parsedAddress, _, err := chains.ParseAddressAndData(message) if err == nil && parsedAddress != (ethcommon.Address{}) { maybeReceiver = parsedAddress.Hex() } @@ -348,7 +350,7 @@ func (ob *ChainClient) BuildInboundVoteMsgForTokenSentToTSS(tx *ethrpc.Transacti tx.Hash, blockNumber, 90_000, - pkg.CoinType_Gas, + coin.CoinType_Gas, "", ob.zetaClient.GetKeys().GetOperatorAddress().String(), 0, // not a smart contract call diff --git a/zetaclient/evm/inbounds_test.go b/zetaclient/evm/inbounds_test.go index 87d60e0436..e4625177e7 100644 --- a/zetaclient/evm/inbounds_test.go +++ b/zetaclient/evm/inbounds_test.go @@ -11,6 +11,8 @@ import ( "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" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" "github.com/zeta-chain/zetacore/zetaclient/evm" @@ -22,7 +24,7 @@ import ( // MockEVMClient creates a mock ChainClient with custom chain, TSS, params etc func MockEVMClient( - chain pkg.Chain, + chain chains.Chain, evmClient interfaces.EVMRPCClient, evmJSONRPC interfaces.EVMJSONRPCClient, zetClient interfaces.ZetaCoreBridger, @@ -52,14 +54,14 @@ func MockEVMClient( func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { // load archived ZetaSent intx, receipt and cctx // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 - chain := pkg.EthChain() + chain := chains.EthChain() confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) intxHash := "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76" t.Run("should pass for archived intx, receipt and cctx", func(t *testing.T) { - tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Zeta) + tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Zeta) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -69,7 +71,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) }) t.Run("should fail on unconfirmed intx", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Zeta) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Zeta) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 @@ -78,7 +80,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.ErrorContains(t, err, "not been confirmed") }) t.Run("should not act if no ZetaSent event", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Zeta) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Zeta) receipt.Logs = receipt.Logs[:2] // remove ZetaSent event require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -89,7 +91,7 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { require.Equal(t, "", ballot) }) t.Run("should not act if emitter is not ZetaConnector", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Zeta) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Zeta) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -103,14 +105,14 @@ func TestEVM_CheckAndVoteInboundTokenZeta(t *testing.T) { func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { // load archived ERC20 intx, receipt and cctx // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := pkg.EthChain() + chain := chains.EthChain() confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) intxHash := "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da" t.Run("should pass for archived intx, receipt and cctx", func(t *testing.T) { - tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_ERC20) + tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_ERC20) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -120,7 +122,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) }) t.Run("should fail on unconfirmed intx", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_ERC20) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_ERC20) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 @@ -129,7 +131,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.ErrorContains(t, err, "not been confirmed") }) t.Run("should not act if no Deposit event", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_ERC20) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_ERC20) receipt.Logs = receipt.Logs[:1] // remove Deposit event require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -140,7 +142,7 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { require.Equal(t, "", ballot) }) t.Run("should not act if emitter is not ERC20 Custody", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_ERC20) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_ERC20) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -154,14 +156,14 @@ func TestEVM_CheckAndVoteInboundTokenERC20(t *testing.T) { func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { // load archived Gas intx, receipt and cctx // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := pkg.EthChain() + chain := chains.EthChain() confirmation := uint64(10) chainID := chain.ChainId chainParam := stub.MockChainParams(chain.ChainId, confirmation) intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" t.Run("should pass for archived intx, receipt and cctx", func(t *testing.T) { - tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt, cctx := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -171,7 +173,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.Equal(t, cctx.InboundTxParams.InboundTxBallotIndex, ballot) }) t.Run("should fail on unconfirmed intx", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation - 1 @@ -180,7 +182,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.ErrorContains(t, err, "not been confirmed") }) t.Run("should not act if receiver is not TSS", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas) tx.To = testutils.OtherAddress1 // use other address require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -191,7 +193,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.Equal(t, "", ballot) }) t.Run("should not act if transaction failed", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas) receipt.Status = ethtypes.ReceiptStatusFailed require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -202,7 +204,7 @@ func TestEVM_CheckAndVoteInboundTokenGas(t *testing.T) { require.Equal(t, "", ballot) }) t.Run("should not act on nil message", func(t *testing.T) { - tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt, _ := testutils.LoadEVMIntxNReceiptNCctx(t, chainID, intxHash, coin.CoinType_Gas) tx.Input = hex.EncodeToString([]byte(pkg.DonationMessage)) // donation will result in nil message require.NoError(t, evm.ValidateEvmTransaction(tx)) lastBlock := receipt.BlockNumber.Uint64() + confirmation @@ -218,10 +220,10 @@ func TestEVM_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { // load archived ZetaSent receipt // https://etherscan.io/tx/0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76 chainID := int64(1) - chain := pkg.EthChain() + chain := chains.EthChain() intxHash := "0xf3935200c80f98502d5edc7e871ffc40ca898e134525c42c2ae3cbc5725f9d76" - receipt := testutils.LoadEVMIntxReceipt(t, chainID, intxHash, pkg.CoinType_Zeta) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, pkg.CoinType_Zeta) + receipt := testutils.LoadEVMIntxReceipt(t, chainID, intxHash, coin.CoinType_Zeta) + cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_Zeta) // parse ZetaSent event ob := MockEVMClient(chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) @@ -264,11 +266,11 @@ func TestEVM_BuildInboundVoteMsgForZetaSentEvent(t *testing.T) { func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { // load archived Deposited receipt // https://etherscan.io/tx/0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId intxHash := "0x4ea69a0e2ff36f7548ab75791c3b990e076e2a4bffeb616035b239b7d33843da" - tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, pkg.CoinType_ERC20) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, pkg.CoinType_ERC20) + tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_ERC20) + cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_ERC20) // parse Deposited event ob := MockEVMClient(chain, nil, nil, nil, nil, 1, stub.MockChainParams(1, 1)) @@ -309,17 +311,17 @@ func TestEVM_BuildInboundVoteMsgForDepositedEvent(t *testing.T) { func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { // load archived gas token transfer to TSS // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" - tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(tx)) - cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, pkg.CoinType_Gas) + cctx := testutils.LoadEVMIntxCctx(t, chainID, intxHash, coin.CoinType_Gas) // load archived gas token donation to TSS // https://etherscan.io/tx/0x52f214cf7b10be71f4d274193287d47bc9632b976e69b9d2cdeb527c2ba32155 inTxHashDonation := "0x52f214cf7b10be71f4d274193287d47bc9632b976e69b9d2cdeb527c2ba32155" - txDonation, receiptDonation := testutils.LoadEVMIntxNReceiptDonation(t, chainID, inTxHashDonation, pkg.CoinType_Gas) + txDonation, receiptDonation := testutils.LoadEVMIntxNReceiptDonation(t, chainID, inTxHashDonation, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(txDonation)) // create test compliance config @@ -358,14 +360,14 @@ func TestEVM_BuildInboundVoteMsgForTokenSentToTSS(t *testing.T) { func TestEVM_ObserveTSSReceiveInBlock(t *testing.T) { // https://etherscan.io/tx/0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532 - chain := pkg.EthChain() + chain := chains.EthChain() chainID := chain.ChainId confirmation := uint64(1) chainParam := stub.MockChainParams(chain.ChainId, confirmation) intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" // load archived tx and receipt - tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, pkg.CoinType_Gas) + tx, receipt := testutils.LoadEVMIntxNReceipt(t, chainID, intxHash, coin.CoinType_Gas) require.NoError(t, evm.ValidateEvmTransaction(tx)) // load archived evm block diff --git a/zetaclient/evm/outbound_transaction_data.go b/zetaclient/evm/outbound_transaction_data.go index c4bc9749b3..0255c1c525 100644 --- a/zetaclient/evm/outbound_transaction_data.go +++ b/zetaclient/evm/outbound_transaction_data.go @@ -10,7 +10,8 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "github.com/rs/zerolog" - "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/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/interfaces" ) @@ -66,7 +67,7 @@ func (txData *OutBoundTransactionData) SetupGas( cctx *types.CrossChainTx, logger zerolog.Logger, client interfaces.EVMRPCClient, - chain *pkg.Chain, + chain *chains.Chain, ) error { txData.gasLimit = cctx.GetCurrentOutTxParam().OutboundTxGasLimit @@ -85,7 +86,7 @@ func (txData *OutBoundTransactionData) SetupGas( // we should possibly remove it completely and return an error if no OutboundTxGasPrice is provided because it means no fee is processed on ZetaChain specified, ok := new(big.Int).SetString(cctx.GetCurrentOutTxParam().OutboundTxGasPrice, 10) if !ok { - if pkg.IsEthereumChain(chain.ChainId) { + if chains.IsEthereumChain(chain.ChainId) { suggested, err := client.SuggestGasPrice(context.Background()) if err != nil { return errors.Join(err, fmt.Errorf("cannot get gas price from chain %s ", chain)) @@ -127,7 +128,7 @@ func NewOutBoundTransactionData( return nil, true, nil } - toChain := pkg.GetChainFromChainID(txData.toChainID.Int64()) + toChain := chains.GetChainFromChainID(txData.toChainID.Int64()) if toChain == nil { return nil, true, fmt.Errorf("unknown chain: %d", txData.toChainID.Int64()) } @@ -169,7 +170,7 @@ func NewOutBoundTransactionData( } // Base64 decode message - if cctx.GetCurrentOutTxParam().CoinType != pkg.CoinType_Cmd { + if cctx.GetCurrentOutTxParam().CoinType != coin.CoinType_Cmd { txData.message, err = base64.StdEncoding.DecodeString(cctx.RelayedMessage) if err != nil { logger.Err(err).Msgf("decode CCTX.Message %s error", cctx.RelayedMessage) diff --git a/zetaclient/evm/outbound_transaction_data_test.go b/zetaclient/evm/outbound_transaction_data_test.go index ebe6d84169..8943091157 100644 --- a/zetaclient/evm/outbound_transaction_data_test.go +++ b/zetaclient/evm/outbound_transaction_data_test.go @@ -7,7 +7,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "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/x/crosschain/types" ) @@ -55,14 +55,14 @@ func TestSigner_SetupGas(t *testing.T) { logger := zerolog.Logger{} t.Run("SetupGas_success", func(t *testing.T) { - chain := pkg.BscMainnetChain() + chain := chains.BscMainnetChain() err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.NoError(t, err) }) t.Run("SetupGas_error", func(t *testing.T) { cctx.GetCurrentOutTxParam().OutboundTxGasPrice = "invalidGasPrice" - chain := pkg.BscMainnetChain() + chain := chains.BscMainnetChain() err := txData.SetupGas(cctx, logger, evmSigner.EvmClient(), &chain) require.ErrorContains(t, err, "cannot convert gas price") }) diff --git a/zetaclient/evm/validation_test.go b/zetaclient/evm/validation_test.go index 9995fbc123..61075b1025 100644 --- a/zetaclient/evm/validation_test.go +++ b/zetaclient/evm/validation_test.go @@ -9,7 +9,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/onrik/ethrpc" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/zetaclient/testutils" ) @@ -117,7 +117,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { }{ { name: "should pass for valid transaction", - tx: testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas), + tx: testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas), fail: false, }, { @@ -129,7 +129,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for empty hash", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.Hash = "" return tx }(), @@ -139,7 +139,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative nonce", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.Nonce = -1 return tx }(), @@ -149,7 +149,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for empty from address", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.From = "" return tx }(), @@ -159,7 +159,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for invalid from address", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.From = "0x" return tx }(), @@ -169,7 +169,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should pass for empty to address", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.To = "" return tx }(), @@ -178,7 +178,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for invalid to address", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.To = "0xinvalid" return tx }(), @@ -188,7 +188,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative value", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.Value = *big.NewInt(-1) return tx }(), @@ -198,7 +198,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative gas", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.Gas = -1 return tx }(), @@ -208,7 +208,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative gas price", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.GasPrice = *big.NewInt(-1) return tx }(), @@ -218,7 +218,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should remove '0x' prefix from input data", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) return tx }(), fail: false, @@ -226,7 +226,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "nil block number should pass", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.BlockNumber = nil return tx }(), @@ -235,7 +235,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative block number", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) negBlockNumber := -1 tx.BlockNumber = &negBlockNumber return tx @@ -246,7 +246,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for empty block hash", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.BlockHash = "" return tx }(), @@ -256,7 +256,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "nil transaction index should fail", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.TransactionIndex = nil return tx }(), @@ -266,7 +266,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for negative transaction index", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) negTransactionIndex := -1 tx.TransactionIndex = &negTransactionIndex return tx @@ -277,7 +277,7 @@ func TestCheckEvmTransactionTable(t *testing.T) { { name: "should fail for invalid input data", tx: func() *ethrpc.Transaction { - tx := testutils.LoadEVMIntx(t, chainID, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, chainID, intxHash, coin.CoinType_Gas) tx.Input = "03befinvalid" return tx }(), @@ -304,7 +304,7 @@ func TestCheckEvmTransaction(t *testing.T) { intxHash := "0xeaec67d5dd5d85f27b21bef83e01cbdf59154fd793ea7a22c297f7c3a722c532" t.Run("should pass for valid transaction", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) err := ValidateEvmTransaction(tx) require.NoError(t, err) }) @@ -313,99 +313,99 @@ func TestCheckEvmTransaction(t *testing.T) { require.ErrorContains(t, err, "transaction is nil") }) t.Run("should fail for empty hash", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.Hash = "" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "hash is empty") }) t.Run("should fail for negative nonce", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.Nonce = -1 err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "nonce -1 is negative") }) t.Run("should fail for empty from address", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.From = "" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "not a valid hex address") }) t.Run("should fail for invalid from address", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.From = "0x" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "from 0x is not a valid hex address") }) t.Run("should pass for empty to address", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.To = "" err := ValidateEvmTransaction(tx) require.NoError(t, err) }) t.Run("should fail for invalid to address", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.To = "0xinvalid" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "to 0xinvalid is not a valid hex address") }) t.Run("should fail for negative value", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.Value = *big.NewInt(-1) err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "value -1 is negative") }) t.Run("should fail for negative gas", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.Gas = -1 err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "gas -1 is negative") }) t.Run("should fail for negative gas price", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.GasPrice = *big.NewInt(-1) err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "gas price -1 is negative") }) t.Run("should remove '0x' prefix from input data", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) err := ValidateEvmTransaction(tx) require.NoError(t, err) require.Equal(t, "", tx.Input) }) t.Run("nil block number should pass", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.BlockNumber = nil err := ValidateEvmTransaction(tx) require.NoError(t, err) }) t.Run("should fail for negative block number", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) negBlockNumber := -1 tx.BlockNumber = &negBlockNumber err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "block number -1 is not positive") }) t.Run("should fail for empty block hash", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.BlockHash = "" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "block hash is empty") }) t.Run("nil transaction index should fail", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.TransactionIndex = nil err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "index is nil") }) t.Run("should fail for negative transaction index", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) negTransactionIndex := -1 tx.TransactionIndex = &negTransactionIndex err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "index -1 is negative") }) t.Run("should fail for invalid input data", func(t *testing.T) { - tx := testutils.LoadEVMIntx(t, 1, intxHash, pkg.CoinType_Gas) + tx := testutils.LoadEVMIntx(t, 1, intxHash, coin.CoinType_Gas) tx.Input = "03befinvalid" err := ValidateEvmTransaction(tx) require.ErrorContains(t, err, "input data is not hex encoded") diff --git a/zetaclient/interfaces/interfaces.go b/zetaclient/interfaces/interfaces.go index ab827df773..75242ab17d 100644 --- a/zetaclient/interfaces/interfaces.go +++ b/zetaclient/interfaces/interfaces.go @@ -5,6 +5,9 @@ import ( "math/big" "github.com/onrik/ethrpc" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/zetaclient/keys" "github.com/zeta-chain/zetacore/zetaclient/outtxprocessor" @@ -20,7 +23,6 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/rs/zerolog" "github.com/zeta-chain/go-tss/blame" - "github.com/zeta-chain/zetacore/pkg" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" ) @@ -71,13 +73,13 @@ type ZetaCoreBridger interface { outTxEffectiveGasPrice *big.Int, outTxEffectiveGasLimit uint64, amount *big.Int, - status pkg.ReceiveStatus, - chain pkg.Chain, + status chains.ReceiveStatus, + chain chains.Chain, nonce uint64, - coinType pkg.CoinType, + coinType coin.CoinType, ) (string, string, error) - PostGasPrice(chain pkg.Chain, gasPrice uint64, supply string, blockNum uint64) (string, error) - PostAddBlockHeader(chainID int64, txhash []byte, height int64, header pkg.HeaderData) (string, error) + PostGasPrice(chain chains.Chain, gasPrice uint64, supply string, blockNum uint64) (string, error) + PostAddBlockHeader(chainID int64, txhash []byte, height int64, header proofs.HeaderData) (string, error) GetBlockHeaderStateByChain(chainID int64) (observertypes.QueryGetBlockHeaderStateResponse, error) PostBlameData(blame *blame.Blame, chainID int64, index string) (string, error) @@ -85,18 +87,18 @@ type ZetaCoreBridger interface { chainID int64, nonce uint64, txHash string, - proof *pkg.Proof, + proof *proofs.Proof, blockHash string, txIndex int64, ) (string, error) GetKeys() *keys.Keys GetBlockHeight() (int64, error) GetZetaBlockHeight() (int64, error) - GetLastBlockHeightByChain(chain pkg.Chain) (*crosschaintypes.LastBlockHeight, error) + GetLastBlockHeightByChain(chain chains.Chain) (*crosschaintypes.LastBlockHeight, error) ListPendingCctx(chainID int64) ([]*crosschaintypes.CrossChainTx, uint64, error) GetPendingNoncesByChain(chainID int64) (observertypes.PendingNonces, error) GetCctxByNonce(chainID int64, nonce uint64) (*crosschaintypes.CrossChainTx, error) - GetOutTxTracker(chain pkg.Chain, nonce uint64) (*crosschaintypes.OutTxTracker, error) + GetOutTxTracker(chain chains.Chain, nonce uint64) (*crosschaintypes.OutTxTracker, error) GetAllOutTxTrackerByChain(chainID int64, order Order) ([]crosschaintypes.OutTxTracker, error) GetCrosschainFlags() (observertypes.CrosschainFlags, error) GetObserverList() ([]string, error) @@ -104,7 +106,7 @@ type ZetaCoreBridger interface { GetBtcTssAddress(chainID int64) (string, error) GetInboundTrackersForChain(chainID int64) ([]crosschaintypes.InTxTracker, error) GetLogger() *zerolog.Logger - ZetaChain() pkg.Chain + ZetaChain() chains.Chain Pause() Unpause() GetZetaHotKeyBalance() (sdkmath.Int, error) diff --git a/zetaclient/interfaces/signer.go b/zetaclient/interfaces/signer.go index aaa4ad71df..461902359c 100644 --- a/zetaclient/interfaces/signer.go +++ b/zetaclient/interfaces/signer.go @@ -4,7 +4,7 @@ import ( "crypto/ecdsa" "fmt" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/btcsuite/btcd/btcec/v2" "github.com/btcsuite/btcd/chaincfg" @@ -17,7 +17,7 @@ import ( type TSSSigner interface { Pubkey() []byte // Sign: Specify optionalPubkey to use a different pubkey than the current pubkey set during keygen - Sign(data []byte, height uint64, nonce uint64, chain *pkg.Chain, optionalPubkey string) ([65]byte, error) + Sign(data []byte, height uint64, nonce uint64, chain *chains.Chain, optionalPubkey string) ([65]byte, error) EVMAddress() ethcommon.Address BTCAddress() string BTCAddressWitnessPubkeyHash() *btcutil.AddressWitnessPubKeyHash @@ -31,7 +31,7 @@ type TestSigner struct { PrivKey *ecdsa.PrivateKey } -func (s TestSigner) Sign(digest []byte, _ uint64, _ uint64, _ *pkg.Chain, _ string) ([65]byte, error) { +func (s TestSigner) Sign(digest []byte, _ uint64, _ uint64, _ *chains.Chain, _ string) ([65]byte, error) { sig, err := crypto.Sign(digest, s.PrivKey) if err != nil { return [65]byte{}, err diff --git a/zetaclient/keys/keys.go b/zetaclient/keys/keys.go index 0396f87e90..0f028474e5 100644 --- a/zetaclient/keys/keys.go +++ b/zetaclient/keys/keys.go @@ -15,8 +15,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/rs/zerolog/log" "github.com/zeta-chain/zetacore/cmd" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/pkg/cosmos" + zetacrypto "github.com/zeta-chain/zetacore/pkg/crypto" "github.com/zeta-chain/zetacore/zetaclient/config" zetaerrors "github.com/zeta-chain/zetacore/zetaclient/errors" ) @@ -78,7 +78,7 @@ func GetKeyringKeybase(cfg config.Config, hotkeyPassword string) (ckeys.Keyring, return nil, "", fmt.Errorf("key not in backend %s present with name (%s): %w", kb.Backend(), granteeName, err) } - pubkeyBech32, err := pkg.GetPubkeyBech32FromRecord(rc) + pubkeyBech32, err := zetacrypto.GetPubkeyBech32FromRecord(rc) if err != nil { return nil, "", fmt.Errorf("fail to get pubkey from record,err:%w", err) } @@ -151,8 +151,8 @@ func (k *Keys) GetKeybase() ckeys.Keyring { return k.kb } -func (k *Keys) GetPubKeySet(password string) (pkg.PubKeySet, error) { - pubkeySet := pkg.PubKeySet{ +func (k *Keys) GetPubKeySet(password string) (zetacrypto.PubKeySet, error) { + pubkeySet := zetacrypto.PubKeySet{ Secp256k1: "", Ed25519: "", } @@ -166,7 +166,7 @@ func (k *Keys) GetPubKeySet(password string) (pkg.PubKeySet, error) { if err != nil { return pubkeySet, zetaerrors.ErrBech32ifyPubKey } - pubkey, err := pkg.NewPubKey(s) + pubkey, err := zetacrypto.NewPubKey(s) if err != nil { return pubkeySet, zetaerrors.ErrNewPubKey } diff --git a/zetaclient/supplychecker/zeta_supply_checker.go b/zetaclient/supplychecker/zeta_supply_checker.go index bd9cb86046..2168c5483e 100644 --- a/zetaclient/supplychecker/zeta_supply_checker.go +++ b/zetaclient/supplychecker/zeta_supply_checker.go @@ -15,7 +15,8 @@ import ( "github.com/ethereum/go-ethereum/ethclient" "github.com/pkg/errors" "github.com/rs/zerolog" - "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/x/crosschain/types" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" clienttypes "github.com/zeta-chain/zetacore/zetaclient/types" @@ -28,8 +29,8 @@ type ZetaSupplyChecker struct { ticker *clienttypes.DynamicTicker stop chan struct{} logger zerolog.Logger - externalEvmChain []pkg.Chain - ethereumChain pkg.Chain + externalEvmChain []chains.Chain + ethereumChain chains.Chain genesisSupply sdkmath.Int } @@ -61,11 +62,11 @@ func NewZetaSupplyChecker(appContext *appcontext.AppContext, zetaClient *zetabri } for chainID := range zetaSupplyChecker.evmClient { - chain := pkg.GetChainFromChainID(chainID) - if chain.IsExternalChain() && pkg.IsEVMChain(chain.ChainId) && !pkg.IsEthereumChain(chain.ChainId) { + chain := chains.GetChainFromChainID(chainID) + if chain.IsExternalChain() && chains.IsEVMChain(chain.ChainId) && !chains.IsEthereumChain(chain.ChainId) { zetaSupplyChecker.externalEvmChain = append(zetaSupplyChecker.externalEvmChain, *chain) } - if pkg.IsEthereumChain(chain.ChainId) { + if chains.IsEthereumChain(chain.ChainId) { zetaSupplyChecker.ethereumChain = *chain } } @@ -224,7 +225,7 @@ func (zs *ZetaSupplyChecker) AbortedTxAmount() (sdkmath.Int, error) { } func (zs *ZetaSupplyChecker) GetAmountOfZetaInTransit() sdkmath.Int { - chainsToCheck := make([]pkg.Chain, len(zs.externalEvmChain)+1) + chainsToCheck := make([]chains.Chain, len(zs.externalEvmChain)+1) chainsToCheck = append(append(chainsToCheck, zs.externalEvmChain...), zs.ethereumChain) cctxs := zs.GetPendingCCTXInTransit(chainsToCheck) amount := sdkmath.ZeroUint() @@ -237,7 +238,7 @@ func (zs *ZetaSupplyChecker) GetAmountOfZetaInTransit() sdkmath.Int { } return amountInt } -func (zs *ZetaSupplyChecker) GetPendingCCTXInTransit(receivingChains []pkg.Chain) []*types.CrossChainTx { +func (zs *ZetaSupplyChecker) GetPendingCCTXInTransit(receivingChains []chains.Chain) []*types.CrossChainTx { cctxInTransit := make([]*types.CrossChainTx, 0) for _, chain := range receivingChains { cctx, _, err := zs.zetaClient.ListPendingCctx(chain.ChainId) @@ -246,7 +247,7 @@ func (zs *ZetaSupplyChecker) GetPendingCCTXInTransit(receivingChains []pkg.Chain } nonceToCctxMap := make(map[uint64]*types.CrossChainTx) for _, c := range cctx { - if c.GetInboundTxParams().CoinType == pkg.CoinType_Zeta { + if c.GetInboundTxParams().CoinType == coin.CoinType_Zeta { nonceToCctxMap[c.GetCurrentOutTxParam().OutboundTxTssNonce] = c } } diff --git a/zetaclient/testutils/stub/chain_signer.go b/zetaclient/testutils/stub/chain_signer.go index e659a16278..487452cea7 100644 --- a/zetaclient/testutils/stub/chain_signer.go +++ b/zetaclient/testutils/stub/chain_signer.go @@ -2,7 +2,7 @@ package stub import ( ethcommon "github.com/ethereum/go-ethereum/common" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/zeta-chain/zetacore/zetaclient/outtxprocessor" @@ -15,13 +15,13 @@ var _ interfaces.ChainSigner = (*EVMSigner)(nil) // EVMSigner is a mock of evm chain signer for testing type EVMSigner struct { - Chain pkg.Chain + Chain chains.Chain ZetaConnectorAddress ethcommon.Address ERC20CustodyAddress ethcommon.Address } func NewEVMSigner( - chain pkg.Chain, + chain chains.Chain, zetaConnectorAddress ethcommon.Address, erc20CustodyAddress ethcommon.Address, ) *EVMSigner { diff --git a/zetaclient/testutils/stub/core_bridge.go b/zetaclient/testutils/stub/core_bridge.go index 337a7b8e00..111d73983a 100644 --- a/zetaclient/testutils/stub/core_bridge.go +++ b/zetaclient/testutils/stub/core_bridge.go @@ -7,7 +7,9 @@ import ( "cosmossdk.io/math" "github.com/rs/zerolog" "github.com/zeta-chain/go-tss/blame" - "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/proofs" cctxtypes "github.com/zeta-chain/zetacore/x/crosschain/types" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/interfaces" @@ -21,11 +23,11 @@ var _ interfaces.ZetaCoreBridger = &MockZetaCoreBridge{} type MockZetaCoreBridge struct { paused bool - zetaChain pkg.Chain + zetaChain chains.Chain } func NewMockZetaCoreBridge() *MockZetaCoreBridge { - zetaChain, err := pkg.ZetaChainFromChainID("zetachain_7000-1") + zetaChain, err := chains.ZetaChainFromChainID("zetachain_7000-1") if err != nil { panic(err) } @@ -42,21 +44,21 @@ func (z *MockZetaCoreBridge) PostVoteInbound(_, _ uint64, _ *cctxtypes.MsgVoteOn return "", "", nil } -func (z *MockZetaCoreBridge) PostVoteOutbound(_ string, _ string, _ uint64, _ uint64, _ *big.Int, _ uint64, _ *big.Int, _ pkg.ReceiveStatus, _ pkg.Chain, _ uint64, _ pkg.CoinType) (string, string, error) { +func (z *MockZetaCoreBridge) PostVoteOutbound(_ string, _ string, _ uint64, _ uint64, _ *big.Int, _ uint64, _ *big.Int, _ chains.ReceiveStatus, _ chains.Chain, _ uint64, _ coin.CoinType) (string, string, error) { if z.paused { return "", "", errors.New(ErrMsgPaused) } return "", "", nil } -func (z *MockZetaCoreBridge) PostGasPrice(_ pkg.Chain, _ uint64, _ string, _ uint64) (string, error) { +func (z *MockZetaCoreBridge) PostGasPrice(_ chains.Chain, _ uint64, _ string, _ uint64) (string, error) { if z.paused { return "", errors.New(ErrMsgPaused) } return "", nil } -func (z *MockZetaCoreBridge) PostAddBlockHeader(_ int64, _ []byte, _ int64, _ pkg.HeaderData) (string, error) { +func (z *MockZetaCoreBridge) PostAddBlockHeader(_ int64, _ []byte, _ int64, _ proofs.HeaderData) (string, error) { if z.paused { return "", errors.New(ErrMsgPaused) } @@ -77,7 +79,7 @@ func (z *MockZetaCoreBridge) PostBlameData(_ *blame.Blame, _ int64, _ string) (s return "", nil } -func (z *MockZetaCoreBridge) AddTxHashToOutTxTracker(_ int64, _ uint64, _ string, _ *pkg.Proof, _ string, _ int64) (string, error) { +func (z *MockZetaCoreBridge) AddTxHashToOutTxTracker(_ int64, _ uint64, _ string, _ *proofs.Proof, _ string, _ int64) (string, error) { if z.paused { return "", errors.New(ErrMsgPaused) } @@ -102,7 +104,7 @@ func (z *MockZetaCoreBridge) GetZetaBlockHeight() (int64, error) { return 0, nil } -func (z *MockZetaCoreBridge) GetLastBlockHeightByChain(_ pkg.Chain) (*cctxtypes.LastBlockHeight, error) { +func (z *MockZetaCoreBridge) GetLastBlockHeightByChain(_ chains.Chain) (*cctxtypes.LastBlockHeight, error) { if z.paused { return nil, errors.New(ErrMsgPaused) } @@ -130,7 +132,7 @@ func (z *MockZetaCoreBridge) GetCctxByNonce(_ int64, _ uint64) (*cctxtypes.Cross return &cctxtypes.CrossChainTx{}, nil } -func (z *MockZetaCoreBridge) GetOutTxTracker(_ pkg.Chain, _ uint64) (*cctxtypes.OutTxTracker, error) { +func (z *MockZetaCoreBridge) GetOutTxTracker(_ chains.Chain, _ uint64) (*cctxtypes.OutTxTracker, error) { if z.paused { return nil, errors.New(ErrMsgPaused) } @@ -183,7 +185,7 @@ func (z *MockZetaCoreBridge) GetLogger() *zerolog.Logger { return nil } -func (z *MockZetaCoreBridge) ZetaChain() pkg.Chain { +func (z *MockZetaCoreBridge) ZetaChain() chains.Chain { return z.zetaChain } diff --git a/zetaclient/testutils/stub/tss_signer.go b/zetaclient/testutils/stub/tss_signer.go index 6f58466297..5270618df0 100644 --- a/zetaclient/testutils/stub/tss_signer.go +++ b/zetaclient/testutils/stub/tss_signer.go @@ -7,7 +7,7 @@ import ( "github.com/btcsuite/btcutil" ethcommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/zetaclient/interfaces" "github.com/zeta-chain/zetacore/zetaclient/testutils" ) @@ -46,7 +46,7 @@ func NewTSSAthens3() *TSS { } // Sign uses test key unrelated to any tss key in production -func (s *TSS) Sign(data []byte, _ uint64, _ uint64, _ *pkg.Chain, _ string) ([65]byte, error) { +func (s *TSS) Sign(data []byte, _ uint64, _ uint64, _ *chains.Chain, _ string) ([65]byte, error) { signature, err := crypto.Sign(data, TestPrivateKey) if err != nil { return [65]byte{}, err diff --git a/zetaclient/testutils/testdata.go b/zetaclient/testutils/testdata.go index 641e4d824d..c8d5788d8d 100644 --- a/zetaclient/testutils/testdata.go +++ b/zetaclient/testutils/testdata.go @@ -11,7 +11,7 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/onrik/ethrpc" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/config" ) @@ -106,7 +106,7 @@ func LoadEVMIntx( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethrpc.Transaction { + coinType coin.CoinType) *ethrpc.Transaction { nameTx := path.Join("../", TestDataPathEVM, FileNameEVMIntx(chainID, intxHash, coinType, false)) tx := ðrpc.Transaction{} @@ -120,7 +120,7 @@ func LoadEVMIntxReceipt( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethtypes.Receipt { + coinType coin.CoinType) *ethtypes.Receipt { nameReceipt := path.Join("../", TestDataPathEVM, FileNameEVMIntxReceipt(chainID, intxHash, coinType, false)) receipt := ðtypes.Receipt{} @@ -134,7 +134,7 @@ func LoadEVMIntxCctx( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *crosschaintypes.CrossChainTx { + coinType coin.CoinType) *crosschaintypes.CrossChainTx { nameCctx := path.Join("../", TestDataPathCctx, FileNameEVMIntxCctx(chainID, intxHash, coinType)) cctx := &crosschaintypes.CrossChainTx{} @@ -161,7 +161,7 @@ func LoadEVMIntxNReceipt( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt) { + coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt) { // load archived intx and receipt tx := LoadEVMIntx(t, chainID, intxHash, coinType) receipt := LoadEVMIntxReceipt(t, chainID, intxHash, coinType) @@ -174,7 +174,7 @@ func LoadEVMIntxDonation( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethrpc.Transaction { + coinType coin.CoinType) *ethrpc.Transaction { nameTx := path.Join("../", TestDataPathEVM, FileNameEVMIntx(chainID, intxHash, coinType, true)) tx := ðrpc.Transaction{} @@ -188,7 +188,7 @@ func LoadEVMIntxReceiptDonation( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethtypes.Receipt { + coinType coin.CoinType) *ethtypes.Receipt { nameReceipt := path.Join("../", TestDataPathEVM, FileNameEVMIntxReceipt(chainID, intxHash, coinType, true)) receipt := ðtypes.Receipt{} @@ -202,7 +202,7 @@ func LoadEVMIntxNReceiptDonation( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt) { + coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt) { // load archived donation intx and receipt tx := LoadEVMIntxDonation(t, chainID, intxHash, coinType) receipt := LoadEVMIntxReceiptDonation(t, chainID, intxHash, coinType) @@ -215,7 +215,7 @@ func LoadEVMIntxNReceiptNCctx( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt, *crosschaintypes.CrossChainTx) { + coinType coin.CoinType) (*ethrpc.Transaction, *ethtypes.Receipt, *crosschaintypes.CrossChainTx) { // load archived intx, receipt and cctx tx := LoadEVMIntx(t, chainID, intxHash, coinType) receipt := LoadEVMIntxReceipt(t, chainID, intxHash, coinType) @@ -229,7 +229,7 @@ func LoadEVMOuttx( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethtypes.Transaction { + coinType coin.CoinType) *ethtypes.Transaction { nameTx := path.Join("../", TestDataPathEVM, FileNameEVMOuttx(chainID, intxHash, coinType)) tx := ðtypes.Transaction{} @@ -243,7 +243,7 @@ func LoadEVMOuttxReceipt( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) *ethtypes.Receipt { + coinType coin.CoinType) *ethtypes.Receipt { nameReceipt := path.Join("../", TestDataPathEVM, FileNameEVMOuttxReceipt(chainID, intxHash, coinType)) receipt := ðtypes.Receipt{} @@ -257,7 +257,7 @@ func LoadEVMOuttxNReceipt( t *testing.T, chainID int64, intxHash string, - coinType pkg.CoinType) (*ethtypes.Transaction, *ethtypes.Receipt) { + coinType coin.CoinType) (*ethtypes.Transaction, *ethtypes.Receipt) { // load archived evm outtx and receipt tx := LoadEVMOuttx(t, chainID, intxHash, coinType) receipt := LoadEVMOuttxReceipt(t, chainID, intxHash, coinType) diff --git a/zetaclient/testutils/testdata_naming.go b/zetaclient/testutils/testdata_naming.go index 43d355054c..bfe842310e 100644 --- a/zetaclient/testutils/testdata_naming.go +++ b/zetaclient/testutils/testdata_naming.go @@ -3,7 +3,7 @@ package testutils import ( "fmt" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" ) // FileNameEVMBlock returns unified archive file name for block @@ -15,7 +15,7 @@ func FileNameEVMBlock(chainID int64, blockNumber uint64, trimmed bool) string { } // FileNameEVMIntx returns unified archive file name for inbound tx -func FileNameEVMIntx(chainID int64, intxHash string, coinType pkg.CoinType, donation bool) string { +func FileNameEVMIntx(chainID int64, intxHash string, coinType coin.CoinType, donation bool) string { if !donation { return fmt.Sprintf("chain_%d_intx_ethrpc_%s_%s.json", chainID, coinType, intxHash) } @@ -23,7 +23,7 @@ func FileNameEVMIntx(chainID int64, intxHash string, coinType pkg.CoinType, dona } // FileNameEVMIntxReceipt returns unified archive file name for inbound tx receipt -func FileNameEVMIntxReceipt(chainID int64, intxHash string, coinType pkg.CoinType, donation bool) string { +func FileNameEVMIntxReceipt(chainID int64, intxHash string, coinType coin.CoinType, donation bool) string { if !donation { return fmt.Sprintf("chain_%d_intx_receipt_%s_%s.json", chainID, coinType, intxHash) } @@ -31,7 +31,7 @@ func FileNameEVMIntxReceipt(chainID int64, intxHash string, coinType pkg.CoinTyp } // FileNameEVMIntxCctx returns unified archive file name for inbound cctx -func FileNameEVMIntxCctx(chainID int64, intxHash string, coinType pkg.CoinType) string { +func FileNameEVMIntxCctx(chainID int64, intxHash string, coinType coin.CoinType) string { return fmt.Sprintf("cctx_intx_%d_%s_%s.json", chainID, coinType, intxHash) } @@ -54,11 +54,11 @@ func FileNameCctxByNonce(chainID int64, nonce uint64) string { } // FileNameEVMOuttx returns unified archive file name for outbound tx -func FileNameEVMOuttx(chainID int64, txHash string, coinType pkg.CoinType) string { +func FileNameEVMOuttx(chainID int64, txHash string, coinType coin.CoinType) string { return fmt.Sprintf("chain_%d_outtx_%s_%s.json", chainID, coinType, txHash) } // FileNameEVMOuttxReceipt returns unified archive file name for outbound tx receipt -func FileNameEVMOuttxReceipt(chainID int64, txHash string, coinType pkg.CoinType) string { +func FileNameEVMOuttxReceipt(chainID int64, txHash string, coinType coin.CoinType) string { return fmt.Sprintf("chain_%d_outtx_receipt_%s_%s.json", chainID, coinType, txHash) } diff --git a/zetaclient/tss/tss_signer.go b/zetaclient/tss/tss_signer.go index 9744d64074..72cc1b30d2 100644 --- a/zetaclient/tss/tss_signer.go +++ b/zetaclient/tss/tss_signer.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/cosmos" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" "github.com/zeta-chain/zetacore/zetaclient/interfaces" @@ -193,7 +193,7 @@ func (tss *TSS) Pubkey() []byte { // Sign signs a digest // digest should be Hashes of some data // NOTE: Specify optionalPubkey to use a different pubkey than the current pubkey set during keygen -func (tss *TSS) Sign(digest []byte, height uint64, nonce uint64, chain *pkg.Chain, optionalPubKey string) ([65]byte, error) { +func (tss *TSS) Sign(digest []byte, height uint64, nonce uint64, chain *chains.Chain, optionalPubKey string) ([65]byte, error) { H := digest log.Debug().Msgf("hash of digest is %s", H) @@ -263,7 +263,7 @@ func (tss *TSS) Sign(digest []byte, height uint64, nonce uint64, chain *pkg.Chai // SignBatch is hash of some data // digest should be batch of hashes of some data -func (tss *TSS) SignBatch(digests [][]byte, height uint64, nonce uint64, chain *pkg.Chain) ([][65]byte, error) { +func (tss *TSS) SignBatch(digests [][]byte, height uint64, nonce uint64, chain *chains.Chain) ([][65]byte, error) { tssPubkey := tss.CurrentPubkey digestBase64 := make([]string, len(digests)) for i, digest := range digests { @@ -589,7 +589,7 @@ func getKeyAddrBTCWitnessPubkeyHash(tssPubkey string, chainID int64) (*btcutil.A return nil, err } - bitcoinNetParams, err := pkg.BitcoinNetParamsFromChainID(chainID) + bitcoinNetParams, err := chains.BitcoinNetParamsFromChainID(chainID) if err != nil { return nil, err } diff --git a/zetaclient/tss/tss_signer_test.go b/zetaclient/tss/tss_signer_test.go index 8871ccd29b..4388fc5ef1 100644 --- a/zetaclient/tss/tss_signer_test.go +++ b/zetaclient/tss/tss_signer_test.go @@ -5,13 +5,13 @@ import ( "os" "testing" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/zetaclient/keys" "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/rs/zerolog" "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/cosmos" + "github.com/zeta-chain/zetacore/pkg/crypto" ) func Test_LoadTssFilesFromDirectory(t *testing.T) { @@ -63,7 +63,7 @@ func GenerateKeyshareFiles(n int, dir string) error { if err != nil { return err } - pk, err := pkg.NewPubKey(spk) + pk, err := crypto.NewPubKey(spk) if err != nil { return err } diff --git a/zetaclient/zetabridge/query.go b/zetaclient/zetabridge/query.go index 7330bfdb7b..218c8494fa 100644 --- a/zetaclient/zetabridge/query.go +++ b/zetaclient/zetabridge/query.go @@ -6,6 +6,8 @@ import ( "sort" "time" + "github.com/zeta-chain/zetacore/pkg/chains" + "github.com/zeta-chain/zetacore/pkg/proofs" "github.com/zeta-chain/zetacore/zetaclient/interfaces" sdkmath "cosmossdk.io/math" @@ -18,7 +20,6 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" tmhttp "github.com/tendermint/tendermint/rpc/client/http" "github.com/zeta-chain/zetacore/cmd/zetacored/config" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "google.golang.org/grpc" @@ -193,7 +194,7 @@ func (b *ZetaCoreBridge) GetNodeInfo() (*tmservice.GetNodeInfoResponse, error) { return nil, err } -func (b *ZetaCoreBridge) GetLastBlockHeightByChain(chain pkg.Chain) (*types.LastBlockHeight, error) { +func (b *ZetaCoreBridge) GetLastBlockHeightByChain(chain chains.Chain) (*types.LastBlockHeight, error) { client := types.NewQueryClient(b.grpcConn) resp, err := client.LastBlockHeight(context.Background(), &types.QueryGetLastBlockHeightRequest{Index: chain.ChainName.String()}) if err != nil { @@ -230,7 +231,7 @@ func (b *ZetaCoreBridge) GetBallotByID(id string) (*observertypes.QueryBallotByI }) } -func (b *ZetaCoreBridge) GetNonceByChain(chain pkg.Chain) (observertypes.ChainNonces, error) { +func (b *ZetaCoreBridge) GetNonceByChain(chain chains.Chain) (observertypes.ChainNonces, error) { client := observertypes.NewQueryClient(b.grpcConn) resp, err := client.ChainNonces(context.Background(), &observertypes.QueryGetChainNoncesRequest{Index: chain.ChainName.String()}) if err != nil { @@ -322,7 +323,7 @@ func (b *ZetaCoreBridge) GetTssHistory() ([]observertypes.TSS, error) { return resp.TssList, nil } -func (b *ZetaCoreBridge) GetOutTxTracker(chain pkg.Chain, nonce uint64) (*types.OutTxTracker, error) { +func (b *ZetaCoreBridge) GetOutTxTracker(chain chains.Chain, nonce uint64) (*types.OutTxTracker, error) { client := types.NewQueryClient(b.grpcConn) resp, err := client.OutTxTracker(context.Background(), &types.QueryGetOutTxTrackerRequest{ ChainID: chain.ChainId, @@ -380,7 +381,7 @@ func (b *ZetaCoreBridge) GetBlockHeaderStateByChain(chainID int64) (observertype return *resp, nil } -func (b *ZetaCoreBridge) GetSupportedChains() ([]*pkg.Chain, error) { +func (b *ZetaCoreBridge) GetSupportedChains() ([]*chains.Chain, error) { client := observertypes.NewQueryClient(b.grpcConn) resp, err := client.SupportedChains(context.Background(), &observertypes.QuerySupportedChains{}) if err != nil { @@ -398,7 +399,7 @@ func (b *ZetaCoreBridge) GetPendingNonces() (*observertypes.QueryAllPendingNonce return resp, nil } -func (b *ZetaCoreBridge) Prove(blockHash string, txHash string, txIndex int64, proof *pkg.Proof, chainID int64) (bool, error) { +func (b *ZetaCoreBridge) Prove(blockHash string, txHash string, txIndex int64, proof *proofs.Proof, chainID int64) (bool, error) { client := observertypes.NewQueryClient(b.grpcConn) resp, err := client.Prove(context.Background(), &observertypes.QueryProveRequest{ BlockHash: blockHash, diff --git a/zetaclient/zetabridge/tx.go b/zetaclient/zetabridge/tx.go index 57d3c93a94..1c604af4ef 100644 --- a/zetaclient/zetabridge/tx.go +++ b/zetaclient/zetabridge/tx.go @@ -7,6 +7,8 @@ import ( "time" "cosmossdk.io/math" + "github.com/zeta-chain/zetacore/pkg/coin" + "github.com/zeta-chain/zetacore/pkg/proofs" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" authz2 "github.com/zeta-chain/zetacore/zetaclient/authz" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" @@ -15,16 +17,16 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" "github.com/pkg/errors" "github.com/zeta-chain/go-tss/blame" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/x/crosschain/types" observerTypes "github.com/zeta-chain/zetacore/x/observer/types" ) // GasPriceMultiplier returns the gas price multiplier for the given chain func GasPriceMultiplier(chainID int64) (float64, error) { - if pkg.IsEVMChain(chainID) { + if chains.IsEVMChain(chainID) { return clientcommon.EVMOuttxGasPriceMultiplier, nil - } else if pkg.IsBitcoinChain(chainID) { + } else if chains.IsBitcoinChain(chainID) { return clientcommon.BTCOuttxGasPriceMultiplier, nil } return 0, fmt.Errorf("cannot get gas price multiplier for unknown chain %d", chainID) @@ -43,7 +45,7 @@ func (b *ZetaCoreBridge) WrapMessageWithAuthz(msg sdk.Msg) (sdk.Msg, authz2.Sign return &authzMessage, authzSigner, nil } -func (b *ZetaCoreBridge) PostGasPrice(chain pkg.Chain, gasPrice uint64, supply string, blockNum uint64) (string, error) { +func (b *ZetaCoreBridge) PostGasPrice(chain chains.Chain, gasPrice uint64, supply string, blockNum uint64) (string, error) { // apply gas price multiplier for the chain multiplier, err := GasPriceMultiplier(chain.ChainId) if err != nil { @@ -75,12 +77,12 @@ func (b *ZetaCoreBridge) AddTxHashToOutTxTracker( chainID int64, nonce uint64, txHash string, - proof *pkg.Proof, + proof *proofs.Proof, blockHash string, txIndex int64, ) (string, error) { // don't report if the tracker already contains the txHash - tracker, err := b.GetOutTxTracker(pkg.Chain{ChainId: chainID}, nonce) + tracker, err := b.GetOutTxTracker(chains.Chain{ChainId: chainID}, nonce) if err == nil { for _, hash := range tracker.HashList { if strings.EqualFold(hash.TxHash, txHash) { @@ -103,7 +105,7 @@ func (b *ZetaCoreBridge) AddTxHashToOutTxTracker( return zetaTxHash, nil } -func (b *ZetaCoreBridge) SetTSS(tssPubkey string, keyGenZetaHeight int64, status pkg.ReceiveStatus) (string, error) { +func (b *ZetaCoreBridge) SetTSS(tssPubkey string, keyGenZetaHeight int64, status chains.ReceiveStatus) (string, error) { signerAddress := b.keys.GetOperatorAddress().String() msg := types.NewMsgCreateTSSVoter(signerAddress, tssPubkey, keyGenZetaHeight, status) @@ -171,7 +173,7 @@ func (b *ZetaCoreBridge) PostBlameData(blame *blame.Blame, chainID int64, index return "", fmt.Errorf("post blame data failed after %d retries", DefaultRetryCount) } -func (b *ZetaCoreBridge) PostAddBlockHeader(chainID int64, blockHash []byte, height int64, header pkg.HeaderData) (string, error) { +func (b *ZetaCoreBridge) PostAddBlockHeader(chainID int64, blockHash []byte, height int64, header proofs.HeaderData) (string, error) { signerAddress := b.keys.GetOperatorAddress().String() msg := observerTypes.NewMsgAddBlockHeader(signerAddress, chainID, blockHash, height, header) @@ -287,10 +289,10 @@ func (b *ZetaCoreBridge) PostVoteOutbound( outTxEffectiveGasPrice *big.Int, outTxEffectiveGasLimit uint64, amount *big.Int, - status pkg.ReceiveStatus, - chain pkg.Chain, + status chains.ReceiveStatus, + chain chains.Chain, nonce uint64, - coinType pkg.CoinType, + coinType coin.CoinType, ) (string, string, error) { signerAddress := b.keys.GetOperatorAddress().String() msg := types.NewMsgVoteOnObservedOutboundTx( @@ -313,7 +315,7 @@ func (b *ZetaCoreBridge) PostVoteOutbound( // the higher gas limit is only necessary when the vote is finalized and the outbound is processed // therefore we use a retryGasLimit with a higher value to resend the tx if it fails (when the vote is finalized) retryGasLimit := uint64(0) - if msg.Status == pkg.ReceiveStatus_Failed { + if msg.Status == chains.ReceiveStatus_Failed { retryGasLimit = PostVoteOutboundRevertGasLimit } diff --git a/zetaclient/zetabridge/tx_vote_inbound.go b/zetaclient/zetabridge/tx_vote_inbound.go index affecdead5..43bbd4aaaf 100644 --- a/zetaclient/zetabridge/tx_vote_inbound.go +++ b/zetaclient/zetabridge/tx_vote_inbound.go @@ -2,7 +2,7 @@ package zetabridge import ( "cosmossdk.io/math" - "github.com/zeta-chain/zetacore/pkg" + "github.com/zeta-chain/zetacore/pkg/coin" "github.com/zeta-chain/zetacore/x/crosschain/types" ) @@ -30,7 +30,7 @@ func GetInBoundVoteMessage( inTxHash string, inBlockHeight uint64, gasLimit uint64, - coinType pkg.CoinType, + coinType coin.CoinType, asset string, signerAddress string, eventIndex uint, diff --git a/zetaclient/zetabridge/zetacore_bridge.go b/zetaclient/zetabridge/zetacore_bridge.go index 89d7b96496..9aaa03f228 100644 --- a/zetaclient/zetabridge/zetacore_bridge.go +++ b/zetaclient/zetabridge/zetacore_bridge.go @@ -5,11 +5,6 @@ import ( "sync" "time" - "github.com/zeta-chain/zetacore/pkg" - "github.com/zeta-chain/zetacore/zetaclient/interfaces" - "github.com/zeta-chain/zetacore/zetaclient/keys" - "github.com/zeta-chain/zetacore/zetaclient/metrics" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp/params" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -18,6 +13,8 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" "github.com/zeta-chain/zetacore/app" + "github.com/zeta-chain/zetacore/pkg/authz" + "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/pkg/cosmos" crosschaintypes "github.com/zeta-chain/zetacore/x/crosschain/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" @@ -35,8 +32,8 @@ var _ interfaces.ZetaCoreBridger = &ZetaCoreBridge{} type ZetaCoreBridge struct { logger zerolog.Logger blockHeight int64 - accountNumber map[pkg.KeyType]uint64 - seqNumber map[pkg.KeyType]uint64 + accountNumber map[authz.KeyType]uint64 + seqNumber map[authz.KeyType]uint64 grpcConn *grpc.ClientConn httpClient *retryablehttp.Client cfg config.ClientConfiguration @@ -44,7 +41,7 @@ type ZetaCoreBridge struct { keys *keys.Keys broadcastLock *sync.RWMutex zetaChainID string - zetaChain pkg.Chain + zetaChain chains.Chain stop chan struct{} pause chan struct{} Telemetry *metrics.TelemetryServer @@ -81,14 +78,14 @@ func NewZetaCoreBridge( logger.Error().Err(err).Msg("grpc dial fail") return nil, err } - accountsMap := make(map[pkg.KeyType]uint64) - seqMap := make(map[pkg.KeyType]uint64) - for _, keyType := range pkg.GetAllKeyTypes() { + accountsMap := make(map[authz.KeyType]uint64) + seqMap := make(map[authz.KeyType]uint64) + for _, keyType := range authz.GetAllKeyTypes() { accountsMap[keyType] = 0 seqMap[keyType] = 0 } - zetaChain, err := pkg.ZetaChainFromChainID(chainID) + zetaChain, err := chains.ZetaChainFromChainID(chainID) if err != nil { return nil, fmt.Errorf("invalid chain id %s, %w", chainID, err) } @@ -129,7 +126,7 @@ func (b *ZetaCoreBridge) UpdateChainID(chainID string) error { if b.zetaChainID != chainID { b.zetaChainID = chainID - zetaChain, err := pkg.ZetaChainFromChainID(chainID) + zetaChain, err := chains.ZetaChainFromChainID(chainID) if err != nil { return fmt.Errorf("invalid chain id %s, %w", chainID, err) } @@ -140,7 +137,7 @@ func (b *ZetaCoreBridge) UpdateChainID(chainID string) error { } // ZetaChain returns the ZetaChain chain object -func (b *ZetaCoreBridge) ZetaChain() pkg.Chain { +func (b *ZetaCoreBridge) ZetaChain() chains.Chain { return b.zetaChain } @@ -150,7 +147,7 @@ func (b *ZetaCoreBridge) Stop() { } // GetAccountNumberAndSequenceNumber We do not use multiple KeyType for now , but this can be optionally used in the future to seprate TSS signer from Zetaclient GRantee -func (b *ZetaCoreBridge) GetAccountNumberAndSequenceNumber(_ pkg.KeyType) (uint64, uint64, error) { +func (b *ZetaCoreBridge) GetAccountNumberAndSequenceNumber(_ authz.KeyType) (uint64, uint64, error) { ctx, err := b.GetContext() if err != nil { return 0, 0, err @@ -159,7 +156,7 @@ func (b *ZetaCoreBridge) GetAccountNumberAndSequenceNumber(_ pkg.KeyType) (uint6 return ctx.AccountRetriever.GetAccountNumberSequence(ctx, address) } -func (b *ZetaCoreBridge) SetAccountNumber(keyType pkg.KeyType) { +func (b *ZetaCoreBridge) SetAccountNumber(keyType authz.KeyType) { ctx, err := b.GetContext() if err != nil { b.logger.Error().Err(err).Msg("fail to get context") @@ -233,19 +230,19 @@ func (b *ZetaCoreBridge) UpdateZetaCoreContext(coreContext *corecontext.ZetaCore b.logger.Info().Msgf("Chain %d is not supported yet", chainParam.ChainId) continue } - if pkg.IsBitcoinChain(chainParam.ChainId) { + if chains.IsBitcoinChain(chainParam.ChainId) { newBTCParams = chainParam - } else if pkg.IsEVMChain(chainParam.ChainId) { + } else if chains.IsEVMChain(chainParam.ChainId) { newEVMParams[chainParam.ChainId] = chainParam } } - chains, err := b.GetSupportedChains() + supporteChains, err := b.GetSupportedChains() if err != nil { return err } - newChains := make([]pkg.Chain, len(chains)) - for i, chain := range chains { + newChains := make([]chains.Chain, len(supporteChains)) + for i, chain := range supporteChains { newChains[i] = *chain } keyGen, err := b.GetKeyGen() diff --git a/zetaclient/zetacore_observer.go b/zetaclient/zetacore_observer.go index b6dcb36c8f..8ec76013a5 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -6,6 +6,7 @@ import ( "time" ethcommon "github.com/ethereum/go-ethereum/common" + "github.com/zeta-chain/zetacore/pkg/chains" appcontext "github.com/zeta-chain/zetacore/zetaclient/app_context" "github.com/zeta-chain/zetacore/zetaclient/bitcoin" corecontext "github.com/zeta-chain/zetacore/zetaclient/core_context" @@ -17,7 +18,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/rs/zerolog" - "github.com/zeta-chain/zetacore/pkg" "github.com/zeta-chain/zetacore/x/crosschain/types" "github.com/zeta-chain/zetacore/zetaclient/metrics" ) @@ -165,9 +165,9 @@ func (co *CoreObserver) startCctxScheduler(appContext *appcontext.AppContext) { // #nosec G701 range is verified zetaHeight := uint64(bn) - if pkg.IsEVMChain(c.ChainId) { + if chains.IsEVMChain(c.ChainId) { co.scheduleCctxEVM(outTxMan, zetaHeight, c.ChainId, cctxList, ob, signer) - } else if pkg.IsBitcoinChain(c.ChainId) { + } else if chains.IsBitcoinChain(c.ChainId) { co.scheduleCctxBTC(outTxMan, zetaHeight, c.ChainId, cctxList, ob, signer) } else { co.logger.ZetaChainWatcher.Error().Msgf("startCctxScheduler: unsupported chain %d", c.ChainId) @@ -332,7 +332,7 @@ func (co *CoreObserver) GetUpdatedSigner(coreContext *corecontext.ZetaCoreContex return nil, fmt.Errorf("signer not found for chainID %d", chainID) } // update EVM signer parameters only. BTC signer doesn't use chain parameters for now. - if pkg.IsEVMChain(chainID) { + if chains.IsEVMChain(chainID) { evmParams, found := coreContext.GetEVMChainParams(chainID) if found { // update zeta connector and ERC20 custody addresses @@ -361,14 +361,14 @@ func (co *CoreObserver) GetUpdatedChainClient(coreContext *corecontext.ZetaCoreC } // update chain client chain parameters curParams := chainOb.GetChainParams() - if pkg.IsEVMChain(chainID) { + if chains.IsEVMChain(chainID) { evmParams, found := coreContext.GetEVMChainParams(chainID) if found && !observertypes.ChainParamsEqual(curParams, *evmParams) { chainOb.SetChainParams(*evmParams) co.logger.ZetaChainWatcher.Info().Msgf( "updated chain params for chainID %d, new params: %v", chainID, *evmParams) } - } else if pkg.IsBitcoinChain(chainID) { + } else if chains.IsBitcoinChain(chainID) { _, btcParams, found := coreContext.GetBTCChainParams() if found && !observertypes.ChainParamsEqual(curParams, *btcParams) { diff --git a/zetaclient/zetacore_observer_test.go b/zetaclient/zetacore_observer_test.go index 21ede8577f..56ca752b97 100644 --- a/zetaclient/zetacore_observer_test.go +++ b/zetaclient/zetacore_observer_test.go @@ -7,7 +7,7 @@ import ( ethcommon "github.com/ethereum/go-ethereum/common" "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/testutil/sample" observertypes "github.com/zeta-chain/zetacore/x/observer/types" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -17,7 +17,7 @@ import ( "github.com/zeta-chain/zetacore/zetaclient/testutils/stub" ) -func MockCoreObserver(t *testing.T, evmChain, btcChain pkg.Chain, evmChainParams, btcChainParams *observertypes.ChainParams) *CoreObserver { +func MockCoreObserver(t *testing.T, evmChain, btcChain chains.Chain, evmChainParams, btcChainParams *observertypes.ChainParams) *CoreObserver { // create mock signers and clients evmSigner := stub.NewEVMSigner( evmChain, @@ -42,7 +42,7 @@ func MockCoreObserver(t *testing.T, evmChain, btcChain pkg.Chain, evmChainParams return observer } -func CreateCoreContext(evmChain, btcChain pkg.Chain, evmChainParams, btcChainParams *observertypes.ChainParams) *corecontext.ZetaCoreContext { +func CreateCoreContext(evmChain, btcChain chains.Chain, evmChainParams, btcChainParams *observertypes.ChainParams) *corecontext.ZetaCoreContext { // new config cfg := config.NewConfig() cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{ @@ -60,7 +60,7 @@ func CreateCoreContext(evmChain, btcChain pkg.Chain, evmChainParams, btcChainPar // feed chain params coreContext.Update( &observertypes.Keygen{}, - []pkg.Chain{evmChain, btcChain}, + []chains.Chain{evmChain, btcChain}, evmChainParamsMap, btcChainParams, "", @@ -73,8 +73,8 @@ func CreateCoreContext(evmChain, btcChain pkg.Chain, evmChainParams, btcChainPar func Test_GetUpdatedSigner(t *testing.T) { // initial parameters for core observer creation - evmChain := pkg.EthChain() - btcChain := pkg.BtcMainnetChain() + evmChain := chains.EthChain() + btcChain := chains.BtcMainnetChain() evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -93,7 +93,7 @@ func Test_GetUpdatedSigner(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC signer should not be found - _, err := observer.GetUpdatedSigner(coreContext, pkg.BscMainnetChain().ChainId) + _, err := observer.GetUpdatedSigner(coreContext, chains.BscMainnetChain().ChainId) require.ErrorContains(t, err, "signer not found") }) t.Run("should be able to update connector and erc20 custody address", func(t *testing.T) { @@ -109,8 +109,8 @@ func Test_GetUpdatedSigner(t *testing.T) { func Test_GetUpdatedChainClient(t *testing.T) { // initial parameters for core observer creation - evmChain := pkg.EthChain() - btcChain := pkg.BtcMainnetChain() + evmChain := chains.EthChain() + btcChain := chains.BtcMainnetChain() evmChainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, ConnectorContractAddress: testutils.ConnectorAddresses[evmChain.ChainId].Hex(), @@ -158,7 +158,7 @@ func Test_GetUpdatedChainClient(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(evmChain, btcChain, evmChainParamsNew, btcChainParams) // BSC chain client should not be found - _, err := observer.GetUpdatedChainClient(coreContext, pkg.BscMainnetChain().ChainId) + _, err := observer.GetUpdatedChainClient(coreContext, chains.BscMainnetChain().ChainId) require.ErrorContains(t, err, "chain client not found") }) t.Run("chain params in evm chain client should be updated successfully", func(t *testing.T) { @@ -174,7 +174,7 @@ func Test_GetUpdatedChainClient(t *testing.T) { observer := MockCoreObserver(t, evmChain, btcChain, evmChainParams, btcChainParams) coreContext := CreateCoreContext(btcChain, btcChain, evmChainParams, btcChainParamsNew) // BTC testnet chain client should not be found - _, err := observer.GetUpdatedChainClient(coreContext, pkg.BtcTestNetChain().ChainId) + _, err := observer.GetUpdatedChainClient(coreContext, chains.BtcTestNetChain().ChainId) require.ErrorContains(t, err, "chain client not found") }) t.Run("chain params in btc chain client should be updated successfully", func(t *testing.T) {