diff --git a/client/config.go b/client/config.go index d5523db9..6fd6c484 100644 --- a/client/config.go +++ b/client/config.go @@ -61,25 +61,3 @@ func ValidateChainID(baseCmd *cobra.Command) *cobra.Command { baseCmd.RunE = validateFn return baseCmd } - -// GenerateChainID wraps a cobra command with a RunE function with base 10 integer chain-id random generation -// when a chain-id is not provided. -func GenerateChainID(baseCmd *cobra.Command) *cobra.Command { - // Copy base run command to be used after chain verification - baseRunE := baseCmd.RunE - - // Function to replace command's RunE function - generateFn := func(cmd *cobra.Command, args []string) error { - chainID, _ := cmd.Flags().GetString(flags.FlagChainID) - - if chainID == "" { - if err := cmd.Flags().Set(flags.FlagChainID, ethermint.GenerateRandomChainID()); err != nil { - return fmt.Errorf("could not set random chain-id: %v", err) - } - } - return baseRunE(cmd, args) - } - - baseCmd.RunE = generateFn - return baseCmd -} diff --git a/client/export.go b/client/export.go index 32003f6d..bb813dd5 100644 --- a/client/export.go +++ b/client/export.go @@ -5,17 +5,15 @@ import ( "fmt" "strings" - "github.com/spf13/cobra" - - "github.com/ethereum/go-ethereum/common/hexutil" - ethcrypto "github.com/ethereum/go-ethereum/crypto" - "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common/hexutil" + ethcrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/ethermint/crypto/ethsecp256k1" "github.com/cosmos/ethermint/crypto/hd" ) @@ -77,13 +75,13 @@ func UnsafeExportEthKeyCommand() *cobra.Command { } // Converts key to Ethermint secp256 implementation - ethermintPrivKey, ok := privKey.(*ethsecp256k1.PrivKey) + ethPrivKey, ok := privKey.(*ethsecp256k1.PrivKey) if !ok { return fmt.Errorf("invalid private key type %T, expected %T", privKey, ðsecp256k1.PrivKey{}) } // Formats key for output - privB := ethcrypto.FromECDSA(ethermintPrivKey.ToECDSA()) + privB := ethcrypto.FromECDSA(ethPrivKey.ToECDSA()) keyS := strings.ToUpper(hexutil.Encode(privB)[2:]) fmt.Println(keyS) diff --git a/client/import.go b/client/import.go new file mode 100644 index 00000000..2baea883 --- /dev/null +++ b/client/import.go @@ -0,0 +1,58 @@ +package client + +import ( + "bufio" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/crypto" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ethermint/crypto/ethsecp256k1" + "github.com/ethereum/go-ethereum/common" + + "github.com/cosmos/ethermint/crypto/hd" +) + +// UnsafeImportKeyCommand imports private keys from a keyfile. +func UnsafeImportKeyCommand() *cobra.Command { + return &cobra.Command{ + Use: "unsafe-import-eth-key ", + Short: "**UNSAFE** Import Ethereum private keys into the local keybase", + Long: "**UNSAFE** Import a hex-encoded Ethereum private key into the local keybase.", + Args: cobra.ExactArgs(2), + RunE: runImportCmd, + } +} + +func runImportCmd(cmd *cobra.Command, args []string) error { + inBuf := bufio.NewReader(cmd.InOrStdin()) + keyringBackend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) + rootDir, _ := cmd.Flags().GetString(flags.FlagHome) + + kb, err := keyring.New( + sdk.KeyringServiceName(), + keyringBackend, + rootDir, + inBuf, + hd.EthSecp256k1Option(), + ) + if err != nil { + return err + } + + passphrase, err := input.GetPassword("Enter passphrase to encrypt your key:", inBuf) + if err != nil { + return err + } + + privKey := ðsecp256k1.PrivKey{ + Key: common.FromHex(args[1]), + } + + armor := crypto.EncryptArmorPrivKey(privKey, passphrase, "eth_secp256k1") + + return kb.ImportPrivKey(args[0], armor, passphrase) +} diff --git a/client/keys.go b/client/keys.go new file mode 100644 index 00000000..82027058 --- /dev/null +++ b/client/keys.go @@ -0,0 +1,109 @@ +package client + +import ( + "bufio" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/keys" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/tendermint/tendermint/libs/cli" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/ethermint/crypto/hd" +) + +const ( + flagDryRun = "dry-run" +) + +// KeyCommands registers a sub-tree of commands to interact with +// local private key storage. +func KeyCommands(defaultNodeHome string) *cobra.Command { + cmd := &cobra.Command{ + Use: "keys", + Short: "Manage your application's keys", + Long: `Keyring management commands. These keys may be in any format supported by the +Tendermint crypto library and can be used by light-clients, full nodes, or any other application +that needs to sign with a private key. + +The keyring supports the following backends: + + os Uses the operating system's default credentials store. + file Uses encrypted file-based keystore within the app's configuration directory. + This keyring will request a password each time it is accessed, which may occur + multiple times in a single command resulting in repeated password prompts. + kwallet Uses KDE Wallet Manager as a credentials management application. + pass Uses the pass command line utility to store and retrieve keys. + test Stores keys insecurely to disk. It does not prompt for a password to be unlocked + and it should be use only for testing purposes. + +kwallet and pass backends depend on external tools. Refer to their respective documentation for more +information: + KWallet https://github.com/KDE/kwallet + pass https://www.passwordstore.org/ + +The pass backend requires GnuPG: https://gnupg.org/ +`, + } + + // support adding Ethereum supported keys + addCmd := keys.AddKeyCommand() + + // update the default signing algorithm value to "eth_secp256k1" + algoFlag := addCmd.Flag("algo") + algoFlag.DefValue = string(hd.EthSecp256k1Type) + err := algoFlag.Value.Set(string(hd.EthSecp256k1Type)) + if err != nil { + panic(err) + } + + addCmd.RunE = runAddCmd + + cmd.AddCommand( + keys.MnemonicKeyCommand(), + addCmd, + keys.ExportKeyCommand(), + keys.ImportKeyCommand(), + keys.ListKeysCmd(), + keys.ShowKeysCmd(), + flags.LineBreak, + keys.DeleteKeyCommand(), + keys.ParseKeyStringCommand(), + keys.MigrateCommand(), + flags.LineBreak, + UnsafeExportEthKeyCommand(), + UnsafeImportKeyCommand(), + ) + + cmd.PersistentFlags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + cmd.PersistentFlags().String(flags.FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") + cmd.PersistentFlags().String(flags.FlagKeyringBackend, keyring.BackendFile, "Select keyring's backend (os|file|test)") + cmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)") + return cmd +} + +func runAddCmd(cmd *cobra.Command, args []string) error { + buf := bufio.NewReader(cmd.InOrStdin()) + clientCtx := client.GetClientContextFromCmd(cmd) + + var ( + kr keyring.Keyring + err error + ) + + dryRun, _ := cmd.Flags().GetBool(flags.FlagDryRun) + if dryRun { + kr, err = keyring.New(sdk.KeyringServiceName(), keyring.BackendMemory, clientCtx.KeyringDir, buf, hd.EthSecp256k1Option()) + } else { + backend, _ := cmd.Flags().GetString(flags.FlagKeyringBackend) + kr, err = keyring.New(sdk.KeyringServiceName(), backend, clientCtx.KeyringDir, buf, hd.EthSecp256k1Option()) + } + + if err != nil { + return err + } + + return keys.RunAddCmd(cmd, args, kr, buf) +} diff --git a/client/testnet.go b/client/testnet.go index 53c33659..59b25e4c 100644 --- a/client/testnet.go +++ b/client/testnet.go @@ -4,13 +4,20 @@ package client import ( "bufio" + "bytes" "encoding/json" "errors" "fmt" + "io/ioutil" + "log" "net" "os" "path/filepath" + "strings" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + + ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/spf13/cobra" tmconfig "github.com/tendermint/tendermint/config" @@ -22,8 +29,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -36,12 +41,14 @@ import ( mintypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - ethcrypto "github.com/ethereum/go-ethereum/crypto" - + "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/ethermint/crypto/hd" - srvconfig "github.com/cosmos/ethermint/server/config" - ethermint "github.com/cosmos/ethermint/types" + chaintypes "github.com/cosmos/ethermint/types" evmtypes "github.com/cosmos/ethermint/x/evm/types" + + "github.com/cosmos/ethermint/cmd/injectived/config" + "github.com/cosmos/ethermint/crypto/ethsecp256k1" + "github.com/ethereum/go-ethereum/common" ) var ( @@ -67,7 +74,7 @@ necessary files (private validator, genesis, config, etc.). Note, strict routability for addresses is turned off in the config file.`, - Example: "ethermintd testnet --v 4 --keyring-backend test --output-dir ./output --ip-addresses 192.168.10.2", + Example: "injectived testnet --v 4 --keyring-backend test --output-dir ./output --ip-addresses 192.168.10.2", RunE: func(cmd *cobra.Command, _ []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -99,13 +106,13 @@ Note, strict routability for addresses is turned off in the config file.`, cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with") cmd.Flags().StringP(flagOutputDir, "o", "./mytestnet", "Directory to store initialization data for the testnet") cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") - cmd.Flags().String(flagNodeDaemonHome, "simd", "Home directory of the node's daemon configuration") + cmd.Flags().String(flagNodeDaemonHome, "injectived", "Home directory of the node's daemon configuration") cmd.Flags().StringSlice(flagIPAddrs, []string{"192.168.0.1"}, "List of IP addresses to use (i.e. `192.168.0.1,172.168.0.1` results in persistent peers list ID0@192.168.0.1:46656, ID1@172.168.0.1)") cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created") - cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", ethermint.AttoPhoton), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01aphoton,0.001stake)") + cmd.Flags().String(server.FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01inj,0.001stake)") cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)") cmd.Flags().String(flags.FlagKeyAlgorithm, string(hd.EthSecp256k1Type), "Key signing algorithm to generate keys for") - cmd.Flags().String(flagCoinDenom, ethermint.AttoPhoton, "Coin denomination used for staking, governance, mint, crisis and evm parameters") + cmd.Flags().String(flagCoinDenom, chaintypes.InjectiveCoin, "Coin denomination used for staking, governance, mint, crisis and evm parameters") return cmd } @@ -129,10 +136,10 @@ func InitTestnet( ) error { if chainID == "" { - chainID = fmt.Sprintf("ethermint-%d", tmrand.Int63n(9999999999999)+1) + chainID = fmt.Sprintf("injective-%d", tmrand.Int63n(9999999999999)+1) } - if !ethermint.IsValidChainID(chainID) { + if !chaintypes.IsValidChainID(chainID) { return fmt.Errorf("invalid chain-id: %s", chainID) } @@ -147,7 +154,7 @@ func InitTestnet( nodeIDs := make([]string, numValidators) valPubKeys := make([]cryptotypes.PubKey, numValidators) - appConfig := srvconfig.DefaultConfig() + appConfig := config.DefaultConfig() appConfig.MinGasPrices = minGasPrices appConfig.API.Enable = true appConfig.Telemetry.Enabled = true @@ -243,7 +250,7 @@ func InitTestnet( ) genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins}) - genAccounts = append(genAccounts, ðermint.EthAccount{ + genAccounts = append(genAccounts, &chaintypes.EthAccount{ BaseAccount: authtypes.NewBaseAccount(addr, nil, 0, 0), CodeHash: ethcrypto.Keccak256(nil), }) @@ -289,7 +296,10 @@ func InitTestnet( return err } - srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig) + config.WriteConfigFile(filepath.Join(nodeDir, "config/app.toml"), appConfig) + + ethPrivKey, err := keyring.NewUnsafe(kb).UnsafeExportPrivKeyHex(nodeDirName) + initPeggo(outputDir, nodeDirName, []byte(strings.ToUpper(ethPrivKey))) } if err := initGenFiles(clientCtx, mbm, chainID, coinDenom, genAccounts, genBalances, genFiles, numValidators); err != nil { @@ -308,6 +318,32 @@ func InitTestnet( return nil } +func initPeggo(outputDir string, nodeDirName string, privKey []byte) { + peggoDir := filepath.Join(outputDir, nodeDirName, "peggo") + if envdata, _ := ioutil.ReadFile("./templates/peggo_config.template"); len(envdata) > 0 { + s := bufio.NewScanner(bytes.NewReader(envdata)) + for s.Scan() { + parts := strings.Split(s.Text(), "=") + if len(parts) != 2 { + continue + } else { + content := []byte(s.Text()) + if parts[0] == "PEGGY_COSMOS_PRIVKEY" { + content = append([]byte(parts[0]+"="), privKey...) + } else if parts[0] == "PEGGY_ETH_PRIVATE_KEY" { + newPrivkey, _ := ethsecp256k1.GenerateKey() + privKeyStr := common.Bytes2Hex(newPrivkey.GetKey()) + privKeyBytes := []byte(strings.ToUpper(privKeyStr)) + content = append([]byte(parts[0]+"="), privKeyBytes...) + } + if err := appendToFile(fmt.Sprintf("config.env"), peggoDir, content); err != nil { + fmt.Println("Error writing peggo config", "error", err) + } + } + } + } +} + func initGenFiles( clientCtx client.Context, mbm module.BasicManager, @@ -476,3 +512,42 @@ func writeFile(name string, dir string, contents []byte) error { return nil } + +func appendToFile(name string, dir string, contents []byte) error { + writePath := filepath.Join(dir) + file := filepath.Join(writePath, name) + + err := tmos.EnsureDir(writePath, 0755) + if err != nil { + return err + } + + if _, err = os.Stat(file); err == nil { + err = os.Chmod(file, 0777) + if err != nil { + fmt.Println(err) + return err + } + } + + f, err := os.OpenFile(file, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + if err != nil { + log.Println(err) + return err + } + defer f.Close() + + _, err = f.Write(contents) + if err != nil { + log.Println(err) + return err + } + + f.Write([]byte("\n")) + if err != nil { + log.Println(err) + return err + } + + return nil +} diff --git a/docs/pre.sh b/docs/pre.sh index 8fc60db9..4ca8b700 100755 --- a/docs/pre.sh +++ b/docs/pre.sh @@ -9,4 +9,4 @@ for D in ../x/*; do fi done -cat ../x/README.md | sed 's/\.\/x/\/modules/g' | sed 's/spec\/README.md//g' \ No newline at end of file +cat ../x/README.md | sed 's/\.\/x/\/x/g' | sed 's/spec\/README.md//g' \ No newline at end of file diff --git a/proto/ethermint/evm/v1alpha1/evm.proto b/proto/ethermint/evm/v1alpha1/evm.proto index 6850b899..ec606f63 100644 --- a/proto/ethermint/evm/v1alpha1/evm.proto +++ b/proto/ethermint/evm/v1alpha1/evm.proto @@ -171,3 +171,79 @@ message Log { // through a filter query. bool removed = 9; } + +// TxReceipt defines the receipt type stored in KV for each EVM transaction. +message TxReceipt { + option (gogoproto.goproto_getters) = false; + + bytes hash = 1; + bytes from = 2; + TxData data = 3; + TxResult result = 4; + uint64 index = 5; + uint64 blockHeight = 6; + bytes blockHash = 7; +} + +// TxResult stores results of Tx execution. +message TxResult { + option (gogoproto.goproto_getters) = false; + + // contract_address contains the ethereum address of the created contract (if + // any). If the state transition is an evm.Call, the contract address will be + // empty. + string contract_address = 1 + [ (gogoproto.moretags) = "yaml:\"contract_address\"" ]; + // bloom represents the bloom filter bytes + bytes bloom = 2; + // tx_logs contains the transaction hash and the proto-compatible ethereum + // logs. + TransactionLogs tx_logs = 3 [ + (gogoproto.moretags) = "yaml:\"tx_logs\"", + (gogoproto.nullable) = false + ]; + // ret defines the bytes from the execution. + bytes ret = 4; + // reverted flag is set to true when the call has been reverted + bool reverted = 5; + // gas_used notes the amount of gas consumed while execution + uint64 gas_used = 6; +} + +// TxData implements the Ethereum transaction data structure. It is used +// solely as intended in Ethereum abiding by the protocol. +message TxData { + option (gogoproto.goproto_getters) = false; + + // nonce corresponds to the account nonce (transaction sequence). + uint64 nonce = 1 [(gogoproto.customname) = "AccountNonce"]; + // price defines the unsigned integer value of the gas price in bytes. + bytes price = 2 [ + (gogoproto.jsontag) = "gasPrice" + ]; + // gas defines the gas limit defined for the transaction. + uint64 gas = 3 [(gogoproto.customname) = "GasLimit"]; + bytes to = 4 [ + (gogoproto.customname) = "Recipient" + ]; + // value defines the unsigned integer value of the transaction amount. + bytes value = 5 [ + (gogoproto.customname) = "Amount" + ]; + // input defines the data payload bytes of the transaction. + bytes input = 6 [(gogoproto.customname) = "Payload"]; + // v defines the signature value + bytes v = 7; + // r defines the signature value + bytes r = 8; + // s define the signature value + bytes s = 9; + // hash defines the tx data hash, which is only used when marshaling to JSON. + string hash = 10 [ (gogoproto.moretags) = "rlp:\"-\"" ]; +} + +message BytesList { + option (gogoproto.goproto_getters) = false; + + repeated bytes bytes = 1; +} diff --git a/proto/ethermint/evm/v1alpha1/genesis.proto b/proto/ethermint/evm/v1alpha1/genesis.proto index 633c9b2f..0d44cdde 100644 --- a/proto/ethermint/evm/v1alpha1/genesis.proto +++ b/proto/ethermint/evm/v1alpha1/genesis.proto @@ -37,4 +37,4 @@ message GenesisAccount { (gogoproto.nullable) = false, (gogoproto.castrepeated) = "Storage" ]; -} \ No newline at end of file +} diff --git a/proto/ethermint/evm/v1alpha1/query.proto b/proto/ethermint/evm/v1alpha1/query.proto index 55dafffd..50382ad2 100644 --- a/proto/ethermint/evm/v1alpha1/query.proto +++ b/proto/ethermint/evm/v1alpha1/query.proto @@ -14,6 +14,11 @@ service Query { option (google.api.http).get = "/ethermint/evm/v1alpha1/account/{address}"; } + // Account queries an Ethereum account's Cosmos Address. + rpc CosmosAccount(QueryCosmosAccountRequest) returns (QueryCosmosAccountResponse) { + option (google.api.http).get = "/ethermint/evm/v1alpha1/cosmos_account/{address}"; + } + // Balance queries the balance of a the EVM denomination for a single // EthAccount. rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { @@ -36,6 +41,21 @@ service Query { option (google.api.http).get = "/ethermint/evm/v1alpha1/tx_logs/{hash}"; } + // TxReceipt queries a receipt by a transaction hash. + rpc TxReceipt(QueryTxReceiptRequest) returns (QueryTxReceiptResponse) { + option (google.api.http).get = "/ethermint/evm/v1alpha1/tx_receipt/{hash}"; + } + + // TxReceiptsByBlockHeight queries tx receipts by a block height. + rpc TxReceiptsByBlockHeight(QueryTxReceiptsByBlockHeightRequest) returns (QueryTxReceiptsByBlockHeightResponse) { + option (google.api.http).get = "/ethermint/evm/v1alpha1/tx_receipts_block/{height}"; + } + + // TxReceiptsByBlockHash queries tx receipts by a block hash. + rpc TxReceiptsByBlockHash(QueryTxReceiptsByBlockHashRequest) returns (QueryTxReceiptsByBlockHashResponse) { + option (google.api.http).get = "/ethermint/evm/v1alpha1/tx_receipts_block_hash/{hash}"; + } + // BlockLogs queries all the ethereum logs for a given block hash. rpc BlockLogs(QueryBlockLogsRequest) returns (QueryBlockLogsResponse) { option (google.api.http).get = "/ethermint/evm/v1alpha1/block_logs/{hash}"; @@ -50,6 +70,11 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/ethermint/evm/v1alpha1/params"; } + + // StaticCall queries the static call value of x/evm module. + rpc StaticCall(QueryStaticCallRequest) returns (QueryStaticCallResponse) { + option (google.api.http).get = "/ethermint/evm/v1alpha1/static_call"; + } } // QueryAccountRequest is the request type for the Query/Account RPC method. @@ -71,6 +96,25 @@ message QueryAccountResponse { uint64 nonce = 3; } +// QueryCosmosAccountRequest is the request type for the Query/CosmosAccount RPC method. +message QueryCosmosAccountRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the ethereum hex address to query the account for. + string address = 1; +} + +// QueryCosmosAccountResponse is the response type for the Query/CosmosAccount RPC method. +message QueryCosmosAccountResponse { + // cosmos_address is the cosmos address of the account. + string cosmos_address = 1; + // sequence is the account's sequence number. + uint64 sequence = 2; + // account_number is the account numbert + uint64 account_number = 3; +} + // QueryBalanceRequest is the request type for the Query/Balance RPC method. message QueryBalanceRequest { option (gogoproto.equal) = false; @@ -136,6 +180,51 @@ message QueryTxLogsResponse { repeated Log logs = 1; } +// QueryTxReceiptRequest is the request type for the Query/TxReceipt RPC method. +message QueryTxReceiptRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // hash is the ethereum transaction hex hash to query the receipt for. + string hash = 1; +} + +// QueryTxReceiptResponse is the response type for the Query/TxReceipt RPC method. +message QueryTxReceiptResponse { + // receipt represents the ethereum receipt for the given transaction. + TxReceipt receipt = 1; +} + +// QueryTxReceiptsByBlockHeightRequest is the request type for the Query/TxReceiptsByBlockHeight RPC method. +message QueryTxReceiptsByBlockHeightRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // height is the block height to query tx receipts for + int64 height = 1; +} + +// QueryTxReceiptsByBlockHeightResponse is the response type for the Query/TxReceiptsByBlockHeight RPC method. +message QueryTxReceiptsByBlockHeightResponse { + // tx receipts list for the block + repeated TxReceipt receipts = 1; +} + +// QueryTxReceiptsByBlockHashRequest is the request type for the Query/TxReceiptsByBlockHash RPC method. +message QueryTxReceiptsByBlockHashRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // hash is the ethereum transaction hex hash to query the receipt for. + string hash = 1; +} + +// QueryTxReceiptsByBlockHashResponse is the response type for the Query/TxReceiptsByBlockHash RPC method. +message QueryTxReceiptsByBlockHashResponse { + // tx receipts list for the block + repeated TxReceipt receipts = 1; +} + // QueryBlockLogsRequest is the request type for the Query/BlockLogs RPC method. message QueryBlockLogsRequest { option (gogoproto.equal) = false; @@ -153,7 +242,7 @@ message QueryBlockLogsResponse { // QueryBlockBloomRequest is the request type for the Query/BlockBloom RPC // method. -message QueryBlockBloomRequest {} +message QueryBlockBloomRequest { int64 height = 1; } // QueryBlockBloomResponse is the response type for the Query/BlockBloom RPC // method. @@ -170,3 +259,16 @@ message QueryParamsResponse { // params define the evm module parameters. Params params = 1 [ (gogoproto.nullable) = false ]; } + +// QueryStaticCallRequest defines static call request +message QueryStaticCallRequest { + // address is the ethereum contract hex address to for static call. + string address = 1; + // static call input generated from abi + bytes input = 2; +} + +// // QueryStaticCallRequest defines static call response +message QueryStaticCallResponse { + bytes data = 1; +} diff --git a/proto/ethermint/evm/v1alpha1/tx.proto b/proto/ethermint/evm/v1alpha1/tx.proto index 1dd18492..b60c2a2a 100644 --- a/proto/ethermint/evm/v1alpha1/tx.proto +++ b/proto/ethermint/evm/v1alpha1/tx.proto @@ -22,14 +22,22 @@ message MsgEthereumTx { SigCache from = 3 [ (gogoproto.jsontag) = "-" ]; } +message ExtensionOptionsEthereumTx { + option (gogoproto.goproto_getters) = false; +} + +message ExtensionOptionsWeb3Tx { + option (gogoproto.goproto_getters) = false; +} + // MsgEthereumTxResponse defines the Msg/EthereumTx response type. -message MsgEthereumTxResponse { +message MsgEthereumTxResponse { option (gogoproto.goproto_getters) = false; // contract_address contains the ethereum address of the created contract (if // any). If the state transition is an evm.Call, the contract address will be // empty. - string contract_address = 1 [(gogoproto.moretags) = "yaml:\"contract_address\""]; + string contract_address = 1 [(gogoproto.moretags) = "yaml:\"contract_address\"" ]; // bloom represents the bloom filter bytes bytes bloom = 2; // tx_logs contains the transaction hash and the proto-compatible ethereum @@ -40,52 +48,8 @@ message MsgEthereumTxResponse { ]; // ret defines the bytes from the execution. bytes ret = 4; -} - -// TxData implements the Ethereum transaction data structure. It is used -// solely as intended in Ethereum abiding by the protocol. -message TxData { - option (gogoproto.goproto_getters) = false; - - // nonce corresponds to the account nonce (transaction sequence). - uint64 nonce = 1 [(gogoproto.customname) = "AccountNonce"]; - // price defines the unsigned integer value of the gas price in bytes. - string price = 2 [ - (gogoproto.jsontag) = "gasPrice", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // gas defines the gas limit defined for the transaction. - uint64 gas = 3 [(gogoproto.customname) = "GasLimit"]; - Recipient to = 4 [ - (gogoproto.customname) = "Recipient", - (gogoproto.moretags) = "rlp:\"nil\"" - ]; - // value defines the unsigned integer value of the transaction amount. - string value = 5 [ - (gogoproto.customname) = "Amount", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // input defines the data payload bytes of the transaction. - bytes input = 6 [(gogoproto.customname) = "Payload"]; - // v defines the signature value - bytes v = 7; - // r defines the signature value - bytes r = 8; - // s define the signature value - bytes s = 9; - // hash defines the tx data hash, which is only used when marshaling to JSON. - string hash = 10 [ (gogoproto.moretags) = "rlp:\"-\"" ]; -} - -// Recipient defines a protobuf-compatible wrapper for an Ethereum address -// pointer. It is required for RLP encoding. -message Recipient { - option (gogoproto.goproto_getters) = false; - - // address defines the hex-formated ethereum address of the recipient - string address = 1; + // reverted flag is set to true when the call has been reverted + bool reverted = 5; } // SigCache is used to cache the derived sender and contains the signer used @@ -94,7 +58,7 @@ message SigCache { option (gogoproto.goproto_getters) = false; EIP155Signer signer = 1; - string address = 2; + bytes address = 2; } // EIP155Transaction implements Signer using the EIP155 rules. @@ -103,4 +67,4 @@ message EIP155Signer { bytes chain_id = 1 [(gogoproto.customname) = "chainId"]; bytes chain_id_mul = 2 [(gogoproto.customname) = "chainIdMul"]; -} \ No newline at end of file +} diff --git a/third_party/proto/cosmos/auth/v1beta1/auth.proto b/third_party/proto/cosmos/auth/v1beta1/auth.proto index 1cf5d883..72e1d9ec 100644 --- a/third_party/proto/cosmos/auth/v1beta1/auth.proto +++ b/third_party/proto/cosmos/auth/v1beta1/auth.proto @@ -11,52 +11,40 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; // for basic account functionality. Any custom account type should extend this // type for additional functionality (e.g. vesting). message BaseAccount { - option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (cosmos_proto.implements_interface) = "AccountI"; - string address = 1; - google.protobuf.Any pub_key = 2 [ - (gogoproto.jsontag) = "public_key,omitempty", - (gogoproto.moretags) = "yaml:\"public_key\"" - ]; - uint64 account_number = 3 - [ (gogoproto.moretags) = "yaml:\"account_number\"" ]; - uint64 sequence = 4; + string address = 1; + google.protobuf.Any pub_key = 2 + [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; + uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; + uint64 sequence = 4; } // ModuleAccount defines an account for modules that holds coins on a pool. message ModuleAccount { - option (gogoproto.goproto_getters) = false; - option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; option (cosmos_proto.implements_interface) = "ModuleAccountI"; - BaseAccount base_account = 1 [ - (gogoproto.embed) = true, - (gogoproto.moretags) = "yaml:\"base_account\"" - ]; - string name = 2; - repeated string permissions = 3; + BaseAccount base_account = 1 [(gogoproto.embed) = true, (gogoproto.moretags) = "yaml:\"base_account\""]; + string name = 2; + repeated string permissions = 3; } // Params defines the parameters for the auth module. message Params { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - uint64 max_memo_characters = 1 - [ (gogoproto.moretags) = "yaml:\"max_memo_characters\"" ]; - uint64 tx_sig_limit = 2 [ (gogoproto.moretags) = "yaml:\"tx_sig_limit\"" ]; - uint64 tx_size_cost_per_byte = 3 - [ (gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\"" ]; - uint64 sig_verify_cost_ed25519 = 4 [ - (gogoproto.customname) = "SigVerifyCostED25519", - (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\"" - ]; - uint64 sig_verify_cost_secp256k1 = 5 [ - (gogoproto.customname) = "SigVerifyCostSecp256k1", - (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\"" - ]; + uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""]; + uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""]; + uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""]; + uint64 sig_verify_cost_ed25519 = 4 + [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; + uint64 sig_verify_cost_secp256k1 = 5 + [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; } diff --git a/third_party/proto/cosmos/auth/v1beta1/genesis.proto b/third_party/proto/cosmos/auth/v1beta1/genesis.proto index 61ad48c4..c88b94ee 100644 --- a/third_party/proto/cosmos/auth/v1beta1/genesis.proto +++ b/third_party/proto/cosmos/auth/v1beta1/genesis.proto @@ -10,7 +10,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types"; // GenesisState defines the auth module's genesis state. message GenesisState { // params defines all the paramaters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + Params params = 1 [(gogoproto.nullable) = false]; // accounts are the accounts present at genesis. repeated google.protobuf.Any accounts = 2; diff --git a/third_party/proto/cosmos/auth/v1beta1/query.proto b/third_party/proto/cosmos/auth/v1beta1/query.proto index 6afc35ee..a8857926 100644 --- a/third_party/proto/cosmos/auth/v1beta1/query.proto +++ b/third_party/proto/cosmos/auth/v1beta1/query.proto @@ -24,7 +24,7 @@ service Query { // QueryAccountRequest is the request type for the Query/Account RPC method. message QueryAccountRequest { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address defines the address to query for. @@ -34,8 +34,7 @@ message QueryAccountRequest { // QueryAccountResponse is the response type for the Query/Account RPC method. message QueryAccountResponse { // account defines the account of the corresponding address. - google.protobuf.Any account = 1 - [ (cosmos_proto.accepts_interface) = "AccountI" ]; + google.protobuf.Any account = 1 [(cosmos_proto.accepts_interface) = "AccountI"]; } // QueryParamsRequest is the request type for the Query/Params RPC method. @@ -44,5 +43,5 @@ message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. message QueryParamsResponse { // params defines the parameters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + Params params = 1 [(gogoproto.nullable) = false]; } diff --git a/third_party/proto/cosmos/authz/v1beta1/authz.proto b/third_party/proto/cosmos/authz/v1beta1/authz.proto new file mode 100644 index 00000000..56c403a7 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/authz.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types"; + +// SendAuthorization allows the grantee to spend up to spend_limit coins from +// the granter's account. +message SendAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; + + repeated cosmos.base.v1beta1.Coin spend_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// GenericAuthorization gives the grantee unrestricted permissions to execute +// the provided method on behalf of the granter's account. +message GenericAuthorization { + option (cosmos_proto.implements_interface) = "Authorization"; + + // method name to grant unrestricted permissions to execute + // Note: MethodName() is already a method on `GenericAuthorization` type, + // we need some custom naming here so using `MessageName` + string method_name = 1 [(gogoproto.customname) = "MessageName"]; +} + +// AuthorizationGrant gives permissions to execute +// the provide method with expiration time. +message AuthorizationGrant { + google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/genesis.proto b/third_party/proto/cosmos/authz/v1beta1/genesis.proto new file mode 100644 index 00000000..940d42e1 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/genesis.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/authz/v1beta1/tx.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types"; + +// GenesisState defines the authz module's genesis state. +message GenesisState { + repeated GrantAuthorization authorization = 1 [(gogoproto.nullable) = false]; +} + +// GrantAuthorization defines the GenesisState/GrantAuthorization type. +message GrantAuthorization { + string granter = 1; + string grantee = 2; + + google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/query.proto b/third_party/proto/cosmos/authz/v1beta1/query.proto new file mode 100644 index 00000000..7a733258 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/query.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/authz/v1beta1/authz.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types"; + +// Query defines the gRPC querier service. +service Query { + // Returns any `Authorization` (or `nil`), with the expiration time, granted to the grantee by the granter for the + // provided msg type. + rpc Authorization(QueryAuthorizationRequest) returns (QueryAuthorizationResponse) { + option (google.api.http).get = "/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grant"; + } + + // Returns list of `Authorization`, granted to the grantee by the granter. + rpc Authorizations(QueryAuthorizationsRequest) returns (QueryAuthorizationsResponse) { + option (google.api.http).get = "/cosmos/authz/v1beta1/granters/{granter}/grantees/{grantee}/grants"; + } +} + +// QueryAuthorizationRequest is the request type for the Query/Authorization RPC method. +message QueryAuthorizationRequest { + string granter = 1; + string grantee = 2; + string method_name = 3; +} + +// QueryAuthorizationResponse is the response type for the Query/Authorization RPC method. +message QueryAuthorizationResponse { + // authorization is a authorization granted for grantee by granter. + cosmos.authz.v1beta1.AuthorizationGrant authorization = 1; +} + +// QueryAuthorizationsRequest is the request type for the Query/Authorizations RPC method. +message QueryAuthorizationsRequest { + string granter = 1; + string grantee = 2; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +// QueryAuthorizationsResponse is the response type for the Query/Authorizations RPC method. +message QueryAuthorizationsResponse { + // authorizations is a list of grants granted for grantee by granter. + repeated cosmos.authz.v1beta1.AuthorizationGrant authorizations = 1; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/authz/v1beta1/tx.proto b/third_party/proto/cosmos/authz/v1beta1/tx.proto new file mode 100644 index 00000000..69e3e6f1 --- /dev/null +++ b/third_party/proto/cosmos/authz/v1beta1/tx.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; +package cosmos.authz.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; +option go_package = "github.com/cosmos/cosmos-sdk/x/authz/types"; + +// Msg defines the authz Msg service. +service Msg { + // GrantAuthorization grants the provided authorization to the grantee on the granter's + // account with the provided expiration time. + rpc GrantAuthorization(MsgGrantAuthorizationRequest) returns (MsgGrantAuthorizationResponse); + + // ExecAuthorized attempts to execute the provided messages using + // authorizations granted to the grantee. Each message should have only + // one signer corresponding to the granter of the authorization. + rpc ExecAuthorized(MsgExecAuthorizedRequest) returns (MsgExecAuthorizedResponse); + + // RevokeAuthorization revokes any authorization corresponding to the provided method name on the + // granter's account that has been granted to the grantee. + rpc RevokeAuthorization(MsgRevokeAuthorizationRequest) returns (MsgRevokeAuthorizationResponse); +} + +// MsgGrantAuthorizationRequest grants the provided authorization to the grantee on the granter's +// account with the provided expiration time. +message MsgGrantAuthorizationRequest { + string granter = 1; + string grantee = 2; + + google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} + +// MsgExecAuthorizedResponse defines the Msg/MsgExecAuthorizedResponse response type. +message MsgExecAuthorizedResponse { + cosmos.base.abci.v1beta1.Result result = 1; +} + +// MsgExecAuthorizedRequest attempts to execute the provided messages using +// authorizations granted to the grantee. Each message should have only +// one signer corresponding to the granter of the authorization. +message MsgExecAuthorizedRequest { + string grantee = 1; + repeated google.protobuf.Any msgs = 2; +} + +// MsgGrantAuthorizationResponse defines the Msg/MsgGrantAuthorization response type. +message MsgGrantAuthorizationResponse {} + +// MsgRevokeAuthorizationRequest revokes any authorization with the provided sdk.Msg type on the +// granter's account with that has been granted to the grantee. +message MsgRevokeAuthorizationRequest { + string granter = 1; + string grantee = 2; + string method_name = 3; +} + +// MsgRevokeAuthorizationResponse defines the Msg/MsgRevokeAuthorizationResponse response type. +message MsgRevokeAuthorizationResponse {} diff --git a/third_party/proto/cosmos/bank/v1beta1/bank.proto b/third_party/proto/cosmos/bank/v1beta1/bank.proto index 2298b51b..5a938336 100644 --- a/third_party/proto/cosmos/bank/v1beta1/bank.proto +++ b/third_party/proto/cosmos/bank/v1beta1/bank.proto @@ -9,60 +9,51 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; // Params defines the parameters for the bank module. message Params { - option (gogoproto.goproto_stringer) = false; - repeated SendEnabled send_enabled = 1 - [ (gogoproto.moretags) = "yaml:\"send_enabled,omitempty\"" ]; - bool default_send_enabled = 2 - [ (gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\"" ]; + option (gogoproto.goproto_stringer) = false; + repeated SendEnabled send_enabled = 1 [(gogoproto.moretags) = "yaml:\"send_enabled,omitempty\""]; + bool default_send_enabled = 2 [(gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\""]; } // SendEnabled maps coin denom to a send_enabled status (whether a denom is // sendable). message SendEnabled { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; - string denom = 1; - bool enabled = 2; + string denom = 1; + bool enabled = 2; } // Input models transaction input. message Input { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string address = 1; - repeated cosmos.base.v1beta1.Coin coins = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + string address = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } // Output models transaction outputs. message Output { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string address = 1; - repeated cosmos.base.v1beta1.Coin coins = 2 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + string address = 1; + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } // Supply represents a struct that passively keeps track of the total supply // amounts in the network. message Supply { - option (gogoproto.equal) = true; - option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = true; + option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - option (cosmos_proto.implements_interface) = - "*github.com/cosmos/cosmos-sdk/x/bank/exported.SupplyI"; + option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/exported.SupplyI"; - repeated cosmos.base.v1beta1.Coin total = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + repeated cosmos.base.v1beta1.Coin total = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } // DenomUnit represents a struct that describes a given diff --git a/third_party/proto/cosmos/bank/v1beta1/genesis.proto b/third_party/proto/cosmos/bank/v1beta1/genesis.proto index 4e190ad3..25c80a38 100644 --- a/third_party/proto/cosmos/bank/v1beta1/genesis.proto +++ b/third_party/proto/cosmos/bank/v1beta1/genesis.proto @@ -10,36 +10,29 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; // GenesisState defines the bank module's genesis state. message GenesisState { // params defines all the paramaters of the module. - Params params = 1 [ (gogoproto.nullable) = false ]; + Params params = 1 [(gogoproto.nullable) = false]; // balances is an array containing the balances of all the accounts. - repeated Balance balances = 2 [ (gogoproto.nullable) = false ]; + repeated Balance balances = 2 [(gogoproto.nullable) = false]; // supply represents the total supply. - repeated cosmos.base.v1beta1.Coin supply = 3 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false - ]; + repeated cosmos.base.v1beta1.Coin supply = 3 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false]; // denom_metadata defines the metadata of the differents coins. - repeated Metadata denom_metadata = 4 [ - (gogoproto.moretags) = "yaml:\"denom_metadata\"", - (gogoproto.nullable) = false - ]; + repeated Metadata denom_metadata = 4 [(gogoproto.moretags) = "yaml:\"denom_metadata\"", (gogoproto.nullable) = false]; } // Balance defines an account address and balance pair used in the bank module's // genesis state. message Balance { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address is the address of the balance holder. string address = 1; // coins defines the different coins this balance holds. - repeated cosmos.base.v1beta1.Coin coins = 2 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.nullable) = false - ]; + repeated cosmos.base.v1beta1.Coin coins = 2 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.nullable) = false]; } diff --git a/third_party/proto/cosmos/bank/v1beta1/query.proto b/third_party/proto/cosmos/bank/v1beta1/query.proto index 7a97384b..bc5e2913 100644 --- a/third_party/proto/cosmos/bank/v1beta1/query.proto +++ b/third_party/proto/cosmos/bank/v1beta1/query.proto @@ -13,8 +13,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; service Query { // Balance queries the balance of a single coin for a single account. rpc Balance(QueryBalanceRequest) returns (QueryBalanceResponse) { - option (google.api.http).get = - "/cosmos/bank/v1beta1/balances/{address}/{denom}"; + option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}/{denom}"; } // AllBalances queries the balance of all coins for a single account. @@ -36,11 +35,21 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/params"; } + + // DenomsMetadata queries the client metadata of a given coin denomination. + rpc DenomMetadata(QueryDenomMetadataRequest) returns (QueryDenomMetadataResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata/{denom}"; + } + + // DenomsMetadata queries the client metadata for all registered coin denominations. + rpc DenomsMetadata(QueryDenomsMetadataRequest) returns (QueryDenomsMetadataResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/denoms_metadata"; + } } // QueryBalanceRequest is the request type for the Query/Balance RPC method. message QueryBalanceRequest { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address is the address to query balances for. @@ -58,7 +67,7 @@ message QueryBalanceResponse { // QueryBalanceRequest is the request type for the Query/AllBalances RPC method. message QueryAllBalancesRequest { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; // address is the address to query balances for. @@ -72,10 +81,8 @@ message QueryAllBalancesRequest { // method. message QueryAllBalancesResponse { // balances is the balances of all the coins. - repeated cosmos.base.v1beta1.Coin balances = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + repeated cosmos.base.v1beta1.Coin balances = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; // pagination defines the pagination in the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; @@ -89,10 +96,8 @@ message QueryTotalSupplyRequest {} // method message QueryTotalSupplyResponse { // supply is the supply of the coins - repeated cosmos.base.v1beta1.Coin supply = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + repeated cosmos.base.v1beta1.Coin supply = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } // QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. @@ -104,7 +109,7 @@ message QuerySupplyOfRequest { // QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. message QuerySupplyOfResponse { // amount is the supply of the coin. - cosmos.base.v1beta1.Coin amount = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.v1beta1.Coin amount = 1 [(gogoproto.nullable) = false]; } // QueryParamsRequest defines the request type for querying x/bank parameters. @@ -112,5 +117,34 @@ message QueryParamsRequest {} // QueryParamsResponse defines the response type for querying x/bank parameters. message QueryParamsResponse { - Params params = 1 [ (gogoproto.nullable) = false ]; + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. +message QueryDenomsMetadataRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC +// method. +message QueryDenomsMetadataResponse { + // metadata provides the client information for all the registered tokens. + repeated Metadata metadatas = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. +message QueryDenomMetadataRequest { + // denom is the coin denom to query the metadata for. + string denom = 1; +} + +// QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC +// method. +message QueryDenomMetadataResponse { + // metadata describes and provides all the client information for the requested token. + Metadata metadata = 1 [(gogoproto.nullable) = false]; } diff --git a/third_party/proto/cosmos/bank/v1beta1/tx.proto b/third_party/proto/cosmos/bank/v1beta1/tx.proto index 0edd462e..26b2ab41 100644 --- a/third_party/proto/cosmos/bank/v1beta1/tx.proto +++ b/third_party/proto/cosmos/bank/v1beta1/tx.proto @@ -7,23 +7,36 @@ import "cosmos/bank/v1beta1/bank.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types"; +// Msg defines the bank Msg service. +service Msg { + // Send defines a method for sending coins from one account to another account. + rpc Send(MsgSend) returns (MsgSendResponse); + + // MultiSend defines a method for sending coins from some accounts to other accounts. + rpc MultiSend(MsgMultiSend) returns (MsgMultiSendResponse); +} + // MsgSend represents a message to send coins from one account to another. message MsgSend { - option (gogoproto.equal) = false; + option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string from_address = 1 [ (gogoproto.moretags) = "yaml:\"from_address\"" ]; - string to_address = 2 [ (gogoproto.moretags) = "yaml:\"to_address\"" ]; - repeated cosmos.base.v1beta1.Coin amount = 3 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; } +// MsgSendResponse defines the Msg/Send response type. +message MsgSendResponse {} + // MsgMultiSend represents an arbitrary multi-in, multi-out send message. message MsgMultiSend { option (gogoproto.equal) = false; - repeated Input inputs = 1 [ (gogoproto.nullable) = false ]; - repeated Output outputs = 2 [ (gogoproto.nullable) = false ]; + repeated Input inputs = 1 [(gogoproto.nullable) = false]; + repeated Output outputs = 2 [(gogoproto.nullable) = false]; } + +// MsgMultiSendResponse defines the Msg/MultiSend response type. +message MsgMultiSendResponse {} diff --git a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto index 08be9135..72da2aac 100644 --- a/third_party/proto/cosmos/base/abci/v1beta1/abci.proto +++ b/third_party/proto/cosmos/base/abci/v1beta1/abci.proto @@ -5,7 +5,7 @@ import "gogoproto/gogo.proto"; import "tendermint/abci/types.proto"; import "google/protobuf/any.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/types"; +option go_package = "github.com/cosmos/cosmos-sdk/types"; option (gogoproto.goproto_stringer_all) = false; // TxResponse defines a structure containing relevant tx data and metadata. The @@ -15,7 +15,7 @@ message TxResponse { // The block height int64 height = 1; // The transaction hash. - string txhash = 2 [ (gogoproto.customname) = "TxHash" ]; + string txhash = 2 [(gogoproto.customname) = "TxHash"]; // Namespace for the Code string codespace = 3; // Response code. @@ -26,10 +26,7 @@ message TxResponse { // non-deterministic. string raw_log = 6; // The output of the application's logger (typed). May be non-deterministic. - repeated ABCIMessageLog logs = 7 [ - (gogoproto.castrepeated) = "ABCIMessageLogs", - (gogoproto.nullable) = false - ]; + repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false]; // Additional information. May be non-deterministic. string info = 8; // Amount of gas requested for transaction. @@ -49,14 +46,11 @@ message ABCIMessageLog { option (gogoproto.stringer) = true; uint32 msg_index = 1; - string log = 2; + string log = 2; // Events contains a slice of Event objects that were emitted during some // execution. - repeated StringEvent events = 3 [ - (gogoproto.castrepeated) = "StringEvents", - (gogoproto.nullable) = false - ]; + repeated StringEvent events = 3 [(gogoproto.castrepeated) = "StringEvents", (gogoproto.nullable) = false]; } // StringEvent defines en Event object wrapper where all the attributes @@ -64,24 +58,24 @@ message ABCIMessageLog { message StringEvent { option (gogoproto.stringer) = true; - string type = 1; - repeated Attribute attributes = 2 [ (gogoproto.nullable) = false ]; + string type = 1; + repeated Attribute attributes = 2 [(gogoproto.nullable) = false]; } // Attribute defines an attribute wrapper where the key and value are // strings instead of raw bytes. message Attribute { - string key = 1; + string key = 1; string value = 2; } // GasInfo defines tx execution gas context. message GasInfo { // GasWanted is the maximum units of work we allow this tx to perform. - uint64 gas_wanted = 1 [ (gogoproto.moretags) = "yaml:\"gas_wanted\"" ]; + uint64 gas_wanted = 1 [(gogoproto.moretags) = "yaml:\"gas_wanted\""]; // GasUsed is the amount of gas actually consumed. - uint64 gas_used = 2 [ (gogoproto.moretags) = "yaml:\"gas_used\"" ]; + uint64 gas_used = 2 [(gogoproto.moretags) = "yaml:\"gas_used\""]; } // Result is the union of ResponseFormat and ResponseCheckTx. @@ -97,15 +91,14 @@ message Result { // Events contains a slice of Event objects that were emitted during message // or handler execution. - repeated tendermint.abci.Event events = 3 [ (gogoproto.nullable) = false ]; + repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false]; } // SimulationResponse defines the response generated when a transaction is // successfully simulated. message SimulationResponse { - GasInfo gas_info = 1 - [ (gogoproto.embed) = true, (gogoproto.nullable) = false ]; - Result result = 2; + GasInfo gas_info = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + Result result = 2; } // MsgData defines the data returned in a Result object during message @@ -114,7 +107,7 @@ message MsgData { option (gogoproto.stringer) = true; string msg_type = 1; - bytes data = 2; + bytes data = 2; } // TxMsgData defines a list of MsgData. A transaction will have a MsgData object @@ -130,22 +123,13 @@ message SearchTxsResult { option (gogoproto.stringer) = true; // Count of all txs - uint64 total_count = 1 [ - (gogoproto.moretags) = "yaml:\"total_count\"", - (gogoproto.jsontag) = "total_count" - ]; + uint64 total_count = 1 [(gogoproto.moretags) = "yaml:\"total_count\"", (gogoproto.jsontag) = "total_count"]; // Count of txs in current page uint64 count = 2; // Index of current page, start from 1 - uint64 page_number = 3 [ - (gogoproto.moretags) = "yaml:\"page_number\"", - (gogoproto.jsontag) = "page_number" - ]; + uint64 page_number = 3 [(gogoproto.moretags) = "yaml:\"page_number\"", (gogoproto.jsontag) = "page_number"]; // Count of total pages - uint64 page_total = 4 [ - (gogoproto.moretags) = "yaml:\"page_total\"", - (gogoproto.jsontag) = "page_total" - ]; + uint64 page_total = 4 [(gogoproto.moretags) = "yaml:\"page_total\"", (gogoproto.jsontag) = "page_total"]; // Max count txs per page uint64 limit = 5; // List of txs in current page diff --git a/third_party/proto/cosmos/base/kv/v1beta1/kv.proto b/third_party/proto/cosmos/base/kv/v1beta1/kv.proto index cdbb73af..4e9b8d28 100644 --- a/third_party/proto/cosmos/base/kv/v1beta1/kv.proto +++ b/third_party/proto/cosmos/base/kv/v1beta1/kv.proto @@ -6,10 +6,12 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/cosmos/cosmos-sdk/types/kv"; // Pairs defines a repeated slice of Pair objects. -message Pairs { repeated Pair pairs = 1 [ (gogoproto.nullable) = false ]; } +message Pairs { + repeated Pair pairs = 1 [(gogoproto.nullable) = false]; +} // Pair defines a key/value bytes tuple. message Pair { - bytes key = 1; + bytes key = 1; bytes value = 2; } diff --git a/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto b/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto index 0752cee1..22670e72 100644 --- a/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto +++ b/third_party/proto/cosmos/base/reflection/v1beta1/reflection.proto @@ -9,15 +9,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/reflection"; service ReflectionService { // ListAllInterfaces lists all the interfaces registered in the interface // registry. - rpc ListAllInterfaces(ListAllInterfacesRequest) - returns (ListAllInterfacesResponse) { + rpc ListAllInterfaces(ListAllInterfacesRequest) returns (ListAllInterfacesResponse) { option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces"; }; // ListImplementations list all the concrete types that implement a given // interface. - rpc ListImplementations(ListImplementationsRequest) - returns (ListImplementationsResponse) { + rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) { option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/" "{interface_name}/implementations"; }; diff --git a/third_party/proto/cosmos/base/simulate/v1beta1/simulate.proto b/third_party/proto/cosmos/base/simulate/v1beta1/simulate.proto deleted file mode 100644 index e7e678d9..00000000 --- a/third_party/proto/cosmos/base/simulate/v1beta1/simulate.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; -package cosmos.base.simulate.v1beta1; - -import "google/api/annotations.proto"; -import "cosmos/base/abci/v1beta1/abci.proto"; -import "cosmos/tx/v1beta1/tx.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/simulate"; - -// SimulateService defines a gRPC service for simulating transactions. -// It may also support querying and broadcasting in the future. -service SimulateService { - // Simulate simulates executing a transaction for estimating gas usage. - rpc Simulate(SimulateRequest) returns (SimulateResponse) { - option (google.api.http).post = "/cosmos/base/simulate/v1beta1/simulate"; - } -} - -// SimulateRequest is the request type for the SimulateServiceService.Simulate -// RPC method. -message SimulateRequest { - // tx is the transaction to simulate. - cosmos.tx.v1beta1.Tx tx = 1; -} - -// SimulateResponse is the response type for the -// SimulateServiceService.SimulateRPC method. -message SimulateResponse { - // gas_info is the information about gas used in the simulation. - cosmos.base.abci.v1beta1.GasInfo gas_info = 1; - // result is the result of the simulation. - cosmos.base.abci.v1beta1.Result result = 2; -} diff --git a/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto index 38831b76..9ac5a7c3 100644 --- a/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto +++ b/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto @@ -7,11 +7,11 @@ option go_package = "github.com/cosmos/cosmos-sdk/snapshots/types"; // Snapshot contains Tendermint state sync snapshot info. message Snapshot { - uint64 height = 1; - uint32 format = 2; - uint32 chunks = 3; - bytes hash = 4; - Metadata metadata = 5 [ (gogoproto.nullable) = false ]; + uint64 height = 1; + uint32 format = 2; + uint32 chunks = 3; + bytes hash = 4; + Metadata metadata = 5 [(gogoproto.nullable) = false]; } // Metadata contains SDK-specific snapshot metadata. diff --git a/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto b/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto index 66caddd0..98a33d30 100644 --- a/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto +++ b/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto @@ -8,15 +8,15 @@ option go_package = "github.com/cosmos/cosmos-sdk/store/types"; // CommitInfo defines commit information used by the multi-store when committing // a version/height. message CommitInfo { - int64 version = 1; - repeated StoreInfo store_infos = 2 [ (gogoproto.nullable) = false ]; + int64 version = 1; + repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false]; } // StoreInfo defines store-specific commit information. It contains a reference // between a store name and the commit ID. message StoreInfo { - string name = 1; - CommitID commit_id = 2 [ (gogoproto.nullable) = false ]; + string name = 1; + CommitID commit_id = 2 [(gogoproto.nullable) = false]; } // CommitID defines the committment information when a specific store is @@ -25,5 +25,5 @@ message CommitID { option (gogoproto.goproto_stringer) = false; int64 version = 1; - bytes hash = 2; + bytes hash = 2; } diff --git a/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto b/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto index 8299dd4b..83485509 100644 --- a/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto +++ b/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto @@ -10,17 +10,19 @@ message SnapshotItem { // item is the specific type of snapshot item. oneof item { SnapshotStoreItem store = 1; - SnapshotIAVLItem iavl = 2 [ (gogoproto.customname) = "IAVL" ]; + SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; } } // SnapshotStoreItem contains metadata about a snapshotted store. -message SnapshotStoreItem { string name = 1; } +message SnapshotStoreItem { + string name = 1; +} // SnapshotIAVLItem is an exported IAVL node. message SnapshotIAVLItem { - bytes key = 1; - bytes value = 2; + bytes key = 1; + bytes value = 2; int64 version = 3; - int32 height = 4; + int32 height = 4; } \ No newline at end of file diff --git a/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto new file mode 100644 index 00000000..4db85186 --- /dev/null +++ b/third_party/proto/cosmos/base/tendermint/v1beta1/query.proto @@ -0,0 +1,135 @@ +syntax = "proto3"; +package cosmos.base.tendermint.v1beta1; + +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "tendermint/p2p/types.proto"; +import "tendermint/types/block.proto"; +import "tendermint/types/types.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/client/grpc/tmservice"; + +// Service defines the gRPC querier service for tendermint queries. +service Service { + // GetNodeInfo queries the current node info. + rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/node_info"; + } + // GetSyncing queries node syncing. + rpc GetSyncing(GetSyncingRequest) returns (GetSyncingResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/syncing"; + } + // GetLatestBlock returns the latest block. + rpc GetLatestBlock(GetLatestBlockRequest) returns (GetLatestBlockResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/latest"; + } + // GetBlockByHeight queries block for given height. + rpc GetBlockByHeight(GetBlockByHeightRequest) returns (GetBlockByHeightResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/{height}"; + } + + // GetLatestValidatorSet queries latest validator-set. + rpc GetLatestValidatorSet(GetLatestValidatorSetRequest) returns (GetLatestValidatorSetResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/latest"; + } + // GetValidatorSetByHeight queries validator-set at a given height. + rpc GetValidatorSetByHeight(GetValidatorSetByHeightRequest) returns (GetValidatorSetByHeightResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/{height}"; + } +} + +// GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +message GetValidatorSetByHeightRequest { + int64 height = 1; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +message GetValidatorSetByHeightResponse { + int64 block_height = 1; + repeated Validator validators = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. +message GetLatestValidatorSetRequest { + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. +message GetLatestValidatorSetResponse { + int64 block_height = 1; + repeated Validator validators = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// Validator is the type for the validator-set. +message Validator { + string address = 1; + google.protobuf.Any pub_key = 2; + int64 voting_power = 3; + int64 proposer_priority = 4; +} + +// GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. +message GetBlockByHeightRequest { + int64 height = 1; +} + +// GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. +message GetBlockByHeightResponse { + .tendermint.types.BlockID block_id = 1; + .tendermint.types.Block block = 2; +} + +// GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. +message GetLatestBlockRequest {} + +// GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. +message GetLatestBlockResponse { + .tendermint.types.BlockID block_id = 1; + .tendermint.types.Block block = 2; +} + +// GetSyncingRequest is the request type for the Query/GetSyncing RPC method. +message GetSyncingRequest {} + +// GetSyncingResponse is the response type for the Query/GetSyncing RPC method. +message GetSyncingResponse { + bool syncing = 1; +} + +// GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. +message GetNodeInfoRequest {} + +// GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. +message GetNodeInfoResponse { + .tendermint.p2p.DefaultNodeInfo default_node_info = 1; + VersionInfo application_version = 2; +} + +// VersionInfo is the type for the GetNodeInfoResponse message. +message VersionInfo { + string name = 1; + string app_name = 2; + string version = 3; + string git_commit = 4; + string build_tags = 5; + string go_version = 6; + repeated Module build_deps = 7; +} + +// Module is the type for VersionInfo +message Module { + // module path + string path = 1; + // module version + string version = 2; + // checksum + string sum = 3; +} diff --git a/third_party/proto/cosmos/base/v1beta1/coin.proto b/third_party/proto/cosmos/base/v1beta1/coin.proto index fbd3ad06..fab75284 100644 --- a/third_party/proto/cosmos/base/v1beta1/coin.proto +++ b/third_party/proto/cosmos/base/v1beta1/coin.proto @@ -3,9 +3,9 @@ package cosmos.base.v1beta1; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/cosmos-sdk/types"; +option go_package = "github.com/cosmos/cosmos-sdk/types"; option (gogoproto.goproto_stringer_all) = false; -option (gogoproto.stringer_all) = false; +option (gogoproto.stringer_all) = false; // Coin defines a token with a denomination and an amount. // @@ -14,9 +14,8 @@ option (gogoproto.stringer_all) = false; message Coin { option (gogoproto.equal) = true; - string denom = 1; - string amount = 2 - [ (gogoproto.customtype) = "Int", (gogoproto.nullable) = false ]; + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; } // DecCoin defines a token with a denomination and a decimal amount. @@ -26,19 +25,16 @@ message Coin { message DecCoin { option (gogoproto.equal) = true; - string denom = 1; - string amount = 2 - [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; + string denom = 1; + string amount = 2 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; } // IntProto defines a Protobuf wrapper around an Int object. message IntProto { - string int = 1 - [ (gogoproto.customtype) = "Int", (gogoproto.nullable) = false ]; + string int = 1 [(gogoproto.customtype) = "Int", (gogoproto.nullable) = false]; } // DecProto defines a Protobuf wrapper around a Dec object. message DecProto { - string dec = 1 - [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; + string dec = 1 [(gogoproto.customtype) = "Dec", (gogoproto.nullable) = false]; } diff --git a/third_party/proto/cosmos/capability/v1beta1/capability.proto b/third_party/proto/cosmos/capability/v1beta1/capability.proto new file mode 100644 index 00000000..1c8332f3 --- /dev/null +++ b/third_party/proto/cosmos/capability/v1beta1/capability.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package cosmos.capability.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; + +import "gogoproto/gogo.proto"; + +// Capability defines an implementation of an object capability. The index +// provided to a Capability must be globally unique. +message Capability { + option (gogoproto.goproto_stringer) = false; + + uint64 index = 1 [(gogoproto.moretags) = "yaml:\"index\""]; +} + +// Owner defines a single capability owner. An owner is defined by the name of +// capability and the module name. +message Owner { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + string module = 1 [(gogoproto.moretags) = "yaml:\"module\""]; + string name = 2 [(gogoproto.moretags) = "yaml:\"name\""]; +} + +// CapabilityOwners defines a set of owners of a single Capability. The set of +// owners must be unique. +message CapabilityOwners { + repeated Owner owners = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/capability/v1beta1/genesis.proto b/third_party/proto/cosmos/capability/v1beta1/genesis.proto new file mode 100644 index 00000000..05bb0afc --- /dev/null +++ b/third_party/proto/cosmos/capability/v1beta1/genesis.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package cosmos.capability.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/capability/v1beta1/capability.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types"; + +// GenesisOwners defines the capability owners with their corresponding index. +message GenesisOwners { + // index is the index of the capability owner. + uint64 index = 1; + + // index_owners are the owners at the given index. + CapabilityOwners index_owners = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"index_owners\""]; +} + +// GenesisState defines the capability module's genesis state. +message GenesisState { + // index is the capability global index. + uint64 index = 1; + + // owners represents a map from index to owners of the capability index + // index key is string to allow amino marshalling. + repeated GenesisOwners owners = 2 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/crisis/v1beta1/genesis.proto b/third_party/proto/cosmos/crisis/v1beta1/genesis.proto new file mode 100644 index 00000000..5b0ff7ec --- /dev/null +++ b/third_party/proto/cosmos/crisis/v1beta1/genesis.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package cosmos.crisis.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// GenesisState defines the crisis module's genesis state. +message GenesisState { + // constant_fee is the fee used to verify the invariant in the crisis + // module. + cosmos.base.v1beta1.Coin constant_fee = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constant_fee\""]; +} diff --git a/third_party/proto/cosmos/crisis/v1beta1/tx.proto b/third_party/proto/cosmos/crisis/v1beta1/tx.proto new file mode 100644 index 00000000..26457ad6 --- /dev/null +++ b/third_party/proto/cosmos/crisis/v1beta1/tx.proto @@ -0,0 +1,25 @@ +syntax = "proto3"; +package cosmos.crisis.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types"; + +import "gogoproto/gogo.proto"; + +// Msg defines the bank Msg service. +service Msg { + // VerifyInvariant defines a method to verify a particular invariance. + rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse); +} + +// MsgVerifyInvariant represents a message to verify a particular invariance. +message MsgVerifyInvariant { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string sender = 1; + string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""]; + string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""]; +} + +// MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. +message MsgVerifyInvariantResponse {} diff --git a/third_party/proto/cosmos/crypto/ed25519/keys.proto b/third_party/proto/cosmos/crypto/ed25519/keys.proto index 344ae8e1..bed9c29c 100644 --- a/third_party/proto/cosmos/crypto/ed25519/keys.proto +++ b/third_party/proto/cosmos/crypto/ed25519/keys.proto @@ -6,15 +6,17 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"; // PubKey defines a ed25519 public key -// Key is the compressed form of the pubkey. The first byte depends is a 0x02 -// byte if the y-coordinate is the lexicographically largest of the two -// associated with the x-coordinate. Otherwise the first byte is a 0x03. This -// prefix is followed with the x-coordinate. +// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. message PubKey { option (gogoproto.goproto_stringer) = false; - bytes key = 1; + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"]; } // PrivKey defines a ed25519 private key. -message PrivKey { bytes key = 1; } +message PrivKey { + bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"]; +} diff --git a/third_party/proto/cosmos/crypto/multisig/keys.proto b/third_party/proto/cosmos/crypto/multisig/keys.proto index 2ceb4db8..f8398e80 100644 --- a/third_party/proto/cosmos/crypto/multisig/keys.proto +++ b/third_party/proto/cosmos/crypto/multisig/keys.proto @@ -12,9 +12,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"; message LegacyAminoPubKey { option (gogoproto.goproto_getters) = false; - uint32 threshold = 1 [ (gogoproto.moretags) = "yaml:\"threshold\"" ]; - repeated google.protobuf.Any public_keys = 2 [ - (gogoproto.customname) = "PubKeys", - (gogoproto.moretags) = "yaml:\"pubkeys\"" - ]; + uint32 threshold = 1 [(gogoproto.moretags) = "yaml:\"threshold\""]; + repeated google.protobuf.Any public_keys = 2 + [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""]; } diff --git a/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto b/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto index db774855..bf671f17 100644 --- a/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto +++ b/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto @@ -10,7 +10,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/crypto/types"; // signed and with which modes. message MultiSignature { option (gogoproto.goproto_unrecognized) = true; - repeated bytes signatures = 1; + repeated bytes signatures = 1; } // CompactBitArray is an implementation of a space efficient bit array. @@ -21,5 +21,5 @@ message CompactBitArray { option (gogoproto.goproto_stringer) = false; uint32 extra_bits_stored = 1; - bytes elems = 2; + bytes elems = 2; } diff --git a/third_party/proto/cosmos/crypto/secp256k1/keys.proto b/third_party/proto/cosmos/crypto/secp256k1/keys.proto index 1c07f93d..a2272571 100644 --- a/third_party/proto/cosmos/crypto/secp256k1/keys.proto +++ b/third_party/proto/cosmos/crypto/secp256k1/keys.proto @@ -6,10 +6,10 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"; // PubKey defines a secp256k1 public key -// Key is the compressed form of the pubkey. The first byte depends is a 0x02 -// byte if the y-coordinate is the lexicographically largest of the two -// associated with the x-coordinate. Otherwise the first byte is a 0x03. This -// prefix is followed with the x-coordinate. +// Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte +// if the y-coordinate is the lexicographically largest of the two associated with +// the x-coordinate. Otherwise the first byte is a 0x03. +// This prefix is followed with the x-coordinate. message PubKey { option (gogoproto.goproto_stringer) = false; @@ -17,4 +17,6 @@ message PubKey { } // PrivKey defines a secp256k1 private key. -message PrivKey { bytes key = 1; } +message PrivKey { + bytes key = 1; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/distribution.proto b/third_party/proto/cosmos/distribution/v1beta1/distribution.proto new file mode 100644 index 00000000..ae98ec0b --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/distribution.proto @@ -0,0 +1,157 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Params defines the set of params for the distribution module. +message Params { + option (gogoproto.goproto_stringer) = false; + string community_tax = 1 [ + (gogoproto.moretags) = "yaml:\"community_tax\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string base_proposer_reward = 2 [ + (gogoproto.moretags) = "yaml:\"base_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string bonus_proposer_reward = 3 [ + (gogoproto.moretags) = "yaml:\"bonus_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bool withdraw_addr_enabled = 4 [(gogoproto.moretags) = "yaml:\"withdraw_addr_enabled\""]; +} + +// ValidatorHistoricalRewards represents historical rewards for a validator. +// Height is implicit within the store key. +// Cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec. +// The reference count indicates the number of objects +// which might need to reference this historical entry at any point. +// ReferenceCount = +// number of outstanding delegations which ended the associated period (and +// might need to read that record) +// + number of slashes which ended the associated period (and might need to +// read that record) +// + one per validator for the zeroeth period, set on initialization +message ValidatorHistoricalRewards { + repeated cosmos.base.v1beta1.DecCoin cumulative_reward_ratio = 1 [ + (gogoproto.moretags) = "yaml:\"cumulative_reward_ratio\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + uint32 reference_count = 2 [(gogoproto.moretags) = "yaml:\"reference_count\""]; +} + +// ValidatorCurrentRewards represents current rewards and current +// period for a validator kept as a running counter and incremented +// each block as long as the validator's tokens remain constant. +message ValidatorCurrentRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; + uint64 period = 2; +} + +// ValidatorAccumulatedCommission represents accumulated commission +// for a validator kept as a running counter, can be withdrawn at any time. +message ValidatorAccumulatedCommission { + repeated cosmos.base.v1beta1.DecCoin commission = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +// ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +// for a validator inexpensive to track, allows simple sanity checks. +message ValidatorOutstandingRewards { + repeated cosmos.base.v1beta1.DecCoin rewards = 1 [ + (gogoproto.moretags) = "yaml:\"rewards\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// ValidatorSlashEvent represents a validator slash event. +// Height is implicit within the store key. +// This is needed to calculate appropriate amount of staking tokens +// for delegations which are withdrawn after a slash has occurred. +message ValidatorSlashEvent { + uint64 validator_period = 1 [(gogoproto.moretags) = "yaml:\"validator_period\""]; + string fraction = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. +message ValidatorSlashEvents { + option (gogoproto.goproto_stringer) = false; + repeated ValidatorSlashEvent validator_slash_events = 1 + [(gogoproto.moretags) = "yaml:\"validator_slash_events\"", (gogoproto.nullable) = false]; +} + +// FeePool is the global fee pool for distribution. +message FeePool { + repeated cosmos.base.v1beta1.DecCoin community_pool = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.moretags) = "yaml:\"community_pool\"" + ]; +} + +// CommunityPoolSpendProposal details a proposal for use of community funds, +// together with how many coins are proposed to be spent, and to which +// recipient account. +message CommunityPoolSpendProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + string recipient = 3; + repeated cosmos.base.v1beta1.Coin amount = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// DelegatorStartingInfo represents the starting info for a delegator reward +// period. It tracks the previous validator period, the delegation's amount of +// staking token, and the creation height (to check later on if any slashes have +// occurred). NOTE: Even though validators are slashed to whole staking tokens, +// the delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used. +message DelegatorStartingInfo { + uint64 previous_period = 1 [(gogoproto.moretags) = "yaml:\"previous_period\""]; + string stake = 2 [ + (gogoproto.moretags) = "yaml:\"stake\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 height = 3 [(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"]; +} + +// DelegationDelegatorReward represents the properties +// of a delegator's delegation reward. +message DelegationDelegatorReward { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + repeated cosmos.base.v1beta1.DecCoin reward = 2 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} + +// CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal +// with a deposit +message CommunityPoolSpendProposalWithDeposit { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + string recipient = 3 [(gogoproto.moretags) = "yaml:\"recipient\""]; + string amount = 4 [(gogoproto.moretags) = "yaml:\"amount\""]; + string deposit = 5 [(gogoproto.moretags) = "yaml:\"deposit\""]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/genesis.proto b/third_party/proto/cosmos/distribution/v1beta1/genesis.proto new file mode 100644 index 00000000..c0b17cdf --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/genesis.proto @@ -0,0 +1,155 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/distribution/v1beta1/distribution.proto"; + +// DelegatorWithdrawInfo is the address for where distributions rewards are +// withdrawn to by default this struct is only used at genesis to feed in +// default withdraw addresses. +message DelegatorWithdrawInfo { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + + // withdraw_address is the address to withdraw the delegation rewards to. + string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; +} + +// ValidatorOutstandingRewardsRecord is used for import/export via genesis json. +message ValidatorOutstandingRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // outstanding_rewards represents the oustanding rewards of a validator. + repeated cosmos.base.v1beta1.DecCoin outstanding_rewards = 2 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"outstanding_rewards\"" + ]; +} + +// ValidatorAccumulatedCommissionRecord is used for import / export via genesis +// json. +message ValidatorAccumulatedCommissionRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // accumulated is the accumulated commission of a validator. + ValidatorAccumulatedCommission accumulated = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"accumulated\""]; +} + +// ValidatorHistoricalRewardsRecord is used for import / export via genesis +// json. +message ValidatorHistoricalRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // period defines the period the historical rewards apply to. + uint64 period = 2; + + // rewards defines the historical rewards of a validator. + ValidatorHistoricalRewards rewards = 3 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; +} + +// ValidatorCurrentRewardsRecord is used for import / export via genesis json. +message ValidatorCurrentRewardsRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // rewards defines the current rewards of a validator. + ValidatorCurrentRewards rewards = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"rewards\""]; +} + +// DelegatorStartingInfoRecord used for import / export via genesis json. +message DelegatorStartingInfoRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address is the address of the delegator. + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + + // validator_address is the address of the validator. + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + + // starting_info defines the starting info of a delegator. + DelegatorStartingInfo starting_info = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"starting_info\""]; +} + +// ValidatorSlashEventRecord is used for import / export via genesis json. +message ValidatorSlashEventRecord { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validator_address is the address of the validator. + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + // height defines the block height at which the slash event occured. + uint64 height = 2; + // period is the period of the slash event. + uint64 period = 3; + // validator_slash_event describes the slash event. + ValidatorSlashEvent validator_slash_event = 4 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"event\""]; +} + +// GenesisState defines the distribution module's genesis state. +message GenesisState { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // params defines all the paramaters of the module. + Params params = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"params\""]; + + // fee_pool defines the fee pool at genesis. + FeePool fee_pool = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"fee_pool\""]; + + // fee_pool defines the delegator withdraw infos at genesis. + repeated DelegatorWithdrawInfo delegator_withdraw_infos = 3 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_withdraw_infos\""]; + + // fee_pool defines the previous proposer at genesis. + string previous_proposer = 4 [(gogoproto.moretags) = "yaml:\"previous_proposer\""]; + + // fee_pool defines the outstanding rewards of all validators at genesis. + repeated ValidatorOutstandingRewardsRecord outstanding_rewards = 5 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"outstanding_rewards\""]; + + // fee_pool defines the accumulated commisions of all validators at genesis. + repeated ValidatorAccumulatedCommissionRecord validator_accumulated_commissions = 6 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_accumulated_commissions\""]; + + // fee_pool defines the historical rewards of all validators at genesis. + repeated ValidatorHistoricalRewardsRecord validator_historical_rewards = 7 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_historical_rewards\""]; + + // fee_pool defines the current rewards of all validators at genesis. + repeated ValidatorCurrentRewardsRecord validator_current_rewards = 8 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_current_rewards\""]; + + // fee_pool defines the delegator starting infos at genesis. + repeated DelegatorStartingInfoRecord delegator_starting_infos = 9 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"delegator_starting_infos\""]; + + // fee_pool defines the validator slash events at genesis. + repeated ValidatorSlashEventRecord validator_slash_events = 10 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_slash_events\""]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/query.proto b/third_party/proto/cosmos/distribution/v1beta1/query.proto new file mode 100644 index 00000000..2991218d --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/query.proto @@ -0,0 +1,218 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/distribution/v1beta1/distribution.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; + +// Query defines the gRPC querier service for distribution module. +service Query { + // Params queries params of the distribution module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/params"; + } + + // ValidatorOutstandingRewards queries rewards of a validator address. + rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) + returns (QueryValidatorOutstandingRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" + "{validator_address}/outstanding_rewards"; + } + + // ValidatorCommission queries accumulated commission for a validator. + rpc ValidatorCommission(QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/" + "{validator_address}/commission"; + } + + // ValidatorSlashes queries slash events of a validator. + rpc ValidatorSlashes(QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/validators/{validator_address}/slashes"; + } + + // DelegationRewards queries the total rewards accrued by a delegation. + rpc DelegationRewards(QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/" + "{validator_address}"; + } + + // DelegationTotalRewards queries the total rewards accrued by a each + // validator. + rpc DelegationTotalRewards(QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards"; + } + + // DelegatorValidators queries the validators of a delegator. + rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" + "{delegator_address}/validators"; + } + + // DelegatorWithdrawAddress queries withdraw address of a delegator. + rpc DelegatorWithdrawAddress(QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/delegators/" + "{delegator_address}/withdraw_address"; + } + + // CommunityPool queries the community pool coins. + rpc CommunityPool(QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) { + option (google.api.http).get = "/cosmos/distribution/v1beta1/community_pool"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorOutstandingRewardsRequest is the request type for the +// Query/ValidatorOutstandingRewards RPC method. +message QueryValidatorOutstandingRewardsRequest { + // validator_address defines the validator address to query for. + string validator_address = 1; +} + +// QueryValidatorOutstandingRewardsResponse is the response type for the +// Query/ValidatorOutstandingRewards RPC method. +message QueryValidatorOutstandingRewardsResponse { + ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorCommissionRequest is the request type for the +// Query/ValidatorCommission RPC method +message QueryValidatorCommissionRequest { + // validator_address defines the validator address to query for. + string validator_address = 1; +} + +// QueryValidatorCommissionResponse is the response type for the +// Query/ValidatorCommission RPC method +message QueryValidatorCommissionResponse { + // commission defines the commision the validator received. + ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorSlashesRequest is the request type for the +// Query/ValidatorSlashes RPC method +message QueryValidatorSlashesRequest { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + // validator_address defines the validator address to query for. + string validator_address = 1; + // starting_height defines the optional starting height to query the slashes. + uint64 starting_height = 2; + // starting_height defines the optional ending height to query the slashes. + uint64 ending_height = 3; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryValidatorSlashesResponse is the response type for the +// Query/ValidatorSlashes RPC method. +message QueryValidatorSlashesResponse { + // slashes defines the slashes the validator received. + repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegationRewardsRequest is the request type for the +// Query/DelegationRewards RPC method. +message QueryDelegationRewardsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; + // validator_address defines the validator address to query for. + string validator_address = 2; +} + +// QueryDelegationRewardsResponse is the response type for the +// Query/DelegationRewards RPC method. +message QueryDelegationRewardsResponse { + // rewards defines the rewards accrued by a delegation. + repeated cosmos.base.v1beta1.DecCoin rewards = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +// QueryDelegationTotalRewardsRequest is the request type for the +// Query/DelegationTotalRewards RPC method. +message QueryDelegationTotalRewardsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegationTotalRewardsResponse is the response type for the +// Query/DelegationTotalRewards RPC method. +message QueryDelegationTotalRewardsResponse { + // rewards defines all the rewards accrued by a delegator. + repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false]; + // total defines the sum of all the rewards. + repeated cosmos.base.v1beta1.DecCoin total = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"]; +} + +// QueryDelegatorValidatorsRequest is the request type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegatorValidatorsResponse is the response type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // validators defines the validators a delegator is delegating for. + repeated string validators = 1; +} + +// QueryDelegatorWithdrawAddressRequest is the request type for the +// Query/DelegatorWithdrawAddress RPC method. +message QueryDelegatorWithdrawAddressRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_address defines the delegator address to query for. + string delegator_address = 1; +} + +// QueryDelegatorWithdrawAddressResponse is the response type for the +// Query/DelegatorWithdrawAddress RPC method. +message QueryDelegatorWithdrawAddressResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // withdraw_address defines the delegator address to query for. + string withdraw_address = 1; +} + +// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC +// method. +message QueryCommunityPoolRequest {} + +// QueryCommunityPoolResponse is the response type for the Query/CommunityPool +// RPC method. +message QueryCommunityPoolResponse { + // pool defines community pool's coins. + repeated cosmos.base.v1beta1.DecCoin pool = 1 + [(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/distribution/v1beta1/tx.proto b/third_party/proto/cosmos/distribution/v1beta1/tx.proto new file mode 100644 index 00000000..e6ce478b --- /dev/null +++ b/third_party/proto/cosmos/distribution/v1beta1/tx.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; +package cosmos.distribution.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +// Msg defines the distribution Msg service. +service Msg { + // SetWithdrawAddress defines a method to change the withdraw address + // for a delegator (or validator self-delegation). + rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); + + // WithdrawDelegatorReward defines a method to withdraw rewards of delegator + // from a single validator. + rpc WithdrawDelegatorReward(MsgWithdrawDelegatorReward) returns (MsgWithdrawDelegatorRewardResponse); + + // WithdrawValidatorCommission defines a method to withdraw the + // full commission to the validator address. + rpc WithdrawValidatorCommission(MsgWithdrawValidatorCommission) returns (MsgWithdrawValidatorCommissionResponse); + + // FundCommunityPool defines a method to allow an account to directly + // fund the community pool. + rpc FundCommunityPool(MsgFundCommunityPool) returns (MsgFundCommunityPoolResponse); +} + +// MsgSetWithdrawAddress sets the withdraw address for +// a delegator (or validator self-delegation). +message MsgSetWithdrawAddress { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string withdraw_address = 2 [(gogoproto.moretags) = "yaml:\"withdraw_address\""]; +} + +// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. +message MsgSetWithdrawAddressResponse {} + +// MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator +// from a single validator. +message MsgWithdrawDelegatorReward { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. +message MsgWithdrawDelegatorRewardResponse {} + +// MsgWithdrawValidatorCommission withdraws the full commission to the validator +// address. +message MsgWithdrawValidatorCommission { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string validator_address = 1 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. +message MsgWithdrawValidatorCommissionResponse {} + +// MsgFundCommunityPool allows an account to directly +// fund the community pool. +message MsgFundCommunityPool { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + string depositor = 2; +} + +// MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. +message MsgFundCommunityPoolResponse {} diff --git a/third_party/proto/cosmos/evidence/v1beta1/evidence.proto b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto new file mode 100644 index 00000000..14612c31 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/evidence.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +// Equivocation implements the Evidence interface and defines evidence of double +// signing misbehavior. +message Equivocation { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + int64 height = 1; + google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; + int64 power = 3; + string consensus_address = 4 [(gogoproto.moretags) = "yaml:\"consensus_address\""]; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/evidence/v1beta1/genesis.proto b/third_party/proto/cosmos/evidence/v1beta1/genesis.proto new file mode 100644 index 00000000..199f446f --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; + +import "google/protobuf/any.proto"; + +// GenesisState defines the evidence module's genesis state. +message GenesisState { + // evidence defines all the evidence at genesis. + repeated google.protobuf.Any evidence = 1; +} diff --git a/third_party/proto/cosmos/evidence/v1beta1/query.proto b/third_party/proto/cosmos/evidence/v1beta1/query.proto new file mode 100644 index 00000000..eda00544 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/query.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; + +// Query defines the gRPC querier service. +service Query { + // Evidence queries evidence based on evidence hash. + rpc Evidence(QueryEvidenceRequest) returns (QueryEvidenceResponse) { + option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence/{evidence_hash}"; + } + + // AllEvidence queries all evidence. + rpc AllEvidence(QueryAllEvidenceRequest) returns (QueryAllEvidenceResponse) { + option (google.api.http).get = "/cosmos/evidence/v1beta1/evidence"; + } +} + +// QueryEvidenceRequest is the request type for the Query/Evidence RPC method. +message QueryEvidenceRequest { + // evidence_hash defines the hash of the requested evidence. + bytes evidence_hash = 1 [(gogoproto.casttype) = "github.com/tendermint/tendermint/libs/bytes.HexBytes"]; +} + +// QueryEvidenceResponse is the response type for the Query/Evidence RPC method. +message QueryEvidenceResponse { + // evidence returns the requested evidence. + google.protobuf.Any evidence = 1; +} + +// QueryEvidenceRequest is the request type for the Query/AllEvidence RPC +// method. +message QueryAllEvidenceRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC +// method. +message QueryAllEvidenceResponse { + // evidence returns all evidences. + repeated google.protobuf.Any evidence = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/evidence/v1beta1/tx.proto b/third_party/proto/cosmos/evidence/v1beta1/tx.proto new file mode 100644 index 00000000..38795f25 --- /dev/null +++ b/third_party/proto/cosmos/evidence/v1beta1/tx.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package cosmos.evidence.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +// Msg defines the evidence Msg service. +service Msg { + // SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or + // counterfactual signing. + rpc SubmitEvidence(MsgSubmitEvidence) returns (MsgSubmitEvidenceResponse); +} + +// MsgSubmitEvidence represents a message that supports submitting arbitrary +// Evidence of misbehavior such as equivocation or counterfactual signing. +message MsgSubmitEvidence { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string submitter = 1; + google.protobuf.Any evidence = 2 [(cosmos_proto.accepts_interface) = "Evidence"]; +} + +// MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. +message MsgSubmitEvidenceResponse { + // hash defines the hash of the evidence. + bytes hash = 4; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto b/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto new file mode 100644 index 00000000..534de582 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/feegrant.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// BasicFeeAllowance implements FeeAllowance with a one-time grant of tokens +// that optionally expires. The delegatee can use up to SpendLimit to cover fees. +message BasicFeeAllowance { + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + // spend_limit specifies the maximum amount of tokens that can be spent + // by this allowance and will be updated as tokens are spent. If it is + // empty, there is no spend limit and any amount of coins can be spent. + repeated cosmos.base.v1beta1.Coin spend_limit = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // expiration specifies an optional time when this allowance expires + ExpiresAt expiration = 2 [(gogoproto.nullable) = false]; +} + +// PeriodicFeeAllowance extends FeeAllowance to allow for both a maximum cap, +// as well as a limit per time period. +message PeriodicFeeAllowance { + option (cosmos_proto.implements_interface) = "FeeAllowanceI"; + + // basic specifies a struct of `BasicFeeAllowance` + BasicFeeAllowance basic = 1 [(gogoproto.nullable) = false]; + + // period specifies the time duration in which period_spend_limit coins can + // be spent before that allowance is reset + Duration period = 2 [(gogoproto.nullable) = false]; + + // period_spend_limit specifies the maximum number of coins that can be spent + // in the period + repeated cosmos.base.v1beta1.Coin period_spend_limit = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // period_can_spend is the number of coins left to be spent before the period_reset time + repeated cosmos.base.v1beta1.Coin period_can_spend = 4 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // period_reset is the time at which this period resets and a new one begins, + // it is calculated from the start time of the first transaction after the + // last period ended + ExpiresAt period_reset = 5 [(gogoproto.nullable) = false]; +} + +// Duration is a span of a clock time or number of blocks. +// This is designed to be added to an ExpiresAt struct. +message Duration { + // sum is the oneof that represents either duration or block + oneof sum { + google.protobuf.Duration duration = 1 [(gogoproto.stdduration) = true]; + uint64 blocks = 2; + } +} + +// ExpiresAt is a point in time where something expires. +// It may be *either* block time or block height +message ExpiresAt { + // sum is the oneof that represents either time or height + oneof sum { + google.protobuf.Timestamp time = 1 [(gogoproto.stdtime) = true]; + int64 height = 2; + } +} + +// FeeAllowanceGrant is stored in the KVStore to record a grant with full context +message FeeAllowanceGrant { + + string granter = 1; + string grantee = 2; + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto b/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto new file mode 100644 index 00000000..a021ea61 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/feegrant/v1beta1/feegrant.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// GenesisState contains a set of fee allowances, persisted from the store +message GenesisState { + repeated FeeAllowanceGrant fee_allowances = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/query.proto b/third_party/proto/cosmos/feegrant/v1beta1/query.proto new file mode 100644 index 00000000..2817ccf6 --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/query.proto @@ -0,0 +1,51 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "cosmos/feegrant/v1beta1/feegrant.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// Query defines the gRPC querier service. +service Query { + + // FeeAllowance returns fee granted to the grantee by the granter. + rpc FeeAllowance(QueryFeeAllowanceRequest) returns (QueryFeeAllowanceResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowance/{granter}/{grantee}"; + } + + // FeeAllowances returns all the grants for address. + rpc FeeAllowances(QueryFeeAllowancesRequest) returns (QueryFeeAllowancesResponse) { + option (google.api.http).get = "/cosmos/feegrant/v1beta1/fee_allowances/{grantee}"; + } +} + +// QueryFeeAllowanceRequest is the request type for the Query/FeeAllowance RPC method. +message QueryFeeAllowanceRequest { + string granter = 1; + string grantee = 2; +} + +// QueryFeeAllowanceResponse is the response type for the Query/FeeAllowance RPC method. +message QueryFeeAllowanceResponse { + // fee_allowance is a fee_allowance granted for grantee by granter. + cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowance = 1; +} + +// QueryFeeAllowancesRequest is the request type for the Query/FeeAllowances RPC method. +message QueryFeeAllowancesRequest { + string grantee = 1; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryFeeAllowancesResponse is the response type for the Query/FeeAllowances RPC method. +message QueryFeeAllowancesResponse { + // fee_allowances are fee_allowance's granted for grantee by granter. + repeated cosmos.feegrant.v1beta1.FeeAllowanceGrant fee_allowances = 1; + + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/feegrant/v1beta1/tx.proto b/third_party/proto/cosmos/feegrant/v1beta1/tx.proto new file mode 100644 index 00000000..a36f358f --- /dev/null +++ b/third_party/proto/cosmos/feegrant/v1beta1/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package cosmos.feegrant.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant/types"; + +// Msg defines the feegrant msg service. +service Msg { + + // GrantFeeAllowance grants fee allowance to the grantee on the granter's + // account with the provided expiration time. + rpc GrantFeeAllowance(MsgGrantFeeAllowance) returns (MsgGrantFeeAllowanceResponse); + + // RevokeFeeAllowance revokes any fee allowance of granter's account that + // has been granted to the grantee. + rpc RevokeFeeAllowance(MsgRevokeFeeAllowance) returns (MsgRevokeFeeAllowanceResponse); +} + +// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance +// of fees from the account of Granter. +message MsgGrantFeeAllowance { + string granter = 1; + string grantee = 2; + google.protobuf.Any allowance = 3 [(cosmos_proto.accepts_interface) = "FeeAllowanceI"]; +} + +// MsgGrantFeeAllowanceResponse defines the Msg/GrantFeeAllowanceResponse response type. +message MsgGrantFeeAllowanceResponse {} + +// MsgRevokeFeeAllowance removes any existing FeeAllowance from Granter to Grantee. +message MsgRevokeFeeAllowance { + string granter = 1; + string grantee = 2; +} + +// MsgRevokeFeeAllowanceResponse defines the Msg/RevokeFeeAllowanceResponse response type. +message MsgRevokeFeeAllowanceResponse {} diff --git a/third_party/proto/cosmos/genutil/v1beta1/genesis.proto b/third_party/proto/cosmos/genutil/v1beta1/genesis.proto index 1dfb5c37..a0207793 100644 --- a/third_party/proto/cosmos/genutil/v1beta1/genesis.proto +++ b/third_party/proto/cosmos/genutil/v1beta1/genesis.proto @@ -10,7 +10,7 @@ message GenesisState { // gen_txs defines the genesis transactions. repeated bytes gen_txs = 1 [ (gogoproto.casttype) = "encoding/json.RawMessage", - (gogoproto.jsontag) = "gentxs", + (gogoproto.jsontag) = "gentxs", (gogoproto.moretags) = "yaml:\"gentxs\"" ]; } diff --git a/third_party/proto/cosmos/gov/v1beta1/genesis.proto b/third_party/proto/cosmos/gov/v1beta1/genesis.proto new file mode 100644 index 00000000..a9995004 --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/genesis.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +package cosmos.gov.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/gov/v1beta1/gov.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// GenesisState defines the gov module's genesis state. +message GenesisState { + // starting_proposal_id is the ID of the starting proposal. + uint64 starting_proposal_id = 1 [(gogoproto.moretags) = "yaml:\"starting_proposal_id\""]; + // deposits defines all the deposits present at genesis. + repeated Deposit deposits = 2 [(gogoproto.castrepeated) = "Deposits", (gogoproto.nullable) = false]; + // votes defines all the votes present at genesis. + repeated Vote votes = 3 [(gogoproto.castrepeated) = "Votes", (gogoproto.nullable) = false]; + // proposals defines all the proposals present at genesis. + repeated Proposal proposals = 4 [(gogoproto.castrepeated) = "Proposals", (gogoproto.nullable) = false]; + // params defines all the paramaters of related to deposit. + DepositParams deposit_params = 5 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_params\""]; + // params defines all the paramaters of related to voting. + VotingParams voting_params = 6 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_params\""]; + // params defines all the paramaters of related to tally. + TallyParams tally_params = 7 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"tally_params\""]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/gov.proto b/third_party/proto/cosmos/gov/v1beta1/gov.proto new file mode 100644 index 00000000..1d72e643 --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/gov.proto @@ -0,0 +1,183 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.stringer_all) = false; +option (gogoproto.goproto_getters_all) = false; + +// VoteOption enumerates the valid vote options for a given governance proposal. +enum VoteOption { + option (gogoproto.goproto_enum_prefix) = false; + + // VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + VOTE_OPTION_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "OptionEmpty"]; + // VOTE_OPTION_YES defines a yes vote option. + VOTE_OPTION_YES = 1 [(gogoproto.enumvalue_customname) = "OptionYes"]; + // VOTE_OPTION_ABSTAIN defines an abstain vote option. + VOTE_OPTION_ABSTAIN = 2 [(gogoproto.enumvalue_customname) = "OptionAbstain"]; + // VOTE_OPTION_NO defines a no vote option. + VOTE_OPTION_NO = 3 [(gogoproto.enumvalue_customname) = "OptionNo"]; + // VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + VOTE_OPTION_NO_WITH_VETO = 4 [(gogoproto.enumvalue_customname) = "OptionNoWithVeto"]; +} + +// TextProposal defines a standard text proposal whose changes need to be +// manually updated in case of approval. +message TextProposal { + option (cosmos_proto.implements_interface) = "Content"; + + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; +} + +// Deposit defines an amount deposited by an account address to an active +// proposal. +message Deposit { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string depositor = 2; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// Proposal defines the core field members of a governance proposal. +message Proposal { + option (gogoproto.equal) = true; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "id", (gogoproto.moretags) = "yaml:\"id\""]; + google.protobuf.Any content = 2 [(cosmos_proto.accepts_interface) = "Content"]; + ProposalStatus status = 3 [(gogoproto.moretags) = "yaml:\"proposal_status\""]; + TallyResult final_tally_result = 4 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"final_tally_result\""]; + google.protobuf.Timestamp submit_time = 5 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"submit_time\""]; + google.protobuf.Timestamp deposit_end_time = 6 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"deposit_end_time\""]; + repeated cosmos.base.v1beta1.Coin total_deposit = 7 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"total_deposit\"" + ]; + google.protobuf.Timestamp voting_start_time = 8 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_start_time\""]; + google.protobuf.Timestamp voting_end_time = 9 + [(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"voting_end_time\""]; +} + +// ProposalStatus enumerates the valid statuses of a proposal. +enum ProposalStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. + PROPOSAL_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "StatusNil"]; + // PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + // period. + PROPOSAL_STATUS_DEPOSIT_PERIOD = 1 [(gogoproto.enumvalue_customname) = "StatusDepositPeriod"]; + // PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + // period. + PROPOSAL_STATUS_VOTING_PERIOD = 2 [(gogoproto.enumvalue_customname) = "StatusVotingPeriod"]; + // PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + // passed. + PROPOSAL_STATUS_PASSED = 3 [(gogoproto.enumvalue_customname) = "StatusPassed"]; + // PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + // been rejected. + PROPOSAL_STATUS_REJECTED = 4 [(gogoproto.enumvalue_customname) = "StatusRejected"]; + // PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + // failed. + PROPOSAL_STATUS_FAILED = 5 [(gogoproto.enumvalue_customname) = "StatusFailed"]; +} + +// TallyResult defines a standard tally for a governance proposal. +message TallyResult { + option (gogoproto.equal) = true; + + string yes = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string abstain = 2 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string no = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string no_with_veto = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"no_with_veto\"" + ]; +} + +// Vote defines a vote on a governance proposal. +// A Vote consists of a proposal ID, the voter, and the vote option. +message Vote { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = false; + + uint64 proposal_id = 1 [(gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + VoteOption option = 3; +} + +// DepositParams defines the params for deposits on governance proposals. +message DepositParams { + // Minimum deposit for a proposal to enter voting period. + repeated cosmos.base.v1beta1.Coin min_deposit = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"min_deposit\"", + (gogoproto.jsontag) = "min_deposit,omitempty" + ]; + + // Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + // months. + google.protobuf.Duration max_deposit_period = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "max_deposit_period,omitempty", + (gogoproto.moretags) = "yaml:\"max_deposit_period\"" + ]; +} + +// VotingParams defines the params for voting on governance proposals. +message VotingParams { + // Length of the voting period. + google.protobuf.Duration voting_period = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.jsontag) = "voting_period,omitempty", + (gogoproto.moretags) = "yaml:\"voting_period\"" + ]; +} + +// TallyParams defines the params for tallying votes on governance proposals. +message TallyParams { + // Minimum percentage of total stake needed to vote for a result to be + // considered valid. + bytes quorum = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "quorum,omitempty" + ]; + + // Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. + bytes threshold = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "threshold,omitempty" + ]; + + // Minimum value of Veto votes to Total votes ratio for proposal to be + // vetoed. Default value: 1/3. + bytes veto_threshold = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "veto_threshold,omitempty", + (gogoproto.moretags) = "yaml:\"veto_threshold\"" + ]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/query.proto b/third_party/proto/cosmos/gov/v1beta1/query.proto new file mode 100644 index 00000000..da62bdba --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/query.proto @@ -0,0 +1,190 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/gov/v1beta1/gov.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// Query defines the gRPC querier service for gov module +service Query { + // Proposal queries proposal details based on ProposalID. + rpc Proposal(QueryProposalRequest) returns (QueryProposalResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}"; + } + + // Proposals queries all proposals based on given status. + rpc Proposals(QueryProposalsRequest) returns (QueryProposalsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals"; + } + + // Vote queries voted information based on proposalID, voterAddr. + rpc Vote(QueryVoteRequest) returns (QueryVoteResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter}"; + } + + // Votes queries votes of a given proposal. + rpc Votes(QueryVotesRequest) returns (QueryVotesResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/votes"; + } + + // Params queries all parameters of the gov module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}"; + } + + // Deposit queries single deposit information based proposalID, depositAddr. + rpc Deposit(QueryDepositRequest) returns (QueryDepositResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor}"; + } + + // Deposits queries all deposits of a single proposal. + rpc Deposits(QueryDepositsRequest) returns (QueryDepositsResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits"; + } + + // TallyResult queries the tally of a proposal vote. + rpc TallyResult(QueryTallyResultRequest) returns (QueryTallyResultResponse) { + option (google.api.http).get = "/cosmos/gov/v1beta1/proposals/{proposal_id}/tally"; + } +} + +// QueryProposalRequest is the request type for the Query/Proposal RPC method. +message QueryProposalRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; +} + +// QueryProposalResponse is the response type for the Query/Proposal RPC method. +message QueryProposalResponse { + Proposal proposal = 1 [(gogoproto.nullable) = false]; +} + +// QueryProposalsRequest is the request type for the Query/Proposals RPC method. +message QueryProposalsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_status defines the status of the proposals. + ProposalStatus proposal_status = 1; + + // voter defines the voter address for the proposals. + string voter = 2; + + // depositor defines the deposit addresses from the proposals. + string depositor = 3; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryProposalsResponse is the response type for the Query/Proposals RPC +// method. +message QueryProposalsResponse { + repeated Proposal proposals = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryVoteRequest is the request type for the Query/Vote RPC method. +message QueryVoteRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // voter defines the oter address for the proposals. + string voter = 2; +} + +// QueryVoteResponse is the response type for the Query/Vote RPC method. +message QueryVoteResponse { + // vote defined the queried vote. + Vote vote = 1 [(gogoproto.nullable) = false]; +} + +// QueryVotesRequest is the request type for the Query/Votes RPC method. +message QueryVotesRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryVotesResponse is the response type for the Query/Votes RPC method. +message QueryVotesResponse { + // votes defined the queried votes. + repeated Vote votes = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest { + // params_type defines which parameters to query for, can be one of "voting", + // "tallying" or "deposit". + string params_type = 1; +} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // voting_params defines the parameters related to voting. + VotingParams voting_params = 1 [(gogoproto.nullable) = false]; + // deposit_params defines the parameters related to deposit. + DepositParams deposit_params = 2 [(gogoproto.nullable) = false]; + // tally_params defines the parameters related to tally. + TallyParams tally_params = 3 [(gogoproto.nullable) = false]; +} + +// QueryDepositRequest is the request type for the Query/Deposit RPC method. +message QueryDepositRequest { + option (gogoproto.goproto_getters) = false; + option (gogoproto.equal) = false; + + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // depositor defines the deposit addresses from the proposals. + string depositor = 2; +} + +// QueryDepositResponse is the response type for the Query/Deposit RPC method. +message QueryDepositResponse { + // deposit defines the requested deposit. + Deposit deposit = 1 [(gogoproto.nullable) = false]; +} + +// QueryDepositsRequest is the request type for the Query/Deposits RPC method. +message QueryDepositsRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDepositsResponse is the response type for the Query/Deposits RPC method. +message QueryDepositsResponse { + repeated Deposit deposits = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryTallyResultRequest is the request type for the Query/Tally RPC method. +message QueryTallyResultRequest { + // proposal_id defines the unique id of the proposal. + uint64 proposal_id = 1; +} + +// QueryTallyResultResponse is the response type for the Query/Tally RPC method. +message QueryTallyResultResponse { + // tally defines the requested tally. + TallyResult tally = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/gov/v1beta1/tx.proto b/third_party/proto/cosmos/gov/v1beta1/tx.proto new file mode 100644 index 00000000..d4f0c1f9 --- /dev/null +++ b/third_party/proto/cosmos/gov/v1beta1/tx.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +package cosmos.gov.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/gov/v1beta1/gov.proto"; +import "cosmos_proto/cosmos.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/gov/types"; + +// Msg defines the bank Msg service. +service Msg { + // SubmitProposal defines a method to create new proposal given a content. + rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse); + + // Vote defines a method to add a vote on a specific proposal. + rpc Vote(MsgVote) returns (MsgVoteResponse); + + // Deposit defines a method to add deposit on a specific proposal. + rpc Deposit(MsgDeposit) returns (MsgDepositResponse); +} + +// MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary +// proposal Content. +message MsgSubmitProposal { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + google.protobuf.Any content = 1 [(cosmos_proto.accepts_interface) = "Content"]; + repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"initial_deposit\"" + ]; + string proposer = 3; +} + +// MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. +message MsgSubmitProposalResponse { + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; +} + +// MsgVote defines a message to cast a vote. +message MsgVote { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + string voter = 2; + VoteOption option = 3; +} + +// MsgVoteResponse defines the Msg/Vote response type. +message MsgVoteResponse {} + +// MsgDeposit defines a message to submit a deposit to an existing proposal. +message MsgDeposit { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = false; + option (gogoproto.goproto_getters) = false; + + uint64 proposal_id = 1 [(gogoproto.jsontag) = "proposal_id", (gogoproto.moretags) = "yaml:\"proposal_id\""]; + string depositor = 2; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// MsgDepositResponse defines the Msg/Deposit response type. +message MsgDepositResponse {} diff --git a/third_party/proto/cosmos/mint/v1beta1/genesis.proto b/third_party/proto/cosmos/mint/v1beta1/genesis.proto new file mode 100644 index 00000000..4e783fb5 --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/genesis.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// GenesisState defines the mint module's genesis state. +message GenesisState { + // minter is a space for holding current inflation information. + Minter minter = 1 [(gogoproto.nullable) = false]; + + // params defines all the paramaters of the module. + Params params = 2 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/mint/v1beta1/mint.proto b/third_party/proto/cosmos/mint/v1beta1/mint.proto new file mode 100644 index 00000000..f94d4ae2 --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/mint.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +import "gogoproto/gogo.proto"; + +// Minter represents the minting state. +message Minter { + // current annual inflation rate + string inflation = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + // current annual expected provisions + string annual_provisions = 2 [ + (gogoproto.moretags) = "yaml:\"annual_provisions\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Params holds parameters for the mint module. +message Params { + option (gogoproto.goproto_stringer) = false; + + // type of coin to mint + string mint_denom = 1; + // maximum annual change in inflation rate + string inflation_rate_change = 2 [ + (gogoproto.moretags) = "yaml:\"inflation_rate_change\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // maximum inflation rate + string inflation_max = 3 [ + (gogoproto.moretags) = "yaml:\"inflation_max\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // minimum inflation rate + string inflation_min = 4 [ + (gogoproto.moretags) = "yaml:\"inflation_min\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // goal of percent bonded atoms + string goal_bonded = 5 [ + (gogoproto.moretags) = "yaml:\"goal_bonded\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + // expected blocks per year + uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""]; +} diff --git a/third_party/proto/cosmos/mint/v1beta1/query.proto b/third_party/proto/cosmos/mint/v1beta1/query.proto new file mode 100644 index 00000000..acd341d7 --- /dev/null +++ b/third_party/proto/cosmos/mint/v1beta1/query.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package cosmos.mint.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/mint/v1beta1/mint.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Params returns the total set of minting parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/params"; + } + + // Inflation returns the current minting inflation value. + rpc Inflation(QueryInflationRequest) returns (QueryInflationResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/inflation"; + } + + // AnnualProvisions current minting annual provisions value. + rpc AnnualProvisions(QueryAnnualProvisionsRequest) returns (QueryAnnualProvisionsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/annual_provisions"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method. +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryInflationRequest is the request type for the Query/Inflation RPC method. +message QueryInflationRequest {} + +// QueryInflationResponse is the response type for the Query/Inflation RPC +// method. +message QueryInflationResponse { + // inflation is the current minting inflation value. + bytes inflation = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// QueryAnnualProvisionsRequest is the request type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsRequest {} + +// QueryAnnualProvisionsResponse is the response type for the +// Query/AnnualProvisions RPC method. +message QueryAnnualProvisionsResponse { + // annual_provisions is the current minting annual provisions value. + bytes annual_provisions = 1 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/params/v1beta1/params.proto b/third_party/proto/cosmos/params/v1beta1/params.proto new file mode 100644 index 00000000..5382fd79 --- /dev/null +++ b/third_party/proto/cosmos/params/v1beta1/params.proto @@ -0,0 +1,27 @@ +syntax = "proto3"; +package cosmos.params.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// ParameterChangeProposal defines a proposal to change one or more parameters. +message ParameterChangeProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; +} + +// ParamChange defines an individual parameter change, for use in +// ParameterChangeProposal. +message ParamChange { + option (gogoproto.goproto_stringer) = false; + + string subspace = 1; + string key = 2; + string value = 3; +} diff --git a/third_party/proto/cosmos/params/v1beta1/query.proto b/third_party/proto/cosmos/params/v1beta1/query.proto new file mode 100644 index 00000000..1078e02a --- /dev/null +++ b/third_party/proto/cosmos/params/v1beta1/query.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package cosmos.params.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/params/v1beta1/params.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal"; + +// Query defines the gRPC querier service. +service Query { + // Params queries a specific parameter of a module, given its subspace and + // key. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/params/v1beta1/params"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest { + // subspace defines the module to query the parameter for. + string subspace = 1; + + // key defines the key of the parameter in the subspace. + string key = 2; +} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // param defines the queried parameter. + ParamChange param = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/genesis.proto b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto new file mode 100644 index 00000000..c8135613 --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/genesis.proto @@ -0,0 +1,50 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/slashing/v1beta1/slashing.proto"; + +// GenesisState defines the slashing module's genesis state. +message GenesisState { + // params defines all the paramaters of related to deposit. + Params params = 1 [(gogoproto.nullable) = false]; + + // signing_infos represents a map between validator addresses and their + // signing infos. + repeated SigningInfo signing_infos = 2 + [(gogoproto.moretags) = "yaml:\"signing_infos\"", (gogoproto.nullable) = false]; + + // signing_infos represents a map between validator addresses and their + // missed blocks. + repeated ValidatorMissedBlocks missed_blocks = 3 + [(gogoproto.moretags) = "yaml:\"missed_blocks\"", (gogoproto.nullable) = false]; +} + +// SigningInfo stores validator signing info of corresponding address. +message SigningInfo { + // address is the validator address. + string address = 1; + // validator_signing_info represents the signing info of this validator. + ValidatorSigningInfo validator_signing_info = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"validator_signing_info\""]; +} + +// ValidatorMissedBlocks contains array of missed blocks of corresponding +// address. +message ValidatorMissedBlocks { + // address is the validator address. + string address = 1; + // missed_blocks is an array of missed blocks by the validator. + repeated MissedBlock missed_blocks = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"missed_blocks\""]; +} + +// MissedBlock contains height and missed status as boolean. +message MissedBlock { + // index is the height at which the block was missed. + int64 index = 1; + // missed is the missed status. + bool missed = 2; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/query.proto b/third_party/proto/cosmos/slashing/v1beta1/query.proto new file mode 100644 index 00000000..869049a0 --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/query.proto @@ -0,0 +1,63 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/slashing/v1beta1/slashing.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; + +// Query provides defines the gRPC querier service +service Query { + // Params queries the parameters of slashing module + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/params"; + } + + // SigningInfo queries the signing info of given cons address + rpc SigningInfo(QuerySigningInfoRequest) returns (QuerySigningInfoResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos/{cons_address}"; + } + + // SigningInfos queries signing info of all validators + rpc SigningInfos(QuerySigningInfosRequest) returns (QuerySigningInfosResponse) { + option (google.api.http).get = "/cosmos/slashing/v1beta1/signing_infos"; + } +} + +// QueryParamsRequest is the request type for the Query/Params RPC method +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the Query/Params RPC method +message QueryParamsResponse { + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC +// method +message QuerySigningInfoRequest { + // cons_address is the address to query signing info of + string cons_address = 1; +} + +// QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC +// method +message QuerySigningInfoResponse { + // val_signing_info is the signing info of requested val cons address + ValidatorSigningInfo val_signing_info = 1 [(gogoproto.nullable) = false]; +} + +// QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC +// method +message QuerySigningInfosRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC +// method +message QuerySigningInfosResponse { + // info is the signing info of all validators + repeated cosmos.slashing.v1beta1.ValidatorSigningInfo info = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/slashing.proto b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto new file mode 100644 index 00000000..882a0fb6 --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/slashing.proto @@ -0,0 +1,58 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +// ValidatorSigningInfo defines a validator's signing info for monitoring their +// liveness activity. +message ValidatorSigningInfo { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string address = 1; + // Height at which validator was first a candidate OR was unjailed + int64 start_height = 2 [(gogoproto.moretags) = "yaml:\"start_height\""]; + // Index which is incremented each time the validator was a bonded + // in a block and may have signed a precommit or not. This in conjunction with the + // `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. + int64 index_offset = 3 [(gogoproto.moretags) = "yaml:\"index_offset\""]; + // Timestamp until which the validator is jailed due to liveness downtime. + google.protobuf.Timestamp jailed_until = 4 + [(gogoproto.moretags) = "yaml:\"jailed_until\"", (gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + // Whether or not a validator has been tombstoned (killed out of validator set). It is set + // once the validator commits an equivocation or for any other configured misbehiavor. + bool tombstoned = 5; + // A counter kept to avoid unnecessary array reads. + // Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + int64 missed_blocks_counter = 6 [(gogoproto.moretags) = "yaml:\"missed_blocks_counter\""]; +} + +// Params represents the parameters used for by the slashing module. +message Params { + int64 signed_blocks_window = 1 [(gogoproto.moretags) = "yaml:\"signed_blocks_window\""]; + bytes min_signed_per_window = 2 [ + (gogoproto.moretags) = "yaml:\"min_signed_per_window\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + google.protobuf.Duration downtime_jail_duration = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"downtime_jail_duration\"" + ]; + bytes slash_fraction_double_sign = 4 [ + (gogoproto.moretags) = "yaml:\"slash_fraction_double_sign\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bytes slash_fraction_downtime = 5 [ + (gogoproto.moretags) = "yaml:\"slash_fraction_downtime\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} diff --git a/third_party/proto/cosmos/slashing/v1beta1/tx.proto b/third_party/proto/cosmos/slashing/v1beta1/tx.proto new file mode 100644 index 00000000..4d63370e --- /dev/null +++ b/third_party/proto/cosmos/slashing/v1beta1/tx.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; +package cosmos.slashing.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types"; +option (gogoproto.equal_all) = true; + +import "gogoproto/gogo.proto"; + +// Msg defines the slashing Msg service. +service Msg { + // Unjail defines a method for unjailing a jailed validator, thus returning + // them into the bonded validator set, so they can begin receiving provisions + // and rewards again. + rpc Unjail(MsgUnjail) returns (MsgUnjailResponse); +} + +// MsgUnjail defines the Msg/Unjail request type +message MsgUnjail { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = true; + + string validator_addr = 1 [(gogoproto.moretags) = "yaml:\"address\"", (gogoproto.jsontag) = "address"]; +} + +// MsgUnjailResponse defines the Msg/Unjail response type +message MsgUnjailResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/staking/v1beta1/genesis.proto b/third_party/proto/cosmos/staking/v1beta1/genesis.proto new file mode 100644 index 00000000..d1563dbc --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/genesis.proto @@ -0,0 +1,53 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +// GenesisState defines the staking module's genesis state. +message GenesisState { + // params defines all the paramaters of related to deposit. + Params params = 1 [(gogoproto.nullable) = false]; + + // last_total_power tracks the total amounts of bonded tokens recorded during + // the previous end block. + bytes last_total_power = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"last_total_power\"", + (gogoproto.nullable) = false + ]; + + // last_validator_powers is a special index that provides a historical list + // of the last-block's bonded validators. + repeated LastValidatorPower last_validator_powers = 3 + [(gogoproto.moretags) = "yaml:\"last_validator_powers\"", (gogoproto.nullable) = false]; + + // delegations defines the validator set at genesis. + repeated Validator validators = 4 [(gogoproto.nullable) = false]; + + // delegations defines the delegations active at genesis. + repeated Delegation delegations = 5 [(gogoproto.nullable) = false]; + + // unbonding_delegations defines the unbonding delegations active at genesis. + repeated UnbondingDelegation unbonding_delegations = 6 + [(gogoproto.moretags) = "yaml:\"unbonding_delegations\"", (gogoproto.nullable) = false]; + + // redelegations defines the redelegations active at genesis. + repeated Redelegation redelegations = 7 [(gogoproto.nullable) = false]; + + bool exported = 8; +} + +// LastValidatorPower required for validator set update logic. +message LastValidatorPower { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address of the validator. + string address = 1; + + // power defines the power of the validator. + int64 power = 2; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/query.proto b/third_party/proto/cosmos/staking/v1beta1/query.proto new file mode 100644 index 00000000..4852c535 --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/query.proto @@ -0,0 +1,348 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "cosmos/base/query/v1beta1/pagination.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// Query defines the gRPC querier service. +service Query { + // Validators queries all validators that match the given status. + rpc Validators(QueryValidatorsRequest) returns (QueryValidatorsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators"; + } + + // Validator queries validator info for given validator address. + rpc Validator(QueryValidatorRequest) returns (QueryValidatorResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}"; + } + + // ValidatorDelegations queries delegate info for given validator. + rpc ValidatorDelegations(QueryValidatorDelegationsRequest) returns (QueryValidatorDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations"; + } + + // ValidatorUnbondingDelegations queries unbonding delegations of a validator. + rpc ValidatorUnbondingDelegations(QueryValidatorUnbondingDelegationsRequest) + returns (QueryValidatorUnbondingDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/" + "{validator_addr}/unbonding_delegations"; + } + + // Delegation queries delegate info for given validator delegator pair. + rpc Delegation(QueryDelegationRequest) returns (QueryDelegationResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" + "{delegator_addr}"; + } + + // UnbondingDelegation queries unbonding info for given validator delegator + // pair. + rpc UnbondingDelegation(QueryUnbondingDelegationRequest) returns (QueryUnbondingDelegationResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/" + "{delegator_addr}/unbonding_delegation"; + } + + // DelegatorDelegations queries all delegations of a given delegator address. + rpc DelegatorDelegations(QueryDelegatorDelegationsRequest) returns (QueryDelegatorDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegations/{delegator_addr}"; + } + + // DelegatorUnbondingDelegations queries all unbonding delegations of a given + // delegator address. + rpc DelegatorUnbondingDelegations(QueryDelegatorUnbondingDelegationsRequest) + returns (QueryDelegatorUnbondingDelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/" + "{delegator_addr}/unbonding_delegations"; + } + + // Redelegations queries redelegations of given address. + rpc Redelegations(QueryRedelegationsRequest) returns (QueryRedelegationsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations"; + } + + // DelegatorValidators queries all validators info for given delegator + // address. + rpc DelegatorValidators(QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators"; + } + + // DelegatorValidator queries validator info for given delegator validator + // pair. + rpc DelegatorValidator(QueryDelegatorValidatorRequest) returns (QueryDelegatorValidatorResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators/" + "{validator_addr}"; + } + + // HistoricalInfo queries the historical info for given height. + rpc HistoricalInfo(QueryHistoricalInfoRequest) returns (QueryHistoricalInfoResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/historical_info/{height}"; + } + + // Pool queries the pool info. + rpc Pool(QueryPoolRequest) returns (QueryPoolResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/pool"; + } + + // Parameters queries the staking parameters. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/staking/v1beta1/params"; + } +} + +// QueryValidatorsRequest is request type for Query/Validators RPC method. +message QueryValidatorsRequest { + // status enables to query for validators matching a given status. + string status = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorsResponse is response type for the Query/Validators RPC method +message QueryValidatorsResponse { + // validators contains all the queried validators. + repeated Validator validators = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryValidatorRequest is response type for the Query/Validator RPC method +message QueryValidatorRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; +} + +// QueryValidatorResponse is response type for the Query/Validator RPC method +message QueryValidatorResponse { + // validator defines the the validator info. + Validator validator = 1 [(gogoproto.nullable) = false]; +} + +// QueryValidatorDelegationsRequest is request type for the +// Query/ValidatorDelegations RPC method +message QueryValidatorDelegationsRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorDelegationsResponse is response type for the +// Query/ValidatorDelegations RPC method +message QueryValidatorDelegationsResponse { + repeated DelegationResponse delegation_responses = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "DelegationResponses"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryValidatorUnbondingDelegationsRequest is required type for the +// Query/ValidatorUnbondingDelegations RPC method +message QueryValidatorUnbondingDelegationsRequest { + // validator_addr defines the validator address to query for. + string validator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryValidatorUnbondingDelegationsResponse is response type for the +// Query/ValidatorUnbondingDelegations RPC method. +message QueryValidatorUnbondingDelegationsResponse { + repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegationRequest is request type for the Query/Delegation RPC method. +message QueryDelegationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegationResponse is response type for the Query/Delegation RPC method. +message QueryDelegationResponse { + // delegation_responses defines the delegation info of a delegation. + DelegationResponse delegation_response = 1; +} + +// QueryUnbondingDelegationRequest is request type for the +// Query/UnbondingDelegation RPC method. +message QueryUnbondingDelegationRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegationResponse is response type for the Query/UnbondingDelegation +// RPC method. +message QueryUnbondingDelegationResponse { + // unbond defines the unbonding information of a delegation. + UnbondingDelegation unbond = 1 [(gogoproto.nullable) = false]; +} + +// QueryDelegatorDelegationsRequest is request type for the +// Query/DelegatorDelegations RPC method. +message QueryDelegatorDelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDelegatorDelegationsResponse is response type for the +// Query/DelegatorDelegations RPC method. +message QueryDelegatorDelegationsResponse { + // delegation_responses defines all the delegations' info of a delegator. + repeated DelegationResponse delegation_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorUnbondingDelegationsRequest is request type for the +// Query/DelegatorUnbondingDelegations RPC method. +message QueryDelegatorUnbondingDelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryUnbondingDelegatorDelegationsResponse is response type for the +// Query/UnbondingDelegatorDelegations RPC method. +message QueryDelegatorUnbondingDelegationsResponse { + repeated UnbondingDelegation unbonding_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryRedelegationsRequest is request type for the Query/Redelegations RPC +// method. +message QueryRedelegationsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // src_validator_addr defines the validator address to redelegate from. + string src_validator_addr = 2; + + // dst_validator_addr defines the validator address to redelegate to. + string dst_validator_addr = 3; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 4; +} + +// QueryRedelegationsResponse is response type for the Query/Redelegations RPC +// method. +message QueryRedelegationsResponse { + repeated RedelegationResponse redelegation_responses = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorValidatorsRequest is request type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryDelegatorValidatorsResponse is response type for the +// Query/DelegatorValidators RPC method. +message QueryDelegatorValidatorsResponse { + // validators defines the the validators' info of a delegator. + repeated Validator validators = 1 [(gogoproto.nullable) = false]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryDelegatorValidatorRequest is request type for the +// Query/DelegatorValidator RPC method. +message QueryDelegatorValidatorRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // delegator_addr defines the delegator address to query for. + string delegator_addr = 1; + + // validator_addr defines the validator address to query for. + string validator_addr = 2; +} + +// QueryDelegatorValidatorResponse response type for the +// Query/DelegatorValidator RPC method. +message QueryDelegatorValidatorResponse { + // validator defines the the validator info. + Validator validator = 1 [(gogoproto.nullable) = false]; +} + +// QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC +// method. +message QueryHistoricalInfoRequest { + // height defines at which height to query the historical info. + int64 height = 1; +} + +// QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC +// method. +message QueryHistoricalInfoResponse { + // hist defines the historical info at the given height. + HistoricalInfo hist = 1; +} + +// QueryPoolRequest is request type for the Query/Pool RPC method. +message QueryPoolRequest {} + +// QueryPoolResponse is response type for the Query/Pool RPC method. +message QueryPoolResponse { + // pool defines the pool info. + Pool pool = 1 [(gogoproto.nullable) = false]; +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/staking.proto b/third_party/proto/cosmos/staking/v1beta1/staking.proto new file mode 100644 index 00000000..eadc86e9 --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/staking.proto @@ -0,0 +1,290 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "tendermint/types/types.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// HistoricalInfo contains header and validator information for a given block. +// It is stored as part of staking module's state, which persists the `n` most +// recent HistoricalInfo +// (`n` is set by the staking module's `historical_entries` parameter). +message HistoricalInfo { + tendermint.types.Header header = 1 [(gogoproto.nullable) = false]; + repeated Validator valset = 2 [(gogoproto.nullable) = false]; +} + +// CommissionRates defines the initial commission rates to be used for creating +// a validator. +message CommissionRates { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string rate = 1 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; + string max_rate = 2 [ + (gogoproto.moretags) = "yaml:\"max_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string max_change_rate = 3 [ + (gogoproto.moretags) = "yaml:\"max_change_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Commission defines commission parameters for a given validator. +message Commission { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + CommissionRates commission_rates = 1 [(gogoproto.embed) = true, (gogoproto.nullable) = false]; + google.protobuf.Timestamp update_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"update_time\""]; +} + +// Description defines a validator description. +message Description { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string moniker = 1; + string identity = 2; + string website = 3; + string security_contact = 4 [(gogoproto.moretags) = "yaml:\"security_contact\""]; + string details = 5; +} + +// Validator defines a validator, together with the total amount of the +// Validator's bond shares and their exchange rate to coins. Slashing results in +// a decrease in the exchange rate, allowing correct calculation of future +// undelegations without iterating over delegators. When coins are delegated to +// this validator, the validator is credited with a delegation whose number of +// bond shares is based on the amount of coins delegated divided by the current +// exchange rate. Voting power can be calculated as total bonded shares +// multiplied by exchange rate. +message Validator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + string operator_address = 1 [(gogoproto.moretags) = "yaml:\"operator_address\""]; + google.protobuf.Any consensus_pubkey = 2 + [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey", (gogoproto.moretags) = "yaml:\"consensus_pubkey\""]; + bool jailed = 3; + BondStatus status = 4; + string tokens = 5 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; + string delegator_shares = 6 [ + (gogoproto.moretags) = "yaml:\"delegator_shares\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + Description description = 7 [(gogoproto.nullable) = false]; + int64 unbonding_height = 8 [(gogoproto.moretags) = "yaml:\"unbonding_height\""]; + google.protobuf.Timestamp unbonding_time = 9 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; + Commission commission = 10 [(gogoproto.nullable) = false]; + string min_self_delegation = 11 [ + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// BondStatus is the status of a validator. +enum BondStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // UNSPECIFIED defines an invalid validator status. + BOND_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "Unspecified"]; + // UNBONDED defines a validator that is not bonded. + BOND_STATUS_UNBONDED = 1 [(gogoproto.enumvalue_customname) = "Unbonded"]; + // UNBONDING defines a validator that is unbonding. + BOND_STATUS_UNBONDING = 2 [(gogoproto.enumvalue_customname) = "Unbonding"]; + // BONDED defines a validator that is bonded. + BOND_STATUS_BONDED = 3 [(gogoproto.enumvalue_customname) = "Bonded"]; +} + +// ValAddresses defines a repeated set of validator addresses. +message ValAddresses { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.stringer) = true; + + repeated string addresses = 1; +} + +// DVPair is struct that just has a delegator-validator pair with no other data. +// It is intended to be used as a marshalable pointer. For example, a DVPair can +// be used to construct the key to getting an UnbondingDelegation from state. +message DVPair { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; +} + +// DVPairs defines an array of DVPair objects. +message DVPairs { + repeated DVPair pairs = 1 [(gogoproto.nullable) = false]; +} + +// DVVTriplet is struct that just has a delegator-validator-validator triplet +// with no other data. It is intended to be used as a marshalable pointer. For +// example, a DVVTriplet can be used to construct the key to getting a +// Redelegation from state. +message DVVTriplet { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; +} + +// DVVTriplets defines an array of DVVTriplet objects. +message DVVTriplets { + repeated DVVTriplet triplets = 1 [(gogoproto.nullable) = false]; +} + +// Delegation represents the bond with tokens held by an account. It is +// owned by one delegator, and is associated with the voting power of one +// validator. +message Delegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + string shares = 3 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// UnbondingDelegation stores all of a single delegator's unbonding bonds +// for a single validator in an time-ordered list. +message UnbondingDelegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + repeated UnbondingDelegationEntry entries = 3 [(gogoproto.nullable) = false]; // unbonding delegation entries +} + +// UnbondingDelegationEntry defines an unbonding object with relevant metadata. +message UnbondingDelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + google.protobuf.Timestamp completion_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +// RedelegationEntry defines a redelegation object with relevant metadata. +message RedelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + int64 creation_height = 1 [(gogoproto.moretags) = "yaml:\"creation_height\""]; + google.protobuf.Timestamp completion_time = 2 + [(gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"completion_time\""]; + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + string shares_dst = 4 + [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; +} + +// Redelegation contains the list of a particular delegator's redelegating bonds +// from a particular source validator to a particular destination validator. +message Redelegation { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + repeated RedelegationEntry entries = 4 [(gogoproto.nullable) = false]; // redelegation entries +} + +// Params defines the parameters for the staking module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + google.protobuf.Duration unbonding_time = 1 + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"unbonding_time\""]; + uint32 max_validators = 2 [(gogoproto.moretags) = "yaml:\"max_validators\""]; + uint32 max_entries = 3 [(gogoproto.moretags) = "yaml:\"max_entries\""]; + uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""]; + string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""]; +} + +// DelegationResponse is equivalent to Delegation except that it contains a +// balance in addition to shares which is more suitable for client responses. +message DelegationResponse { + option (gogoproto.equal) = false; + option (gogoproto.goproto_stringer) = false; + + Delegation delegation = 1 [(gogoproto.nullable) = false]; + + cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; +} + +// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it +// contains a balance in addition to shares which is more suitable for client +// responses. +message RedelegationEntryResponse { + option (gogoproto.equal) = true; + + RedelegationEntry redelegation_entry = 1 [(gogoproto.nullable) = false]; + string balance = 4 [(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false]; +} + +// RedelegationResponse is equivalent to a Redelegation except that its entries +// contain a balance in addition to shares which is more suitable for client +// responses. +message RedelegationResponse { + option (gogoproto.equal) = false; + + Redelegation redelegation = 1 [(gogoproto.nullable) = false]; + repeated RedelegationEntryResponse entries = 2 [(gogoproto.nullable) = false]; +} + +// Pool is used for tracking bonded and not-bonded token supply of the bond +// denomination. +message Pool { + option (gogoproto.description) = true; + option (gogoproto.equal) = true; + string not_bonded_tokens = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.jsontag) = "not_bonded_tokens", + (gogoproto.nullable) = false + ]; + string bonded_tokens = 2 [ + (gogoproto.jsontag) = "bonded_tokens", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"bonded_tokens\"" + ]; +} diff --git a/third_party/proto/cosmos/staking/v1beta1/tx.proto b/third_party/proto/cosmos/staking/v1beta1/tx.proto new file mode 100644 index 00000000..7b05d89e --- /dev/null +++ b/third_party/proto/cosmos/staking/v1beta1/tx.proto @@ -0,0 +1,126 @@ +syntax = "proto3"; +package cosmos.staking.v1beta1; + +import "google/protobuf/any.proto"; +import "google/protobuf/timestamp.proto"; +import "gogoproto/gogo.proto"; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/staking/v1beta1/staking.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// Msg defines the staking Msg service. +service Msg { + // CreateValidator defines a method for creating a new validator. + rpc CreateValidator(MsgCreateValidator) returns (MsgCreateValidatorResponse); + + // EditValidator defines a method for editing an existing validator. + rpc EditValidator(MsgEditValidator) returns (MsgEditValidatorResponse); + + // Delegate defines a method for performing a delegation of coins + // from a delegator to a validator. + rpc Delegate(MsgDelegate) returns (MsgDelegateResponse); + + // BeginRedelegate defines a method for performing a redelegation + // of coins from a delegator and source validator to a destination validator. + rpc BeginRedelegate(MsgBeginRedelegate) returns (MsgBeginRedelegateResponse); + + // Undelegate defines a method for performing an undelegation from a + // delegate and a validator. + rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse); +} + +// MsgCreateValidator defines a SDK message for creating a new validator. +message MsgCreateValidator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Description description = 1 [(gogoproto.nullable) = false]; + CommissionRates commission = 2 [(gogoproto.nullable) = false]; + string min_self_delegation = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.nullable) = false + ]; + string delegator_address = 4 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 5 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + google.protobuf.Any pubkey = 6 [(cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey"]; + cosmos.base.v1beta1.Coin value = 7 [(gogoproto.nullable) = false]; +} + +// MsgCreateValidatorResponse defines the Msg/CreateValidator response type. +message MsgCreateValidatorResponse {} + +// MsgEditValidator defines a SDK message for editing an existing validator. +message MsgEditValidator { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + Description description = 1 [(gogoproto.nullable) = false]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"address\""]; + + // We pass a reference to the new commission rate and min self delegation as + // it's not mandatory to update. If not updated, the deserialized rate will be + // zero with no way to distinguish if an update was intended. + // REF: #2373 + string commission_rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"commission_rate\"" + ]; + string min_self_delegation = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"" + ]; +} + +// MsgEditValidatorResponse defines the Msg/EditValidator response type. +message MsgEditValidatorResponse {} + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +message MsgDelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; +} + +// MsgDelegateResponse defines the Msg/Delegate response type. +message MsgDelegateResponse {} + +// MsgBeginRedelegate defines a SDK message for performing a redelegation +// of coins from a delegator and source validator to a destination validator. +message MsgBeginRedelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_src_address = 2 [(gogoproto.moretags) = "yaml:\"validator_src_address\""]; + string validator_dst_address = 3 [(gogoproto.moretags) = "yaml:\"validator_dst_address\""]; + cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false]; +} + +// MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. +message MsgBeginRedelegateResponse { + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} + +// MsgUndelegate defines a SDK message for performing an undelegation from a +// delegate and a validator. +message MsgUndelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(gogoproto.moretags) = "yaml:\"delegator_address\""]; + string validator_address = 2 [(gogoproto.moretags) = "yaml:\"validator_address\""]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false]; +} + +// MsgUndelegateResponse defines the Msg/Undelegate response type. +message MsgUndelegateResponse { + google.protobuf.Timestamp completion_time = 1 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} diff --git a/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto b/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto index 2a970224..4c1be405 100644 --- a/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto +++ b/third_party/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -43,14 +43,13 @@ message SignatureDescriptor { Data data = 2; // sequence is the sequence of the account, which describes the - // number of committed transactions signed by a given address. It is used to - // prevent replay attacks. + // number of committed transactions signed by a given address. It is used to prevent + // replay attacks. uint64 sequence = 3; // Data represents signature data message Data { - // sum is the oneof that specifies whether this represents single or - // multi-signature data + // sum is the oneof that specifies whether this represents single or multi-signature data oneof sum { // single represents a single signer Single single = 1; diff --git a/third_party/proto/cosmos/tx/v1beta1/service.proto b/third_party/proto/cosmos/tx/v1beta1/service.proto new file mode 100644 index 00000000..59df75ba --- /dev/null +++ b/third_party/proto/cosmos/tx/v1beta1/service.proto @@ -0,0 +1,117 @@ +syntax = "proto3"; +package cosmos.tx.v1beta1; + +import "google/api/annotations.proto"; +import "cosmos/base/abci/v1beta1/abci.proto"; +import "cosmos/tx/v1beta1/tx.proto"; +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/types/tx"; + +// Service defines a gRPC service for interacting with transactions. +service Service { + // Simulate simulates executing a transaction for estimating gas usage. + rpc Simulate(SimulateRequest) returns (SimulateResponse) { + option (google.api.http) = { + post: "/cosmos/tx/v1beta1/simulate" + body: "*" + }; + } + // GetTx fetches a tx by hash. + rpc GetTx(GetTxRequest) returns (GetTxResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs/{hash}"; + } + // BroadcastTx broadcast transaction. + rpc BroadcastTx(BroadcastTxRequest) returns (BroadcastTxResponse) { + option (google.api.http) = { + post: "/cosmos/tx/v1beta1/txs" + body: "*" + }; + } + // GetTxsEvent fetches txs by event. + rpc GetTxsEvent(GetTxsEventRequest) returns (GetTxsEventResponse) { + option (google.api.http).get = "/cosmos/tx/v1beta1/txs"; + } +} + +// GetTxsEventRequest is the request type for the Service.TxsByEvents +// RPC method. +message GetTxsEventRequest { + // events is the list of transaction event type. + repeated string events = 1; + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// GetTxsEventResponse is the response type for the Service.TxsByEvents +// RPC method. +message GetTxsEventResponse { + // txs is the list of queried transactions. + repeated cosmos.tx.v1beta1.Tx txs = 1; + // tx_responses is the list of queried TxResponses. + repeated cosmos.base.abci.v1beta1.TxResponse tx_responses = 2; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 3; +} + +// BroadcastTxRequest is the request type for the Service.BroadcastTxRequest +// RPC method. +message BroadcastTxRequest { + // tx_bytes is the raw transaction. + bytes tx_bytes = 1; + BroadcastMode mode = 2; +} + +// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. +enum BroadcastMode { + // zero-value for mode ordering + BROADCAST_MODE_UNSPECIFIED = 0; + // BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + // the tx to be committed in a block. + BROADCAST_MODE_BLOCK = 1; + // BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + // a CheckTx execution response only. + BROADCAST_MODE_SYNC = 2; + // BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + // immediately. + BROADCAST_MODE_ASYNC = 3; +} + +// BroadcastTxResponse is the response type for the +// Service.BroadcastTx method. +message BroadcastTxResponse { + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 1; +} + +// SimulateRequest is the request type for the Service.Simulate +// RPC method. +message SimulateRequest { + // tx is the transaction to simulate. + cosmos.tx.v1beta1.Tx tx = 1; +} + +// SimulateResponse is the response type for the +// Service.SimulateRPC method. +message SimulateResponse { + // gas_info is the information about gas used in the simulation. + cosmos.base.abci.v1beta1.GasInfo gas_info = 1; + // result is the result of the simulation. + cosmos.base.abci.v1beta1.Result result = 2; +} + +// GetTxRequest is the request type for the Service.GetTx +// RPC method. +message GetTxRequest { + // hash is the tx hash to query, encoded as a hex string. + string hash = 1; +} + +// GetTxResponse is the response type for the Service.GetTx method. +message GetTxResponse { + // tx is the queried transaction. + cosmos.tx.v1beta1.Tx tx = 1; + // tx_response is the queried TxResponses. + cosmos.base.abci.v1beta1.TxResponse tx_response = 2; +} \ No newline at end of file diff --git a/third_party/proto/cosmos/tx/v1beta1/tx.proto b/third_party/proto/cosmos/tx/v1beta1/tx.proto index ffc1fd95..2b02874c 100644 --- a/third_party/proto/cosmos/tx/v1beta1/tx.proto +++ b/third_party/proto/cosmos/tx/v1beta1/tx.proto @@ -69,7 +69,6 @@ message TxBody { // those messages define the number and order of elements in AuthInfo's // signer_infos and Tx's signatures. Each required signer address is added to // the list only the first time it occurs. - // // By convention, the first required signer (usually from the first message) // is referred to as the primary signer and pays the fee for the whole // transaction. @@ -163,24 +162,20 @@ message ModeInfo { // which must be above some miminum to be accepted into the mempool. message Fee { // amount is the amount of coins to be paid as a fee - repeated cosmos.base.v1beta1.Coin amount = 1 [ - (gogoproto.nullable) = false, - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" - ]; + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; // gas_limit is the maximum gas that can be used in transaction processing // before an out of gas error occurs uint64 gas_limit = 2; - // if unset, the first signer is responsible for paying the fees. If set, the - // specified account must pay the fees. the payer must be a tx signer (and - // thus have signed this field in AuthInfo). setting this field does *not* - // change the ordering of required signers for the transaction. + // if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + // the payer must be a tx signer (and thus have signed this field in AuthInfo). + // setting this field does *not* change the ordering of required signers for the transaction. string payer = 3; - // if set, the fee payer (either the first signer or the value of the payer - // field) requests that a fee grant be used to pay fees instead of the fee - // payer's own balance. If an appropriate fee grant does not exist or the - // chain does not support fee grants, this will fail + // if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used + // to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does + // not support fee grants, this will fail string granter = 4; } diff --git a/third_party/proto/cosmos/upgrade/v1beta1/query.proto b/third_party/proto/cosmos/upgrade/v1beta1/query.proto new file mode 100644 index 00000000..9eab27e7 --- /dev/null +++ b/third_party/proto/cosmos/upgrade/v1beta1/query.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package cosmos.upgrade.v1beta1; + +import "google/protobuf/any.proto"; +import "google/api/annotations.proto"; +import "cosmos/upgrade/v1beta1/upgrade.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; + +// Query defines the gRPC upgrade querier service. +service Query { + // CurrentPlan queries the current upgrade plan. + rpc CurrentPlan(QueryCurrentPlanRequest) returns (QueryCurrentPlanResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/current_plan"; + } + + // AppliedPlan queries a previously applied upgrade plan by its name. + rpc AppliedPlan(QueryAppliedPlanRequest) returns (QueryAppliedPlanResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/applied_plan/{name}"; + } + + // UpgradedConsensusState queries the consensus state that will serve + // as a trusted kernel for the next version of this chain. It will only be + // stored at the last height of this chain. + // UpgradedConsensusState RPC not supported with legacy querier + rpc UpgradedConsensusState(QueryUpgradedConsensusStateRequest) returns (QueryUpgradedConsensusStateResponse) { + option (google.api.http).get = "/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height}"; + } +} + +// QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC +// method. +message QueryCurrentPlanRequest {} + +// QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC +// method. +message QueryCurrentPlanResponse { + // plan is the current upgrade plan. + Plan plan = 1; +} + +// QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC +// method. +message QueryAppliedPlanRequest { + // name is the name of the applied plan to query for. + string name = 1; +} + +// QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC +// method. +message QueryAppliedPlanResponse { + // height is the block height at which the plan was applied. + int64 height = 1; +} + +// QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState +// RPC method. +message QueryUpgradedConsensusStateRequest { + // last height of the current chain must be sent in request + // as this is the height under which next consensus state is stored + int64 last_height = 1; +} + +// QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState +// RPC method. +message QueryUpgradedConsensusStateResponse { + google.protobuf.Any upgraded_consensus_state = 1; +} diff --git a/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto new file mode 100644 index 00000000..6d6839ca --- /dev/null +++ b/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto @@ -0,0 +1,62 @@ +syntax = "proto3"; +package cosmos.upgrade.v1beta1; + +import "google/protobuf/any.proto"; +import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/upgrade/types"; +option (gogoproto.goproto_stringer_all) = false; +option (gogoproto.goproto_getters_all) = false; + +// Plan specifies information about a planned upgrade and when it should occur. +message Plan { + option (gogoproto.equal) = true; + + // Sets the name for the upgrade. This name will be used by the upgraded + // version of the software to apply any special "on-upgrade" commands during + // the first BeginBlock method after the upgrade is applied. It is also used + // to detect whether a software version can handle a given upgrade. If no + // upgrade handler with this name has been set in the software, it will be + // assumed that the software is out-of-date when the upgrade Time or Height is + // reached and the software will exit. + string name = 1; + + // The time after which the upgrade must be performed. + // Leave set to its zero value to use a pre-defined Height instead. + google.protobuf.Timestamp time = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; + + // The height at which the upgrade must be performed. + // Only used if Time is not set. + int64 height = 3; + + // Any application specific upgrade info to be included on-chain + // such as a git commit that validators could automatically upgrade to + string info = 4; + + // IBC-enabled chains can opt-in to including the upgraded client state in its upgrade plan + // This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, + // so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the + // previous version of the chain. + // This will allow IBC connections to persist smoothly across planned chain upgrades + google.protobuf.Any upgraded_client_state = 5 [(gogoproto.moretags) = "yaml:\"upgraded_client_state\""]; +} + +// SoftwareUpgradeProposal is a gov Content type for initiating a software +// upgrade. +message SoftwareUpgradeProposal { + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; + Plan plan = 3 [(gogoproto.nullable) = false]; +} + +// CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software +// upgrade. +message CancelSoftwareUpgradeProposal { + option (gogoproto.equal) = true; + + string title = 1; + string description = 2; +} diff --git a/third_party/proto/cosmos/vesting/v1beta1/tx.proto b/third_party/proto/cosmos/vesting/v1beta1/tx.proto new file mode 100644 index 00000000..c49be802 --- /dev/null +++ b/third_party/proto/cosmos/vesting/v1beta1/tx.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package cosmos.vesting.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; + +// Msg defines the bank Msg service. +service Msg { + // CreateVestingAccount defines a method that enables creating a vesting + // account. + rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); +} + +// MsgCreateVestingAccount defines a message that enables creating a vesting +// account. +message MsgCreateVestingAccount { + option (gogoproto.equal) = true; + + string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""]; + string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""]; + repeated cosmos.base.v1beta1.Coin amount = 3 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + int64 end_time = 4 [(gogoproto.moretags) = "yaml:\"end_time\""]; + bool delayed = 5; +} + +// MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. +message MsgCreateVestingAccountResponse {} \ No newline at end of file diff --git a/third_party/proto/cosmos/vesting/v1beta1/vesting.proto b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto new file mode 100644 index 00000000..6bdbbf08 --- /dev/null +++ b/third_party/proto/cosmos/vesting/v1beta1/vesting.proto @@ -0,0 +1,73 @@ +syntax = "proto3"; +package cosmos.vesting.v1beta1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/auth/v1beta1/auth.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"; + +// BaseVestingAccount implements the VestingAccount interface. It contains all +// the necessary fields needed for any vesting account implementation. +message BaseVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + cosmos.auth.v1beta1.BaseAccount base_account = 1 [(gogoproto.embed) = true]; + repeated cosmos.base.v1beta1.Coin original_vesting = 2 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"original_vesting\"" + ]; + repeated cosmos.base.v1beta1.Coin delegated_free = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"delegated_free\"" + ]; + repeated cosmos.base.v1beta1.Coin delegated_vesting = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"delegated_vesting\"" + ]; + int64 end_time = 5 [(gogoproto.moretags) = "yaml:\"end_time\""]; +} + +// ContinuousVestingAccount implements the VestingAccount interface. It +// continuously vests by unlocking coins linearly with respect to time. +message ContinuousVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; + int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; +} + +// DelayedVestingAccount implements the VestingAccount interface. It vests all +// coins after a specific time, but non prior. In other words, it keeps them +// locked until a specified time. +message DelayedVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; +} + +// Period defines a length of time and amount of coins that will vest. +message Period { + option (gogoproto.goproto_stringer) = false; + + int64 length = 1; + repeated cosmos.base.v1beta1.Coin amount = 2 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// PeriodicVestingAccount implements the VestingAccount interface. It +// periodically vests by unlocking coins during each specified period. +message PeriodicVestingAccount { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true]; + int64 start_time = 2 [(gogoproto.moretags) = "yaml:\"start_time\""]; + repeated Period vesting_periods = 3 [(gogoproto.moretags) = "yaml:\"vesting_periods\"", (gogoproto.nullable) = false]; +} diff --git a/third_party/proto/cosmos_proto/cosmos.proto b/third_party/proto/cosmos_proto/cosmos.proto index 167b1707..d4719a38 100644 --- a/third_party/proto/cosmos_proto/cosmos.proto +++ b/third_party/proto/cosmos_proto/cosmos.proto @@ -6,11 +6,9 @@ import "google/protobuf/descriptor.proto"; option go_package = "github.com/regen-network/cosmos-proto"; extend google.protobuf.MessageOptions { - string interface_type = 93001; + string interface_type = 93001; - string implements_interface = 93002; + string implements_interface = 93002; } -extend google.protobuf.FieldOptions { - string accepts_interface = 93001; -} +extend google.protobuf.FieldOptions { string accepts_interface = 93001; } diff --git a/third_party/proto/gogoproto/gogo.proto b/third_party/proto/gogoproto/gogo.proto index 49e78f99..91ff4718 100644 --- a/third_party/proto/gogoproto/gogo.proto +++ b/third_party/proto/gogoproto/gogo.proto @@ -36,110 +36,110 @@ option java_outer_classname = "GoGoProtos"; option go_package = "github.com/gogo/protobuf/gogoproto"; extend google.protobuf.EnumOptions { - optional bool goproto_enum_prefix = 62001; - optional bool goproto_enum_stringer = 62021; - optional bool enum_stringer = 62022; - optional string enum_customname = 62023; - optional bool enumdecl = 62024; + optional bool goproto_enum_prefix = 62001; + optional bool goproto_enum_stringer = 62021; + optional bool enum_stringer = 62022; + optional string enum_customname = 62023; + optional bool enumdecl = 62024; } extend google.protobuf.EnumValueOptions { - optional string enumvalue_customname = 66001; + optional string enumvalue_customname = 66001; } extend google.protobuf.FileOptions { - optional bool goproto_getters_all = 63001; - optional bool goproto_enum_prefix_all = 63002; - optional bool goproto_stringer_all = 63003; - optional bool verbose_equal_all = 63004; - optional bool face_all = 63005; - optional bool gostring_all = 63006; - optional bool populate_all = 63007; - optional bool stringer_all = 63008; - optional bool onlyone_all = 63009; + optional bool goproto_getters_all = 63001; + optional bool goproto_enum_prefix_all = 63002; + optional bool goproto_stringer_all = 63003; + optional bool verbose_equal_all = 63004; + optional bool face_all = 63005; + optional bool gostring_all = 63006; + optional bool populate_all = 63007; + optional bool stringer_all = 63008; + optional bool onlyone_all = 63009; - optional bool equal_all = 63013; - optional bool description_all = 63014; - optional bool testgen_all = 63015; - optional bool benchgen_all = 63016; - optional bool marshaler_all = 63017; - optional bool unmarshaler_all = 63018; - optional bool stable_marshaler_all = 63019; + optional bool equal_all = 63013; + optional bool description_all = 63014; + optional bool testgen_all = 63015; + optional bool benchgen_all = 63016; + optional bool marshaler_all = 63017; + optional bool unmarshaler_all = 63018; + optional bool stable_marshaler_all = 63019; - optional bool sizer_all = 63020; + optional bool sizer_all = 63020; - optional bool goproto_enum_stringer_all = 63021; - optional bool enum_stringer_all = 63022; + optional bool goproto_enum_stringer_all = 63021; + optional bool enum_stringer_all = 63022; - optional bool unsafe_marshaler_all = 63023; - optional bool unsafe_unmarshaler_all = 63024; + optional bool unsafe_marshaler_all = 63023; + optional bool unsafe_unmarshaler_all = 63024; - optional bool goproto_extensions_map_all = 63025; - optional bool goproto_unrecognized_all = 63026; - optional bool gogoproto_import = 63027; - optional bool protosizer_all = 63028; - optional bool compare_all = 63029; - optional bool typedecl_all = 63030; - optional bool enumdecl_all = 63031; + optional bool goproto_extensions_map_all = 63025; + optional bool goproto_unrecognized_all = 63026; + optional bool gogoproto_import = 63027; + optional bool protosizer_all = 63028; + optional bool compare_all = 63029; + optional bool typedecl_all = 63030; + optional bool enumdecl_all = 63031; - optional bool goproto_registration = 63032; - optional bool messagename_all = 63033; + optional bool goproto_registration = 63032; + optional bool messagename_all = 63033; - optional bool goproto_sizecache_all = 63034; - optional bool goproto_unkeyed_all = 63035; + optional bool goproto_sizecache_all = 63034; + optional bool goproto_unkeyed_all = 63035; } extend google.protobuf.MessageOptions { - optional bool goproto_getters = 64001; - optional bool goproto_stringer = 64003; - optional bool verbose_equal = 64004; - optional bool face = 64005; - optional bool gostring = 64006; - optional bool populate = 64007; - optional bool stringer = 67008; - optional bool onlyone = 64009; + optional bool goproto_getters = 64001; + optional bool goproto_stringer = 64003; + optional bool verbose_equal = 64004; + optional bool face = 64005; + optional bool gostring = 64006; + optional bool populate = 64007; + optional bool stringer = 67008; + optional bool onlyone = 64009; - optional bool equal = 64013; - optional bool description = 64014; - optional bool testgen = 64015; - optional bool benchgen = 64016; - optional bool marshaler = 64017; - optional bool unmarshaler = 64018; - optional bool stable_marshaler = 64019; + optional bool equal = 64013; + optional bool description = 64014; + optional bool testgen = 64015; + optional bool benchgen = 64016; + optional bool marshaler = 64017; + optional bool unmarshaler = 64018; + optional bool stable_marshaler = 64019; - optional bool sizer = 64020; + optional bool sizer = 64020; - optional bool unsafe_marshaler = 64023; - optional bool unsafe_unmarshaler = 64024; + optional bool unsafe_marshaler = 64023; + optional bool unsafe_unmarshaler = 64024; - optional bool goproto_extensions_map = 64025; - optional bool goproto_unrecognized = 64026; + optional bool goproto_extensions_map = 64025; + optional bool goproto_unrecognized = 64026; - optional bool protosizer = 64028; - optional bool compare = 64029; + optional bool protosizer = 64028; + optional bool compare = 64029; - optional bool typedecl = 64030; + optional bool typedecl = 64030; - optional bool messagename = 64033; + optional bool messagename = 64033; - optional bool goproto_sizecache = 64034; - optional bool goproto_unkeyed = 64035; + optional bool goproto_sizecache = 64034; + optional bool goproto_unkeyed = 64035; } extend google.protobuf.FieldOptions { - optional bool nullable = 65001; - optional bool embed = 65002; - optional string customtype = 65003; - optional string customname = 65004; - optional string jsontag = 65005; - optional string moretags = 65006; - optional string casttype = 65007; - optional string castkey = 65008; - optional string castvalue = 65009; + optional bool nullable = 65001; + optional bool embed = 65002; + optional string customtype = 65003; + optional string customname = 65004; + optional string jsontag = 65005; + optional string moretags = 65006; + optional string casttype = 65007; + optional string castkey = 65008; + optional string castvalue = 65009; - optional bool stdtime = 65010; - optional bool stdduration = 65011; - optional bool wktpointer = 65012; + optional bool stdtime = 65010; + optional bool stdduration = 65011; + optional bool wktpointer = 65012; - optional string castrepeated = 65013; + optional string castrepeated = 65013; } diff --git a/third_party/proto/google/api/http.proto b/third_party/proto/google/api/http.proto index 775e5420..f5388aaf 100644 --- a/third_party/proto/google/api/http.proto +++ b/third_party/proto/google/api/http.proto @@ -56,7 +56,8 @@ message Http { // // service Messaging { // rpc GetMessage(GetMessageRequest) returns (Message) { -// option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; +// option (google.api.http).get = +// "/v1/messages/{message_id}/{sub.subfield}"; // } // } // message GetMessageRequest { @@ -83,7 +84,8 @@ message Http { // // HTTP | RPC // -----|----- -// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` +// `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: +// SubMessage(subfield: "foo"))` // // In general, not only fields but also field paths can be referenced // from a path pattern. Fields mapped to the path pattern cannot be @@ -113,7 +115,9 @@ message Http { // // HTTP | RPC // -----|----- -// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` +// `GET /v1/messages/123456?revision=2&sub.subfield=foo` | +// `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: +// "foo"))` // // Note that fields which are mapped to HTTP parameters must have a // primitive type or a repeated primitive type. Message types are not @@ -145,7 +149,8 @@ message Http { // // HTTP | RPC // -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` +// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: +// "123456" message { text: "Hi!" })` // // The special name `*` can be used in the body mapping to define that // every field not bound by the path template should be mapped to the @@ -170,7 +175,8 @@ message Http { // // HTTP | RPC // -----|----- -// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` +// `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: +// "123456" text: "Hi!")` // // Note that when using `*` in the body mapping, it is not possible to // have HTTP parameters, as all fields not bound by the path end in @@ -203,7 +209,8 @@ message Http { // HTTP | RPC // -----|----- // `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` -// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` +// `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: +// "123456")` // // # Rules for HTTP mapping // @@ -261,7 +268,8 @@ message Http { message HttpRule { // Selects methods to which this rule applies. // - // Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + // Refer to [selector][google.api.DocumentationRule.selector] for syntax + // details. string selector = 1; // Determines the URL pattern is matched by this rules. This pattern can be diff --git a/third_party/proto/google/protobuf/any.proto b/third_party/proto/google/protobuf/any.proto index 1431810e..b5ddc4af 100644 --- a/third_party/proto/google/protobuf/any.proto +++ b/third_party/proto/google/protobuf/any.proto @@ -89,7 +89,7 @@ option objc_class_prefix = "GPB"; // The pack methods provided by protobuf library will by default use // 'type.googleapis.com/full.type.name' as the type URL and the unpack // methods only use the fully qualified type name after the last '/' -// in the type URL, for example "foo.bar.com/x/y.z" will yield type +// in the type URL, for example "foo.bar.com/modules/y.z" will yield type // name "y.z". // // diff --git a/third_party/proto/google/protobuf/descriptor.proto b/third_party/proto/google/protobuf/descriptor.proto new file mode 100644 index 00000000..b9b3bb3d --- /dev/null +++ b/third_party/proto/google/protobuf/descriptor.proto @@ -0,0 +1,894 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// https://developers.google.com/protocol-buffers/ +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Author: kenton@google.com (Kenton Varda) +// Based on original Protocol Buffers design by +// Sanjay Ghemawat, Jeff Dean, and others. +// +// The messages in this file describe the definitions found in .proto files. +// A valid .proto file can be translated directly to a FileDescriptorProto +// without any other information (e.g. without reading its imports). + +syntax = "proto2"; + +package google.protobuf; + +option go_package = "google.golang.org/protobuf/types/descriptorpb"; +option java_package = "com.google.protobuf"; +option java_outer_classname = "DescriptorProtos"; +option csharp_namespace = "Google.Protobuf.Reflection"; +option objc_class_prefix = "GPB"; +option cc_enable_arenas = true; + +// descriptor.proto must be optimized for speed because reflection-based +// algorithms don't work during bootstrapping. +option optimize_for = SPEED; + +// The protocol compiler can output a FileDescriptorSet containing the .proto +// files it parses. +message FileDescriptorSet { repeated FileDescriptorProto file = 1; } + +// Describes a complete .proto file. +message FileDescriptorProto { + optional string name = 1; // file name, relative to root of source tree + optional string package = 2; // e.g. "foo", "foo.bar", etc. + + // Names of files imported by this file. + repeated string dependency = 3; + // Indexes of the public imported files in the dependency list above. + repeated int32 public_dependency = 10; + // Indexes of the weak imported files in the dependency list. + // For Google-internal migration only. Do not use. + repeated int32 weak_dependency = 11; + + // All top-level definitions in this file. + repeated DescriptorProto message_type = 4; + repeated EnumDescriptorProto enum_type = 5; + repeated ServiceDescriptorProto service = 6; + repeated FieldDescriptorProto extension = 7; + + optional FileOptions options = 8; + + // This field contains optional information about the original source code. + // You may safely remove this entire field without harming runtime + // functionality of the descriptors -- the information is needed only by + // development tools. + optional SourceCodeInfo source_code_info = 9; + + // The syntax of the proto file. + // The supported values are "proto2" and "proto3". + optional string syntax = 12; +} + +// Describes a message type. +message DescriptorProto { + optional string name = 1; + + repeated FieldDescriptorProto field = 2; + repeated FieldDescriptorProto extension = 6; + + repeated DescriptorProto nested_type = 3; + repeated EnumDescriptorProto enum_type = 4; + + message ExtensionRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + + optional ExtensionRangeOptions options = 3; + } + repeated ExtensionRange extension_range = 5; + + repeated OneofDescriptorProto oneof_decl = 8; + + optional MessageOptions options = 7; + + // Range of reserved tag numbers. Reserved tag numbers may not be used by + // fields or extension ranges in the same message. Reserved ranges may + // not overlap. + message ReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Exclusive. + } + repeated ReservedRange reserved_range = 9; + // Reserved field names, which may not be used by fields in the same message. + // A given name may only be reserved once. + repeated string reserved_name = 10; +} + +message ExtensionRangeOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// Describes a field within a message. +message FieldDescriptorProto { + enum Type { + // 0 is reserved for errors. + // Order is weird for historical reasons. + TYPE_DOUBLE = 1; + TYPE_FLOAT = 2; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + // negative values are likely. + TYPE_INT64 = 3; + TYPE_UINT64 = 4; + // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + // negative values are likely. + TYPE_INT32 = 5; + TYPE_FIXED64 = 6; + TYPE_FIXED32 = 7; + TYPE_BOOL = 8; + TYPE_STRING = 9; + // Tag-delimited aggregate. + // Group type is deprecated and not supported in proto3. However, Proto3 + // implementations should still be able to parse the group wire format and + // treat group fields as unknown fields. + TYPE_GROUP = 10; + TYPE_MESSAGE = 11; // Length-delimited aggregate. + + // New in version 2. + TYPE_BYTES = 12; + TYPE_UINT32 = 13; + TYPE_ENUM = 14; + TYPE_SFIXED32 = 15; + TYPE_SFIXED64 = 16; + TYPE_SINT32 = 17; // Uses ZigZag encoding. + TYPE_SINT64 = 18; // Uses ZigZag encoding. + } + + enum Label { + // 0 is reserved for errors + LABEL_OPTIONAL = 1; + LABEL_REQUIRED = 2; + LABEL_REPEATED = 3; + } + + optional string name = 1; + optional int32 number = 3; + optional Label label = 4; + + // If type_name is set, this need not be set. If both this and type_name + // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + optional Type type = 5; + + // For message and enum types, this is the name of the type. If the name + // starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + // rules are used to find the type (i.e. first the nested types within this + // message are searched, then within the parent, on up to the root + // namespace). + optional string type_name = 6; + + // For extensions, this is the name of the type being extended. It is + // resolved in the same manner as type_name. + optional string extendee = 2; + + // For numeric types, contains the original text representation of the value. + // For booleans, "true" or "false". + // For strings, contains the default text contents (not escaped in any way). + // For bytes, contains the C escaped value. All bytes >= 128 are escaped. + // TODO(kenton): Base-64 encode? + optional string default_value = 7; + + // If set, gives the index of a oneof in the containing type's oneof_decl + // list. This field is a member of that oneof. + optional int32 oneof_index = 9; + + // JSON name of this field. The value is set by protocol compiler. If the + // user has set a "json_name" option on this field, that option's value + // will be used. Otherwise, it's deduced from the field's name by converting + // it to camelCase. + optional string json_name = 10; + + optional FieldOptions options = 8; + + // If true, this is a proto3 "optional". When a proto3 field is optional, it + // tracks presence regardless of field type. + // + // When proto3_optional is true, this field must be belong to a oneof to + // signal to old proto3 clients that presence is tracked for this field. This + // oneof is known as a "synthetic" oneof, and this field must be its sole + // member (each proto3 optional field gets its own synthetic oneof). Synthetic + // oneofs exist in the descriptor only, and do not generate any API. Synthetic + // oneofs must be ordered after all "real" oneofs. + // + // For message fields, proto3_optional doesn't create any semantic change, + // since non-repeated message fields always track presence. However it still + // indicates the semantic detail of whether the user wrote "optional" or not. + // This can be useful for round-tripping the .proto file. For consistency we + // give message fields a synthetic oneof also, even though it is not required + // to track presence. This is especially important because the parser can't + // tell if a field is a message or an enum, so it must always create a + // synthetic oneof. + // + // Proto2 optional fields do not set this flag, because they already indicate + // optional with `LABEL_OPTIONAL`. + optional bool proto3_optional = 17; +} + +// Describes a oneof. +message OneofDescriptorProto { + optional string name = 1; + optional OneofOptions options = 2; +} + +// Describes an enum type. +message EnumDescriptorProto { + optional string name = 1; + + repeated EnumValueDescriptorProto value = 2; + + optional EnumOptions options = 3; + + // Range of reserved numeric values. Reserved values may not be used by + // entries in the same enum. Reserved ranges may not overlap. + // + // Note that this is distinct from DescriptorProto.ReservedRange in that it + // is inclusive such that it can appropriately represent the entire int32 + // domain. + message EnumReservedRange { + optional int32 start = 1; // Inclusive. + optional int32 end = 2; // Inclusive. + } + + // Range of reserved numeric values. Reserved numeric values may not be used + // by enum values in the same enum declaration. Reserved ranges may not + // overlap. + repeated EnumReservedRange reserved_range = 4; + + // Reserved enum value names, which may not be reused. A given name may only + // be reserved once. + repeated string reserved_name = 5; +} + +// Describes a value within an enum. +message EnumValueDescriptorProto { + optional string name = 1; + optional int32 number = 2; + + optional EnumValueOptions options = 3; +} + +// Describes a service. +message ServiceDescriptorProto { + optional string name = 1; + repeated MethodDescriptorProto method = 2; + + optional ServiceOptions options = 3; +} + +// Describes a method of a service. +message MethodDescriptorProto { + optional string name = 1; + + // Input and output type names. These are resolved in the same way as + // FieldDescriptorProto.type_name, but must refer to a message type. + optional string input_type = 2; + optional string output_type = 3; + + optional MethodOptions options = 4; + + // Identifies if client streams multiple client messages + optional bool client_streaming = 5 [ default = false ]; + // Identifies if server streams multiple server messages + optional bool server_streaming = 6 [ default = false ]; +} + +// =================================================================== +// Options + +// Each of the definitions above may have "options" attached. These are +// just annotations which may cause code to be generated slightly differently +// or may contain hints for code that manipulates protocol messages. +// +// Clients may define custom options as extensions of the *Options messages. +// These extensions may not yet be known at parsing time, so the parser cannot +// store the values in them. Instead it stores them in a field in the *Options +// message called uninterpreted_option. This field must have the same name +// across all *Options messages. We then use this field to populate the +// extensions when we build a descriptor, at which point all protos have been +// parsed and so all extensions are known. +// +// Extension numbers for custom options may be chosen as follows: +// * For options which will only be used within a single application or +// organization, or for experimental options, use field numbers 50000 +// through 99999. It is up to you to ensure that you do not use the +// same number for multiple options. +// * For options which will be published and used publicly by multiple +// independent entities, e-mail protobuf-global-extension-registry@google.com +// to reserve extension numbers. Simply provide your project name (e.g. +// Objective-C plugin) and your project website (if available) -- there's no +// need to explain how you intend to use them. Usually you only need one +// extension number. You can declare multiple options with only one extension +// number by putting them in a sub-message. See the Custom Options section of +// the docs for examples: +// https://developers.google.com/protocol-buffers/docs/proto#options +// If this turns out to be popular, a web service will be set up +// to automatically assign option numbers. + +message FileOptions { + + // Sets the Java package where classes generated from this .proto will be + // placed. By default, the proto package is used, but this is often + // inappropriate because proto packages do not normally start with backwards + // domain names. + optional string java_package = 1; + + // If set, all the classes from the .proto file are wrapped in a single + // outer class with the given name. This applies to both Proto1 + // (equivalent to the old "--one_java_file" option) and Proto2 (where + // a .proto always translates to a single class, but you may want to + // explicitly choose the class name). + optional string java_outer_classname = 8; + + // If set true, then the Java code generator will generate a separate .java + // file for each top-level message, enum, and service defined in the .proto + // file. Thus, these types will *not* be nested inside the outer class + // named by java_outer_classname. However, the outer class will still be + // generated to contain the file's getDescriptor() method as well as any + // top-level extensions defined in the file. + optional bool java_multiple_files = 10 [ default = false ]; + + // This option does nothing. + optional bool java_generate_equals_and_hash = 20 [ deprecated = true ]; + + // If set true, then the Java2 code generator will generate code that + // throws an exception whenever an attempt is made to assign a non-UTF-8 + // byte sequence to a string field. + // Message reflection will do the same. + // However, an extension field still accepts non-UTF-8 byte sequences. + // This option has no effect on when used with the lite runtime. + optional bool java_string_check_utf8 = 27 [ default = false ]; + + // Generated classes can be optimized for speed or code size. + enum OptimizeMode { + SPEED = 1; // Generate complete code for parsing, serialization, + // etc. + CODE_SIZE = 2; // Use ReflectionOps to implement these methods. + LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime. + } + optional OptimizeMode optimize_for = 9 [ default = SPEED ]; + + // Sets the Go package where structs generated from this .proto will be + // placed. If omitted, the Go package will be derived from the following: + // - The basename of the package import path, if provided. + // - Otherwise, the package statement in the .proto file, if present. + // - Otherwise, the basename of the .proto file, without extension. + optional string go_package = 11; + + // Should generic services be generated in each language? "Generic" services + // are not specific to any particular RPC system. They are generated by the + // main code generators in each language (without additional plugins). + // Generic services were the only kind of service generation supported by + // early versions of google.protobuf. + // + // Generic services are now considered deprecated in favor of using plugins + // that generate code specific to your particular RPC system. Therefore, + // these default to false. Old code which depends on generic services should + // explicitly set them to true. + optional bool cc_generic_services = 16 [ default = false ]; + optional bool java_generic_services = 17 [ default = false ]; + optional bool py_generic_services = 18 [ default = false ]; + optional bool php_generic_services = 42 [ default = false ]; + + // Is this file deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for everything in the file, or it will be completely ignored; in the very + // least, this is a formalization for deprecating files. + optional bool deprecated = 23 [ default = false ]; + + // Enables the use of arenas for the proto messages in this file. This applies + // only to generated classes for C++. + optional bool cc_enable_arenas = 31 [ default = true ]; + + // Sets the objective c class prefix which is prepended to all objective c + // generated classes from this .proto. There is no default. + optional string objc_class_prefix = 36; + + // Namespace for generated classes; defaults to the package. + optional string csharp_namespace = 37; + + // By default Swift generators will take the proto package and CamelCase it + // replacing '.' with underscore and use that to prefix the types/symbols + // defined. When this options is provided, they will use this value instead + // to prefix the types/symbols defined. + optional string swift_prefix = 39; + + // Sets the php class prefix which is prepended to all php generated classes + // from this .proto. Default is empty. + optional string php_class_prefix = 40; + + // Use this option to change the namespace of php generated classes. Default + // is empty. When this option is empty, the package name will be used for + // determining the namespace. + optional string php_namespace = 41; + + // Use this option to change the namespace of php generated metadata classes. + // Default is empty. When this option is empty, the proto file name will be + // used for determining the namespace. + optional string php_metadata_namespace = 44; + + // Use this option to change the package of ruby generated classes. Default + // is empty. When this option is not set, the package name will be used for + // determining the ruby package. + optional string ruby_package = 45; + + // The parser stores options it doesn't recognize here. + // See the documentation for the "Options" section above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. + // See the documentation for the "Options" section above. + extensions 1000 to max; + + reserved 38; +} + +message MessageOptions { + // Set true to use the old proto1 MessageSet wire format for extensions. + // This is provided for backwards-compatibility with the MessageSet wire + // format. You should not use this for any other reason: It's less + // efficient, has fewer features, and is more complicated. + // + // The message must be defined exactly as follows: + // message Foo { + // option message_set_wire_format = true; + // extensions 4 to max; + // } + // Note that the message cannot have any defined fields; MessageSets only + // have extensions. + // + // All extensions of your type must be singular messages; e.g. they cannot + // be int32s, enums, or repeated messages. + // + // Because this is an option, the above two restrictions are not enforced by + // the protocol compiler. + optional bool message_set_wire_format = 1 [ default = false ]; + + // Disables the generation of the standard "descriptor()" accessor, which can + // conflict with a field of the same name. This is meant to make migration + // from proto1 easier; new code should avoid fields named "descriptor". + optional bool no_standard_descriptor_accessor = 2 [ default = false ]; + + // Is this message deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the message, or it will be completely ignored; in the very least, + // this is a formalization for deprecating messages. + optional bool deprecated = 3 [ default = false ]; + + // Whether the message is an automatically generated map entry type for the + // maps field. + // + // For maps fields: + // map map_field = 1; + // The parsed descriptor looks like: + // message MapFieldEntry { + // option map_entry = true; + // optional KeyType key = 1; + // optional ValueType value = 2; + // } + // repeated MapFieldEntry map_field = 1; + // + // Implementations may choose not to generate the map_entry=true message, but + // use a native map in the target language to hold the keys and values. + // The reflection APIs in such implementations still need to work as + // if the field is a repeated message field. + // + // NOTE: Do not set the option in .proto files. Always use the maps syntax + // instead. The option should only be implicitly set by the proto compiler + // parser. + optional bool map_entry = 7; + + reserved 8; // javalite_serializable + reserved 9; // javanano_as_lite + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message FieldOptions { + // The ctype option instructs the C++ code generator to use a different + // representation of the field than it normally would. See the specific + // options below. This option is not yet implemented in the open source + // release -- sorry, we'll try to include it in a future version! + optional CType ctype = 1 [ default = STRING ]; + enum CType { + // Default mode. + STRING = 0; + + CORD = 1; + + STRING_PIECE = 2; + } + // The packed option can be enabled for repeated primitive fields to enable + // a more efficient representation on the wire. Rather than repeatedly + // writing the tag and type for each element, the entire array is encoded as + // a single length-delimited blob. In proto3, only explicit setting it to + // false will avoid using packed encoding. + optional bool packed = 2; + + // The jstype option determines the JavaScript type used for values of the + // field. The option is permitted only for 64 bit integral and fixed types + // (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + // is represented as JavaScript string, which avoids loss of precision that + // can happen when a large value is converted to a floating point JavaScript. + // Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + // use the JavaScript "number" type. The behavior of the default option + // JS_NORMAL is implementation dependent. + // + // This option is an enum to permit additional types to be added, e.g. + // goog.math.Integer. + optional JSType jstype = 6 [ default = JS_NORMAL ]; + enum JSType { + // Use the default type. + JS_NORMAL = 0; + + // Use JavaScript strings. + JS_STRING = 1; + + // Use JavaScript numbers. + JS_NUMBER = 2; + } + + // Should this field be parsed lazily? Lazy applies only to message-type + // fields. It means that when the outer message is initially parsed, the + // inner message's contents will not be parsed but instead stored in encoded + // form. The inner message will actually be parsed when it is first accessed. + // + // This is only a hint. Implementations are free to choose whether to use + // eager or lazy parsing regardless of the value of this option. However, + // setting this option true suggests that the protocol author believes that + // using lazy parsing on this field is worth the additional bookkeeping + // overhead typically needed to implement it. + // + // This option does not affect the public interface of any generated code; + // all method signatures remain the same. Furthermore, thread-safety of the + // interface is not affected by this option; const methods remain safe to + // call from multiple threads concurrently, while non-const methods continue + // to require exclusive access. + // + // + // Note that implementations may choose not to check required fields within + // a lazy sub-message. That is, calling IsInitialized() on the outer message + // may return true even if the inner message has missing required fields. + // This is necessary because otherwise the inner message would have to be + // parsed in order to perform the check, defeating the purpose of lazy + // parsing. An implementation which chooses not to check required fields + // must be consistent about it. That is, for any particular sub-message, the + // implementation must either *always* check its required fields, or *never* + // check its required fields, regardless of whether or not the message has + // been parsed. + optional bool lazy = 5 [ default = false ]; + + // Is this field deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for accessors, or it will be completely ignored; in the very least, this + // is a formalization for deprecating fields. + optional bool deprecated = 3 [ default = false ]; + + // For Google-internal migration only. Do not use. + optional bool weak = 10 [ default = false ]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; + + reserved 4; // removed jtype +} + +message OneofOptions { + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumOptions { + + // Set this option to true to allow mapping different tag names to the same + // value. + optional bool allow_alias = 2; + + // Is this enum deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum, or it will be completely ignored; in the very least, this + // is a formalization for deprecating enums. + optional bool deprecated = 3 [ default = false ]; + + reserved 5; // javanano_as_lite + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message EnumValueOptions { + // Is this enum value deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the enum value, or it will be completely ignored; in the very least, + // this is a formalization for deprecating enum values. + optional bool deprecated = 1 [ default = false ]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message ServiceOptions { + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this service deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the service, or it will be completely ignored; in the very least, + // this is a formalization for deprecating services. + optional bool deprecated = 33 [ default = false ]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +message MethodOptions { + + // Note: Field numbers 1 through 32 are reserved for Google's internal RPC + // framework. We apologize for hoarding these numbers to ourselves, but + // we were already using them long before we decided to release Protocol + // Buffers. + + // Is this method deprecated? + // Depending on the target platform, this can emit Deprecated annotations + // for the method, or it will be completely ignored; in the very least, + // this is a formalization for deprecating methods. + optional bool deprecated = 33 [ default = false ]; + + // Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + // or neither? HTTP based RPC implementation may choose GET verb for safe + // methods, and PUT verb for idempotent methods instead of the default POST. + enum IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0; + NO_SIDE_EFFECTS = 1; // implies idempotent + IDEMPOTENT = 2; // idempotent, but may have side effects + } + optional IdempotencyLevel idempotency_level = 34 + [ default = IDEMPOTENCY_UNKNOWN ]; + + // The parser stores options it doesn't recognize here. See above. + repeated UninterpretedOption uninterpreted_option = 999; + + // Clients can define custom options in extensions of this message. See above. + extensions 1000 to max; +} + +// A message representing a option the parser does not recognize. This only +// appears in options protos created by the compiler::Parser class. +// DescriptorPool resolves these when building Descriptor objects. Therefore, +// options protos in descriptor objects (e.g. returned by Descriptor::options(), +// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions +// in them. +message UninterpretedOption { + // The name of the uninterpreted option. Each string represents a segment in + // a dot-separated name. is_extension is true iff a segment represents an + // extension (denoted with parentheses in options specs in .proto files). + // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + // "foo.(bar.baz).qux". + message NamePart { + required string name_part = 1; + required bool is_extension = 2; + } + repeated NamePart name = 2; + + // The value of the uninterpreted option, in whatever type the tokenizer + // identified it as during parsing. Exactly one of these should be set. + optional string identifier_value = 3; + optional uint64 positive_int_value = 4; + optional int64 negative_int_value = 5; + optional double double_value = 6; + optional bytes string_value = 7; + optional string aggregate_value = 8; +} + +// =================================================================== +// Optional source code info + +// Encapsulates information about the original source file from which a +// FileDescriptorProto was generated. +message SourceCodeInfo { + // A Location identifies a piece of source code in a .proto file which + // corresponds to a particular definition. This information is intended + // to be useful to IDEs, code indexers, documentation generators, and similar + // tools. + // + // For example, say we have a file like: + // message Foo { + // optional string foo = 1; + // } + // Let's look at just the field definition: + // optional string foo = 1; + // ^ ^^ ^^ ^ ^^^ + // a bc de f ghi + // We have the following locations: + // span path represents + // [a,i) [ 4, 0, 2, 0 ] The whole field definition. + // [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + // [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + // [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + // [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + // + // Notes: + // - A location may refer to a repeated field itself (i.e. not to any + // particular index within it). This is used whenever a set of elements are + // logically enclosed in a single code segment. For example, an entire + // extend block (possibly containing multiple extension definitions) will + // have an outer location whose path refers to the "extensions" repeated + // field without an index. + // - Multiple locations may have the same path. This happens when a single + // logical declaration is spread out across multiple places. The most + // obvious example is the "extend" block again -- there may be multiple + // extend blocks in the same scope, each of which will have the same path. + // - A location's span is not always a subset of its parent's span. For + // example, the "extendee" of an extension declaration appears at the + // beginning of the "extend" block and is shared by all extensions within + // the block. + // - Just because a location's span is a subset of some other location's span + // does not mean that it is a descendant. For example, a "group" defines + // both a type and a field in a single declaration. Thus, the locations + // corresponding to the type and field and their components will overlap. + // - Code which tries to interpret locations should probably be designed to + // ignore those that it doesn't understand, as more types of locations could + // be recorded in the future. + repeated Location location = 1; + message Location { + // Identifies which part of the FileDescriptorProto was defined at this + // location. + // + // Each element is a field number or an index. They form a path from + // the root FileDescriptorProto to the place where the definition. For + // example, this path: + // [ 4, 3, 2, 7, 1 ] + // refers to: + // file.message_type(3) // 4, 3 + // .field(7) // 2, 7 + // .name() // 1 + // This is because FileDescriptorProto.message_type has field number 4: + // repeated DescriptorProto message_type = 4; + // and DescriptorProto.field has field number 2: + // repeated FieldDescriptorProto field = 2; + // and FieldDescriptorProto.name has field number 1: + // optional string name = 1; + // + // Thus, the above path gives the location of a field name. If we removed + // the last element: + // [ 4, 3, 2, 7 ] + // this path refers to the whole field declaration (from the beginning + // of the label to the terminating semicolon). + repeated int32 path = 1 [ packed = true ]; + + // Always has exactly three or four elements: start line, start column, + // end line (optional, otherwise assumed same as start line), end column. + // These are packed into a single field for efficiency. Note that line + // and column numbers are zero-based -- typically you will want to add + // 1 to each before displaying to a user. + repeated int32 span = 2 [ packed = true ]; + + // If this SourceCodeInfo represents a complete declaration, these are any + // comments appearing before and after the declaration which appear to be + // attached to the declaration. + // + // A series of line comments appearing on consecutive lines, with no other + // tokens appearing on those lines, will be treated as a single comment. + // + // leading_detached_comments will keep paragraphs of comments that appear + // before (but not connected to) the current element. Each paragraph, + // separated by empty lines, will be one comment element in the repeated + // field. + // + // Only the comment content is provided; comment markers (e.g. //) are + // stripped out. For block comments, leading whitespace and an asterisk + // will be stripped from the beginning of each line other than the first. + // Newlines are included in the output. + // + // Examples: + // + // optional int32 foo = 1; // Comment attached to foo. + // // Comment attached to bar. + // optional int32 bar = 2; + // + // optional string baz = 3; + // // Comment attached to baz. + // // Another line attached to baz. + // + // // Comment attached to qux. + // // + // // Another line attached to qux. + // optional double qux = 4; + // + // // Detached comment for corge. This is not leading or trailing comments + // // to qux or corge because there are blank lines separating it from + // // both. + // + // // Detached comment for corge paragraph 2. + // + // optional string corge = 5; + // /* Block comment attached + // * to corge. Leading asterisks + // * will be removed. */ + // /* Block comment attached to + // * grault. */ + // optional int32 grault = 6; + // + // // ignored detached comments. + optional string leading_comments = 3; + optional string trailing_comments = 4; + repeated string leading_detached_comments = 6; + } +} + +// Describes the relationship between generated code and its original source +// file. A GeneratedCodeInfo message is associated with only one generated +// source file, but may contain references to different source .proto files. +message GeneratedCodeInfo { + // An Annotation connects some span of text in generated code to an element + // of its generating .proto file. + repeated Annotation annotation = 1; + message Annotation { + // Identifies the element in the original source .proto file. This field + // is formatted the same as SourceCodeInfo.Location.path. + repeated int32 path = 1 [ packed = true ]; + + // Identifies the filesystem path to the original source .proto. + optional string source_file = 2; + + // Identifies the starting offset in bytes in the generated code + // that relates to the identified object. + optional int32 begin = 3; + + // Identifies the ending offset in bytes in the generated code that + // relates to the identified offset. The end offset should be one past + // the last relevant byte (so the length of the text = end - begin). + optional int32 end = 4; + } +} diff --git a/third_party/proto/tendermint/libs/bits/types.proto b/third_party/proto/tendermint/libs/bits/types.proto index 4cae6efd..3111d113 100644 --- a/third_party/proto/tendermint/libs/bits/types.proto +++ b/third_party/proto/tendermint/libs/bits/types.proto @@ -4,6 +4,6 @@ package tendermint.libs.bits; option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits"; message BitArray { - int64 bits = 1; + int64 bits = 1; repeated uint64 elems = 2; } diff --git a/third_party/proto/tendermint/p2p/types.proto b/third_party/proto/tendermint/p2p/types.proto new file mode 100644 index 00000000..0d42ea40 --- /dev/null +++ b/third_party/proto/tendermint/p2p/types.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; +package tendermint.p2p; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/p2p"; + +import "gogoproto/gogo.proto"; + +message NetAddress { + string id = 1 [(gogoproto.customname) = "ID"]; + string ip = 2 [(gogoproto.customname) = "IP"]; + uint32 port = 3; +} + +message ProtocolVersion { + uint64 p2p = 1 [(gogoproto.customname) = "P2P"]; + uint64 block = 2; + uint64 app = 3; +} + +message DefaultNodeInfo { + ProtocolVersion protocol_version = 1 [(gogoproto.nullable) = false]; + string default_node_id = 2 [(gogoproto.customname) = "DefaultNodeID"]; + string listen_addr = 3; + string network = 4; + string version = 5; + bytes channels = 6; + string moniker = 7; + DefaultNodeInfoOther other = 8 [(gogoproto.nullable) = false]; +} + +message DefaultNodeInfoOther { + string tx_index = 1; + string rpc_address = 2 [(gogoproto.customname) = "RPCAddress"]; +} diff --git a/third_party/proto/tendermint/types/block.proto b/third_party/proto/tendermint/types/block.proto new file mode 100644 index 00000000..84e9bb15 --- /dev/null +++ b/third_party/proto/tendermint/types/block.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package tendermint.types; + +option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; + +import "gogoproto/gogo.proto"; +import "tendermint/types/types.proto"; +import "tendermint/types/evidence.proto"; + +message Block { + Header header = 1 [(gogoproto.nullable) = false]; + Data data = 2 [(gogoproto.nullable) = false]; + tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false]; + Commit last_commit = 4; +} diff --git a/third_party/proto/tendermint/types/evidence.proto b/third_party/proto/tendermint/types/evidence.proto index 285cf6e5..3b234571 100644 --- a/third_party/proto/tendermint/types/evidence.proto +++ b/third_party/proto/tendermint/types/evidence.proto @@ -4,29 +4,35 @@ package tendermint.types; option go_package = "github.com/tendermint/tendermint/proto/tendermint/types"; import "gogoproto/gogo.proto"; +import "google/protobuf/timestamp.proto"; import "tendermint/types/types.proto"; - -// DuplicateVoteEvidence contains evidence a validator signed two conflicting -// votes. -message DuplicateVoteEvidence { - Vote vote_a = 1; - Vote vote_b = 2; -} - -message LightClientAttackEvidence { - LightBlock conflicting_block = 1; - int64 common_height = 2; -} +import "tendermint/types/validator.proto"; message Evidence { oneof sum { - DuplicateVoteEvidence duplicate_vote_evidence = 1; + DuplicateVoteEvidence duplicate_vote_evidence = 1; LightClientAttackEvidence light_client_attack_evidence = 2; } } -// EvidenceData contains any evidence of malicious wrong-doing by validators -message EvidenceData { - repeated Evidence evidence = 1 [ (gogoproto.nullable) = false ]; - bytes hash = 2; +// DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. +message DuplicateVoteEvidence { + tendermint.types.Vote vote_a = 1; + tendermint.types.Vote vote_b = 2; + int64 total_voting_power = 3; + int64 validator_power = 4; + google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} + +// LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. +message LightClientAttackEvidence { + tendermint.types.LightBlock conflicting_block = 1; + int64 common_height = 2; + repeated tendermint.types.Validator byzantine_validators = 3; + int64 total_voting_power = 4; + google.protobuf.Timestamp timestamp = 5 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} + +message EvidenceList { + repeated Evidence evidence = 1 [(gogoproto.nullable) = false]; } diff --git a/third_party/proto/tendermint/types/params.proto b/third_party/proto/tendermint/types/params.proto index a709fabb..0de7d846 100644 --- a/third_party/proto/tendermint/types/params.proto +++ b/third_party/proto/tendermint/types/params.proto @@ -11,10 +11,10 @@ option (gogoproto.equal_all) = true; // ConsensusParams contains consensus critical parameters that determine the // validity of blocks. message ConsensusParams { - BlockParams block = 1 [ (gogoproto.nullable) = false ]; - EvidenceParams evidence = 2 [ (gogoproto.nullable) = false ]; - ValidatorParams validator = 3 [ (gogoproto.nullable) = false ]; - VersionParams version = 4 [ (gogoproto.nullable) = false ]; + BlockParams block = 1 [(gogoproto.nullable) = false]; + EvidenceParams evidence = 2 [(gogoproto.nullable) = false]; + ValidatorParams validator = 3 [(gogoproto.nullable) = false]; + VersionParams version = 4 [(gogoproto.nullable) = false]; } // BlockParams contains limits on the block size. @@ -46,20 +46,19 @@ message EvidenceParams { // mechanism for handling [Nothing-At-Stake // attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). google.protobuf.Duration max_age_duration = 2 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + [(gogoproto.nullable) = false, (gogoproto.stdduration) = true]; - // This sets the maximum number of evidence that can be committed in a single - // block. and should fall comfortably under the max block bytes when we - // consider the size of each evidence (See MaxEvidenceBytes). The maximum - // number is MaxEvidencePerBlock. Default is 50 - uint32 max_num = 3; + // This sets the maximum size of total evidence in bytes that can be committed in a single block. + // and should fall comfortably under the max block bytes. + // Default is 1048576 or 1MB + int64 max_bytes = 3; } // ValidatorParams restrict the public key types validators can use. // NOTE: uses ABCI pubkey naming, not Amino names. message ValidatorParams { option (gogoproto.populate) = true; - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; repeated string pub_key_types = 1; } @@ -67,7 +66,7 @@ message ValidatorParams { // VersionParams contains the ABCI application version. message VersionParams { option (gogoproto.populate) = true; - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; uint64 app_version = 1; } @@ -77,5 +76,5 @@ message VersionParams { // It is hashed into the Header.ConsensusHash. message HashedParams { int64 block_max_bytes = 1; - int64 block_max_gas = 2; + int64 block_max_gas = 2; } diff --git a/third_party/proto/tendermint/types/validator.proto b/third_party/proto/tendermint/types/validator.proto index 5e6dc8ba..49860b96 100644 --- a/third_party/proto/tendermint/types/validator.proto +++ b/third_party/proto/tendermint/types/validator.proto @@ -7,19 +7,19 @@ import "gogoproto/gogo.proto"; import "tendermint/crypto/keys.proto"; message ValidatorSet { - repeated Validator validators = 1; - Validator proposer = 2; - int64 total_voting_power = 3; + repeated Validator validators = 1; + Validator proposer = 2; + int64 total_voting_power = 3; } message Validator { - bytes address = 1; - tendermint.crypto.PublicKey pub_key = 2 [ (gogoproto.nullable) = false ]; - int64 voting_power = 3; - int64 proposer_priority = 4; + bytes address = 1; + tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false]; + int64 voting_power = 3; + int64 proposer_priority = 4; } message SimpleValidator { - tendermint.crypto.PublicKey pub_key = 1; - int64 voting_power = 2; + tendermint.crypto.PublicKey pub_key = 1; + int64 voting_power = 2; } diff --git a/third_party/proto/tendermint/version/types.proto b/third_party/proto/tendermint/version/types.proto index 4b7a52dd..6061868b 100644 --- a/third_party/proto/tendermint/version/types.proto +++ b/third_party/proto/tendermint/version/types.proto @@ -13,12 +13,12 @@ message App { string software = 2; } -// Consensus captures the consensus rules for processing a block in the -// blockchain, including all blockchain data structures and the rules of the -// application's state transition machine. +// Consensus captures the consensus rules for processing a block in the blockchain, +// including all blockchain data structures and the rules of the application's +// state transition machine. message Consensus { option (gogoproto.equal) = true; uint64 block = 1; - uint64 app = 2; + uint64 app = 2; } diff --git a/x/evm/client/cli/query.go b/x/evm/client/cli/query.go index f6ce7643..a3e197df 100644 --- a/x/evm/client/cli/query.go +++ b/x/evm/client/cli/query.go @@ -1,12 +1,19 @@ package cli import ( + "math/big" + "strings" + + rpctypes "github.com/cosmos/ethermint/ethereum/rpc/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - rpctypes "github.com/cosmos/ethermint/rpc/types" + "github.com/InjectiveLabs/sdk-go/ethereum/rpc" + "github.com/InjectiveLabs/sdk-go/wrappers" "github.com/cosmos/ethermint/x/evm/types" ) @@ -23,6 +30,8 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand( GetStorageCmd(), GetCodeCmd(), + GetErc20Balance(), + GetAccount(), ) return cmd } @@ -103,3 +112,88 @@ func GetCodeCmd() *cobra.Command { flags.AddQueryFlagsToCmd(cmd) return cmd } + +// GetErc20Balance queries the erc20 balance of an address +func GetErc20Balance() *cobra.Command { + cmd := &cobra.Command{ + Use: "erc20balance [contract] [address]", + Short: "Gets erc20 balance of an account", + Long: "Gets erc20 balance of an account.", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + contract := args[0] + address := args[1] + + erc20ABI, err := abi.JSON(strings.NewReader(wrappers.ERC20ABI)) + if err != nil { + return err + } + input, err := erc20ABI.Pack("balanceOf", common.HexToAddress(address)) + if err != nil { + return err + } + + req := &types.QueryStaticCallRequest{ + Address: contract, + Input: input, + } + + res, err := queryClient.StaticCall(rpc.ContextWithHeight(clientCtx.Height), req) + if err != nil { + return err + } + ret := big.NewInt(0) + err = erc20ABI.UnpackIntoInterface(&ret, "balanceOf", res.Data) + if err != nil { + return err + } + + return clientCtx.PrintString(ret.String()) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} + +// GetAccount queries the account by address +func GetAccount() *cobra.Command { + cmd := &cobra.Command{ + Use: "account [address]", + Short: "Get an account by address", + Long: "Get an account by address", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + address := args[0] + + req := &types.QueryAccountRequest{ + Address: address, + } + + res, err := queryClient.Account(rpc.ContextWithHeight(clientCtx.Height), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd +} diff --git a/x/evm/client/cli/utils.go b/x/evm/client/cli/utils.go index 7277cdae..6114246c 100644 --- a/x/evm/client/cli/utils.go +++ b/x/evm/client/cli/utils.go @@ -45,3 +45,19 @@ func formatKeyToHash(key string) string { return ethkey.Hex() } + +func cosmosAddressFromArg(addr string) (sdk.AccAddress, error) { + if strings.HasPrefix(addr, sdk.GetConfig().GetBech32AccountAddrPrefix()) { + // Check to see if address is Cosmos bech32 formatted + toAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return nil, errors.Wrap(err, "invalid bech32 formatted address") + } + return toAddr, nil + } + + // Strip 0x prefix if exists + addr = strings.TrimPrefix(addr, "0x") + + return sdk.AccAddressFromHex(addr) +} diff --git a/x/evm/client/cli/utils_test.go b/x/evm/client/cli/utils_test.go index ffe18a5a..8ddb3102 100644 --- a/x/evm/client/cli/utils_test.go +++ b/x/evm/client/cli/utils_test.go @@ -61,3 +61,24 @@ func TestCosmosToEthereumTypes(t *testing.T) { require.NoError(t, err) require.Equal(t, hexString, ethDecoded) } + +func TestAddressToCosmosAddress(t *testing.T) { + baseAddr, err := sdk.AccAddressFromHex("6A98D72760f7bbA69d62Ed6F48278451251948E7") + require.NoError(t, err) + + // Test cosmos string back to address + cosmosFormatted, err := cosmosAddressFromArg(baseAddr.String()) + require.NoError(t, err) + require.Equal(t, baseAddr, cosmosFormatted) + + // Test account address from Ethereum address + ethAddr := common.BytesToAddress(baseAddr.Bytes()) + ethFormatted, err := cosmosAddressFromArg(ethAddr.Hex()) + require.NoError(t, err) + require.Equal(t, baseAddr, ethFormatted) + + // Test encoding without the 0x prefix + ethFormatted, err = cosmosAddressFromArg(ethAddr.Hex()[2:]) + require.NoError(t, err) + require.Equal(t, baseAddr, ethFormatted) +} diff --git a/x/evm/client/rest/rest.go b/x/evm/client/rest/rest.go index 01ee019f..380ebb0b 100644 --- a/x/evm/client/rest/rest.go +++ b/x/evm/client/rest/rest.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/rest" authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" - rpctypes "github.com/cosmos/ethermint/rpc/types" + rpctypes "github.com/cosmos/ethermint/ethereum/rpc/types" "github.com/ethereum/go-ethereum/common" ) @@ -81,7 +81,7 @@ func getEthTransactionByHash(clientCtx client.Context, hashHex string) ([]byte, return nil, err } - blockHash := common.BytesToHash(block.Block.Hash()) + blockHash := common.BytesToHash(block.Block.Header.Hash()) ethTx, err := rpctypes.RawTxToEthTx(clientCtx, tx.Tx) if err != nil { diff --git a/x/evm/genesis.go b/x/evm/genesis.go index 731677fb..897b8d93 100644 --- a/x/evm/genesis.go +++ b/x/evm/genesis.go @@ -5,14 +5,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - ethcmn "github.com/ethereum/go-ethereum/common" + abci "github.com/tendermint/tendermint/abci/types" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/x/evm/keeper" "github.com/cosmos/ethermint/x/evm/types" - - abci "github.com/tendermint/tendermint/abci/types" ) // InitGenesis initializes genesis state based on exported genesis diff --git a/x/evm/genesis_test.go b/x/evm/genesis_test.go index 967ad860..4d8c0568 100644 --- a/x/evm/genesis_test.go +++ b/x/evm/genesis_test.go @@ -1,15 +1,17 @@ package evm_test import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "crypto/ecdsa" + "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/golang/protobuf/proto" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/ethermint/crypto/ethsecp256k1" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/x/evm" "github.com/cosmos/ethermint/x/evm/types" - - "github.com/ethereum/go-ethereum/common" - ethcmn "github.com/ethereum/go-ethereum/common" ) func (suite *EvmTestSuite) TestExportImport() { @@ -25,7 +27,7 @@ func (suite *EvmTestSuite) TestInitGenesis() { privkey, err := ethsecp256k1.GenerateKey() suite.Require().NoError(err) - address := ethcmn.HexToAddress(privkey.PubKey().Address().String()) + address := common.HexToAddress(privkey.PubKey().Address().String()) testCases := []struct { name string @@ -45,7 +47,7 @@ func (suite *EvmTestSuite) TestInitGenesis() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, address.Bytes()) suite.Require().NotNil(acc) - err := suite.app.BankKeeper.SetBalance(suite.ctx, address.Bytes(), ethermint.NewPhotonCoinInt64(1)) + err := suite.app.BankKeeper.SetBalance(suite.ctx, address.Bytes(), ethermint.NewInjectiveCoinInt64(1)) suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) }, @@ -115,3 +117,49 @@ func (suite *EvmTestSuite) TestInitGenesis() { }) } } + +func (suite *EvmTestSuite) TestContractExportImport() { + gasLimit := uint64(5000000) + gasPrice := big.NewInt(1) + + priv, err := ethsecp256k1.GenerateKey() + suite.Require().NoError(err, "failed to create key") + + ensFactoryCode := common.FromHex("0x608060405234801561001057600080fd5b50612033806100206000396000f3006080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663e9358b018114610045575b600080fd5b34801561005157600080fd5b5061007373ffffffffffffffffffffffffffffffffffffffff6004351661009c565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60008060006100a961057f565b604051809103906000f0801580156100c5573d6000803e3d6000fd5b50604080517f06ab59230000000000000000000000000000000000000000000000000000000081526000600482018190527f4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f06024830152306044830152915192945073ffffffffffffffffffffffffffffffffffffffff8516926306ab59239260648084019391929182900301818387803b15801561016357600080fd5b505af1158015610177573d6000803e3d6000fd5b505050508161018461058f565b73ffffffffffffffffffffffffffffffffffffffff909116815260405190819003602001906000f0801580156101be573d6000803e3d6000fd5b50604080517f06ab59230000000000000000000000000000000000000000000000000000000081527f93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae60048201527f329539a1d23af1810c48a07fe7fc66a3b34fbc8b37e9b3cdb97bb88ceab7e4bf6024820152306044820152905191925073ffffffffffffffffffffffffffffffffffffffff8416916306ab59239160648082019260009290919082900301818387803b15801561027c57600080fd5b505af1158015610290573d6000803e3d6000fd5b5050604080517f1896f70a0000000000000000000000000000000000000000000000000000000081527ffdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5600482015273ffffffffffffffffffffffffffffffffffffffff858116602483015291519186169350631896f70a925060448082019260009290919082900301818387803b15801561032b57600080fd5b505af115801561033f573d6000803e3d6000fd5b5050604080517fd5fa2b000000000000000000000000000000000000000000000000000000000081527ffdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5600482015273ffffffffffffffffffffffffffffffffffffffff851660248201819052915191935063d5fa2b00925060448082019260009290919082900301818387803b1580156103d957600080fd5b505af11580156103ed573d6000803e3d6000fd5b5050604080517f5b0fc9c30000000000000000000000000000000000000000000000000000000081527f93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae600482015273ffffffffffffffffffffffffffffffffffffffff888116602483015291519186169350635b0fc9c3925060448082019260009290919082900301818387803b15801561048857600080fd5b505af115801561049c573d6000803e3d6000fd5b5050604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260006004820181905273ffffffffffffffffffffffffffffffffffffffff898116602484015292519287169450635b0fc9c39350604480830193919282900301818387803b15801561051657600080fd5b505af115801561052a573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8616815290517fdbfb5ababf63f86424e8df6053dfb90f8b63ea26d7e1e8f68407af4fb2d2c4f29350908190036020019150a15092915050565b60405161064a806105a083390190565b60405161141e80610bea833901905600608060405234801561001057600080fd5b5060008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a031916331790556105f1806100596000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008757806302571be3146100c857806306ab5923146100e057806314ab90381461011657806316a25cbd1461013b5780631896f70a146101705780635b0fc9c3146101a1575b600080fd5b34801561009357600080fd5b5061009f6004356101d2565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100d457600080fd5b5061009f6004356101fd565b3480156100ec57600080fd5b5061011460043560243573ffffffffffffffffffffffffffffffffffffffff60443516610225565b005b34801561012257600080fd5b5061011460043567ffffffffffffffff60243516610311565b34801561014757600080fd5b506101536004356103e7565b6040805167ffffffffffffffff9092168252519081900360200190f35b34801561017c57600080fd5b5061011460043573ffffffffffffffffffffffffffffffffffffffff6024351661041e565b3480156101ad57600080fd5b5061011460043573ffffffffffffffffffffffffffffffffffffffff602435166104f3565b60009081526020819052604090206001015473ffffffffffffffffffffffffffffffffffffffff1690565b60009081526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600083815260208190526040812054849073ffffffffffffffffffffffffffffffffffffffff16331461025757600080fd5b6040805186815260208082018790528251918290038301822073ffffffffffffffffffffffffffffffffffffffff871683529251929450869288927fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8292908290030190a350600090815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff929092169190911790555050565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461034357600080fd5b6040805167ffffffffffffffff84168152905184917f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68919081900360200190a250600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461045057600080fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152905184917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a25060009182526020829052604090912060010180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461052557600080fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152905184917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a25060009182526020829052604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9092169190911790555600a165627a7a723058203213a96a5c5e630e44a93f7fa415f3c625e46c7a560debc4dcf02cff9018ee6e0029608060405234801561001057600080fd5b5060405160208061141e833981016040525160008054600160a060020a03909216600160a060020a03199092169190911790556113cc806100526000396000f3006080604052600436106100c45763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166301ffc9a781146100c957806310f13a8c146101175780632203ab56146101b557806329cd62ea1461024f5780632dff69411461026d5780633b3b57de1461029757806359d1d43c146102d8578063623195b0146103ab578063691f34311461040b5780637737221314610423578063c3d014d614610481578063c86902331461049c578063d5fa2b00146104cd575b600080fd5b3480156100d557600080fd5b506101037fffffffff00000000000000000000000000000000000000000000000000000000600435166104fe565b604080519115158252519081900360200190f35b34801561012357600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526101b395833595369560449491939091019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506107139650505050505050565b005b3480156101c157600080fd5b506101d060043560243561098f565b6040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102135781810151838201526020016101fb565b50505050905090810190601f1680156102405780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b34801561025b57600080fd5b506101b3600435602435604435610a9b565b34801561027957600080fd5b50610285600435610bcb565b60408051918252519081900360200190f35b3480156102a357600080fd5b506102af600435610be1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156102e457600080fd5b5060408051602060046024803582810135601f8101859004850286018501909652858552610336958335953695604494919390910191908190840183828082843750949750610c099650505050505050565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610370578181015183820152602001610358565b50505050905090810190601f16801561039d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103b757600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101b3948235946024803595369594606494920191908190840183828082843750949750610d309650505050505050565b34801561041757600080fd5b50610336600435610e61565b34801561042f57600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526101b3958335953695604494919390910191908190840183828082843750949750610f059650505050505050565b34801561048d57600080fd5b506101b360043560243561108b565b3480156104a857600080fd5b506104b460043561119c565b6040805192835260208301919091528051918290030190f35b3480156104d957600080fd5b506101b360043573ffffffffffffffffffffffffffffffffffffffff602435166111b9565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f3b3b57de00000000000000000000000000000000000000000000000000000000148061059157507fffffffff0000000000000000000000000000000000000000000000000000000082167fd8389dc500000000000000000000000000000000000000000000000000000000145b806105dd57507fffffffff0000000000000000000000000000000000000000000000000000000082167f691f343100000000000000000000000000000000000000000000000000000000145b8061062957507fffffffff0000000000000000000000000000000000000000000000000000000082167f2203ab5600000000000000000000000000000000000000000000000000000000145b8061067557507fffffffff0000000000000000000000000000000000000000000000000000000082167fc869023300000000000000000000000000000000000000000000000000000000145b806106c157507fffffffff0000000000000000000000000000000000000000000000000000000082167f59d1d43c00000000000000000000000000000000000000000000000000000000145b8061070d57507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561078957600080fd5b505af115801561079d573d6000803e3d6000fd5b505050506040513d60208110156107b357600080fd5b505173ffffffffffffffffffffffffffffffffffffffff16146107d557600080fd5b6000848152600160209081526040918290209151855185936005019287929182918401908083835b6020831061083a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107fd565b51815160209384036101000a6000190180199092169116179052920194855250604051938490038101909320845161087b9591949190910192509050611305565b50826040518082805190602001908083835b602083106108ca57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161088d565b51815160209384036101000a60001901801990921691161790526040805192909401829003822081835289518383015289519096508a95507fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a7550948a94508392908301919085019080838360005b8381101561094f578181015183820152602001610937565b50505050905090810190601f16801561097c5780820380516001836020036101000a031916815260200191505b509250505060405180910390a350505050565b60008281526001602081905260409091206060905b838311610a8e57828416158015906109dd5750600083815260068201602052604081205460026000196101006001841615020190911604115b15610a8357600083815260068201602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610a775780601f10610a4c57610100808354040283529160200191610a77565b820191906000526020600020905b815481529060010190602001808311610a5a57829003601f168201915b50505050509150610a93565b6002909202916109a4565b600092505b509250929050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610b1157600080fd5b505af1158015610b25573d6000803e3d6000fd5b505050506040513d6020811015610b3b57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610b5d57600080fd5b604080518082018252848152602080820185815260008881526001835284902092516003840155516004909201919091558151858152908101849052815186927f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e46928290030190a250505050565b6000908152600160208190526040909120015490565b60009081526001602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600082815260016020908152604091829020915183516060936005019285929182918401908083835b60208310610c6f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c32565b518151600019602094850361010090810a820192831692199390931691909117909252949092019687526040805197889003820188208054601f6002600183161590980290950116959095049283018290048202880182019052818752929450925050830182828015610d235780601f10610cf857610100808354040283529160200191610d23565b820191906000526020600020905b815481529060010190602001808311610d0657829003601f168201915b5050505050905092915050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610da657600080fd5b505af1158015610dba573d6000803e3d6000fd5b505050506040513d6020811015610dd057600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610df257600080fd5b6000198301831615610e0357600080fd5b600084815260016020908152604080832086845260060182529091208351610e2d92850190611305565b50604051839085907faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe390600090a350505050565b6000818152600160208181526040928390206002908101805485516000199582161561010002959095011691909104601f81018390048302840183019094528383526060939091830182828015610ef95780601f10610ece57610100808354040283529160200191610ef9565b820191906000526020600020905b815481529060010190602001808311610edc57829003601f168201915b50505050509050919050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610f7b57600080fd5b505af1158015610f8f573d6000803e3d6000fd5b505050506040513d6020811015610fa557600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610fc757600080fd5b60008381526001602090815260409091208351610fec92600290920191850190611305565b50604080516020808252845181830152845186937fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f79387939092839283019185019080838360005b8381101561104c578181015183820152602001611034565b50505050905090810190601f1680156110795780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561110157600080fd5b505af1158015611115573d6000803e3d6000fd5b505050506040513d602081101561112b57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff161461114d57600080fd5b6000838152600160208181526040928390209091018490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600090815260016020526040902060038101546004909101549091565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561122f57600080fd5b505af1158015611243573d6000803e3d6000fd5b505050506040513d602081101561125957600080fd5b505173ffffffffffffffffffffffffffffffffffffffff161461127b57600080fd5b60008381526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86169081179091558251908152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a2505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061134657805160ff1916838001178555611373565b82800160010185558215611373579182015b82811115611373578251825591602001919060010190611358565b5061137f929150611383565b5090565b61139d91905b8082111561137f5760008155600101611389565b905600a165627a7a72305820494d2089cb484863f6172bb6f0ed3b148d6c8eb2a0dd86d330bf08813f99f65d0029a165627a7a72305820df7d6399d923bc8a4fe3d290869ee8614cd2e7d4ac7481c4de85e2df61d183370029") + address := suite.deployContract(ensFactoryCode, 1, gasLimit, gasPrice, priv.ToECDSA()) + + var genState *types.GenesisState + suite.Require().NotPanics(func() { + genState = evm.ExportGenesis(suite.ctx, *suite.app.EvmKeeper, suite.app.AccountKeeper) + }) + + // sanity check that contract was deployed + deployedEnsFactoryCode := common.FromHex("0x6080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663e9358b018114610045575b600080fd5b34801561005157600080fd5b5061007373ffffffffffffffffffffffffffffffffffffffff6004351661009c565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b60008060006100a961057f565b604051809103906000f0801580156100c5573d6000803e3d6000fd5b50604080517f06ab59230000000000000000000000000000000000000000000000000000000081526000600482018190527f4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f06024830152306044830152915192945073ffffffffffffffffffffffffffffffffffffffff8516926306ab59239260648084019391929182900301818387803b15801561016357600080fd5b505af1158015610177573d6000803e3d6000fd5b505050508161018461058f565b73ffffffffffffffffffffffffffffffffffffffff909116815260405190819003602001906000f0801580156101be573d6000803e3d6000fd5b50604080517f06ab59230000000000000000000000000000000000000000000000000000000081527f93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae60048201527f329539a1d23af1810c48a07fe7fc66a3b34fbc8b37e9b3cdb97bb88ceab7e4bf6024820152306044820152905191925073ffffffffffffffffffffffffffffffffffffffff8416916306ab59239160648082019260009290919082900301818387803b15801561027c57600080fd5b505af1158015610290573d6000803e3d6000fd5b5050604080517f1896f70a0000000000000000000000000000000000000000000000000000000081527ffdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5600482015273ffffffffffffffffffffffffffffffffffffffff858116602483015291519186169350631896f70a925060448082019260009290919082900301818387803b15801561032b57600080fd5b505af115801561033f573d6000803e3d6000fd5b5050604080517fd5fa2b000000000000000000000000000000000000000000000000000000000081527ffdd5d5de6dd63db72bbc2d487944ba13bf775b50a80805fe6fcaba9b0fba88f5600482015273ffffffffffffffffffffffffffffffffffffffff851660248201819052915191935063d5fa2b00925060448082019260009290919082900301818387803b1580156103d957600080fd5b505af11580156103ed573d6000803e3d6000fd5b5050604080517f5b0fc9c30000000000000000000000000000000000000000000000000000000081527f93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae600482015273ffffffffffffffffffffffffffffffffffffffff888116602483015291519186169350635b0fc9c3925060448082019260009290919082900301818387803b15801561048857600080fd5b505af115801561049c573d6000803e3d6000fd5b5050604080517f5b0fc9c300000000000000000000000000000000000000000000000000000000815260006004820181905273ffffffffffffffffffffffffffffffffffffffff898116602484015292519287169450635b0fc9c39350604480830193919282900301818387803b15801561051657600080fd5b505af115801561052a573d6000803e3d6000fd5b50506040805173ffffffffffffffffffffffffffffffffffffffff8616815290517fdbfb5ababf63f86424e8df6053dfb90f8b63ea26d7e1e8f68407af4fb2d2c4f29350908190036020019150a15092915050565b60405161064a806105a083390190565b60405161141e80610bea833901905600608060405234801561001057600080fd5b5060008080526020527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb58054600160a060020a031916331790556105f1806100596000396000f3006080604052600436106100825763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630178b8bf811461008757806302571be3146100c857806306ab5923146100e057806314ab90381461011657806316a25cbd1461013b5780631896f70a146101705780635b0fc9c3146101a1575b600080fd5b34801561009357600080fd5b5061009f6004356101d2565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100d457600080fd5b5061009f6004356101fd565b3480156100ec57600080fd5b5061011460043560243573ffffffffffffffffffffffffffffffffffffffff60443516610225565b005b34801561012257600080fd5b5061011460043567ffffffffffffffff60243516610311565b34801561014757600080fd5b506101536004356103e7565b6040805167ffffffffffffffff9092168252519081900360200190f35b34801561017c57600080fd5b5061011460043573ffffffffffffffffffffffffffffffffffffffff6024351661041e565b3480156101ad57600080fd5b5061011460043573ffffffffffffffffffffffffffffffffffffffff602435166104f3565b60009081526020819052604090206001015473ffffffffffffffffffffffffffffffffffffffff1690565b60009081526020819052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600083815260208190526040812054849073ffffffffffffffffffffffffffffffffffffffff16331461025757600080fd5b6040805186815260208082018790528251918290038301822073ffffffffffffffffffffffffffffffffffffffff871683529251929450869288927fce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e8292908290030190a350600090815260208190526040902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff929092169190911790555050565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461034357600080fd5b6040805167ffffffffffffffff84168152905184917f1d4f9bbfc9cab89d66e1a1562f2233ccbf1308cb4f63de2ead5787adddb8fa68919081900360200190a250600091825260208290526040909120600101805467ffffffffffffffff90921674010000000000000000000000000000000000000000027fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff909216919091179055565b60009081526020819052604090206001015474010000000000000000000000000000000000000000900467ffffffffffffffff1690565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461045057600080fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152905184917f335721b01866dc23fbee8b6b2c7b1e14d6f05c28cd35a2c934239f94095602a0919081900360200190a25060009182526020829052604090912060010180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b600082815260208190526040902054829073ffffffffffffffffffffffffffffffffffffffff16331461052557600080fd5b6040805173ffffffffffffffffffffffffffffffffffffffff84168152905184917fd4735d920b0f87494915f556dd9b54c8f309026070caea5c737245152564d266919081900360200190a25060009182526020829052604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9092169190911790555600a165627a7a723058203213a96a5c5e630e44a93f7fa415f3c625e46c7a560debc4dcf02cff9018ee6e0029608060405234801561001057600080fd5b5060405160208061141e833981016040525160008054600160a060020a03909216600160a060020a03199092169190911790556113cc806100526000396000f3006080604052600436106100c45763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166301ffc9a781146100c957806310f13a8c146101175780632203ab56146101b557806329cd62ea1461024f5780632dff69411461026d5780633b3b57de1461029757806359d1d43c146102d8578063623195b0146103ab578063691f34311461040b5780637737221314610423578063c3d014d614610481578063c86902331461049c578063d5fa2b00146104cd575b600080fd5b3480156100d557600080fd5b506101037fffffffff00000000000000000000000000000000000000000000000000000000600435166104fe565b604080519115158252519081900360200190f35b34801561012357600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526101b395833595369560449491939091019190819084018382808284375050604080516020601f89358b018035918201839004830284018301909452808352979a9998810197919650918201945092508291508401838280828437509497506107139650505050505050565b005b3480156101c157600080fd5b506101d060043560243561098f565b6040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102135781810151838201526020016101fb565b50505050905090810190601f1680156102405780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b34801561025b57600080fd5b506101b3600435602435604435610a9b565b34801561027957600080fd5b50610285600435610bcb565b60408051918252519081900360200190f35b3480156102a357600080fd5b506102af600435610be1565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156102e457600080fd5b5060408051602060046024803582810135601f8101859004850286018501909652858552610336958335953695604494919390910191908190840183828082843750949750610c099650505050505050565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610370578181015183820152602001610358565b50505050905090810190601f16801561039d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156103b757600080fd5b50604080516020600460443581810135601f81018490048402850184019095528484526101b3948235946024803595369594606494920191908190840183828082843750949750610d309650505050505050565b34801561041757600080fd5b50610336600435610e61565b34801561042f57600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526101b3958335953695604494919390910191908190840183828082843750949750610f059650505050505050565b34801561048d57600080fd5b506101b360043560243561108b565b3480156104a857600080fd5b506104b460043561119c565b6040805192835260208301919091528051918290030190f35b3480156104d957600080fd5b506101b360043573ffffffffffffffffffffffffffffffffffffffff602435166111b9565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f3b3b57de00000000000000000000000000000000000000000000000000000000148061059157507fffffffff0000000000000000000000000000000000000000000000000000000082167fd8389dc500000000000000000000000000000000000000000000000000000000145b806105dd57507fffffffff0000000000000000000000000000000000000000000000000000000082167f691f343100000000000000000000000000000000000000000000000000000000145b8061062957507fffffffff0000000000000000000000000000000000000000000000000000000082167f2203ab5600000000000000000000000000000000000000000000000000000000145b8061067557507fffffffff0000000000000000000000000000000000000000000000000000000082167fc869023300000000000000000000000000000000000000000000000000000000145b806106c157507fffffffff0000000000000000000000000000000000000000000000000000000082167f59d1d43c00000000000000000000000000000000000000000000000000000000145b8061070d57507fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a700000000000000000000000000000000000000000000000000000000145b92915050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561078957600080fd5b505af115801561079d573d6000803e3d6000fd5b505050506040513d60208110156107b357600080fd5b505173ffffffffffffffffffffffffffffffffffffffff16146107d557600080fd5b6000848152600160209081526040918290209151855185936005019287929182918401908083835b6020831061083a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107fd565b51815160209384036101000a6000190180199092169116179052920194855250604051938490038101909320845161087b9591949190910192509050611305565b50826040518082805190602001908083835b602083106108ca57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161088d565b51815160209384036101000a60001901801990921691161790526040805192909401829003822081835289518383015289519096508a95507fd8c9334b1a9c2f9da342a0a2b32629c1a229b6445dad78947f674b44444a7550948a94508392908301919085019080838360005b8381101561094f578181015183820152602001610937565b50505050905090810190601f16801561097c5780820380516001836020036101000a031916815260200191505b509250505060405180910390a350505050565b60008281526001602081905260409091206060905b838311610a8e57828416158015906109dd5750600083815260068201602052604081205460026000196101006001841615020190911604115b15610a8357600083815260068201602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610a775780601f10610a4c57610100808354040283529160200191610a77565b820191906000526020600020905b815481529060010190602001808311610a5a57829003601f168201915b50505050509150610a93565b6002909202916109a4565b600092505b509250929050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610b1157600080fd5b505af1158015610b25573d6000803e3d6000fd5b505050506040513d6020811015610b3b57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610b5d57600080fd5b604080518082018252848152602080820185815260008881526001835284902092516003840155516004909201919091558151858152908101849052815186927f1d6f5e03d3f63eb58751986629a5439baee5079ff04f345becb66e23eb154e46928290030190a250505050565b6000908152600160208190526040909120015490565b60009081526001602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b600082815260016020908152604091829020915183516060936005019285929182918401908083835b60208310610c6f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c32565b518151600019602094850361010090810a820192831692199390931691909117909252949092019687526040805197889003820188208054601f6002600183161590980290950116959095049283018290048202880182019052818752929450925050830182828015610d235780601f10610cf857610100808354040283529160200191610d23565b820191906000526020600020905b815481529060010190602001808311610d0657829003601f168201915b5050505050905092915050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810187905290518693339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610da657600080fd5b505af1158015610dba573d6000803e3d6000fd5b505050506040513d6020811015610dd057600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610df257600080fd5b6000198301831615610e0357600080fd5b600084815260016020908152604080832086845260060182529091208351610e2d92850190611305565b50604051839085907faa121bbeef5f32f5961a2a28966e769023910fc9479059ee3495d4c1a696efe390600090a350505050565b6000818152600160208181526040928390206002908101805485516000199582161561010002959095011691909104601f81018390048302840183019094528383526060939091830182828015610ef95780601f10610ece57610100808354040283529160200191610ef9565b820191906000526020600020905b815481529060010190602001808311610edc57829003601f168201915b50505050509050919050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b158015610f7b57600080fd5b505af1158015610f8f573d6000803e3d6000fd5b505050506040513d6020811015610fa557600080fd5b505173ffffffffffffffffffffffffffffffffffffffff1614610fc757600080fd5b60008381526001602090815260409091208351610fec92600290920191850190611305565b50604080516020808252845181830152845186937fb7d29e911041e8d9b843369e890bcb72c9388692ba48b65ac54e7214c4c348f79387939092839283019185019080838360005b8381101561104c578181015183820152602001611034565b50505050905090810190601f1680156110795780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505050565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561110157600080fd5b505af1158015611115573d6000803e3d6000fd5b505050506040513d602081101561112b57600080fd5b505173ffffffffffffffffffffffffffffffffffffffff161461114d57600080fd5b6000838152600160208181526040928390209091018490558151848152915185927f0424b6fe0d9c3bdbece0e7879dc241bb0c22e900be8b6c168b4ee08bd9bf83bc92908290030190a2505050565b600090815260016020526040902060038101546004909101549091565b60008054604080517f02571be30000000000000000000000000000000000000000000000000000000081526004810186905290518593339373ffffffffffffffffffffffffffffffffffffffff16926302571be39260248083019360209383900390910190829087803b15801561122f57600080fd5b505af1158015611243573d6000803e3d6000fd5b505050506040513d602081101561125957600080fd5b505173ffffffffffffffffffffffffffffffffffffffff161461127b57600080fd5b60008381526001602090815260409182902080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff86169081179091558251908152915185927f52d7d861f09ab3d26239d492e8968629f95e9e318cf0b73bfddc441522a15fd292908290030190a2505050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061134657805160ff1916838001178555611373565b82800160010185558215611373579182015b82811115611373578251825591602001919060010190611358565b5061137f929150611383565b5090565b61139d91905b8082111561137f5760008155600101611389565b905600a165627a7a72305820494d2089cb484863f6172bb6f0ed3b148d6c8eb2a0dd86d330bf08813f99f65d0029a165627a7a72305820df7d6399d923bc8a4fe3d290869ee8614cd2e7d4ac7481c4de85e2df61d183370029") + code := suite.app.EvmKeeper.GetCode(suite.ctx, address) + suite.Require().Equal(deployedEnsFactoryCode, code) + + suite.T().Logf("account address 0x%s", priv.PubKey().Address()) + suite.T().Logf("contract addr 0x%x", address) + + // clear keeper code and re-initialize + suite.app.EvmKeeper.SetCode(suite.ctx, address, nil) + _ = evm.InitGenesis(suite.ctx, *suite.app.EvmKeeper, suite.app.AccountKeeper, suite.app.BankKeeper, *genState) + + resCode := suite.app.EvmKeeper.GetCode(suite.ctx, address) + suite.Require().Equal(deployedEnsFactoryCode, resCode) +} + +func (suite *EvmTestSuite) deployContract(code []byte, nonce, gasLimit uint64, gasPrice *big.Int, priv *ecdsa.PrivateKey) common.Address { + tx := types.NewMsgEthereumTx(nonce, nil, big.NewInt(0), gasLimit, gasPrice, code) + err := tx.Sign(big.NewInt(888), priv) + suite.Require().NoError(err) + + result, err := suite.handler(suite.ctx, tx) + suite.Require().NoError(err, "failed to handle eth tx msg") + + var resp types.MsgEthereumTxResponse + err = proto.Unmarshal(result.Data, &resp) + suite.Require().NoError(err, "failed to unmarshal tx result") + + return common.HexToAddress(resp.ContractAddress) +} diff --git a/x/evm/handler.go b/x/evm/handler.go index a3d68a03..4bf9f496 100644 --- a/x/evm/handler.go +++ b/x/evm/handler.go @@ -2,53 +2,23 @@ package evm import ( "fmt" - "time" + "runtime/debug" + + log "github.com/xlab/suplog" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + ethcmn "github.com/ethereum/go-ethereum/common" "github.com/cosmos/ethermint/x/evm/keeper" "github.com/cosmos/ethermint/x/evm/types" - - ethcmn "github.com/ethereum/go-ethereum/common" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // NewHandler returns a handler for Ethermint type messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - defer telemetry.MeasureSince(time.Now(), "evm", "state_transition") +func NewHandler(k *keeper.Keeper) sdk.Handler { + return func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) { + defer Recover(&err) - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - snapshotStateDB := k.CommitStateDB.Copy() - - // The "recover" code here is used to solve the problem of dirty data - // in CommitStateDB due to insufficient gas. - - // The following is a detailed description: - // If the gas is insufficient during the execution of the "handler", - // panic will be thrown from the function "ConsumeGas" and finally - // caught by the function "runTx" from Cosmos. The function "runTx" - // will think that the execution of Msg has failed and the modified - // data in the Store will not take effect. - - // Stacktrace:runTx->runMsgs->handler->...->gaskv.Store.Set->ConsumeGas - - // The problem is that when the modified data in the Store does not take - // effect, the data in the modified CommitStateDB is not rolled back, - // they take effect, and dirty data is generated. - // Therefore, the code here specifically deals with this situation. - // See https://github.com/cosmos/ethermint/issues/668 for more information. - defer func() { - if r := recover(); r != nil { - // We first used "k.CommitStateDB = snapshotStateDB" to roll back - // CommitStateDB, but this can only change the CommitStateDB in the - // current Keeper object, but the Keeper object will be destroyed - // soon, it is not a global variable, so the content pointed to by - // the CommitStateDB pointer can be modified to take effect. - types.CopyCommitStateDB(snapshotStateDB, k.CommitStateDB) - panic(r) - } - }() ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { @@ -56,11 +26,8 @@ func NewHandler(k keeper.Keeper) sdk.Handler { // execute state transition res, err := k.EthereumTx(sdk.WrapSDKContext(ctx), msg) if err != nil { - return nil, err - } - - result, err := sdk.WrapServiceResult(ctx, res, err) - if err != nil { + return sdk.WrapServiceResult(ctx, res, err) + } else if result, err = sdk.WrapServiceResult(ctx, res, nil); err != nil { return nil, err } @@ -69,22 +36,48 @@ func NewHandler(k keeper.Keeper) sdk.Handler { if res.ContractAddress != "" { recipientLog = fmt.Sprintf("contract address %s", res.ContractAddress) } else { - recipientLog = fmt.Sprintf("recipient address %s", msg.Data.Recipient) + var recipient string + if to := msg.To(); to != nil { + recipient = to.Hex() + } + + recipientLog = fmt.Sprintf("recipient address %s", recipient) } sender := ethcmn.BytesToAddress(msg.GetFrom().Bytes()) - log := fmt.Sprintf( - "executed EVM state transition; sender address %s; %s", sender, recipientLog, - ) - - k.Logger(ctx).Info(log) - result.Log = log + if res.Reverted { + result.Log = "transaction reverted" + log := fmt.Sprintf( + "reverted EVM state transition; sender address %s; %s", sender.Hex(), recipientLog, + ) + k.Logger(ctx).Info(log) + } else { + log := fmt.Sprintf( + "executed EVM state transition; sender address %s; %s", sender.Hex(), recipientLog, + ) + result.Log = log + k.Logger(ctx).Info(log) + } return result, nil default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + err := sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) + return nil, err + } + } +} + +func Recover(err *error) { + if r := recover(); r != nil { + *err = sdkerrors.Wrapf(sdkerrors.ErrPanic, "%v", r) + + if e, ok := r.(error); ok { + log.WithError(e).Errorln("evm msg handler panicked with an error") + log.Debugln(string(debug.Stack())) + } else { + log.Errorln(r) } } } diff --git a/x/evm/handler_test.go b/x/evm/handler_test.go index 961b03cf..f843ae77 100644 --- a/x/evm/handler_test.go +++ b/x/evm/handler_test.go @@ -33,7 +33,7 @@ type EvmTestSuite struct { ctx sdk.Context handler sdk.Handler - app *app.EthermintApp + app *app.InjectiveApp codec codec.BinaryMarshaler privKey *ethsecp256k1.PrivKey @@ -45,8 +45,8 @@ func (suite *EvmTestSuite) SetupTest() { checkTx := false suite.app = app.Setup(checkTx) - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, ChainID: "ethermint-3", Time: time.Now().UTC()}) - suite.handler = evm.NewHandler(*suite.app.EvmKeeper) + suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, ChainID: "888", Time: time.Now().UTC()}) + suite.handler = evm.NewHandler(suite.app.EvmKeeper) suite.codec = suite.app.AppCodec() privKey, err := ethsecp256k1.GenerateKey() @@ -78,7 +78,7 @@ func (suite *EvmTestSuite) TestHandleMsgEthereumTx() { "passed", func() { suite.app.EvmKeeper.SetBalance(suite.ctx, suite.from, big.NewInt(100)) - tx = types.NewMsgEthereumTx(0, &suite.from, big.NewInt(0), 0, big.NewInt(10000), nil) + tx = types.NewMsgEthereumTx(0, &suite.from, big.NewInt(100), 0, big.NewInt(10000), nil) // parse context chain ID to big.Int chainID, err := ethermint.ParseChainID(suite.ctx.ChainID()) @@ -176,7 +176,7 @@ func (suite *EvmTestSuite) TestHandlerLogs() { bytecode := common.FromHex("0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029") tx := types.NewMsgEthereumTx(1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode) - err = tx.Sign(big.NewInt(3), priv.ToECDSA()) + err = tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err := suite.handler(suite.ctx, tx) @@ -195,34 +195,7 @@ func (suite *EvmTestSuite) TestHandlerLogs() { logs, err := suite.app.EvmKeeper.GetLogs(suite.ctx, ethcmn.BytesToHash(hash)) suite.Require().NoError(err, "failed to get logs") - suite.Require().Equal(len(logs), len(txResponse.TxLogs.Logs)) - - for i, logI := range logs { - for j, logJ := range txResponse.TxLogs.Logs { - if i != j { - continue - } - suite.Require().Equal(uint64(logI.Index), logJ.Index) - suite.Require().Equal(logI.Data, logJ.Data) - suite.Require().Equal(logI.Address.String(), logJ.Address) - suite.Require().Equal(logI.BlockHash.String(), logJ.BlockHash) - suite.Require().Equal(logI.BlockNumber, logJ.BlockNumber) - suite.Require().Equal(logI.Removed, logJ.Removed) - suite.Require().Equal(logI.TxHash.String(), logJ.TxHash) - suite.Require().Equal(uint64(logI.TxIndex), logJ.TxIndex) - - suite.Require().Equal(len(logI.Topics), len(logJ.Topics)) - - for i2, topicI := range logI.Topics { - for j2, topicJ := range logJ.Topics { - if i2 != j2 { - continue - } - suite.Require().Equal(topicI.String(), topicJ) - } - } - } - } + suite.Require().Equal(logs, txResponse.TxLogs.Logs) } func (suite *EvmTestSuite) TestQueryTxLogs() { @@ -235,7 +208,7 @@ func (suite *EvmTestSuite) TestQueryTxLogs() { // send contract deployment transaction with an event in the constructor bytecode := common.FromHex("0x6080604052348015600f57600080fd5b5060117f775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd73889860405160405180910390a2603580604b6000396000f3fe6080604052600080fdfea165627a7a723058206cab665f0f557620554bb45adf266708d2bd349b8a4314bdff205ee8440e3c240029") tx := types.NewMsgEthereumTx(1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode) - err = tx.Sign(big.NewInt(3), priv.ToECDSA()) + err = tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err := suite.handler(suite.ctx, tx) @@ -321,7 +294,7 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { bytecode := common.FromHex("0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a36102c4806100dc6000396000f3fe608060405234801561001057600080fd5b5060043610610053576000357c010000000000000000000000000000000000000000000000000000000090048063893d20e814610058578063a6f9dae1146100a2575b600080fd5b6100606100e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100e4600480360360208110156100b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061010f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f43616c6c6572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fea265627a7a72315820f397f2733a89198bc7fed0764083694c5b828791f39ebcbc9e414bccef14b48064736f6c63430005100032") tx := types.NewMsgEthereumTx(1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode) - tx.Sign(big.NewInt(3), priv.ToECDSA()) + tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err := suite.handler(suite.ctx, tx) @@ -338,7 +311,7 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { storeAddr := "0xa6f9dae10000000000000000000000006a82e4a67715c8412a9114fbd2cbaefbc8181424" bytecode = common.FromHex(storeAddr) tx = types.NewMsgEthereumTx(2, &receiver, big.NewInt(0), gasLimit, gasPrice, bytecode) - tx.Sign(big.NewInt(3), priv.ToECDSA()) + tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err = suite.handler(suite.ctx, tx) @@ -350,7 +323,7 @@ func (suite *EvmTestSuite) TestDeployAndCallContract() { // query - getOwner bytecode = common.FromHex("0x893d20e8") tx = types.NewMsgEthereumTx(2, &receiver, big.NewInt(0), gasLimit, gasPrice, bytecode) - tx.Sign(big.NewInt(3), priv.ToECDSA()) + tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err = suite.handler(suite.ctx, tx) @@ -375,7 +348,7 @@ func (suite *EvmTestSuite) TestSendTransaction() { // send simple value transfer with gasLimit=21000 tx := types.NewMsgEthereumTx(1, ðcmn.Address{0x1}, big.NewInt(1), gasLimit, gasPrice, nil) - err = tx.Sign(big.NewInt(3), priv.ToECDSA()) + err = tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) result, err := suite.handler(suite.ctx, tx) @@ -448,7 +421,7 @@ func (suite *EvmTestSuite) TestOutOfGasWhenDeployContract() { bytecode := common.FromHex("0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a36102c4806100dc6000396000f3fe608060405234801561001057600080fd5b5060043610610053576000357c010000000000000000000000000000000000000000000000000000000090048063893d20e814610058578063a6f9dae1146100a2575b600080fd5b6100606100e6565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b6100e4600480360360208110156100b857600080fd5b81019080803573ffffffffffffffffffffffffffffffffffffffff16906020019092919050505061010f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146101d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260138152602001807f43616c6c6572206973206e6f74206f776e65720000000000000000000000000081525060200191505060405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff166000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f342827c97908e5e2f71151c08502a66d44b6f758e3ac2f1de95f02eb95f0a73560405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505056fea265627a7a72315820f397f2733a89198bc7fed0764083694c5b828791f39ebcbc9e414bccef14b48064736f6c63430005100032") tx := types.NewMsgEthereumTx(1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode) - tx.Sign(big.NewInt(3), priv.ToECDSA()) + tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) snapshotCommitStateDBJson, err := json.Marshal(suite.app.EvmKeeper.CommitStateDB) @@ -478,7 +451,7 @@ func (suite *EvmTestSuite) TestErrorWhenDeployContract() { bytecode := common.FromHex("0xa6f9dae10000000000000000000000006a82e4a67715c8412a9114fbd2cbaefbc8181424") tx := types.NewMsgEthereumTx(1, nil, big.NewInt(0), gasLimit, gasPrice, bytecode) - tx.Sign(big.NewInt(3), priv.ToECDSA()) + tx.Sign(big.NewInt(888), priv.ToECDSA()) suite.Require().NoError(err) snapshotCommitStateDBJson, err := json.Marshal(suite.app.EvmKeeper.CommitStateDB) diff --git a/x/evm/keeper/abci.go b/x/evm/keeper/abci.go index da39e10e..d4641bb2 100644 --- a/x/evm/keeper/abci.go +++ b/x/evm/keeper/abci.go @@ -3,29 +3,29 @@ package keeper import ( "math/big" - abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/ethermint/metrics" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + abci "github.com/tendermint/tendermint/abci/types" ) -// BeginBlock sets the block height -> header hash map for the previous block height +// BeginBlock sets the block hash -> block height map for the previous block height // and resets the Bloom filter and the transaction count to 0. func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { - if req.Header.LastBlockId.GetHash() == nil || req.Header.GetHeight() < 1 { + if req.Header.Height < 1 { return } // Gas costs are handled within msg handler so costs should be ignored ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) - // Set the hash -> height and height -> hash mapping. - currentHash := req.Hash - height := req.Header.GetHeight() + k.SetBlockHash(ctx, req.Hash, req.Header.Height) + k.SetBlockHeightToHash(ctx, req.Hash, req.Header.Height) - k.SetHeightHash(ctx, uint64(height), common.BytesToHash(hash)) + // special setter for csdb + k.SetHeightHash(ctx, uint64(req.Header.Height), common.BytesToHash(req.Hash)) // reset counters that are used on CommitStateDB.Prepare k.Bloom = big.NewInt(0) @@ -37,6 +37,10 @@ func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { // the store. The EVM end block logic doesn't update the validator set, thus it returns // an empty slice. func (k Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + // Gas costs are handled within msg handler so costs should be ignored ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) diff --git a/x/evm/keeper/abci_test.go b/x/evm/keeper/abci_test.go deleted file mode 100644 index 6ffc85b6..00000000 --- a/x/evm/keeper/abci_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package keeper_test - -import ( - abci "github.com/tendermint/tendermint/abci/types" -) - -func (suite *KeeperTestSuite) TestBeginBlock() { - // update the counters - suite.app.EvmKeeper.Bloom.SetInt64(10) - suite.app.EvmKeeper.TxCount = 10 - - suite.app.EvmKeeper.BeginBlock(suite.ctx, abci.RequestBeginBlock{}) - suite.Require().NotZero(suite.app.EvmKeeper.Bloom.Int64()) - suite.Require().NotZero(suite.app.EvmKeeper.TxCount) -} - -func (suite *KeeperTestSuite) TestEndBlock() { - // update the counters - suite.app.EvmKeeper.Bloom.SetInt64(10) - - // set gas limit to 1 to ensure no gas is consumed during the operation - initialConsumed := suite.ctx.GasMeter().GasConsumed() - - _ = suite.app.EvmKeeper.EndBlock(suite.ctx, abci.RequestEndBlock{Height: 100}) - - suite.Require().Equal(int64(initialConsumed), int64(suite.ctx.GasMeter().GasConsumed())) - - bloom, found := suite.app.EvmKeeper.GetBlockBloom(suite.ctx, 100) - suite.Require().True(found) - suite.Require().Equal(int64(10), bloom.Big().Int64()) - -} diff --git a/x/evm/keeper/grpc_query.go b/x/evm/keeper/grpc_query.go index 29d16a01..33aea3d9 100644 --- a/x/evm/keeper/grpc_query.go +++ b/x/evm/keeper/grpc_query.go @@ -2,14 +2,17 @@ package keeper import ( "context" + "math/big" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" + tmtypes "github.com/tendermint/tendermint/types" ethcmn "github.com/ethereum/go-ethereum/common" + "github.com/cosmos/ethermint/metrics" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/x/evm/types" ) @@ -17,12 +20,18 @@ import ( var _ types.QueryServer = Keeper{} // Account implements the Query/Account gRPC method -func (q Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*types.QueryAccountResponse, error) { +func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*types.QueryAccountResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } - if len(req.Address) == 0 { + if types.IsZeroAddress(req.Address) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrZeroAddress.Error(), @@ -30,9 +39,10 @@ func (q Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*typ } ctx := sdk.UnwrapSDKContext(c) - so := q.GetOrNewStateObject(ctx, ethcmn.HexToAddress(req.Address)) + so := k.GetOrNewStateObject(ctx, ethcmn.HexToAddress(req.Address)) balance, err := ethermint.MarshalBigInt(so.Balance()) if err != nil { + metrics.ReportFuncError(k.svcTags) return nil, err } @@ -43,13 +53,18 @@ func (q Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*typ }, nil } -// Balance implements the Query/Balance gRPC method -func (q Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { +func (k Keeper) CosmosAccount(c context.Context, req *types.QueryCosmosAccountRequest) (*types.QueryCosmosAccountResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } - if len(req.Address) == 0 { + if types.IsZeroAddress(req.Address) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrZeroAddress.Error(), @@ -58,9 +73,48 @@ func (q Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*typ ctx := sdk.UnwrapSDKContext(c) - balanceInt := q.GetBalance(ctx, ethcmn.HexToAddress(req.Address)) + ethStr := req.Address + ethAddr := ethcmn.FromHex(ethStr) + + ethToCosmosAddr := sdk.AccAddress(ethAddr[:]).String() + cosmosToEthAddr, _ := sdk.AccAddressFromBech32(ethToCosmosAddr) + + acc := k.accountKeeper.GetAccount(ctx, cosmosToEthAddr) + res := types.QueryCosmosAccountResponse{ + CosmosAddress: cosmosToEthAddr.String(), + } + if acc != nil { + res.Sequence = acc.GetSequence() + res.AccountNumber = acc.GetAccountNumber() + } + return &res, nil +} + +// Balance implements the Query/Balance gRPC method +func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*types.QueryBalanceResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if types.IsZeroAddress(req.Address) { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error( + codes.InvalidArgument, + types.ErrZeroAddress.Error(), + ) + } + + ctx := sdk.UnwrapSDKContext(c) + + balanceInt := k.GetBalance(ctx, ethcmn.HexToAddress(req.Address)) balance, err := ethermint.MarshalBigInt(balanceInt) if err != nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.Internal, "failed to marshal big.Int to string", @@ -73,31 +127,30 @@ func (q Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*typ } // Storage implements the Query/Storage gRPC method -func (q Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*types.QueryStorageResponse, error) { +func (k Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*types.QueryStorageResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } - if len(req.Address) == 0 { + if types.IsZeroAddress(req.Address) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrZeroAddress.Error(), ) } - if len(req.Key) == 0 { - return nil, status.Error( - codes.InvalidArgument, - types.ErrEmptyHash.Error(), - ) - } - ctx := sdk.UnwrapSDKContext(c) address := ethcmn.HexToAddress(req.Address) key := ethcmn.HexToHash(req.Key) - state := q.GetState(ctx, address, key) + state := k.GetState(ctx, address, key) return &types.QueryStorageResponse{ Value: state.String(), @@ -105,12 +158,18 @@ func (q Keeper) Storage(c context.Context, req *types.QueryStorageRequest) (*typ } // Code implements the Query/Code gRPC method -func (q Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error) { +func (k Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.QueryCodeResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } - if len(req.Address) == 0 { + if types.IsZeroAddress(req.Address) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrZeroAddress.Error(), @@ -120,7 +179,7 @@ func (q Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.Que ctx := sdk.UnwrapSDKContext(c) address := ethcmn.HexToAddress(req.Address) - code := q.GetCode(ctx, address) + code := k.GetCode(ctx, address) return &types.QueryCodeResponse{ Code: code, @@ -128,12 +187,18 @@ func (q Keeper) Code(c context.Context, req *types.QueryCodeRequest) (*types.Que } // TxLogs implements the Query/TxLogs gRPC method -func (q Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types.QueryTxLogsResponse, error) { +func (k Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types.QueryTxLogsResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } if types.IsEmptyHash(req.Hash) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrEmptyHash.Error(), @@ -143,8 +208,9 @@ func (q Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types ctx := sdk.UnwrapSDKContext(c) hash := ethcmn.HexToHash(req.Hash) - logs, err := q.GetLogs(ctx, hash) + logs, err := k.GetLogs(ctx, hash) if err != nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.Internal, err.Error(), @@ -156,13 +222,19 @@ func (q Keeper) TxLogs(c context.Context, req *types.QueryTxLogsRequest) (*types }, nil } -// BlockLogs implements the Query/BlockLogs gRPC method -func (q Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) (*types.QueryBlockLogsResponse, error) { +// TxReceipt implements the Query/TxReceipt gRPC method +func (k Keeper) TxReceipt(c context.Context, req *types.QueryTxReceiptRequest) (*types.QueryTxReceiptResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + if req == nil { + metrics.ReportFuncError(k.svcTags) return nil, status.Error(codes.InvalidArgument, "empty request") } if types.IsEmptyHash(req.Hash) { + metrics.ReportFuncError(k.svcTags) return nil, status.Error( codes.InvalidArgument, types.ErrEmptyHash.Error(), @@ -171,7 +243,90 @@ func (q Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) ( ctx := sdk.UnwrapSDKContext(c) - txLogs := q.GetAllTxLogs(ctx) + hash := ethcmn.HexToHash(req.Hash) + receipt, found := k.GetTxReceiptFromHash(ctx, hash) + if !found { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error( + codes.NotFound, types.ErrTxReceiptNotFound.Error(), + ) + } + + return &types.QueryTxReceiptResponse{ + Receipt: receipt, + }, nil +} + +// TxReceiptsByBlockHeight implements the Query/TxReceiptsByBlockHeight gRPC method +func (k Keeper) TxReceiptsByBlockHeight(c context.Context, req *types.QueryTxReceiptsByBlockHeightRequest) (*types.QueryTxReceiptsByBlockHeightResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + + receipts := k.GetTxReceiptsByBlockHeight(ctx, req.Height) + return &types.QueryTxReceiptsByBlockHeightResponse{ + Receipts: receipts, + }, nil +} + +// TxReceiptsByBlockHash implements the Query/TxReceiptsByBlockHash gRPC method +func (k Keeper) TxReceiptsByBlockHash(c context.Context, req *types.QueryTxReceiptsByBlockHashRequest) (*types.QueryTxReceiptsByBlockHashResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if types.IsEmptyHash(req.Hash) { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error( + codes.InvalidArgument, + types.ErrEmptyHash.Error(), + ) + } + + ctx := sdk.UnwrapSDKContext(c) + + hash := ethcmn.HexToHash(req.Hash) + receipts := k.GetTxReceiptsByBlockHash(ctx, hash) + + return &types.QueryTxReceiptsByBlockHashResponse{ + Receipts: receipts, + }, nil +} + +// BlockLogs implements the Query/BlockLogs gRPC method +func (k Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) (*types.QueryBlockLogsResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + if types.IsEmptyHash(req.Hash) { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error( + codes.InvalidArgument, + types.ErrEmptyHash.Error(), + ) + } + + ctx := sdk.UnwrapSDKContext(c) + + txLogs := k.GetAllTxLogs(ctx) return &types.QueryBlockLogsResponse{ TxLogs: txLogs, @@ -179,14 +334,28 @@ func (q Keeper) BlockLogs(c context.Context, req *types.QueryBlockLogsRequest) ( } // BlockBloom implements the Query/BlockBloom gRPC method -func (q Keeper) BlockBloom(c context.Context, _ *types.QueryBlockBloomRequest) (*types.QueryBlockBloomResponse, error) { +func (k Keeper) BlockBloom(c context.Context, req *types.QueryBlockBloomRequest) (*types.QueryBlockBloomResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) - // use block height provided through the gRPC header - bloom, found := q.GetBlockBloom(ctx, ctx.BlockHeight()) + height := ctx.BlockHeight() + if setHeight := req.Height; setHeight > 0 { + height = setHeight + } + + bloom, found := k.GetBlockBloom(ctx, height) if !found { - return nil, status.Errorf( - codes.NotFound, "%s: height %d", types.ErrBloomNotFound.Error(), ctx.BlockHeight(), + metrics.ReportFuncError(k.svcTags) + return nil, status.Error( + codes.NotFound, types.ErrBloomNotFound.Error(), ) } @@ -196,11 +365,73 @@ func (q Keeper) BlockBloom(c context.Context, _ *types.QueryBlockBloomRequest) ( } // Params implements the Query/Params gRPC method -func (q Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + if req == nil { + metrics.ReportFuncError(k.svcTags) + return nil, status.Error(codes.InvalidArgument, "empty request") + } + ctx := sdk.UnwrapSDKContext(c) - params := q.GetParams(ctx) + params := k.GetParams(ctx) return &types.QueryParamsResponse{ Params: params, }, nil } + +// StaticCall implements Query/StaticCall gRPCP method +func (k Keeper) StaticCall(c context.Context, req *types.QueryStaticCallRequest) (*types.QueryStaticCallResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c) + + // parse the chainID from a string to a base-10 integer + chainIDEpoch, err := ethermint.ParseChainID(ctx.ChainID()) + if err != nil { + return nil, err + } + + txHash := tmtypes.Tx(ctx.TxBytes()).Hash() + ethHash := ethcmn.BytesToHash(txHash) + + var recipient *ethcmn.Address + if len(req.Address) > 0 { + addr := ethcmn.HexToAddress(req.Address) + recipient = &addr + } + + so := k.GetOrNewStateObject(ctx, *recipient) + sender := ethcmn.HexToAddress("0xaDd00275E3d9d213654Ce5223f0FADE8b106b707") + + st := &types.StateTransition{ + AccountNonce: so.Nonce(), + Price: new(big.Int).SetBytes(big.NewInt(0).Bytes()), + GasLimit: 100000000, + Recipient: recipient, + Amount: new(big.Int).SetBytes(big.NewInt(0).Bytes()), + Payload: req.Input, + Csdb: k.CommitStateDB.WithContext(ctx), + ChainID: chainIDEpoch, + TxHash: ðHash, + Sender: sender, + Simulate: ctx.IsCheckTx(), + } + + config, found := k.GetChainConfig(ctx) + if !found { + return nil, types.ErrChainConfigNotFound + } + + ret, err := st.StaticCall(ctx, config) + if err != nil { + return nil, err + } + + return &types.QueryStaticCallResponse{Data: ret}, nil +} diff --git a/x/evm/keeper/grpc_query_test.go b/x/evm/keeper/grpc_query_test.go deleted file mode 100644 index 25b3aa10..00000000 --- a/x/evm/keeper/grpc_query_test.go +++ /dev/null @@ -1,499 +0,0 @@ -package keeper_test - -import ( - "fmt" - "google.golang.org/grpc/metadata" - - ethcmn "github.com/ethereum/go-ethereum/common" - ethtypes "github.com/ethereum/go-ethereum/core/types" - ethcrypto "github.com/ethereum/go-ethereum/crypto" - - sdk "github.com/cosmos/cosmos-sdk/types" - - ethermint "github.com/cosmos/ethermint/types" - "github.com/cosmos/ethermint/x/evm/types" - - grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" -) - -func (suite *KeeperTestSuite) TestQueryAccount() { - var ( - req *types.QueryAccountRequest - expAccount *types.QueryAccountResponse - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"zero address", - func() { - suite.app.BankKeeper.SetBalance(suite.ctx, suite.address.Bytes(), ethermint.NewPhotonCoinInt64(0)) - expAccount = &types.QueryAccountResponse{ - Balance: "0", - CodeHash: ethcrypto.Keccak256(nil), - Nonce: 0, - } - req = &types.QueryAccountRequest{ - Address: ethcmn.Address{}.String(), - } - }, - true, - }, - { - "success", - func() { - suite.app.BankKeeper.SetBalance(suite.ctx, suite.address.Bytes(), ethermint.NewPhotonCoinInt64(100)) - expAccount = &types.QueryAccountResponse{ - Balance: "100", - CodeHash: ethcrypto.Keccak256(nil), - Nonce: 0, - } - req = &types.QueryAccountRequest{ - Address: suite.address.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Account(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expAccount, res) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryBalance() { - var ( - req *types.QueryBalanceRequest - expBalance string - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"zero address", - func() { - suite.app.BankKeeper.SetBalance(suite.ctx, suite.address.Bytes(), ethermint.NewPhotonCoinInt64(0)) - expBalance = "0" - req = &types.QueryBalanceRequest{ - Address: ethcmn.Address{}.String(), - } - }, - true, - }, - { - "success", - func() { - suite.app.BankKeeper.SetBalance(suite.ctx, suite.address.Bytes(), ethermint.NewPhotonCoinInt64(100)) - expBalance = "100" - req = &types.QueryBalanceRequest{ - Address: suite.address.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Balance(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expBalance, res.Balance) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryStorage() { - var ( - req *types.QueryStorageRequest - expValue string - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"zero address", - func() { - req = &types.QueryStorageRequest{ - Address: ethcmn.Address{}.String(), - } - }, - false, - }, - {"empty hash", - func() { - req = &types.QueryStorageRequest{ - Address: suite.address.String(), - Key: ethcmn.Hash{}.String(), - } - exp := &types.QueryStorageResponse{Value: "0x0000000000000000000000000000000000000000000000000000000000000000"} - expValue = exp.Value - }, - true, - }, - { - "success", - func() { - key := ethcmn.BytesToHash([]byte("key")) - value := ethcmn.BytesToHash([]byte("value")) - expValue = value.String() - suite.app.EvmKeeper.SetState(suite.ctx, suite.address, key, value) - req = &types.QueryStorageRequest{ - Address: suite.address.String(), - Key: key.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Storage(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expValue, res.Value) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryCode() { - var ( - req *types.QueryCodeRequest - expCode []byte - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"zero address", - func() { - req = &types.QueryCodeRequest{ - Address: ethcmn.Address{}.String(), - } - exp := &types.QueryCodeResponse{} - expCode = exp.Code - }, - true, - }, - { - "success", - func() { - expCode = []byte("code") - suite.app.EvmKeeper.SetCode(suite.ctx, suite.address, expCode) - - req = &types.QueryCodeRequest{ - Address: suite.address.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.Code(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expCode, res.Code) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryTxLogs() { - var ( - req *types.QueryTxLogsRequest - expLogs []*types.Log - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"empty hash", - func() { - req = &types.QueryTxLogsRequest{ - Hash: ethcmn.Hash{}.String(), - } - }, - false, - }, - {"logs not found", - func() { - hash := ethcmn.BytesToHash([]byte("hash")) - req = &types.QueryTxLogsRequest{ - Hash: hash.String(), - } - }, - true, - }, - { - "success", - func() { - hash := ethcmn.BytesToHash([]byte("tx_hash")) - - expLogs = []*types.Log{ - { - Address: suite.address.String(), - Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, - Data: []byte("data"), - BlockNumber: 1, - TxHash: hash.String(), - TxIndex: 1, - BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), - Index: 0, - Removed: false, - }, - } - - suite.app.EvmKeeper.SetLogs(suite.ctx, hash, types.LogsToEthereum(expLogs)) - - req = &types.QueryTxLogsRequest{ - Hash: hash.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.TxLogs(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expLogs, res.Logs) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryBlockLogs() { - var ( - req *types.QueryBlockLogsRequest - expLogs []types.TransactionLogs - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"empty hash", - func() { - req = &types.QueryBlockLogsRequest{ - Hash: ethcmn.Hash{}.String(), - } - }, - false, - }, - {"logs not found", - func() { - hash := ethcmn.BytesToHash([]byte("hash")) - req = &types.QueryBlockLogsRequest{ - Hash: hash.String(), - } - }, - true, - }, - { - "success", - func() { - - hash := ethcmn.BytesToHash([]byte("block_hash")) - expLogs = []types.TransactionLogs{ - { - Hash: ethcmn.BytesToHash([]byte("tx_hash_0")).String(), - Logs: []*types.Log{ - { - Address: suite.address.String(), - Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, - Data: []byte("data"), - BlockNumber: 1, - TxHash: ethcmn.BytesToHash([]byte("tx_hash_0")).String(), - TxIndex: 1, - BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), - Index: 0, - Removed: false, - }, - }, - }, - { - Hash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(), - Logs: []*types.Log{ - { - Address: suite.address.String(), - Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, - Data: []byte("data"), - BlockNumber: 1, - TxHash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(), - TxIndex: 1, - BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), - Index: 0, - Removed: false, - }, - { - Address: suite.address.String(), - Topics: []string{ethcmn.BytesToHash([]byte("topic_1")).String()}, - Data: []byte("data_1"), - BlockNumber: 1, - TxHash: ethcmn.BytesToHash([]byte("tx_hash_1")).String(), - TxIndex: 1, - BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), - Index: 0, - Removed: false, - }, - }, - }, - } - - suite.app.EvmKeeper.SetLogs(suite.ctx, ethcmn.BytesToHash([]byte("tx_hash_0")), types.LogsToEthereum(expLogs[0].Logs)) - suite.app.EvmKeeper.SetLogs(suite.ctx, ethcmn.BytesToHash([]byte("tx_hash_1")), types.LogsToEthereum(expLogs[1].Logs)) - - req = &types.QueryBlockLogsRequest{ - Hash: hash.String(), - } - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - res, err := suite.queryClient.BlockLogs(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expLogs, res.TxLogs) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryBlockBloom() { - var ( - req *types.QueryBlockBloomRequest - expBloom []byte - ) - - testCases := []struct { - msg string - malleate func() - expPass bool - }{ - {"bloom bytes not found for height", - func() {}, - false, - }, - { - "success", - func() { - req = &types.QueryBlockBloomRequest{} - bloom := ethtypes.BytesToBloom([]byte("bloom")) - expBloom = bloom.Bytes() - suite.ctx = suite.ctx.WithBlockHeight(1) - suite.app.EvmKeeper.SetBlockBloom(suite.ctx, 1, bloom) - }, - true, - }, - } - - for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { - suite.SetupTest() // reset - - tc.malleate() - ctx := sdk.WrapSDKContext(suite.ctx) - ctx = metadata.AppendToOutgoingContext(ctx, grpctypes.GRPCBlockHeightHeader, fmt.Sprintf("%d", suite.ctx.BlockHeight())) - res, err := suite.queryClient.BlockBloom(ctx, req) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(res) - - suite.Require().Equal(expBloom, res.Bloom) - } else { - suite.Require().Error(err) - } - }) - } -} - -func (suite *KeeperTestSuite) TestQueryParams() { - ctx := sdk.WrapSDKContext(suite.ctx) - expParams := types.DefaultParams() - - res, err := suite.queryClient.Params(ctx, &types.QueryParamsRequest{}) - suite.Require().NoError(err) - suite.Require().Equal(expParams, res.Params) -} diff --git a/x/evm/keeper/invariants_test.go b/x/evm/keeper/invariants_test.go index 051a2c18..093da8f5 100644 --- a/x/evm/keeper/invariants_test.go +++ b/x/evm/keeper/invariants_test.go @@ -4,10 +4,8 @@ import ( "math/big" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/ethermint/crypto/ethsecp256k1" ethermint "github.com/cosmos/ethermint/types" - ethcmn "github.com/ethereum/go-ethereum/common" ) @@ -27,7 +25,7 @@ func (suite *KeeperTestSuite) TestBalanceInvariant() { func() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, address.Bytes()) suite.Require().NotNil(acc) - suite.app.BankKeeper.SetBalance(suite.ctx, acc.GetAddress(), ethermint.NewPhotonCoinInt64(1)) + suite.app.BankKeeper.SetBalance(suite.ctx, acc.GetAddress(), ethermint.NewInjectiveCoinInt64(1)) suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) @@ -40,7 +38,7 @@ func (suite *KeeperTestSuite) TestBalanceInvariant() { func() { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, address.Bytes()) suite.Require().NotNil(acc) - suite.app.BankKeeper.SetBalance(suite.ctx, acc.GetAddress(), ethermint.NewPhotonCoinInt64(1)) + suite.app.BankKeeper.SetBalance(suite.ctx, acc.GetAddress(), ethermint.NewInjectiveCoinInt64(1)) suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 88b59914..2f401b0c 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -1,20 +1,17 @@ package keeper import ( - "fmt" "math/big" - "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - - "github.com/cosmos/ethermint/x/evm/types" - "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/ethermint/metrics" + "github.com/cosmos/ethermint/x/evm/types" ) // Keeper wraps the CommitStateDB, allowing us to pass in SDK context while adhering @@ -27,11 +24,12 @@ type Keeper struct { // - storing Account's Code // - storing transaction Logs // - storing block height -> bloom filter map. Needed for the Web3 API. - // - storing block hash -> block height map. Needed for the Web3 API. + // - storing block hash -> block height map. Needed for the Web3 API. TODO: remove storeKey sdk.StoreKey - // Account Keeper for fetching accounts + accountKeeper types.AccountKeeper bankKeeper types.BankKeeper + // Ethermint concrete implementation on the EVM StateDB interface CommitStateDB *types.CommitStateDB // Transaction counter in a block. Used on StateSB's Prepare function. @@ -39,6 +37,12 @@ type Keeper struct { // on the KVStore or adding it as a field on the EVM genesis state. TxCount int Bloom *big.Int + + // LogsCache keeps mapping of contract address -> eth logs emitted + // during EVM execution in the current block. + LogsCache map[common.Address][]*ethtypes.Log + + svcTags metrics.Tags } // NewKeeper generates new evm module keeper @@ -53,6 +57,10 @@ func NewKeeper( // NOTE: we pass in the parameter space to the CommitStateDB in order to use custom denominations for the EVM operations return &Keeper{ + svcTags: metrics.Tags{ + "svc": "evm_k", + }, + cdc: cdc, accountKeeper: ak, bankKeeper: bankKeeper, @@ -60,19 +68,116 @@ func NewKeeper( CommitStateDB: types.NewCommitStateDB(sdk.Context{}, storeKey, paramSpace, ak, bankKeeper), TxCount: 0, Bloom: big.NewInt(0), + LogsCache: map[common.Address][]*ethtypes.Log{}, } } // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { - return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) + return ctx.Logger().With("module", types.ModuleName) } // ---------------------------------------------------------------------------- -// Epoch Height -> hash mapping functions -// Required by EVM context's GetHashFunc +// Block bloom bits mapping functions +// Required by Web3 API. // ---------------------------------------------------------------------------- +// GetBlockBloom gets bloombits from block height +func (k Keeper) GetBlockBloom(ctx sdk.Context, height int64) (ethtypes.Bloom, bool) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + + key := types.BloomKey(height) + has := store.Has(key) + if !has { + return ethtypes.Bloom{}, true // sometimes bloom not found, fix this + } + + bz := store.Get(key) + return ethtypes.BytesToBloom(bz), true +} + +// SetBlockBloom sets the mapping from block height to bloom bits +func (k Keeper) SetBlockBloom(ctx sdk.Context, height int64, bloom ethtypes.Bloom) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + + key := types.BloomKey(height) + store.Set(key, bloom.Bytes()) +} + +// GetBlockHash gets block height from block consensus hash +func (k Keeper) GetBlockHashFromHeight(ctx sdk.Context, height int64) ([]byte, bool) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyBlockHeightHash(uint64(height))) + if len(bz) == 0 { + return common.Hash{}.Bytes(), false + } + + return common.BytesToHash(bz).Bytes(), true +} + +// SetBlockHash sets the mapping from block consensus hash to block height +func (k Keeper) SetBlockHash(ctx sdk.Context, hash []byte, height int64) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + bz := sdk.Uint64ToBigEndian(uint64(height)) + store.Set(types.KeyBlockHash(common.BytesToHash(hash)), bz) +} + +// GetBlockHash gets block height from block consensus hash +func (k Keeper) GetBlockHeightByHash(ctx sdk.Context, hash common.Hash) (int64, bool) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.KeyBlockHash(hash)) + if len(bz) == 0 { + return 0, false + } + + height := sdk.BigEndianToUint64(bz) + return int64(height), true +} + +// SetBlockHash sets the mapping from block consensus hash to block height +func (k Keeper) SetBlockHeightToHash(ctx sdk.Context, hash []byte, height int64) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyBlockHeightHash(uint64(height)), hash) +} + +// SetTxReceiptToHash sets the mapping from tx hash to tx receipt +func (k Keeper) SetTxReceiptToHash(ctx sdk.Context, hash common.Hash, receipt *types.TxReceipt) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + + data := k.cdc.MustMarshalBinaryBare(receipt) + + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyHashTxReceipt(hash), data) +} + // GetHeightHash returns the block header hash associated with a given block height and chain epoch number. func (k Keeper) GetHeightHash(ctx sdk.Context, height uint64) common.Hash { return k.CommitStateDB.WithContext(ctx).GetHeightHash(height) @@ -83,31 +188,121 @@ func (k Keeper) SetHeightHash(ctx sdk.Context, height uint64, hash common.Hash) k.CommitStateDB.WithContext(ctx).SetHeightHash(height, hash) } -// ---------------------------------------------------------------------------- -// Block bloom bits mapping functions -// Required by Web3 API. -// ---------------------------------------------------------------------------- +// GetTxReceiptFromHash gets tx receipt by tx hash. +func (k Keeper) GetTxReceiptFromHash(ctx sdk.Context, hash common.Hash) (*types.TxReceipt, bool) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() -// GetBlockBloom gets bloombits from block height -func (k Keeper) GetBlockBloom(ctx sdk.Context, height int64) (ethtypes.Bloom, bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixBloom) - has := store.Has(types.BloomKey(height)) - if !has { - return ethtypes.Bloom{}, false + store := ctx.KVStore(k.storeKey) + data := store.Get(types.KeyHashTxReceipt(hash)) + if data == nil || len(data) == 0 { + return nil, false } - bz := store.Get(types.BloomKey(height)) - return ethtypes.BytesToBloom(bz), true + var receipt types.TxReceipt + k.cdc.MustUnmarshalBinaryBare(data, &receipt) + + return &receipt, true } -// SetBlockBloom sets the mapping from block height to bloom bits -func (k Keeper) SetBlockBloom(ctx sdk.Context, height int64, bloom ethtypes.Bloom) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixBloom) - store.Set(types.BloomKey(height), bloom.Bytes()) +// AddTxHashToBlock stores tx hash in the list of tx for the block. +func (k Keeper) AddTxHashToBlock(ctx sdk.Context, blockHeight int64, txHash common.Hash) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + key := types.KeyBlockHeightTxs(uint64(blockHeight)) + + list := types.BytesList{} + + store := ctx.KVStore(k.storeKey) + data := store.Get(key) + if len(data) > 0 { + k.cdc.MustUnmarshalBinaryBare(data, &list) + } + + list.Bytes = append(list.Bytes, txHash.Bytes()) + + data = k.cdc.MustMarshalBinaryBare(&list) + store.Set(key, data) +} + +// GetTxsFromBlock returns list of tx hash in the block by height. +func (k Keeper) GetTxsFromBlock(ctx sdk.Context, blockHeight int64) []common.Hash { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + key := types.KeyBlockHeightTxs(uint64(blockHeight)) + + store := ctx.KVStore(k.storeKey) + data := store.Get(key) + if len(data) > 0 { + list := types.BytesList{} + k.cdc.MustUnmarshalBinaryBare(data, &list) + + txs := make([]common.Hash, 0, len(list.Bytes)) + for _, b := range list.Bytes { + txs = append(txs, common.BytesToHash(b)) + } + + return txs + } + + return nil +} + +// GetTxReceiptsByBlockHeight gets tx receipts by block height. +func (k Keeper) GetTxReceiptsByBlockHeight(ctx sdk.Context, blockHeight int64) []*types.TxReceipt { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + txs := k.GetTxsFromBlock(ctx, blockHeight) + if len(txs) == 0 { + return nil + } + + store := ctx.KVStore(k.storeKey) + + receipts := make([]*types.TxReceipt, 0, len(txs)) + + for idx, txHash := range txs { + data := store.Get(types.KeyHashTxReceipt(txHash)) + if data == nil || len(data) == 0 { + continue + } + + var receipt types.TxReceipt + k.cdc.MustUnmarshalBinaryBare(data, &receipt) + receipt.Index = uint64(idx) + receipts = append(receipts, &receipt) + } + + return receipts +} + +// GetTxReceiptsByBlockHash gets tx receipts by block hash. +func (k Keeper) GetTxReceiptsByBlockHash(ctx sdk.Context, hash common.Hash) []*types.TxReceipt { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + blockHeight, ok := k.GetBlockHeightByHash(ctx, hash) + if !ok { + return nil + } + + return k.GetTxReceiptsByBlockHeight(ctx, blockHeight) } // GetAllTxLogs return all the transaction logs from the store. func (k Keeper) GetAllTxLogs(ctx sdk.Context) []types.TransactionLogs { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefixLogs) defer iterator.Close() @@ -125,6 +320,10 @@ func (k Keeper) GetAllTxLogs(ctx sdk.Context) []types.TransactionLogs { // GetAccountStorage return state storage associated with an account func (k Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) (types.Storage, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + storage := types.Storage{} err := k.ForEachStorage(ctx, address, func(key, value common.Hash) bool { @@ -140,6 +339,10 @@ func (k Keeper) GetAccountStorage(ctx sdk.Context, address common.Address) (type // GetChainConfig gets block height from block consensus hash func (k Keeper) GetChainConfig(ctx sdk.Context) (types.ChainConfig, bool) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + store := ctx.KVStore(k.storeKey) bz := store.Get(types.KeyPrefixChainConfig) if len(bz) == 0 { @@ -153,6 +356,10 @@ func (k Keeper) GetChainConfig(ctx sdk.Context) (types.ChainConfig, bool) { // SetChainConfig sets the mapping from block consensus hash to block height func (k Keeper) SetChainConfig(ctx sdk.Context, config types.ChainConfig) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshalBinaryBare(&config) store.Set(types.KeyPrefixChainConfig, bz) diff --git a/x/evm/keeper/keeper_test.go b/x/evm/keeper/keeper_test.go index e37a05e2..f32a279f 100644 --- a/x/evm/keeper/keeper_test.go +++ b/x/evm/keeper/keeper_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -32,24 +31,20 @@ var ( type KeeperTestSuite struct { suite.Suite - ctx sdk.Context - app *app.EthermintApp - queryClient types.QueryClient - address ethcmn.Address + ctx sdk.Context + querier sdk.Querier + app *app.InjectiveApp + address ethcmn.Address } func (suite *KeeperTestSuite) SetupTest() { checkTx := false suite.app = app.Setup(checkTx) - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, ChainID: "ethermint-3", Time: time.Now().UTC()}) + suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, ChainID: "3", Time: time.Now().UTC()}) suite.address = ethcmn.HexToAddress(addrHex) - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.EvmKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) - - balance := ethermint.NewPhotonCoin(sdk.ZeroInt()) + balance := ethermint.NewInjectiveCoin(sdk.ZeroInt()) acc := ðermint.EthAccount{ BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), CodeHash: ethcrypto.Keccak256(nil), @@ -69,13 +64,11 @@ func (suite *KeeperTestSuite) TestTransactionLogs() { Address: suite.address, Data: []byte("log"), BlockNumber: 10, - Topics: []ethcmn.Hash{}, } log2 := ðtypes.Log{ Address: suite.address, Data: []byte("log2"), BlockNumber: 11, - Topics: []ethcmn.Hash{}, } expLogs := []*ethtypes.Log{log} @@ -90,7 +83,6 @@ func (suite *KeeperTestSuite) TestTransactionLogs() { // add another log under the zero hash suite.app.EvmKeeper.AddLog(suite.ctx, log2) - log2.Index = 0 logs = suite.app.EvmKeeper.AllLogs(suite.ctx) suite.Require().Equal(expLogs, logs) @@ -99,19 +91,17 @@ func (suite *KeeperTestSuite) TestTransactionLogs() { Address: suite.address, Data: []byte("log3"), BlockNumber: 10, - Topics: []ethcmn.Hash{}, } suite.app.EvmKeeper.AddLog(suite.ctx, log3) - log3.Index = 0 txLogs := suite.app.EvmKeeper.GetAllTxLogs(suite.ctx) suite.Require().Equal(2, len(txLogs)) suite.Require().Equal(ethcmn.Hash{}.String(), txLogs[0].Hash) - suite.Require().Equal([]*ethtypes.Log{log2, log3}, txLogs[0].EthLogs()) + suite.Require().Equal([]*ethtypes.Log{log2, log3}, txLogs[0].Logs) suite.Require().Equal(ethHash.String(), txLogs[1].Hash) - suite.Require().Equal([]*ethtypes.Log{log}, txLogs[1].EthLogs()) + suite.Require().Equal([]*ethtypes.Log{log}, txLogs[1].Logs) } func (suite *KeeperTestSuite) TestDBStorage() { diff --git a/x/evm/keeper/msg_server.go b/x/evm/keeper/msg_server.go index 3c949729..e177f2ac 100644 --- a/x/evm/keeper/msg_server.go +++ b/x/evm/keeper/msg_server.go @@ -2,57 +2,68 @@ package keeper import ( "context" + "math/big" - "github.com/armon/go-metrics" + "github.com/pkg/errors" + log "github.com/xlab/suplog" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + ethcmn "github.com/ethereum/go-ethereum/common" tmtypes "github.com/tendermint/tendermint/types" - ethcmn "github.com/ethereum/go-ethereum/common" - - "github.com/cosmos/cosmos-sdk/telemetry" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/cosmos/ethermint/metrics" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/x/evm/types" ) -var _ types.MsgServer = Keeper{} +var _ types.MsgServer = &Keeper{} + +func (k *Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() -// EthereumTx implements the Msg/EthereumTx gRPC method. -func (k Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*types.MsgEthereumTxResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // parse the chainID from a string to a base-10 integer chainIDEpoch, err := ethermint.ParseChainID(ctx.ChainID()) if err != nil { + metrics.ReportFuncError(k.svcTags) return nil, err } // Verify signature and retrieve sender address - sender, err := msg.VerifySig(chainIDEpoch) - if err != nil { - return nil, err + var homesteadErr error + sender, eip155Err := msg.VerifySig(chainIDEpoch) + if eip155Err != nil { + sender, homesteadErr = msg.VerifySigHomestead() + if homesteadErr != nil { + log.WithFields(log.Fields{ + "eip155_err": eip155Err.Error(), + "homestead_err": homesteadErr.Error(), + }).Warningln("failed to verify signatures with EIP155 and Homestead signers") + + metrics.ReportFuncError(k.svcTags) + return nil, errors.New("no valid signatures") + } } txHash := tmtypes.Tx(ctx.TxBytes()).Hash() ethHash := ethcmn.BytesToHash(txHash) var recipient *ethcmn.Address - - labels := []metrics.Label{telemetry.NewLabel("operation", "create")} - - if msg.Data.Recipient != nil { - addr := ethcmn.HexToAddress(msg.Data.Recipient.Address) + if len(msg.Data.Recipient) > 0 { + addr := ethcmn.BytesToAddress(msg.Data.Recipient) recipient = &addr - labels = []metrics.Label{telemetry.NewLabel("operation", "call")} } - st := types.StateTransition{ + st := &types.StateTransition{ AccountNonce: msg.Data.AccountNonce, - Price: msg.Data.Price.BigInt(), + Price: new(big.Int).SetBytes(msg.Data.Price), GasLimit: msg.Data.GasLimit, Recipient: recipient, - Amount: msg.Data.Amount.BigInt(), + Amount: new(big.Int).SetBytes(msg.Data.Amount), Payload: msg.Data.Payload, Csdb: k.CommitStateDB.WithContext(ctx), ChainID: chainIDEpoch, @@ -66,18 +77,47 @@ func (k Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*ty // other nodes, causing a consensus error if !st.Simulate { // Prepare db for logs - blockHash := types.HashFromContext(ctx) - k.Prepare(ctx, ethHash, blockHash, k.TxCount) + hash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.Prepare(ctx, ethHash, ethcmn.BytesToHash(hash), k.TxCount) k.TxCount++ } config, found := k.GetChainConfig(ctx) if !found { + metrics.ReportFuncError(k.svcTags) return nil, types.ErrChainConfigNotFound } executionResult, err := st.TransitionDb(ctx, config) if err != nil { + if err.Error() == "execution reverted" && executionResult != nil { + // keep the execution result for revert reason + executionResult.Response.Reverted = true + metrics.ReportFuncError(k.svcTags) + + if !st.Simulate { + blockHash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{ + Hash: ethHash.Bytes(), + From: sender.Bytes(), + Data: msg.Data, + BlockHeight: uint64(ctx.BlockHeight()), + BlockHash: blockHash, + Result: &types.TxResult{ + ContractAddress: executionResult.Response.ContractAddress, + Bloom: executionResult.Response.Bloom, + TxLogs: executionResult.Response.TxLogs, + Ret: executionResult.Response.Ret, + Reverted: executionResult.Response.Reverted, + GasUsed: executionResult.GasInfo.GasConsumed, + }, + }) + } + + return executionResult.Response, nil + } + + metrics.ReportFuncError(k.svcTags) return nil, err } @@ -86,28 +126,42 @@ func (k Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*ty k.Bloom.Or(k.Bloom, executionResult.Bloom) // update transaction logs in KVStore - err = k.SetLogs(ctx, ethcmn.BytesToHash(txHash), executionResult.Logs) + err = k.SetLogs(ctx, ethHash, executionResult.Logs) if err != nil { panic(err) } - } - // add metrics for the transaction - defer func() { - if st.Amount.IsInt64() { - telemetry.SetGaugeWithLabels( - []string{"tx", "msg", "ethereum"}, - float32(st.Amount.Int64()), - labels, - ) + blockHash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{ + Hash: ethHash.Bytes(), + From: sender.Bytes(), + Data: msg.Data, + Index: uint64(st.Csdb.TxIndex()), + BlockHeight: uint64(ctx.BlockHeight()), + BlockHash: blockHash, + Result: &types.TxResult{ + ContractAddress: executionResult.Response.ContractAddress, + Bloom: executionResult.Response.Bloom, + TxLogs: executionResult.Response.TxLogs, + Ret: executionResult.Response.Ret, + Reverted: executionResult.Response.Reverted, + GasUsed: executionResult.GasInfo.GasConsumed, + }, + }) + + k.AddTxHashToBlock(ctx, ctx.BlockHeight(), ethHash) + + for _, ethLog := range executionResult.Logs { + k.LogsCache[ethLog.Address] = append(k.LogsCache[ethLog.Address], ethLog) } - }() + } // emit events ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeEthereumTx, sdk.NewAttribute(sdk.AttributeKeyAmount, st.Amount.String()), + sdk.NewAttribute(types.AttributeKeyTxHash, ethcmn.BytesToHash(txHash).Hex()), ), sdk.NewEvent( sdk.EventTypeMessage, @@ -116,11 +170,209 @@ func (k Keeper) EthereumTx(goCtx context.Context, msg *types.MsgEthereumTx) (*ty ), }) - if msg.Data.Recipient != nil { + if len(msg.Data.Recipient) > 0 { + ethAddr := ethcmn.BytesToAddress(msg.Data.Recipient) ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeEthereumTx, - sdk.NewAttribute(types.AttributeKeyRecipient, msg.Data.Recipient.Address), + sdk.NewAttribute(types.AttributeKeyRecipient, ethAddr.Hex()), + ), + ) + } + + metrics.ReportFuncError(k.svcTags) + return executionResult.Response, nil +} + +func (k *Keeper) SendInternalEthereumTx( + ctx sdk.Context, + payload []byte, + senderAddress common.Address, + recipientAddress common.Address, +) (*types.MsgEthereumTxResponse, error) { + + accAddress := sdk.AccAddress(senderAddress.Bytes()) + + acc := k.accountKeeper.GetAccount(ctx, accAddress) + if acc == nil { + acc = k.accountKeeper.NewAccountWithAddress(ctx, accAddress) + k.accountKeeper.SetAccount(ctx, acc) + } + + ethAccount, ok := acc.(*ethermint.EthAccount) + if !ok { + return nil, errors.New("could not cast account to EthAccount") + } + + if err := ethAccount.SetSequence(ethAccount.GetSequence() + 1); err != nil { + return nil, errors.New("failed to set acc sequence") + } + + k.accountKeeper.SetAccount(ctx, ethAccount) + + res, err := k.InternalEthereumTx(sdk.WrapSDKContext(ctx), senderAddress, &types.TxData{ + AccountNonce: ethAccount.GetSequence(), + Recipient: recipientAddress.Bytes(), + Amount: big.NewInt(0).Bytes(), + Price: big.NewInt(0).Bytes(), + GasLimit: 10000000, // TODO: don't hardcode, maybe set a limit? + Payload: payload, + }) + + if err != nil { + err = errors.Wrapf(err, "failed to execute InternalEthereumTx at contract %s", recipientAddress.Hex()) + return nil, err + } + + return res, nil +} + +func (k *Keeper) InternalEthereumTx( + goCtx context.Context, + sender common.Address, + tx *types.TxData, +) (*types.MsgEthereumTxResponse, error) { + metrics.ReportFuncCall(k.svcTags) + doneFn := metrics.ReportFuncTiming(k.svcTags) + defer doneFn() + + ctx := sdk.UnwrapSDKContext(goCtx) + // parse the chainID from a string to a base-10 integer + chainIDEpoch, err := ethermint.ParseChainID(ctx.ChainID()) + if err != nil { + metrics.ReportFuncError(k.svcTags) + return nil, err + } + + // true Ethereum tx hash based on its data + ethHash := (&types.MsgEthereumTx{ + Data: tx, + }).RLPSignBytes(chainIDEpoch) + + var recipient *ethcmn.Address + if len(tx.Recipient) > 0 { + addr := ethcmn.BytesToAddress(tx.Recipient) + recipient = &addr + } + + st := &types.StateTransition{ + AccountNonce: tx.AccountNonce, + Price: new(big.Int).SetBytes(tx.Price), + GasLimit: tx.GasLimit, + Recipient: recipient, + Amount: new(big.Int).SetBytes(tx.Amount), + Payload: tx.Payload, + Csdb: k.CommitStateDB.WithContext(ctx), + ChainID: chainIDEpoch, + TxHash: ðHash, + Sender: sender, + Simulate: ctx.IsCheckTx(), + } + + // since the txCount is used by the stateDB, and a simulated tx is run only on the node it's submitted to, + // then this will cause the txCount/stateDB of the node that ran the simulated tx to be different than the + // other nodes, causing a consensus error + if !st.Simulate { + // Prepare db for logs + hash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.Prepare(ctx, ethHash, ethcmn.BytesToHash(hash), k.TxCount) + k.TxCount++ + } + + config, found := k.GetChainConfig(ctx) + if !found { + metrics.ReportFuncError(k.svcTags) + return nil, types.ErrChainConfigNotFound + } + + executionResult, err := st.TransitionDb(ctx, config) + if err != nil { + if err.Error() == "execution reverted" && executionResult != nil { + // keep the execution result for revert reason + executionResult.Response.Reverted = true + metrics.ReportFuncError(k.svcTags) + + if !st.Simulate { + blockHash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{ + Hash: ethHash.Bytes(), + From: sender.Bytes(), + Data: tx, + BlockHeight: uint64(ctx.BlockHeight()), + BlockHash: blockHash, + Result: &types.TxResult{ + ContractAddress: executionResult.Response.ContractAddress, + Bloom: executionResult.Response.Bloom, + TxLogs: executionResult.Response.TxLogs, + Ret: executionResult.Response.Ret, + Reverted: executionResult.Response.Reverted, + GasUsed: executionResult.GasInfo.GasConsumed, + }, + }) + } + + return executionResult.Response, err + } + + metrics.ReportFuncError(k.svcTags) + return nil, err + } + + blockHash, _ := k.GetBlockHashFromHeight(ctx, ctx.BlockHeight()) + k.SetTxReceiptToHash(ctx, ethHash, &types.TxReceipt{ + Hash: ethHash.Bytes(), + From: sender.Bytes(), + Data: tx, + Index: uint64(st.Csdb.TxIndex()), + BlockHeight: uint64(ctx.BlockHeight()), + BlockHash: blockHash, + Result: &types.TxResult{ + ContractAddress: executionResult.Response.ContractAddress, + Bloom: executionResult.Response.Bloom, + TxLogs: executionResult.Response.TxLogs, + Ret: executionResult.Response.Ret, + Reverted: executionResult.Response.Reverted, + GasUsed: executionResult.GasInfo.GasConsumed, + }, + }) + + k.AddTxHashToBlock(ctx, ctx.BlockHeight(), ethHash) + + if !st.Simulate { + // update block bloom filter + k.Bloom.Or(k.Bloom, executionResult.Bloom) + + // update transaction logs in KVStore + err = k.SetLogs(ctx, ethHash, executionResult.Logs) + if err != nil { + panic(err) + } + + for _, ethLog := range executionResult.Logs { + k.LogsCache[ethLog.Address] = append(k.LogsCache[ethLog.Address], ethLog) + } + } + + // emit events + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeEthereumTx, + sdk.NewAttribute(sdk.AttributeKeyAmount, st.Amount.String()), + sdk.NewAttribute(types.AttributeKeyTxHash, ethHash.Hex()), + ), + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender.String()), + ), + }) + + if len(tx.Recipient) > 0 { + ethAddr := ethcmn.BytesToAddress(tx.Recipient) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeEthereumTx, + sdk.NewAttribute(types.AttributeKeyRecipient, ethAddr.Hex()), ), ) } diff --git a/x/evm/keeper/params_test.go b/x/evm/keeper/params_test.go index 4eda8b73..5d5268a6 100644 --- a/x/evm/keeper/params_test.go +++ b/x/evm/keeper/params_test.go @@ -7,7 +7,7 @@ import ( func (suite *KeeperTestSuite) TestParams() { params := suite.app.EvmKeeper.GetParams(suite.ctx) suite.Require().Equal(types.DefaultParams(), params) - params.EvmDenom = "ara" + params.EvmDenom = "inj" suite.app.EvmKeeper.SetParams(suite.ctx, params) newParams := suite.app.EvmKeeper.GetParams(suite.ctx) suite.Require().Equal(newParams, params) diff --git a/x/evm/keeper/statedb.go b/x/evm/keeper/statedb.go index 1deb6455..0337b708 100644 --- a/x/evm/keeper/statedb.go +++ b/x/evm/keeper/statedb.go @@ -49,6 +49,11 @@ func (k *Keeper) SetCode(ctx sdk.Context, addr ethcmn.Address, code []byte) { // SetLogs calls CommitStateDB.SetLogs using the passed in context func (k *Keeper) SetLogs(ctx sdk.Context, hash ethcmn.Hash, logs []*ethtypes.Log) error { + // TODO:@albert + // since SetLogs is only called for non-simulation mode, GasEstimation is quite not correct + // I suggest using ctx.ConsumeGas(XXX) where XXX is max of gas consume for set logs. + ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + return k.CommitStateDB.WithContext(ctx).SetLogs(hash, logs) } @@ -225,8 +230,8 @@ func (k *Keeper) Reset(ctx sdk.Context, root ethcmn.Hash) error { } // Prepare calls CommitStateDB.Prepare using the passed in context -func (k *Keeper) Prepare(ctx sdk.Context, thash ethcmn.Hash, txi int) { - k.CommitStateDB.WithContext(ctx).Prepare(thash, txi) +func (k *Keeper) Prepare(ctx sdk.Context, thash, bhash ethcmn.Hash, txi int) { + k.CommitStateDB.WithContext(ctx).Prepare(thash, bhash, txi) } // CreateAccount calls CommitStateDB.CreateAccount using the passed in context diff --git a/x/evm/keeper/statedb_test.go b/x/evm/keeper/statedb_test.go index 66c9baeb..76af93d8 100644 --- a/x/evm/keeper/statedb_test.go +++ b/x/evm/keeper/statedb_test.go @@ -18,7 +18,7 @@ import ( func (suite *KeeperTestSuite) TestBloomFilter() { // Prepare db for logs tHash := ethcmn.BytesToHash([]byte{0x1}) - suite.app.EvmKeeper.Prepare(suite.ctx, tHash, 0) + suite.app.EvmKeeper.Prepare(suite.ctx, tHash, ethcmn.Hash{}, 0) contractAddress := ethcmn.BigToAddress(big.NewInt(1)) log := ethtypes.Log{Address: contractAddress, Topics: []ethcmn.Hash{}} @@ -230,7 +230,6 @@ func (suite *KeeperTestSuite) TestStateDB_Logs() { suite.Require().Empty(dbLogs, tc.name) suite.app.EvmKeeper.AddLog(suite.ctx, tc.log) - tc.log.Index = 0 // reset index suite.Require().Equal(logs, suite.app.EvmKeeper.AllLogs(suite.ctx), tc.name) //resets state but checking to see if storekey still persists. @@ -360,8 +359,7 @@ func (suite *KeeperTestSuite) TestSuiteDB_Prepare() { bhash := ethcmn.BytesToHash([]byte("bhash")) txi := 1 - suite.app.EvmKeeper.Prepare(suite.ctx, thash, txi) - suite.app.EvmKeeper.CommitStateDB.SetBlockHash(bhash) + suite.app.EvmKeeper.Prepare(suite.ctx, thash, bhash, txi) suite.Require().Equal(txi, suite.app.EvmKeeper.TxIndex(suite.ctx)) suite.Require().Equal(bhash, suite.app.EvmKeeper.BlockHash(suite.ctx)) diff --git a/x/evm/module.go b/x/evm/module.go index 49b63b19..53b1a005 100644 --- a/x/evm/module.go +++ b/x/evm/module.go @@ -57,17 +57,16 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, _ client.TxEncodi // RegisterRESTRoutes performs a no-op as the EVM module doesn't expose REST // endpoints -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) { +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { } -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the evm module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { - if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(c client.Context, serveMux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(c)); err != nil { panic(err) } } -// GetTxCmd returns nil as the evm module doesn't support transactions through the CLI. +// GetTxCmd returns the root tx command for the evm module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } @@ -82,7 +81,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) types.RegisterInterfaces(registry) } -// ____________________________________________________________________________ +//____________________________________________________________________________ // AppModule implements an application module for the evm module. type AppModule struct { @@ -107,20 +106,23 @@ func (AppModule) Name() string { return types.ModuleName } -// RegisterInvariants interface for registering invariants +// RegisterInvariants interface for registering invariants. Performs a no-op +// as the evm module doesn't expose invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { - keeper.RegisterInvariants(ir, *am.keeper) + // Invariats lead to performance degradation + // + // keeper.RegisterInvariants(ir, *am.keeper) } -// RegisterServices registers the evm module Msg and gRPC services. +// RegisterQueryService registers a GRPC query service to respond to the +// module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // Route returns the message routing key for the evm module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(*am.keeper)) + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) } // QuerierRoute returns the evm module's querier route name. @@ -149,7 +151,8 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, data j var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - return InitGenesis(ctx, *am.keeper, am.ak, am.bk, genesisState) + InitGenesis(ctx, *am.keeper, am.ak, am.bk, genesisState) + return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the evm diff --git a/x/evm/types/chain_config.go b/x/evm/types/chain_config.go index 8515212a..aaffae56 100644 --- a/x/evm/types/chain_config.go +++ b/x/evm/types/chain_config.go @@ -28,12 +28,13 @@ func (cc ChainConfig) EthereumConfig(chainID *big.Int) *params.ChainConfig { PetersburgBlock: getBlockValue(cc.PetersburgBlock), IstanbulBlock: getBlockValue(cc.IstanbulBlock), MuirGlacierBlock: getBlockValue(cc.MuirGlacierBlock), - YoloV2Block: getBlockValue(cc.YoloV2Block), - EWASMBlock: getBlockValue(cc.EWASMBlock), + //TODO(xlab): after upgrading ethereum to newer version, this should be set to YoloV2Block + YoloV2Block: getBlockValue(cc.YoloV2Block), + EWASMBlock: getBlockValue(cc.EWASMBlock), } } -// DefaultChainConfig returns default evm parameters. +// DefaultChainConfig returns default evm parameters. Th func DefaultChainConfig() ChainConfig { return ChainConfig{ HomesteadBlock: sdk.ZeroInt(), @@ -46,8 +47,8 @@ func DefaultChainConfig() ChainConfig { ByzantiumBlock: sdk.ZeroInt(), ConstantinopleBlock: sdk.ZeroInt(), PetersburgBlock: sdk.ZeroInt(), - IstanbulBlock: sdk.ZeroInt(), - MuirGlacierBlock: sdk.ZeroInt(), + IstanbulBlock: sdk.NewInt(-1), + MuirGlacierBlock: sdk.NewInt(-1), YoloV2Block: sdk.NewInt(-1), EWASMBlock: sdk.NewInt(-1), } @@ -125,13 +126,3 @@ func validateBlock(block sdk.Int) error { return nil } - -// IsIstanbul returns whether the Istanbul version is enabled. -func (cc ChainConfig) IsIstanbul() bool { - return getBlockValue(cc.IstanbulBlock) != nil -} - -// IsHomestead returns whether the Homestead version is enabled. -func (cc ChainConfig) IsHomestead() bool { - return getBlockValue(cc.HomesteadBlock) != nil -} diff --git a/x/evm/types/chain_config_test.go b/x/evm/types/chain_config_test.go index f77ca8ef..18b75b7f 100644 --- a/x/evm/types/chain_config_test.go +++ b/x/evm/types/chain_config_test.go @@ -226,7 +226,7 @@ func TestChainConfigValidate(t *testing.T) { } func TestChainConfig_String(t *testing.T) { + configStr := `homestead_block:"0" dao_fork_block:"0" dao_fork_support:true eip150_block:"0" eip150_hash:"0x0000000000000000000000000000000000000000000000000000000000000000" eip155_block:"0" eip158_block:"0" byzantium_block:"0" constantinople_block:"0" petersburg_block:"0" istanbul_block:"-1" muir_glacier_block:"-1" yolo_v2_block:"-1" ewasm_block:"-1" ` config := DefaultChainConfig() - configStr := `homestead_block:"0" dao_fork_block:"0" dao_fork_support:true eip150_block:"0" eip150_hash:"0x0000000000000000000000000000000000000000000000000000000000000000" eip155_block:"0" eip158_block:"0" byzantium_block:"0" constantinople_block:"0" petersburg_block:"0" istanbul_block:"0" muir_glacier_block:"0" yolo_v2_block:"-1" ewasm_block:"-1" ` require.Equal(t, configStr, config.String()) } diff --git a/x/evm/types/codec.go b/x/evm/types/codec.go index 9187a1b7..8bffd086 100644 --- a/x/evm/types/codec.go +++ b/x/evm/types/codec.go @@ -4,28 +4,33 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +type ( + ExtensionOptionsEthereumTxI interface{} + ExtensionOptionsWeb3TxI interface{} ) // RegisterInterfaces registers the client interfaces to protobuf Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - registry.RegisterImplementations( - (*sdk.Tx)(nil), - &MsgEthereumTx{}, - ) registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgEthereumTx{}, ) - msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) + registry.RegisterInterface("injective.evm.v1beta1.ExtensionOptionsEthereumTx", (*ExtensionOptionsEthereumTxI)(nil)) + registry.RegisterImplementations( + (*ExtensionOptionsEthereumTxI)(nil), + &ExtensionOptionsEthereumTx{}, + ) + + registry.RegisterInterface("injective.evm.v1beta1.ExtensionOptionsWeb3Tx", (*ExtensionOptionsWeb3TxI)(nil)) + registry.RegisterImplementations( + (*ExtensionOptionsWeb3TxI)(nil), + &ExtensionOptionsWeb3Tx{}, + ) } var ( - // ModuleCdc references the global evm module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to x/evm and - // defined at the application level. ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) ) diff --git a/x/evm/types/errors.go b/x/evm/types/errors.go index 5e171b2a..a35971d6 100644 --- a/x/evm/types/errors.go +++ b/x/evm/types/errors.go @@ -25,9 +25,21 @@ var ( // ErrBloomNotFound returns an error if the block bloom cannot be found on the store. ErrBloomNotFound = sdkerrors.Register(ModuleName, 7, "block bloom not found") + // ErrInvalidValue returns an error resulting from an invalid value. + ErrInvalidValue = sdkerrors.Register(ModuleName, 8, "invalid value") + + // ErrInvalidChainID returns an error resulting from an invalid chain ID. + ErrInvalidChainID = sdkerrors.Register(ModuleName, 9, "invalid chain ID") + + // ErrVMExecution returns an error resulting from an error in EVM execution. + ErrVMExecution = sdkerrors.Register(ModuleName, 10, "error while executing evm transaction") + + // ErrTxReceiptNotFound returns an error if the transaction receipt could not be found + ErrTxReceiptNotFound = sdkerrors.Register(ModuleName, 11, "transaction receipt not found") + // ErrCreateDisabled returns an error if the EnableCreate parameter is false. - ErrCreateDisabled = sdkerrors.Register(ModuleName, 8, "EVM Create operation is disabled") + ErrCreateDisabled = sdkerrors.Register(ModuleName, 12, "EVM Create operation is disabled") // ErrCallDisabled returns an error if the EnableCall parameter is false. - ErrCallDisabled = sdkerrors.Register(ModuleName, 9, "EVM Call operation is disabled") + ErrCallDisabled = sdkerrors.Register(ModuleName, 13, "EVM Call operation is disabled") ) diff --git a/x/evm/types/events.go b/x/evm/types/events.go index 3d146b09..982a7c2a 100644 --- a/x/evm/types/events.go +++ b/x/evm/types/events.go @@ -6,5 +6,6 @@ const ( AttributeKeyContractAddress = "contract" AttributeKeyRecipient = "recipient" + AttributeKeyTxHash = "txHash" AttributeValueCategory = ModuleName ) diff --git a/x/evm/types/evm.pb.go b/x/evm/types/evm.pb.go index e4fe1523..a168bca9 100644 --- a/x/evm/types/evm.pb.go +++ b/x/evm/types/evm.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/evm/v1alpha1/evm.proto +// source: injective/evm/v1beta1/evm.proto package types @@ -40,7 +40,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_98f00fcca8b6b943, []int{0} + return fileDescriptor_5dd0cebaeafb1bee, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -144,7 +144,7 @@ func (m *ChainConfig) Reset() { *m = ChainConfig{} } func (m *ChainConfig) String() string { return proto.CompactTextString(m) } func (*ChainConfig) ProtoMessage() {} func (*ChainConfig) Descriptor() ([]byte, []int) { - return fileDescriptor_98f00fcca8b6b943, []int{1} + return fileDescriptor_5dd0cebaeafb1bee, []int{1} } func (m *ChainConfig) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,7 +197,7 @@ func (m *State) Reset() { *m = State{} } func (m *State) String() string { return proto.CompactTextString(m) } func (*State) ProtoMessage() {} func (*State) Descriptor() ([]byte, []int) { - return fileDescriptor_98f00fcca8b6b943, []int{2} + return fileDescriptor_5dd0cebaeafb1bee, []int{2} } func (m *State) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -252,7 +252,7 @@ func (m *TransactionLogs) Reset() { *m = TransactionLogs{} } func (m *TransactionLogs) String() string { return proto.CompactTextString(m) } func (*TransactionLogs) ProtoMessage() {} func (*TransactionLogs) Descriptor() ([]byte, []int) { - return fileDescriptor_98f00fcca8b6b943, []int{3} + return fileDescriptor_5dd0cebaeafb1bee, []int{3} } func (m *TransactionLogs) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -325,7 +325,7 @@ func (m *Log) Reset() { *m = Log{} } func (m *Log) String() string { return proto.CompactTextString(m) } func (*Log) ProtoMessage() {} func (*Log) Descriptor() ([]byte, []int) { - return fileDescriptor_98f00fcca8b6b943, []int{4} + return fileDescriptor_5dd0cebaeafb1bee, []int{4} } func (m *Log) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -417,82 +417,296 @@ func (m *Log) GetRemoved() bool { return false } -func init() { - proto.RegisterType((*Params)(nil), "ethermint.evm.v1alpha1.Params") - proto.RegisterType((*ChainConfig)(nil), "ethermint.evm.v1alpha1.ChainConfig") - proto.RegisterType((*State)(nil), "ethermint.evm.v1alpha1.State") - proto.RegisterType((*TransactionLogs)(nil), "ethermint.evm.v1alpha1.TransactionLogs") - proto.RegisterType((*Log)(nil), "ethermint.evm.v1alpha1.Log") +// TxReceipt defines the receipt type stored in KV for each EVM transaction. +type TxReceipt struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + From []byte `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` + Data *TxData `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + Result *TxResult `protobuf:"bytes,4,opt,name=result,proto3" json:"result,omitempty"` + Index uint64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` + BlockHeight uint64 `protobuf:"varint,6,opt,name=blockHeight,proto3" json:"blockHeight,omitempty"` + BlockHash []byte `protobuf:"bytes,7,opt,name=blockHash,proto3" json:"blockHash,omitempty"` } -func init() { proto.RegisterFile("ethermint/evm/v1alpha1/evm.proto", fileDescriptor_98f00fcca8b6b943) } +func (m *TxReceipt) Reset() { *m = TxReceipt{} } +func (m *TxReceipt) String() string { return proto.CompactTextString(m) } +func (*TxReceipt) ProtoMessage() {} +func (*TxReceipt) Descriptor() ([]byte, []int) { + return fileDescriptor_5dd0cebaeafb1bee, []int{5} +} +func (m *TxReceipt) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxReceipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxReceipt.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 *TxReceipt) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxReceipt.Merge(m, src) +} +func (m *TxReceipt) XXX_Size() int { + return m.Size() +} +func (m *TxReceipt) XXX_DiscardUnknown() { + xxx_messageInfo_TxReceipt.DiscardUnknown(m) +} -var fileDescriptor_98f00fcca8b6b943 = []byte{ - // 1023 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x96, 0xcf, 0x6f, 0xdb, 0x36, - 0x14, 0xc7, 0xe3, 0xd8, 0x49, 0x6c, 0xda, 0x71, 0x3c, 0xc6, 0xcb, 0xbc, 0x15, 0xb0, 0x02, 0x1e, - 0xb6, 0x1c, 0x5a, 0xbb, 0xc9, 0x10, 0x2c, 0x28, 0xb0, 0x43, 0x9c, 0xa6, 0x8d, 0xb1, 0x74, 0x0b, - 0x98, 0xa2, 0x01, 0x76, 0x11, 0x68, 0x8b, 0x95, 0xb5, 0x48, 0xa2, 0x26, 0xd2, 0xae, 0x3d, 0x60, - 0xc0, 0xfe, 0x84, 0x1d, 0x77, 0xdc, 0x5f, 0x33, 0x14, 0x3b, 0xf5, 0x38, 0xec, 0x20, 0x0c, 0xce, - 0x2d, 0x47, 0x9f, 0x77, 0x28, 0xf8, 0x43, 0x76, 0x9c, 0xe4, 0x62, 0xe4, 0x24, 0xbe, 0xc7, 0xf7, - 0xbe, 0x1f, 0x3e, 0x4a, 0x7c, 0x14, 0xd8, 0xa6, 0xa2, 0x47, 0xe3, 0xc0, 0x0b, 0x45, 0x93, 0x0e, - 0x82, 0xe6, 0x60, 0x97, 0xf8, 0x51, 0x8f, 0xec, 0x4a, 0xa3, 0x11, 0xc5, 0x4c, 0x30, 0xb8, 0x35, - 0x8d, 0x68, 0x48, 0x67, 0x1a, 0xf1, 0x45, 0xd5, 0x65, 0x2e, 0x53, 0x21, 0x4d, 0x39, 0xd2, 0xd1, - 0xe8, 0xff, 0x0c, 0x58, 0x3d, 0x23, 0x31, 0x09, 0x38, 0xdc, 0x05, 0x05, 0x3a, 0x08, 0x6c, 0x87, - 0x86, 0x2c, 0xa8, 0x65, 0xb6, 0x33, 0x3b, 0x85, 0x56, 0x75, 0x92, 0x58, 0x95, 0x11, 0x09, 0xfc, - 0x67, 0x68, 0x3a, 0x85, 0x70, 0x9e, 0x0e, 0x82, 0xe7, 0x72, 0x08, 0xbf, 0x05, 0xeb, 0x34, 0x24, - 0x1d, 0x9f, 0xda, 0xdd, 0x98, 0x12, 0x41, 0x6b, 0xcb, 0xdb, 0x99, 0x9d, 0x7c, 0xab, 0x36, 0x49, - 0xac, 0xaa, 0x49, 0xbb, 0x39, 0x8d, 0x70, 0x49, 0xdb, 0x47, 0xca, 0x84, 0xdf, 0x80, 0x62, 0x3a, - 0x4f, 0x7c, 0xbf, 0x96, 0x55, 0xc9, 0x5b, 0x93, 0xc4, 0x82, 0xf3, 0xc9, 0xc4, 0xf7, 0x11, 0x06, - 0x26, 0x95, 0xf8, 0x3e, 0x3c, 0x04, 0x80, 0x0e, 0x45, 0x4c, 0x6c, 0xea, 0x45, 0xbc, 0x96, 0xdb, - 0xce, 0xee, 0x64, 0x5b, 0x68, 0x9c, 0x58, 0x85, 0x63, 0xe9, 0x3d, 0x6e, 0x9f, 0xf1, 0x49, 0x62, - 0x7d, 0x62, 0x44, 0xa6, 0x81, 0x08, 0x17, 0x94, 0x71, 0xec, 0x45, 0xfc, 0x59, 0xee, 0x8f, 0x3f, - 0xad, 0x25, 0xf4, 0x57, 0x09, 0x14, 0x8f, 0x7a, 0xc4, 0x0b, 0x8f, 0x58, 0xf8, 0xd6, 0x73, 0xe1, - 0xcf, 0x60, 0xa3, 0xc7, 0x02, 0xca, 0x05, 0x25, 0x8e, 0xdd, 0xf1, 0x59, 0xf7, 0xd2, 0xec, 0xc4, - 0xc9, 0xfb, 0xc4, 0x5a, 0xfa, 0x37, 0xb1, 0xbe, 0x74, 0x3d, 0xd1, 0xeb, 0x77, 0x1a, 0x5d, 0x16, - 0x34, 0xbb, 0x8c, 0x07, 0x8c, 0x9b, 0xc7, 0x13, 0xee, 0x5c, 0x36, 0xc5, 0x28, 0xa2, 0xbc, 0xd1, - 0x0e, 0xc5, 0x24, 0xb1, 0xb6, 0x34, 0xfe, 0x96, 0x1c, 0xc2, 0xe5, 0xa9, 0xa7, 0x25, 0x1d, 0xf0, - 0x57, 0x50, 0x76, 0x08, 0xb3, 0xdf, 0xb2, 0xf8, 0xd2, 0x10, 0x97, 0x15, 0xf1, 0x62, 0x31, 0xe2, - 0x38, 0xb1, 0x4a, 0xcf, 0x0f, 0x7f, 0x78, 0xc1, 0xe2, 0x4b, 0xa5, 0x3b, 0x49, 0xac, 0x4f, 0xf5, - 0x0a, 0xe6, 0xd5, 0x11, 0x2e, 0x39, 0x84, 0x4d, 0xc3, 0xe0, 0x05, 0xa8, 0x4c, 0x03, 0x78, 0x3f, - 0x8a, 0x58, 0x2c, 0xcc, 0x8b, 0x78, 0x32, 0x4e, 0xac, 0xb2, 0x91, 0x3c, 0xd7, 0x33, 0x93, 0xc4, - 0xfa, 0xec, 0x96, 0xa8, 0xc9, 0x41, 0xb8, 0x6c, 0x64, 0x4d, 0x28, 0x7c, 0x07, 0x4a, 0xd4, 0x8b, - 0x76, 0xf7, 0x9f, 0x9a, 0xaa, 0x72, 0xaa, 0xaa, 0xd7, 0x0b, 0x57, 0x55, 0x3c, 0x6e, 0x9f, 0xed, - 0xee, 0x3f, 0x4d, 0x8b, 0xda, 0x34, 0x6f, 0xf5, 0x86, 0x34, 0xc2, 0x45, 0x6d, 0xea, 0x8a, 0xda, - 0xc0, 0x98, 0x76, 0x8f, 0xf0, 0x5e, 0x6d, 0x45, 0x71, 0x77, 0xc6, 0x89, 0x05, 0xb4, 0xd2, 0x09, - 0xe1, 0xbd, 0xd9, 0xfb, 0xe9, 0x8c, 0x7e, 0x21, 0xa1, 0xf0, 0xfa, 0x41, 0xaa, 0x05, 0x74, 0xb2, - 0x8c, 0x9a, 0xd6, 0xb0, 0x6f, 0x6a, 0x58, 0x7d, 0x50, 0x0d, 0xfb, 0xf7, 0xd5, 0xb0, 0x3f, 0x5f, - 0x83, 0x8e, 0x99, 0x82, 0x0f, 0x0c, 0x78, 0xed, 0x41, 0xe0, 0x83, 0xfb, 0xc0, 0x07, 0xf3, 0x60, - 0x1d, 0x23, 0x0f, 0xc0, 0xad, 0x1d, 0xa9, 0xe5, 0x1f, 0x76, 0x00, 0xee, 0x6c, 0x70, 0x79, 0xea, - 0xd1, 0xc8, 0xdf, 0x32, 0xa0, 0xda, 0x65, 0x21, 0x17, 0xd2, 0x19, 0xb2, 0xc8, 0xa7, 0x06, 0x5c, - 0x50, 0xe0, 0x57, 0x0b, 0x83, 0x1f, 0x69, 0xf0, 0x7d, 0x9a, 0x08, 0x6f, 0xce, 0xbb, 0xf5, 0x12, - 0x04, 0xa8, 0x44, 0x54, 0xd0, 0x98, 0x77, 0xfa, 0xb1, 0x6b, 0xe8, 0x40, 0xd1, 0xdb, 0x0b, 0xd3, - 0xcd, 0x01, 0xb9, 0xad, 0x87, 0xf0, 0xc6, 0xcc, 0xa5, 0xa9, 0x21, 0x28, 0x7b, 0x72, 0x29, 0x9d, - 0xbe, 0x6f, 0x98, 0x45, 0xc5, 0x7c, 0xb9, 0x30, 0xd3, 0x9c, 0xf4, 0x79, 0x35, 0x84, 0xd7, 0x53, - 0x87, 0xe6, 0x8d, 0x00, 0x0c, 0xfa, 0x5e, 0x6c, 0xbb, 0x3e, 0xe9, 0x7a, 0x34, 0x36, 0xcc, 0x92, - 0x62, 0x7e, 0xb7, 0x30, 0xf3, 0x73, 0xcd, 0xbc, 0xab, 0x88, 0x70, 0x45, 0x3a, 0x5f, 0x6a, 0x9f, - 0x46, 0xff, 0x04, 0xd6, 0x47, 0xcc, 0x67, 0xf6, 0x60, 0xcf, 0x50, 0xd7, 0x15, 0xf5, 0xc5, 0xc2, - 0x54, 0x73, 0xad, 0xcc, 0x89, 0x21, 0x5c, 0x94, 0xf6, 0x9b, 0x3d, 0xcd, 0xe2, 0xa0, 0x48, 0xdf, - 0x11, 0x9e, 0x7e, 0xbe, 0x65, 0x45, 0xc2, 0x0b, 0x1f, 0x1d, 0x70, 0x7c, 0x71, 0x78, 0xfe, 0x2a, - 0x3d, 0x39, 0xe9, 0x8d, 0x34, 0x13, 0x96, 0x9d, 0x42, 0x5a, 0x2a, 0x02, 0x35, 0xc1, 0xca, 0xb9, - 0x90, 0x77, 0x5a, 0x05, 0x64, 0x2f, 0xe9, 0x48, 0xdf, 0x1a, 0x58, 0x0e, 0x61, 0x15, 0xac, 0x0c, - 0x88, 0xdf, 0xd7, 0x97, 0x63, 0x01, 0x6b, 0x03, 0xbd, 0x01, 0x1b, 0xaf, 0x63, 0x12, 0x72, 0xd2, - 0x15, 0x1e, 0x0b, 0x4f, 0x99, 0xcb, 0x21, 0x04, 0x39, 0xd5, 0xb1, 0x74, 0xae, 0x1a, 0xc3, 0x26, - 0xc8, 0xf9, 0xcc, 0xe5, 0xb5, 0xe5, 0xed, 0xec, 0x4e, 0x71, 0xef, 0x51, 0xe3, 0xfe, 0xcb, 0xbd, - 0x71, 0xca, 0x5c, 0xac, 0x02, 0xd1, 0xdf, 0xcb, 0x20, 0x7b, 0xca, 0x5c, 0x58, 0x03, 0x6b, 0xc4, - 0x71, 0x62, 0xca, 0xb9, 0xd1, 0x4b, 0x4d, 0xb8, 0x05, 0x56, 0x05, 0x8b, 0xbc, 0xae, 0x16, 0x2d, - 0x60, 0x63, 0x49, 0xbc, 0x43, 0x04, 0x51, 0xdd, 0xbf, 0x84, 0xd5, 0x18, 0xee, 0x81, 0x92, 0x2a, - 0xd6, 0x0e, 0xfb, 0x41, 0x87, 0xc6, 0xaa, 0x89, 0xe7, 0x5a, 0x1b, 0xd7, 0x89, 0x55, 0x54, 0xfe, - 0xef, 0x95, 0x1b, 0xdf, 0x34, 0xe0, 0x63, 0xb0, 0x26, 0x86, 0x37, 0x7b, 0xef, 0xe6, 0x75, 0x62, - 0x6d, 0x88, 0x59, 0xb1, 0xb2, 0xb5, 0xe2, 0x55, 0x31, 0x3c, 0xd1, 0x05, 0xe6, 0xc5, 0xd0, 0xf6, - 0x42, 0x87, 0x0e, 0x55, 0x7b, 0xcd, 0xb5, 0xaa, 0xd7, 0x89, 0x55, 0xb9, 0x11, 0xde, 0x96, 0x73, - 0x78, 0x4d, 0x0c, 0xd5, 0x00, 0x3e, 0x06, 0x40, 0x2f, 0x49, 0x11, 0x74, 0x63, 0x5c, 0xbf, 0x4e, - 0xac, 0x82, 0xf2, 0x2a, 0xed, 0xd9, 0x10, 0x22, 0xb0, 0xa2, 0xb5, 0xf3, 0x4a, 0xbb, 0x74, 0x9d, - 0x58, 0x79, 0x9f, 0xb9, 0x5a, 0x53, 0x4f, 0xc9, 0xad, 0x8a, 0x69, 0xc0, 0x06, 0xd4, 0x51, 0x2d, - 0x27, 0x8f, 0x53, 0xb3, 0x75, 0xf8, 0x7e, 0x5c, 0xcf, 0x7c, 0x18, 0xd7, 0x33, 0xff, 0x8d, 0xeb, - 0x99, 0xdf, 0xaf, 0xea, 0x4b, 0x1f, 0xae, 0xea, 0x4b, 0xff, 0x5c, 0xd5, 0x97, 0x7e, 0xfc, 0xea, - 0xee, 0x77, 0x34, 0xfb, 0x33, 0x1b, 0xaa, 0x7f, 0x33, 0xf5, 0x31, 0x75, 0x56, 0xd5, 0x7f, 0xd6, - 0xd7, 0x1f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x98, 0x33, 0x7d, 0xb9, 0x09, 0x00, 0x00, +var xxx_messageInfo_TxReceipt proto.InternalMessageInfo + +// TxResult stores results of Tx execution. +type TxResult struct { + // contract_address contains the ethereum address of the created contract (if + // any). If the state transition is an evm.Call, the contract address will be + // empty. + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` + // bloom represents the bloom filter bytes + Bloom []byte `protobuf:"bytes,2,opt,name=bloom,proto3" json:"bloom,omitempty"` + // tx_logs contains the transaction hash and the proto-compatible ethereum + // logs. + TxLogs TransactionLogs `protobuf:"bytes,3,opt,name=tx_logs,json=txLogs,proto3" json:"tx_logs" yaml:"tx_logs"` + // ret defines the bytes from the execution. + Ret []byte `protobuf:"bytes,4,opt,name=ret,proto3" json:"ret,omitempty"` + // reverted flag is set to true when the call has been reverted + Reverted bool `protobuf:"varint,5,opt,name=reverted,proto3" json:"reverted,omitempty"` + // gas_used notes the amount of gas consumed while execution + GasUsed uint64 `protobuf:"varint,6,opt,name=gas_used,json=gasUsed,proto3" json:"gas_used,omitempty"` +} + +func (m *TxResult) Reset() { *m = TxResult{} } +func (m *TxResult) String() string { return proto.CompactTextString(m) } +func (*TxResult) ProtoMessage() {} +func (*TxResult) Descriptor() ([]byte, []int) { + return fileDescriptor_5dd0cebaeafb1bee, []int{6} +} +func (m *TxResult) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxResult.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 *TxResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxResult.Merge(m, src) +} +func (m *TxResult) XXX_Size() int { + return m.Size() +} +func (m *TxResult) XXX_DiscardUnknown() { + xxx_messageInfo_TxResult.DiscardUnknown(m) +} + +var xxx_messageInfo_TxResult proto.InternalMessageInfo + +// TxData implements the Ethereum transaction data structure. It is used +// solely as intended in Ethereum abiding by the protocol. +type TxData struct { + AccountNonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"` + Price []byte `protobuf:"bytes,2,opt,name=price,proto3" json:"gasPrice"` + GasLimit uint64 `protobuf:"varint,3,opt,name=gas,proto3" json:"gas,omitempty"` + Recipient []byte `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty"` + Amount []byte `protobuf:"bytes,5,opt,name=value,proto3" json:"value,omitempty"` + Payload []byte `protobuf:"bytes,6,opt,name=input,proto3" json:"input,omitempty"` + // signature values + V []byte `protobuf:"bytes,7,opt,name=v,proto3" json:"v,omitempty"` + R []byte `protobuf:"bytes,8,opt,name=r,proto3" json:"r,omitempty"` + S []byte `protobuf:"bytes,9,opt,name=s,proto3" json:"s,omitempty"` + // hash defines the tx data hash, which is only used when marshaling to JSON. + Hash string `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty" rlp:"-"` +} + +func (m *TxData) Reset() { *m = TxData{} } +func (m *TxData) String() string { return proto.CompactTextString(m) } +func (*TxData) ProtoMessage() {} +func (*TxData) Descriptor() ([]byte, []int) { + return fileDescriptor_5dd0cebaeafb1bee, []int{7} +} +func (m *TxData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TxData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TxData.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 *TxData) XXX_Merge(src proto.Message) { + xxx_messageInfo_TxData.Merge(m, src) +} +func (m *TxData) XXX_Size() int { + return m.Size() +} +func (m *TxData) XXX_DiscardUnknown() { + xxx_messageInfo_TxData.DiscardUnknown(m) +} + +var xxx_messageInfo_TxData proto.InternalMessageInfo + +type BytesList struct { + Bytes [][]byte `protobuf:"bytes,1,rep,name=bytes,proto3" json:"bytes,omitempty"` +} + +func (m *BytesList) Reset() { *m = BytesList{} } +func (m *BytesList) String() string { return proto.CompactTextString(m) } +func (*BytesList) ProtoMessage() {} +func (*BytesList) Descriptor() ([]byte, []int) { + return fileDescriptor_5dd0cebaeafb1bee, []int{8} +} +func (m *BytesList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BytesList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BytesList.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 *BytesList) XXX_Merge(src proto.Message) { + xxx_messageInfo_BytesList.Merge(m, src) +} +func (m *BytesList) XXX_Size() int { + return m.Size() +} +func (m *BytesList) XXX_DiscardUnknown() { + xxx_messageInfo_BytesList.DiscardUnknown(m) +} + +var xxx_messageInfo_BytesList proto.InternalMessageInfo + +func init() { + proto.RegisterType((*Params)(nil), "injective.evm.v1beta1.Params") + proto.RegisterType((*ChainConfig)(nil), "injective.evm.v1beta1.ChainConfig") + proto.RegisterType((*State)(nil), "injective.evm.v1beta1.State") + proto.RegisterType((*TransactionLogs)(nil), "injective.evm.v1beta1.TransactionLogs") + proto.RegisterType((*Log)(nil), "injective.evm.v1beta1.Log") + proto.RegisterType((*TxReceipt)(nil), "injective.evm.v1beta1.TxReceipt") + proto.RegisterType((*TxResult)(nil), "injective.evm.v1beta1.TxResult") + proto.RegisterType((*TxData)(nil), "injective.evm.v1beta1.TxData") + proto.RegisterType((*BytesList)(nil), "injective.evm.v1beta1.BytesList") +} + +func init() { proto.RegisterFile("injective/evm/v1beta1/evm.proto", fileDescriptor_5dd0cebaeafb1bee) } + +var fileDescriptor_5dd0cebaeafb1bee = []byte{ + // 1450 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x57, 0x3b, 0x6f, 0x1b, 0xc7, + 0x16, 0x16, 0x1f, 0xa2, 0xc8, 0xe1, 0x8a, 0xe2, 0x1d, 0xcb, 0xba, 0xb4, 0x7d, 0xad, 0xd5, 0xdd, + 0xc2, 0x57, 0x85, 0x25, 0x5a, 0xba, 0x10, 0x6c, 0x08, 0x48, 0xa1, 0xb5, 0x65, 0x9b, 0x88, 0xec, + 0x08, 0x63, 0x39, 0x02, 0xd2, 0x10, 0xc3, 0xdd, 0xf1, 0x6a, 0xad, 0xdd, 0x9d, 0xcd, 0xce, 0x90, + 0x26, 0x03, 0x04, 0x48, 0x99, 0xd2, 0x65, 0xca, 0xb4, 0xf9, 0x23, 0x81, 0x91, 0xca, 0x65, 0x90, + 0x62, 0x11, 0xd0, 0x9d, 0x4a, 0xb6, 0x49, 0x11, 0xcc, 0x63, 0xf9, 0x90, 0xe5, 0x82, 0x70, 0xc5, + 0x39, 0x67, 0xce, 0x7c, 0xdf, 0x9c, 0xe7, 0x2c, 0x81, 0xe9, 0x47, 0xaf, 0x89, 0xc3, 0xfd, 0x1e, + 0x69, 0x92, 0x5e, 0xd8, 0xec, 0xed, 0x74, 0x08, 0xc7, 0x3b, 0x62, 0xbd, 0x1d, 0x27, 0x94, 0x53, + 0x78, 0x7d, 0x6c, 0xb0, 0x2d, 0x94, 0xda, 0xe0, 0xe6, 0xaa, 0x47, 0x3d, 0x2a, 0x2d, 0x9a, 0x62, + 0xa5, 0x8c, 0xad, 0xbf, 0x73, 0xa0, 0x74, 0x8c, 0x13, 0x1c, 0x32, 0xb8, 0x03, 0x2a, 0xa4, 0x17, + 0xb6, 0x5d, 0x12, 0xd1, 0xb0, 0x91, 0xdb, 0xc8, 0x6d, 0x56, 0xec, 0xd5, 0x51, 0x6a, 0xd6, 0x07, + 0x38, 0x0c, 0xf6, 0xad, 0xf1, 0x96, 0x85, 0xca, 0xa4, 0x17, 0x3e, 0x12, 0x4b, 0xf8, 0x05, 0x58, + 0x26, 0x11, 0xee, 0x04, 0xa4, 0xed, 0x24, 0x04, 0x73, 0xd2, 0xc8, 0x6f, 0xe4, 0x36, 0xcb, 0x76, + 0x63, 0x94, 0x9a, 0xab, 0xfa, 0xd8, 0xf4, 0xb6, 0x85, 0x0c, 0x25, 0x3f, 0x94, 0x22, 0xbc, 0x0f, + 0xaa, 0xd9, 0x3e, 0x0e, 0x82, 0x46, 0x41, 0x1e, 0x5e, 0x1b, 0xa5, 0x26, 0x9c, 0x3d, 0x8c, 0x83, + 0xc0, 0x42, 0x40, 0x1f, 0xc5, 0x41, 0x00, 0x0f, 0x00, 0x20, 0x7d, 0x9e, 0xe0, 0x36, 0xf1, 0x63, + 0xd6, 0x28, 0x6e, 0x14, 0x36, 0x0b, 0xb6, 0x35, 0x4c, 0xcd, 0xca, 0xa1, 0xd0, 0x1e, 0xb6, 0x8e, + 0xd9, 0x28, 0x35, 0xff, 0xa5, 0x41, 0xc6, 0x86, 0x16, 0xaa, 0x48, 0xe1, 0xd0, 0x8f, 0xd9, 0x7e, + 0xf1, 0xa7, 0x9f, 0xcd, 0x05, 0xeb, 0x57, 0x03, 0x54, 0x1f, 0x9e, 0x61, 0x3f, 0x7a, 0x48, 0xa3, + 0x57, 0xbe, 0x07, 0xbf, 0x05, 0x2b, 0x67, 0x34, 0x24, 0x8c, 0x13, 0xec, 0xb6, 0x3b, 0x01, 0x75, + 0xce, 0x75, 0x24, 0x9e, 0xbe, 0x4b, 0xcd, 0x85, 0x3f, 0x52, 0xf3, 0x8e, 0xe7, 0xf3, 0xb3, 0x6e, + 0x67, 0xdb, 0xa1, 0x61, 0xd3, 0xa1, 0x2c, 0xa4, 0x4c, 0xff, 0x6c, 0x31, 0xf7, 0xbc, 0xc9, 0x07, + 0x31, 0x61, 0xdb, 0xad, 0x88, 0x8f, 0x52, 0x73, 0x4d, 0xd1, 0x5f, 0x82, 0xb3, 0x50, 0x6d, 0xac, + 0xb1, 0x85, 0x02, 0x7e, 0x0f, 0x6a, 0x2e, 0xa6, 0xed, 0x57, 0x34, 0x39, 0xd7, 0x8c, 0x79, 0xc9, + 0x78, 0x3a, 0x1f, 0xe3, 0x30, 0x35, 0x8d, 0x47, 0x07, 0x5f, 0x3d, 0xa6, 0xc9, 0xb9, 0xc4, 0x1d, + 0xa5, 0xe6, 0x75, 0x75, 0x83, 0x59, 0x74, 0x0b, 0x19, 0x2e, 0xa6, 0x63, 0x33, 0x78, 0x0a, 0xea, + 0x63, 0x03, 0xd6, 0x8d, 0x63, 0x9a, 0x70, 0x9d, 0x88, 0xad, 0x61, 0x6a, 0xd6, 0x34, 0xe4, 0x0b, + 0xb5, 0x33, 0x4a, 0xcd, 0x7f, 0x5f, 0x02, 0xd5, 0x67, 0x2c, 0x54, 0xd3, 0xb0, 0xda, 0x14, 0xbe, + 0x01, 0x06, 0xf1, 0xe3, 0x9d, 0xbd, 0x7b, 0xda, 0xab, 0xa2, 0xf4, 0xea, 0x64, 0x6e, 0xaf, 0xaa, + 0x87, 0xad, 0xe3, 0x9d, 0xbd, 0x7b, 0x99, 0x53, 0xd7, 0x74, 0x56, 0xa7, 0xa0, 0x2d, 0x54, 0x55, + 0xa2, 0xf2, 0xa8, 0x05, 0xb4, 0xd8, 0x3e, 0xc3, 0xec, 0xac, 0xb1, 0x28, 0x79, 0x37, 0x87, 0xa9, + 0x09, 0x14, 0xd2, 0x53, 0xcc, 0xce, 0x26, 0xf9, 0xe9, 0x0c, 0xbe, 0xc3, 0x11, 0xf7, 0xbb, 0x61, + 0x86, 0x05, 0xd4, 0x61, 0x61, 0x35, 0xf6, 0x61, 0x4f, 0xfb, 0x50, 0xfa, 0x2c, 0x1f, 0xf6, 0xae, + 0xf2, 0x61, 0x6f, 0xd6, 0x07, 0x65, 0x33, 0x26, 0x7e, 0xa0, 0x89, 0x97, 0x3e, 0x8b, 0xf8, 0xc1, + 0x55, 0xc4, 0x0f, 0x66, 0x89, 0x95, 0x8d, 0x68, 0x80, 0x4b, 0x11, 0x69, 0x94, 0x3f, 0xaf, 0x01, + 0x3e, 0x0a, 0x70, 0x6d, 0xac, 0x51, 0x94, 0x3f, 0xe4, 0xc0, 0xaa, 0x43, 0x23, 0xc6, 0x85, 0x32, + 0xa2, 0x71, 0x40, 0x34, 0x71, 0x45, 0x12, 0x3f, 0x9b, 0x9b, 0xf8, 0x96, 0x22, 0xbe, 0x0a, 0xd3, + 0x42, 0xd7, 0x66, 0xd5, 0xea, 0x0a, 0x1c, 0xd4, 0x63, 0xc2, 0x49, 0xc2, 0x3a, 0xdd, 0xc4, 0xd3, + 0xec, 0x40, 0xb2, 0xb7, 0xe6, 0x66, 0xd7, 0x0d, 0x72, 0x19, 0xcf, 0x42, 0x2b, 0x13, 0x95, 0x62, + 0x8d, 0x40, 0xcd, 0x17, 0x57, 0xe9, 0x74, 0x03, 0xcd, 0x59, 0x95, 0x9c, 0x4f, 0xe6, 0xe6, 0xd4, + 0x9d, 0x3e, 0x8b, 0x66, 0xa1, 0xe5, 0x4c, 0xa1, 0xf8, 0x06, 0x00, 0x86, 0x5d, 0x3f, 0x69, 0x7b, + 0x01, 0x76, 0x7c, 0x92, 0x68, 0x4e, 0x43, 0x72, 0x7e, 0x39, 0x37, 0xe7, 0x0d, 0xc5, 0xf9, 0x31, + 0xa2, 0x85, 0xea, 0x42, 0xf9, 0x44, 0xe9, 0x14, 0xf5, 0x6b, 0xb0, 0x3c, 0xa0, 0x01, 0x6d, 0xf7, + 0x76, 0x35, 0xeb, 0xb2, 0x64, 0x7d, 0x3c, 0x37, 0xab, 0x7e, 0x56, 0x66, 0xc0, 0x2c, 0x54, 0x15, + 0xf2, 0xd7, 0xbb, 0x8a, 0x8b, 0x81, 0x2a, 0x79, 0x83, 0x59, 0x56, 0xbe, 0x35, 0xc9, 0x84, 0xe6, + 0x6e, 0x1d, 0x70, 0x78, 0x7a, 0xf0, 0xe2, 0x59, 0xd6, 0x39, 0xd9, 0x8b, 0x34, 0x01, 0x16, 0x93, + 0x42, 0x48, 0xd2, 0xc2, 0x6a, 0x82, 0xc5, 0x17, 0x5c, 0xbc, 0x69, 0x75, 0x50, 0x38, 0x27, 0x03, + 0xf5, 0x6a, 0x20, 0xb1, 0x84, 0xab, 0x60, 0xb1, 0x87, 0x83, 0xae, 0x7a, 0x1c, 0x2b, 0x48, 0x09, + 0xd6, 0x4b, 0xb0, 0x72, 0x92, 0xe0, 0x88, 0x61, 0x87, 0xfb, 0x34, 0x3a, 0xa2, 0x1e, 0x83, 0x10, + 0x14, 0xe5, 0xc4, 0x52, 0x67, 0xe5, 0x1a, 0x6e, 0x83, 0x62, 0x40, 0x3d, 0xd6, 0xc8, 0x6f, 0x14, + 0x36, 0xab, 0xbb, 0x37, 0xb7, 0xaf, 0x7c, 0xdb, 0xb7, 0x8f, 0xa8, 0x87, 0xa4, 0x9d, 0xf5, 0x5b, + 0x1e, 0x14, 0x8e, 0xa8, 0x07, 0x1b, 0x60, 0x09, 0xbb, 0x6e, 0x42, 0x18, 0xd3, 0x70, 0x99, 0x08, + 0xd7, 0x40, 0x89, 0xd3, 0xd8, 0x77, 0x14, 0x66, 0x05, 0x69, 0x49, 0xb0, 0xbb, 0x98, 0x63, 0x39, + 0xfc, 0x0d, 0x24, 0xd7, 0x70, 0x17, 0x18, 0xd2, 0xd7, 0x76, 0xd4, 0x0d, 0x3b, 0x24, 0x91, 0x33, + 0xbc, 0x68, 0xaf, 0x5c, 0xa4, 0x66, 0x55, 0xea, 0x9f, 0x4b, 0x35, 0x9a, 0x16, 0xe0, 0x5d, 0xb0, + 0xc4, 0xfb, 0xd3, 0xa3, 0xf7, 0xda, 0x45, 0x6a, 0xae, 0xf0, 0x89, 0xaf, 0x62, 0xb2, 0xa2, 0x12, + 0xef, 0xcb, 0x09, 0xdb, 0x04, 0x65, 0xde, 0x6f, 0xfb, 0x91, 0x4b, 0xfa, 0x72, 0xba, 0x16, 0xed, + 0xd5, 0x8b, 0xd4, 0xac, 0x4f, 0x99, 0xb7, 0xc4, 0x1e, 0x5a, 0xe2, 0x7d, 0xb9, 0x80, 0x77, 0x01, + 0x50, 0x57, 0x92, 0x0c, 0x6a, 0x2e, 0x2e, 0x5f, 0xa4, 0x66, 0x45, 0x6a, 0x25, 0xf6, 0x64, 0x09, + 0x2d, 0xb0, 0xa8, 0xb0, 0xcb, 0x12, 0xdb, 0xb8, 0x48, 0xcd, 0x72, 0x40, 0x3d, 0x85, 0xa9, 0xb6, + 0x44, 0xa8, 0x12, 0x12, 0xd2, 0x1e, 0x71, 0xe5, 0xc4, 0x29, 0xa3, 0x4c, 0xb4, 0xfe, 0xca, 0x81, + 0xca, 0x49, 0x1f, 0x11, 0x87, 0xf8, 0x31, 0x9f, 0x49, 0x8f, 0xa1, 0xd3, 0x03, 0x41, 0xf1, 0x55, + 0x42, 0x43, 0x99, 0x5a, 0x03, 0xc9, 0x35, 0xdc, 0x99, 0x0a, 0x64, 0x75, 0xf7, 0xf6, 0x27, 0x52, + 0x76, 0xd2, 0x7f, 0x84, 0x39, 0xd6, 0x71, 0xbe, 0x0f, 0x4a, 0x09, 0x61, 0xdd, 0x80, 0xcb, 0x08, + 0x57, 0x77, 0xcd, 0x4f, 0x1e, 0x42, 0xd2, 0x0c, 0x69, 0x73, 0x51, 0x5b, 0xca, 0x3f, 0x11, 0xea, + 0x62, 0xe6, 0xd1, 0x06, 0x50, 0x19, 0x79, 0x4a, 0x7c, 0xef, 0x8c, 0xab, 0xb8, 0xa2, 0x69, 0x15, + 0xfc, 0x0f, 0x98, 0x04, 0x49, 0x06, 0xd1, 0x98, 0x8a, 0xda, 0x7e, 0xf1, 0x47, 0xf1, 0x6d, 0xf4, + 0x36, 0x0f, 0xca, 0x19, 0x21, 0x7c, 0x0c, 0xea, 0x0e, 0x8d, 0x78, 0x82, 0x1d, 0xde, 0x9e, 0x29, + 0x2c, 0xfb, 0xd6, 0x64, 0xe6, 0x5d, 0xb6, 0xb0, 0xd0, 0x4a, 0xa6, 0x3a, 0xd0, 0xd5, 0xb7, 0x0a, + 0x16, 0x3b, 0x01, 0x1d, 0x47, 0x4c, 0x09, 0xf0, 0x54, 0xd6, 0x8c, 0x2c, 0x74, 0x15, 0xb5, 0x3b, + 0x9f, 0x0a, 0xc0, 0x6c, 0xcb, 0xd8, 0x6b, 0xa2, 0xad, 0x47, 0xa9, 0x59, 0x53, 0x17, 0xd0, 0x20, + 0x96, 0x28, 0x2f, 0xd9, 0x52, 0x75, 0x50, 0x48, 0x88, 0x8a, 0xaa, 0x81, 0xc4, 0x12, 0xde, 0x04, + 0xe5, 0x84, 0xf4, 0x48, 0xc2, 0x89, 0x2b, 0x83, 0x56, 0x46, 0x63, 0x19, 0xde, 0x00, 0x65, 0x0f, + 0xb3, 0x76, 0x97, 0x11, 0x57, 0x07, 0x6d, 0xc9, 0xc3, 0xec, 0x25, 0x23, 0xae, 0x0e, 0xc9, 0x2f, + 0x79, 0x50, 0x52, 0x89, 0x83, 0x77, 0xc0, 0x62, 0x44, 0x23, 0x87, 0xc8, 0x28, 0x14, 0xed, 0xba, + 0xf8, 0xfe, 0x3a, 0x70, 0x1c, 0xda, 0x8d, 0xf8, 0x73, 0xa1, 0x47, 0x6a, 0x5b, 0x54, 0x60, 0x9c, + 0xf8, 0x8e, 0xea, 0x7e, 0x43, 0x55, 0xa0, 0x87, 0xd9, 0xb1, 0xd0, 0x21, 0xb5, 0x05, 0xd7, 0x41, + 0xc1, 0xc3, 0xca, 0xf5, 0xa2, 0x6d, 0x0c, 0x53, 0xb3, 0xfc, 0x04, 0xb3, 0x23, 0x3f, 0xf4, 0x39, + 0x12, 0x1b, 0xf0, 0x36, 0xc8, 0x73, 0xaa, 0x9c, 0xb0, 0x97, 0xc5, 0x67, 0x2e, 0x22, 0x8e, 0x1f, + 0xfb, 0x24, 0xe2, 0x28, 0xcf, 0x29, 0xdc, 0xc8, 0x06, 0xcc, 0xa2, 0xb4, 0x00, 0xc3, 0xd4, 0x2c, + 0x1d, 0x84, 0xe2, 0x26, 0x7a, 0xd8, 0xc0, 0xff, 0x8a, 0x32, 0x89, 0xbb, 0xaa, 0x14, 0x0c, 0xbb, + 0x3a, 0x4c, 0xcd, 0xa5, 0x63, 0x3c, 0x08, 0x28, 0x76, 0x91, 0xda, 0x81, 0x06, 0xc8, 0xf5, 0x74, + 0x25, 0xe4, 0x7a, 0x42, 0x4a, 0x64, 0xcf, 0x18, 0x28, 0x97, 0x08, 0x89, 0xc9, 0xde, 0x30, 0x50, + 0x8e, 0x41, 0x53, 0xf7, 0x81, 0x7a, 0x20, 0xab, 0xa3, 0xd4, 0x5c, 0x4a, 0x82, 0x78, 0xdf, 0xda, + 0xb2, 0x54, 0x53, 0xe8, 0x58, 0xfd, 0x0f, 0x54, 0xec, 0x01, 0x27, 0xec, 0xc8, 0x67, 0xb2, 0x4e, + 0x3b, 0x42, 0x68, 0xe4, 0x36, 0x0a, 0x32, 0xed, 0x42, 0x50, 0x86, 0xb6, 0xf3, 0x6e, 0xb8, 0x9e, + 0x7b, 0x3f, 0x5c, 0xcf, 0xfd, 0x39, 0x5c, 0xcf, 0xbd, 0xfd, 0xb0, 0xbe, 0xf0, 0xfe, 0xc3, 0xfa, + 0xc2, 0xef, 0x1f, 0xd6, 0x17, 0xbe, 0x69, 0x4d, 0x0d, 0xeb, 0x56, 0x56, 0x0f, 0x47, 0xb8, 0xc3, + 0x9a, 0xe3, 0xea, 0xd8, 0x72, 0x68, 0x42, 0xa6, 0x45, 0xf1, 0x31, 0xdf, 0x0c, 0xa9, 0xdb, 0x0d, + 0x08, 0x93, 0x7f, 0x90, 0xe4, 0x4c, 0xef, 0x94, 0xe4, 0xdf, 0x9d, 0xff, 0xff, 0x13, 0x00, 0x00, + 0xff, 0xff, 0x97, 0x23, 0xde, 0x19, 0x3e, 0x0d, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -890,6 +1104,274 @@ func (m *Log) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TxReceipt) 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 *TxReceipt) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxReceipt) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockHash) > 0 { + i -= len(m.BlockHash) + copy(dAtA[i:], m.BlockHash) + i = encodeVarintEvm(dAtA, i, uint64(len(m.BlockHash))) + i-- + dAtA[i] = 0x3a + } + if m.BlockHeight != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x30 + } + if m.Index != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x28 + } + if m.Result != nil { + { + size, err := m.Result.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.Data != nil { + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.From) > 0 { + i -= len(m.From) + copy(dAtA[i:], m.From) + i = encodeVarintEvm(dAtA, i, uint64(len(m.From))) + i-- + dAtA[i] = 0x12 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TxResult) 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 *TxResult) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.GasUsed != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.GasUsed)) + i-- + dAtA[i] = 0x30 + } + if m.Reverted { + i-- + if m.Reverted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if len(m.Ret) > 0 { + i -= len(m.Ret) + copy(dAtA[i:], m.Ret) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Ret))) + i-- + dAtA[i] = 0x22 + } + { + size, err := m.TxLogs.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintEvm(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Bloom) > 0 { + i -= len(m.Bloom) + copy(dAtA[i:], m.Bloom) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Bloom))) + i-- + dAtA[i] = 0x12 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintEvm(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TxData) 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 *TxData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TxData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x52 + } + if len(m.S) > 0 { + i -= len(m.S) + copy(dAtA[i:], m.S) + i = encodeVarintEvm(dAtA, i, uint64(len(m.S))) + i-- + dAtA[i] = 0x4a + } + if len(m.R) > 0 { + i -= len(m.R) + copy(dAtA[i:], m.R) + i = encodeVarintEvm(dAtA, i, uint64(len(m.R))) + i-- + dAtA[i] = 0x42 + } + if len(m.V) > 0 { + i -= len(m.V) + copy(dAtA[i:], m.V) + i = encodeVarintEvm(dAtA, i, uint64(len(m.V))) + i-- + dAtA[i] = 0x3a + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0x32 + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x2a + } + if len(m.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Recipient))) + i-- + dAtA[i] = 0x22 + } + if m.GasLimit != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.GasLimit)) + i-- + dAtA[i] = 0x18 + } + if len(m.Price) > 0 { + i -= len(m.Price) + copy(dAtA[i:], m.Price) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Price))) + i-- + dAtA[i] = 0x12 + } + if m.AccountNonce != 0 { + i = encodeVarintEvm(dAtA, i, uint64(m.AccountNonce)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BytesList) 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 *BytesList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BytesList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Bytes) > 0 { + for iNdEx := len(m.Bytes) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Bytes[iNdEx]) + copy(dAtA[i:], m.Bytes[iNdEx]) + i = encodeVarintEvm(dAtA, i, uint64(len(m.Bytes[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintEvm(dAtA []byte, offset int, v uint64) int { offset -= sovEvm(v) base := offset @@ -1046,6 +1528,132 @@ func (m *Log) Size() (n int) { return n } +func (m *TxReceipt) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.From) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + if m.Data != nil { + l = m.Data.Size() + n += 1 + l + sovEvm(uint64(l)) + } + if m.Result != nil { + l = m.Result.Size() + n += 1 + l + sovEvm(uint64(l)) + } + if m.Index != 0 { + n += 1 + sovEvm(uint64(m.Index)) + } + if m.BlockHeight != 0 { + n += 1 + sovEvm(uint64(m.BlockHeight)) + } + l = len(m.BlockHash) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + return n +} + +func (m *TxResult) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.Bloom) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = m.TxLogs.Size() + n += 1 + l + sovEvm(uint64(l)) + l = len(m.Ret) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + if m.Reverted { + n += 2 + } + if m.GasUsed != 0 { + n += 1 + sovEvm(uint64(m.GasUsed)) + } + return n +} + +func (m *TxData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.AccountNonce != 0 { + n += 1 + sovEvm(uint64(m.AccountNonce)) + } + l = len(m.Price) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + if m.GasLimit != 0 { + n += 1 + sovEvm(uint64(m.GasLimit)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.V) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.R) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.S) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovEvm(uint64(l)) + } + return n +} + +func (m *BytesList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Bytes) > 0 { + for _, b := range m.Bytes { + l = len(b) + n += 1 + l + sovEvm(uint64(l)) + } + } + return n +} + func sovEvm(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1235,10 +1843,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthEvm - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } if (iNdEx + skippy) > l { @@ -1748,10 +2353,7 @@ func (m *ChainConfig) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthEvm - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } if (iNdEx + skippy) > l { @@ -1865,10 +2467,7 @@ func (m *State) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthEvm - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } if (iNdEx + skippy) > l { @@ -1984,10 +2583,7 @@ func (m *TransactionLogs) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthEvm - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } if (iNdEx + skippy) > l { @@ -2276,10 +2872,931 @@ func (m *Log) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxReceipt) 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 ErrIntOverflowEvm + } + 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: TxReceipt: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxReceipt: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field From", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.From = append(m.From[:0], dAtA[iNdEx:postIndex]...) + if m.From == nil { + m.From = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = &TxData{} + } + if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Result == nil { + m.Result = &TxResult{} + } + if err := m.Result.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHash = append(m.BlockHash[:0], dAtA[iNdEx:postIndex]...) + if m.BlockHash == nil { + m.BlockHash = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxResult) 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 ErrIntOverflowEvm + } + 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: TxResult: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxResult: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + 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 ErrInvalidLengthEvm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bloom", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bloom = append(m.Bloom[:0], dAtA[iNdEx:postIndex]...) + if m.Bloom == nil { + m.Bloom = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxLogs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TxLogs.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ret", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Ret = append(m.Ret[:0], dAtA[iNdEx:postIndex]...) + if m.Ret == nil { + m.Ret = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Reverted", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Reverted = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasUsed", wireType) + } + m.GasUsed = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasUsed |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TxData) 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 ErrIntOverflowEvm + } + 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: TxData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TxData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountNonce", wireType) + } + m.AccountNonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountNonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Price = append(m.Price[:0], dAtA[iNdEx:postIndex]...) + if m.Price == nil { + m.Price = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) + } + m.GasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.GasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Recipient = append(m.Recipient[:0], dAtA[iNdEx:postIndex]...) + if m.Recipient == nil { + m.Recipient = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount[:0], dAtA[iNdEx:postIndex]...) + if m.Amount == nil { + m.Amount = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field V", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...) + if m.V == nil { + m.V = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field R", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...) + if m.R == nil { + m.R = []byte{} + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field S", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...) + if m.S == nil { + m.S = []byte{} + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + 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 ErrInvalidLengthEvm + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvm + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BytesList) 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 ErrIntOverflowEvm + } + 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: BytesList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BytesList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvm + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthEvm + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthEvm + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bytes = append(m.Bytes, make([]byte, postIndex-iNdEx)) + copy(m.Bytes[len(m.Bytes)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvm(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthEvm } if (iNdEx + skippy) > l { diff --git a/x/evm/types/genesis.go b/x/evm/types/genesis.go index 8768852e..fb084eae 100644 --- a/x/evm/types/genesis.go +++ b/x/evm/types/genesis.go @@ -4,13 +4,12 @@ import ( "errors" "fmt" - ethermint "github.com/cosmos/ethermint/types" ethcmn "github.com/ethereum/go-ethereum/common" ) // Validate performs a basic validation of a GenesisAccount fields. func (ga GenesisAccount) Validate() error { - if ethermint.IsZeroAddress(ga.Address) { + if IsZeroAddress(ga.Address) { return fmt.Errorf("address cannot be the zero address %s", ga.Address) } if len(ethcmn.Hex2Bytes(ga.Code)) == 0 { diff --git a/x/evm/types/genesis.pb.go b/x/evm/types/genesis.pb.go index 56adf308..0c60ca1c 100644 --- a/x/evm/types/genesis.pb.go +++ b/x/evm/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/evm/v1alpha1/genesis.proto +// source: injective/evm/v1beta1/genesis.proto package types @@ -38,7 +38,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_8205a12b97b89a87, []int{0} + return fileDescriptor_edebcfd612cffc8a, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -111,7 +111,7 @@ func (m *GenesisAccount) Reset() { *m = GenesisAccount{} } func (m *GenesisAccount) String() string { return proto.CompactTextString(m) } func (*GenesisAccount) ProtoMessage() {} func (*GenesisAccount) Descriptor() ([]byte, []int) { - return fileDescriptor_8205a12b97b89a87, []int{1} + return fileDescriptor_edebcfd612cffc8a, []int{1} } func (m *GenesisAccount) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -162,42 +162,43 @@ func (m *GenesisAccount) GetStorage() Storage { } func init() { - proto.RegisterType((*GenesisState)(nil), "ethermint.evm.v1alpha1.GenesisState") - proto.RegisterType((*GenesisAccount)(nil), "ethermint.evm.v1alpha1.GenesisAccount") + proto.RegisterType((*GenesisState)(nil), "injective.evm.v1beta1.GenesisState") + proto.RegisterType((*GenesisAccount)(nil), "injective.evm.v1beta1.GenesisAccount") } func init() { - proto.RegisterFile("ethermint/evm/v1alpha1/genesis.proto", fileDescriptor_8205a12b97b89a87) + proto.RegisterFile("injective/evm/v1beta1/genesis.proto", fileDescriptor_edebcfd612cffc8a) } -var fileDescriptor_8205a12b97b89a87 = []byte{ - // 405 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xb1, 0x8e, 0xda, 0x30, - 0x18, 0xc7, 0x13, 0x40, 0x04, 0x0c, 0x2a, 0x92, 0x5b, 0xb5, 0x11, 0x55, 0x03, 0x4a, 0xab, 0xc2, - 0x94, 0x08, 0xba, 0x55, 0x5d, 0x08, 0x43, 0x19, 0x3a, 0x54, 0xa1, 0x53, 0x3b, 0x20, 0x63, 0x5c, - 0x27, 0x12, 0x89, 0xa3, 0xd8, 0x20, 0x78, 0x83, 0x1b, 0xef, 0x39, 0xee, 0x49, 0x18, 0x19, 0x99, - 0xb8, 0x13, 0xbc, 0xc1, 0x3d, 0xc1, 0x29, 0x4e, 0x02, 0x77, 0xd2, 0x65, 0x73, 0xa4, 0xdf, 0xff, - 0xe7, 0x7f, 0x3e, 0x7f, 0xe0, 0x0b, 0x11, 0x1e, 0x89, 0x03, 0x3f, 0x14, 0x36, 0x59, 0x07, 0xf6, - 0x7a, 0x80, 0x96, 0x91, 0x87, 0x06, 0x36, 0x25, 0x21, 0xe1, 0x3e, 0xb7, 0xa2, 0x98, 0x09, 0x06, - 0xdf, 0x5f, 0x28, 0x8b, 0xac, 0x03, 0x2b, 0xa7, 0xda, 0xef, 0x28, 0xa3, 0x4c, 0x22, 0x76, 0x72, - 0x4a, 0xe9, 0x76, 0xb7, 0xc0, 0x99, 0x44, 0x25, 0x61, 0x1e, 0x4a, 0xa0, 0xf9, 0x33, 0xbd, 0x61, - 0x2a, 0x90, 0x20, 0x70, 0x02, 0x6a, 0x08, 0x63, 0xb6, 0x0a, 0x05, 0xd7, 0xd5, 0x6e, 0xb9, 0xdf, - 0x18, 0x7e, 0xb5, 0x5e, 0xbf, 0xd3, 0xca, 0x72, 0xa3, 0x14, 0x77, 0x2a, 0xbb, 0x63, 0x47, 0x71, - 0x2f, 0x69, 0x88, 0x41, 0x13, 0x7b, 0xc8, 0x0f, 0x67, 0x98, 0x85, 0xff, 0x7d, 0xaa, 0x97, 0xba, - 0x6a, 0xbf, 0x31, 0xfc, 0x5c, 0x64, 0x1b, 0x27, 0xec, 0x58, 0xa2, 0xce, 0xc7, 0x44, 0xf5, 0x78, - 0xec, 0xbc, 0xdd, 0xa2, 0x60, 0xf9, 0xdd, 0x7c, 0xae, 0x31, 0xdd, 0x06, 0xbe, 0x92, 0xf0, 0x07, - 0xa8, 0x46, 0x28, 0x46, 0x01, 0xd7, 0xcb, 0x52, 0x6f, 0x14, 0xe9, 0x7f, 0x4b, 0x2a, 0x2b, 0x99, - 0x65, 0xe0, 0x3f, 0x50, 0x13, 0x1b, 0x3e, 0x5b, 0x32, 0xca, 0xf5, 0x8a, 0xfc, 0xd9, 0x5e, 0x51, - 0xfe, 0x4f, 0x8c, 0x42, 0x8e, 0xb0, 0xf0, 0x59, 0xf8, 0x8b, 0x51, 0xee, 0x7c, 0xc8, 0x2a, 0xb6, - 0xd2, 0x8a, 0xb9, 0xc6, 0x74, 0x35, 0xb1, 0xe1, 0x09, 0x61, 0xde, 0xa8, 0xe0, 0xcd, 0xcb, 0x11, - 0x41, 0x1d, 0x68, 0x68, 0xb1, 0x88, 0x09, 0x4f, 0x66, 0xab, 0xf6, 0xeb, 0x6e, 0xfe, 0x09, 0x21, - 0xa8, 0x60, 0xb6, 0x20, 0x72, 0x48, 0x75, 0x57, 0x9e, 0xe1, 0x04, 0x68, 0x5c, 0xb0, 0x18, 0x51, - 0xa2, 0x97, 0x65, 0xb9, 0x4f, 0x45, 0xe5, 0xe4, 0xd3, 0x39, 0xad, 0xa4, 0xd2, 0xdd, 0x7d, 0x47, - 0x9b, 0xa6, 0x29, 0x37, 0x8f, 0x3b, 0xa3, 0xdd, 0xc9, 0x50, 0xf7, 0x27, 0x43, 0x7d, 0x38, 0x19, - 0xea, 0xed, 0xd9, 0x50, 0xf6, 0x67, 0x43, 0x39, 0x9c, 0x0d, 0xe5, 0x6f, 0x8f, 0xfa, 0xc2, 0x5b, - 0xcd, 0x2d, 0xcc, 0x02, 0x1b, 0x33, 0x1e, 0x30, 0x6e, 0x5f, 0x77, 0x66, 0x23, 0xb7, 0x46, 0x6c, - 0x23, 0xc2, 0xe7, 0x55, 0xb9, 0x2f, 0xdf, 0x9e, 0x02, 0x00, 0x00, 0xff, 0xff, 0xf3, 0x74, 0xbc, - 0x46, 0xa7, 0x02, 0x00, 0x00, +var fileDescriptor_edebcfd612cffc8a = []byte{ + // 420 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xc1, 0x8e, 0xd2, 0x40, + 0x18, 0xc7, 0xdb, 0x85, 0x6c, 0x77, 0x87, 0x8d, 0x9b, 0x8c, 0x1a, 0x1b, 0xd4, 0x96, 0xd4, 0x68, + 0xb8, 0xd8, 0x06, 0xbc, 0xe9, 0xc9, 0x72, 0x20, 0x24, 0x1c, 0x4c, 0xf1, 0xc4, 0x85, 0x4c, 0xa7, + 0xe3, 0x50, 0x43, 0x3b, 0xa4, 0x33, 0x34, 0xf0, 0x04, 0x5e, 0x7d, 0x0e, 0x9f, 0x84, 0x23, 0x07, + 0x0f, 0x9e, 0xd0, 0xc0, 0x1b, 0xf8, 0x04, 0x66, 0xa6, 0x2d, 0xb2, 0x09, 0xbd, 0xcd, 0x24, 0xbf, + 0xff, 0x6f, 0xfe, 0xfd, 0xfa, 0x81, 0x57, 0x71, 0xfa, 0x95, 0x60, 0x11, 0xe7, 0xc4, 0x23, 0x79, + 0xe2, 0xe5, 0xbd, 0x90, 0x08, 0xd4, 0xf3, 0x28, 0x49, 0x09, 0x8f, 0xb9, 0xbb, 0xcc, 0x98, 0x60, + 0xf0, 0xe9, 0x09, 0x72, 0x49, 0x9e, 0xb8, 0x25, 0xd4, 0x7e, 0x42, 0x19, 0x65, 0x8a, 0xf0, 0xe4, + 0xa9, 0x80, 0xdb, 0xf6, 0x65, 0xa3, 0x0c, 0x2a, 0xc0, 0xf9, 0x79, 0x05, 0xee, 0x86, 0x85, 0x7f, + 0x22, 0x90, 0x20, 0x70, 0x08, 0x6e, 0x10, 0xc6, 0x6c, 0x95, 0x0a, 0x6e, 0xea, 0x9d, 0x46, 0xb7, + 0xd5, 0x7f, 0xed, 0x5e, 0x7c, 0xd1, 0x2d, 0x63, 0x1f, 0x0b, 0xda, 0x6f, 0x6e, 0xf7, 0xb6, 0x16, + 0x9c, 0xc2, 0x30, 0x04, 0x77, 0x78, 0x8e, 0xe2, 0x74, 0x86, 0x59, 0xfa, 0x25, 0xa6, 0xe6, 0x55, + 0x47, 0xef, 0xb6, 0xfa, 0x4e, 0x8d, 0x6c, 0x20, 0xd1, 0x81, 0x22, 0xfd, 0xe7, 0xd2, 0xf4, 0x77, + 0x6f, 0x3f, 0xde, 0xa0, 0x64, 0xf1, 0xde, 0x39, 0xb7, 0x38, 0x41, 0x0b, 0xff, 0x27, 0xe1, 0x07, + 0x70, 0xbd, 0x44, 0x19, 0x4a, 0xb8, 0xd9, 0x50, 0xf6, 0x97, 0x35, 0xf6, 0x4f, 0x0a, 0x2a, 0x2b, + 0x96, 0x11, 0x38, 0x05, 0x37, 0x62, 0xcd, 0x67, 0x0b, 0x46, 0xb9, 0xd9, 0x54, 0x5f, 0xfa, 0xa6, + 0x26, 0xfe, 0x39, 0x43, 0x29, 0x47, 0x58, 0xc4, 0x2c, 0x1d, 0x33, 0xca, 0xfd, 0x67, 0x65, 0xc1, + 0xfb, 0xa2, 0x60, 0x65, 0x71, 0x02, 0x43, 0xac, 0xb9, 0x24, 0x9c, 0x6f, 0x3a, 0x78, 0xf4, 0x70, + 0x3e, 0xd0, 0x04, 0x06, 0x8a, 0xa2, 0x8c, 0x70, 0x39, 0x57, 0xbd, 0x7b, 0x1b, 0x54, 0x57, 0x08, + 0x41, 0x13, 0xb3, 0x88, 0xa8, 0x09, 0xdd, 0x06, 0xea, 0x0c, 0x87, 0xc0, 0xe0, 0x82, 0x65, 0x88, + 0x12, 0xb3, 0xa1, 0xba, 0xbd, 0xa8, 0xe9, 0xa6, 0xfe, 0x9a, 0x7f, 0x2f, 0x1b, 0xfd, 0xf8, 0x6d, + 0x1b, 0x93, 0x22, 0x14, 0x54, 0x69, 0x1f, 0x6f, 0x0f, 0x96, 0xbe, 0x3b, 0x58, 0xfa, 0x9f, 0x83, + 0xa5, 0x7f, 0x3f, 0x5a, 0xda, 0xee, 0x68, 0x69, 0xbf, 0x8e, 0x96, 0x36, 0x1d, 0xd1, 0x58, 0xcc, + 0x57, 0xa1, 0x8b, 0x59, 0xe2, 0x8d, 0x2a, 0xf7, 0x18, 0x85, 0xdc, 0x3b, 0xbd, 0xf4, 0x16, 0xb3, + 0x8c, 0x9c, 0x5f, 0xe5, 0xec, 0xbd, 0x84, 0x45, 0xab, 0x05, 0xe1, 0x6a, 0xa3, 0xc4, 0x66, 0x49, + 0x78, 0x78, 0xad, 0x96, 0xe9, 0xdd, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xed, 0x3b, 0xae, 0x70, + 0xc1, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -556,10 +557,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { @@ -707,10 +705,7 @@ func (m *GenesisAccount) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/x/evm/types/genesis_test.go b/x/evm/types/genesis_test.go index d6baacc6..f158a1be 100644 --- a/x/evm/types/genesis_test.go +++ b/x/evm/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/suite" + sdk "github.com/cosmos/cosmos-sdk/types" ethcmn "github.com/ethereum/go-ethereum/common" "github.com/cosmos/ethermint/crypto/ethsecp256k1" @@ -42,6 +43,7 @@ func (suite *GenesisTestSuite) TestValidateGenesisAccount() { "valid genesis account", GenesisAccount{ Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ NewState(suite.hash, suite.hash), @@ -53,6 +55,23 @@ func (suite *GenesisTestSuite) TestValidateGenesisAccount() { "empty account address bytes", GenesisAccount{ Address: ethcmn.Address{}.String(), + Balance: sdk.OneInt(), + }, + false, + }, + { + "empty account balance", + GenesisAccount{ + Address: suite.address, + Balance: sdk.Int{}, + }, + false, + }, + { + "negative account balance", + GenesisAccount{ + Address: suite.address, + Balance: sdk.NewInt(-1), }, false, }, @@ -60,6 +79,7 @@ func (suite *GenesisTestSuite) TestValidateGenesisAccount() { "empty code bytes", GenesisAccount{ Address: suite.address, + Balance: sdk.OneInt(), Code: "", }, false, @@ -78,6 +98,7 @@ func (suite *GenesisTestSuite) TestValidateGenesisAccount() { } func (suite *GenesisTestSuite) TestValidateGenesis() { + testCases := []struct { name string genState *GenesisState @@ -94,6 +115,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Accounts: []GenesisAccount{ { Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ {Key: suite.hash.String()}, @@ -145,6 +167,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Accounts: []GenesisAccount{ { Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ NewState(suite.hash, suite.hash), @@ -152,6 +175,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { }, { Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ NewState(suite.hash, suite.hash), @@ -167,6 +191,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Accounts: []GenesisAccount{ { Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ {Key: suite.hash.String()}, @@ -216,6 +241,7 @@ func (suite *GenesisTestSuite) TestValidateGenesis() { Accounts: []GenesisAccount{ { Address: suite.address, + Balance: sdk.OneInt(), Code: suite.code, Storage: Storage{ {Key: suite.hash.String()}, diff --git a/x/evm/types/journal_test.go b/x/evm/types/journal_test.go index 9f85a4bb..34614230 100644 --- a/x/evm/types/journal_test.go +++ b/x/evm/types/journal_test.go @@ -5,14 +5,14 @@ import ( "os" "testing" + ethermint "github.com/cosmos/ethermint/types" + "github.com/stretchr/testify/suite" tmlog "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmdb "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" @@ -26,9 +26,10 @@ import ( ethtypes "github.com/ethereum/go-ethereum/core/types" ethcrypto "github.com/ethereum/go-ethereum/crypto" - ethermintcodec "github.com/cosmos/ethermint/codec" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + ethcodec "github.com/cosmos/ethermint/codec" "github.com/cosmos/ethermint/crypto/ethsecp256k1" - ethermint "github.com/cosmos/ethermint/types" ) func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) { @@ -38,7 +39,7 @@ func newTestCodec() (codec.BinaryMarshaler, *codec.LegacyAmino) { sdk.RegisterLegacyAminoCodec(amino) - ethermintcodec.RegisterInterfaces(interfaceRegistry) + ethcodec.RegisterInterfaces(interfaceRegistry) return cdc, amino } @@ -61,7 +62,7 @@ func (suite *JournalTestSuite) SetupTest() { suite.address = ethcmn.BytesToAddress(privkey.PubKey().Address().Bytes()) suite.journal = newJournal() - balance := ethermint.NewPhotonCoin(sdk.NewInt(100)) + balance := ethermint.NewInjectiveCoin(sdk.NewInt(100)) acc := ðermint.EthAccount{ BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), CodeHash: ethcrypto.Keccak256(nil), diff --git a/x/evm/types/key.go b/x/evm/types/key.go index ddd81190..879f8b31 100644 --- a/x/evm/types/key.go +++ b/x/evm/types/key.go @@ -21,26 +21,21 @@ const ( // KVStore key prefixes var ( - KeyPrefixBloom = []byte{0x01} - KeyPrefixLogs = []byte{0x02} - KeyPrefixCode = []byte{0x03} - KeyPrefixStorage = []byte{0x04} - KeyPrefixChainConfig = []byte{0x05} - KeyPrefixHeightHash = []byte{0x06} + KeyPrefixBlockHash = []byte{0x01} + KeyPrefixBloom = []byte{0x02} + KeyPrefixLogs = []byte{0x03} + KeyPrefixCode = []byte{0x04} + KeyPrefixStorage = []byte{0x05} + KeyPrefixChainConfig = []byte{0x06} + KeyPrefixBlockHeightHash = []byte{0x07} + KeyPrefixHashTxReceipt = []byte{0x08} + KeyPrefixBlockHeightTxs = []byte{0x09} ) -// HeightHashKey returns the key for the given chain epoch and height. -// The key will be composed in the following order: -// key = prefix + bytes(height) -// This ordering facilitates the iteration by height for the EVM GetHashFn -// queries. -func HeightHashKey(height uint64) []byte { - return sdk.Uint64ToBigEndian(height) -} - // BloomKey defines the store key for a block Bloom func BloomKey(height int64) []byte { - return sdk.Uint64ToBigEndian(uint64(height)) + heightBytes := sdk.Uint64ToBigEndian(uint64(height)) + return append(KeyPrefixBloom, heightBytes...) } // AddressStoragePrefix returns a prefix to iterate over a given account storage. @@ -53,4 +48,24 @@ func StateKey(address ethcmn.Address, key []byte) []byte { return append(AddressStoragePrefix(address), key...) } -// TODO: fix Logs key and append block hash +// KeyBlockHash returns a key for accessing block hash data. +func KeyBlockHash(hash ethcmn.Hash) []byte { + return append(KeyPrefixBlockHash, hash.Bytes()...) +} + +// KeyBlockHash returns a key for accessing block hash data. +func KeyBlockHeightHash(height uint64) []byte { + heightBytes := sdk.Uint64ToBigEndian(height) + return append(KeyPrefixBlockHeightHash, heightBytes...) +} + +// KeyHashTxReceipt returns a key for accessing tx receipt data by hash. +func KeyHashTxReceipt(hash ethcmn.Hash) []byte { + return append(KeyPrefixHashTxReceipt, hash.Bytes()...) +} + +// KeyBlockHeightTxs returns a key for accessing tx hash list by block height. +func KeyBlockHeightTxs(height uint64) []byte { + heightBytes := sdk.Uint64ToBigEndian(height) + return append(KeyPrefixBlockHeightTxs, heightBytes...) +} diff --git a/x/evm/types/logs.go b/x/evm/types/logs.go index 711aaf43..fd6a5a4d 100644 --- a/x/evm/types/logs.go +++ b/x/evm/types/logs.go @@ -1,10 +1,12 @@ package types import ( + "bytes" "errors" "fmt" - ethermint "github.com/cosmos/ethermint/types" + log "github.com/xlab/suplog" + ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" ) @@ -32,7 +34,7 @@ func NewTransactionLogsFromEth(hash ethcmn.Hash, ethlogs []*ethtypes.Log) Transa // Validate performs a basic validation of a GenesisAccount fields. func (tx TransactionLogs) Validate() error { - if ethermint.IsEmptyHash(tx.Hash) { + if bytes.Equal(ethcmn.Hex2Bytes(tx.Hash), ethcmn.Hash{}.Bytes()) { return fmt.Errorf("hash cannot be the empty %s", tx.Hash) } @@ -57,7 +59,7 @@ func (tx TransactionLogs) EthLogs() []*ethtypes.Log { // Validate performs a basic validation of an ethereum Log fields. func (log *Log) Validate() error { - if ethermint.IsZeroAddress(log.Address) { + if IsZeroAddress(log.Address) { return fmt.Errorf("log address cannot be empty %s", log.Address) } if IsEmptyHash(log.BlockHash) { @@ -66,7 +68,7 @@ func (log *Log) Validate() error { if log.BlockNumber == 0 { return errors.New("block number cannot be zero") } - if ethermint.IsEmptyHash(log.TxHash) { + if IsEmptyHash(log.TxHash) { return fmt.Errorf("tx hash cannot be the empty %s", log.TxHash) } return nil @@ -86,6 +88,7 @@ func (log *Log) ToEthereum() *ethtypes.Log { BlockNumber: log.BlockNumber, TxHash: ethcmn.HexToHash(log.TxHash), TxIndex: uint(log.TxIndex), + Index: uint(log.Index), BlockHash: ethcmn.HexToHash(log.BlockHash), Removed: log.Removed, } @@ -95,6 +98,12 @@ func (log *Log) ToEthereum() *ethtypes.Log { func LogsToEthereum(logs []*Log) []*ethtypes.Log { ethLogs := make([]*ethtypes.Log, len(logs)) for i := range logs { + err := logs[i].Validate() + if err != nil { + log.WithError(err).Errorln("failed log validation", logs[i].String()) + continue + } + ethLogs[i] = logs[i].ToEthereum() } return ethLogs diff --git a/x/evm/types/logs_test.go b/x/evm/types/logs_test.go index 30b3470a..299d761b 100644 --- a/x/evm/types/logs_test.go +++ b/x/evm/types/logs_test.go @@ -1,10 +1,21 @@ package types import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ethermint/crypto/ethsecp256k1" + ethcmn "github.com/ethereum/go-ethereum/common" + ethcrypto "github.com/ethereum/go-ethereum/crypto" ) -func (suite *GenesisTestSuite) TestTransactionLogsValidate() { +func TestTransactionLogsValidate(t *testing.T) { + priv, err := ethsecp256k1.GenerateKey() + require.NoError(t, err) + addr := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey).String() + testCases := []struct { name string txLogs TransactionLogs @@ -13,16 +24,16 @@ func (suite *GenesisTestSuite) TestTransactionLogsValidate() { { "valid log", TransactionLogs{ - Hash: suite.hash.String(), + Hash: ethcmn.BytesToHash([]byte("tx_hash")).String(), Logs: []*Log{ { - Address: suite.address, - Topics: []string{suite.hash.String()}, + Address: addr, + Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, Data: []byte("data"), BlockNumber: 1, - TxHash: suite.hash.String(), + TxHash: ethcmn.BytesToHash([]byte("tx_hash")).String(), TxIndex: 1, - BlockHash: suite.hash.String(), + BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), Index: 1, Removed: false, }, @@ -40,24 +51,24 @@ func (suite *GenesisTestSuite) TestTransactionLogsValidate() { { "invalid log", TransactionLogs{ - Hash: suite.hash.String(), - Logs: []*Log{nil}, + Hash: ethcmn.BytesToHash([]byte("tx_hash")).String(), + Logs: []*Log{{}}, }, false, }, { "hash mismatch log", TransactionLogs{ - Hash: suite.hash.String(), + Hash: ethcmn.BytesToHash([]byte("tx_hash")).String(), Logs: []*Log{ { - Address: suite.address, - Topics: []string{suite.hash.String()}, + Address: addr, + Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, Data: []byte("data"), BlockNumber: 1, TxHash: ethcmn.BytesToHash([]byte("other_hash")).String(), TxIndex: 1, - BlockHash: suite.hash.String(), + BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), Index: 1, Removed: false, }, @@ -71,14 +82,18 @@ func (suite *GenesisTestSuite) TestTransactionLogsValidate() { tc := tc err := tc.txLogs.Validate() if tc.expPass { - suite.Require().NoError(err, tc.name) + require.NoError(t, err, tc.name) } else { - suite.Require().Error(err, tc.name) + require.Error(t, err, tc.name) } } } -func (suite *GenesisTestSuite) TestValidateLog() { +func TestValidateLog(t *testing.T) { + priv, err := ethsecp256k1.GenerateKey() + require.NoError(t, err) + addr := ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey).String() + testCases := []struct { name string log *Log @@ -87,13 +102,13 @@ func (suite *GenesisTestSuite) TestValidateLog() { { "valid log", &Log{ - Address: suite.address, - Topics: []string{suite.hash.String()}, + Address: addr, + Topics: []string{ethcmn.BytesToHash([]byte("topic")).String()}, Data: []byte("data"), BlockNumber: 1, - TxHash: suite.hash.String(), + TxHash: ethcmn.BytesToHash([]byte("tx_hash")).String(), TxIndex: 1, - BlockHash: suite.hash.String(), + BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), Index: 1, Removed: false, }, @@ -112,7 +127,7 @@ func (suite *GenesisTestSuite) TestValidateLog() { { "empty block hash", &Log{ - Address: suite.address, + Address: addr, BlockHash: ethcmn.Hash{}.String(), }, false, @@ -120,8 +135,8 @@ func (suite *GenesisTestSuite) TestValidateLog() { { "zero block number", &Log{ - Address: suite.address, - BlockHash: suite.hash.String(), + Address: addr, + BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), BlockNumber: 0, }, false, @@ -129,8 +144,8 @@ func (suite *GenesisTestSuite) TestValidateLog() { { "empty tx hash", &Log{ - Address: suite.address, - BlockHash: suite.hash.String(), + Address: addr, + BlockHash: ethcmn.BytesToHash([]byte("block_hash")).String(), BlockNumber: 1, TxHash: ethcmn.Hash{}.String(), }, @@ -142,9 +157,9 @@ func (suite *GenesisTestSuite) TestValidateLog() { tc := tc err := tc.log.Validate() if tc.expPass { - suite.Require().NoError(err, tc.name) + require.NoError(t, err, tc.name) } else { - suite.Require().Error(err, tc.name) + require.Error(t, err, tc.name) } } } diff --git a/x/evm/types/msg.go b/x/evm/types/msg.go index 3c0fb334..41404286 100644 --- a/x/evm/types/msg.go +++ b/x/evm/types/msg.go @@ -2,13 +2,10 @@ package types import ( "crypto/ecdsa" - "errors" "fmt" "io" "math/big" - ethermint "github.com/cosmos/ethermint/types" - sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -27,7 +24,7 @@ var big8 = big.NewInt(8) // message type and route constants const ( - // TypeMsgEthereumTx defines the type string of an Ethereum transaction + // TypeMsgEthereumTx defines the type string of an Ethereum tranasction TypeMsgEthereumTx = "ethereum" ) @@ -55,28 +52,28 @@ func newMsgEthereumTx( payload = ethcmn.CopyBytes(payload) } - var recipient *Recipient + var toBz []byte if to != nil { - recipient = &Recipient{Address: to.String()} + toBz = to.Bytes() } txData := &TxData{ AccountNonce: nonce, - Recipient: recipient, + Recipient: toBz, Payload: payload, GasLimit: gasLimit, - Amount: sdk.ZeroInt(), - Price: sdk.ZeroInt(), + Amount: []byte{}, + Price: []byte{}, V: []byte{}, R: []byte{}, S: []byte{}, } if amount != nil { - txData.Amount = sdk.NewIntFromBigInt(amount) + txData.Amount = amount.Bytes() } if gasPrice != nil { - txData.Price = sdk.NewIntFromBigInt(gasPrice) + txData.Price = gasPrice.Bytes() } return &MsgEthereumTx{Data: txData} @@ -91,17 +88,19 @@ func (msg MsgEthereumTx) Type() string { return TypeMsgEthereumTx } // ValidateBasic implements the sdk.Msg interface. It performs basic validation // checks of a Transaction. If returns an error if validation fails. func (msg MsgEthereumTx) ValidateBasic() error { - if msg.Data.Price.IsZero() { - return sdkerrors.Wrapf(ethermint.ErrInvalidValue, "gas price cannot be 0") - } + gasPrice := new(big.Int).SetBytes(msg.Data.Price) + // if gasPrice.Sign() == 0 { + // return sdkerrors.Wrapf(ErrInvalidValue, "gas price cannot be 0") + // } - if msg.Data.Price.IsNegative() { - return sdkerrors.Wrapf(ethermint.ErrInvalidValue, "gas price cannot be negative %s", msg.Data.Price) + if gasPrice.Sign() == -1 { + return sdkerrors.Wrapf(ErrInvalidValue, "gas price cannot be negative %s", gasPrice) } // Amount can be 0 - if msg.Data.Amount.IsNegative() { - return sdkerrors.Wrapf(ethermint.ErrInvalidValue, "amount cannot be negative %s", msg.Data.Amount) + amount := new(big.Int).SetBytes(msg.Data.Amount) + if amount.Sign() == -1 { + return sdkerrors.Wrapf(ErrInvalidValue, "amount cannot be negative %s", amount) } return nil @@ -110,11 +109,11 @@ func (msg MsgEthereumTx) ValidateBasic() error { // To returns the recipient address of the transaction. It returns nil if the // transaction is a contract creation. func (msg MsgEthereumTx) To() *ethcmn.Address { - if msg.Data.Recipient == nil { + if len(msg.Data.Recipient) == 0 { return nil } - recipient := ethcmn.HexToAddress(msg.Data.Recipient.Address) + recipient := ethcmn.BytesToAddress(msg.Data.Recipient) return &recipient } @@ -149,52 +148,33 @@ func (msg MsgEthereumTx) GetSignBytes() []byte { func (msg MsgEthereumTx) RLPSignBytes(chainID *big.Int) ethcmn.Hash { return rlpHash([]interface{}{ msg.Data.AccountNonce, - msg.Data.Price.BigInt(), + new(big.Int).SetBytes(msg.Data.Price), msg.Data.GasLimit, msg.To(), - msg.Data.Amount.BigInt(), - msg.Data.Payload, + new(big.Int).SetBytes(msg.Data.Amount), + new(big.Int).SetBytes(msg.Data.Payload), chainID, uint(0), uint(0), }) } +// RLPSignHomesteadBytes returns the RLP hash of an Ethereum transaction message with a +// a Homestead layout without chainID. +func (msg MsgEthereumTx) RLPSignHomesteadBytes() ethcmn.Hash { + return rlpHash([]interface{}{ + msg.Data.AccountNonce, + msg.Data.Price, + msg.Data.GasLimit, + msg.To(), + msg.Data.Amount, + msg.Data.Payload, + }) +} + // EncodeRLP implements the rlp.Encoder interface. func (msg *MsgEthereumTx) EncodeRLP(w io.Writer) error { - var hash ethcmn.Hash - if len(msg.Data.Hash) > 0 { - hash = ethcmn.HexToHash(msg.Data.Hash) - } - - data := struct { - AccountNonce uint64 - Price *big.Int `json:"gasPrice"` - GasLimit uint64 `json:"gas"` - Recipient *ethcmn.Address `json:"to" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value"` - Payload []byte `json:"input"` - - // signature values - V *big.Int `json:"v"` - R *big.Int `json:"r"` - S *big.Int `json:"s"` - - // hash is only used when marshaling to JSON - Hash *ethcmn.Hash `json:"hash" rlp:"-"` - }{ - AccountNonce: msg.Data.AccountNonce, - Price: msg.Data.Price.BigInt(), - GasLimit: msg.Data.GasLimit, - Recipient: msg.To(), - Amount: msg.Data.Amount.BigInt(), - Payload: msg.Data.Payload, - V: new(big.Int).SetBytes(msg.Data.V), - R: new(big.Int).SetBytes(msg.Data.R), - S: new(big.Int).SetBytes(msg.Data.S), - Hash: &hash, - } - return rlp.Encode(w, data) + return rlp.Encode(w, &msg.Data) } // DecodeRLP implements the rlp.Decoder interface. @@ -205,50 +185,10 @@ func (msg *MsgEthereumTx) DecodeRLP(s *rlp.Stream) error { return err } - var data struct { - AccountNonce uint64 - Price *big.Int `json:"gasPrice"` - GasLimit uint64 `json:"gas"` - Recipient *ethcmn.Address `json:"to" rlp:"nil"` // nil means contract creation - Amount *big.Int `json:"value"` - Payload []byte `json:"input"` - - // signature values - V *big.Int `json:"v"` - R *big.Int `json:"r"` - S *big.Int `json:"s"` - - // hash is only used when marshaling to JSON - Hash *ethcmn.Hash `json:"hash" rlp:"-"` - } - - if err := s.Decode(&data); err != nil { + if err := s.Decode(&msg.Data); err != nil { return err } - var hash string - if data.Hash != nil { - hash = data.Hash.String() - } - - var recipient *Recipient - if data.Recipient != nil { - recipient = &Recipient{Address: data.Recipient.String()} - } - - msg.Data = &TxData{ - AccountNonce: data.AccountNonce, - Price: sdk.NewIntFromBigInt(data.Price), - GasLimit: data.GasLimit, - Recipient: recipient, - Amount: sdk.NewIntFromBigInt(data.Amount), - Payload: data.Payload, - V: data.V.Bytes(), - R: data.R.Bytes(), - S: data.S.Bytes(), - Hash: hash, - } - msg.Size_ = float64(ethcmn.StorageSize(rlp.ListSize(size))) return nil } @@ -292,23 +232,27 @@ func (msg *MsgEthereumTx) Sign(chainID *big.Int, priv *ecdsa.PrivateKey) error { // VerifySig attempts to verify a Transaction's signature for a given chainID. // A derived address is returned upon success or an error if recovery fails. func (msg *MsgEthereumTx) VerifySig(chainID *big.Int) (ethcmn.Address, error) { - v, r, s := msg.RawSignatureValues() signer := ethtypes.NewEIP155Signer(chainID) if msg.From != nil { + if msg.From.Signer == nil { + return msg.VerifySigHomestead() + } + // If the signer used to derive from in a previous call is not the same as // used current, invalidate the cache. fromSigner := ethtypes.NewEIP155Signer(new(big.Int).SetBytes(msg.From.Signer.chainId)) if signer.Equal(fromSigner) { - return ethcmn.HexToAddress(msg.From.Address), nil + return ethcmn.BytesToAddress(msg.From.Address), nil } } // do not allow recovery for transactions with an unprotected chainID if chainID.Sign() == 0 { - return ethcmn.Address{}, errors.New("chainID cannot be zero") + return msg.VerifySigHomestead() } + v, r, s := msg.RawSignatureValues() chainIDMul := new(big.Int).Mul(chainID, big.NewInt(2)) V := new(big.Int).Sub(v, chainIDMul) V.Sub(V, big8) @@ -324,8 +268,35 @@ func (msg *MsgEthereumTx) VerifySig(chainID *big.Int) (ethcmn.Address, error) { chainId: chainID.Bytes(), chainIdMul: new(big.Int).Mul(chainID, big.NewInt(2)).Bytes(), }, - Address: sender.String(), + Address: sender.Bytes(), } + + return sender, nil +} + +// VerifySigHomestead attempts to verify a Transaction's signature in legacy way (no EIP155). +// A derived address is returned upon success or an error if recovery fails. +func (msg *MsgEthereumTx) VerifySigHomestead() (ethcmn.Address, error) { + // signer := ethtypes.HomesteadSigner{} + if msg.From != nil { + // If the signer used to derive from in a previous call is not the same as + // used current, invalidate the cache. + if msg.From.Signer == nil { + return ethcmn.BytesToAddress(msg.From.Address), nil + } + } + + v, r, s := msg.RawSignatureValues() + sigHash := msg.RLPSignHomesteadBytes() + sender, err := recoverEthSig(r, s, v, sigHash) + if err != nil { + return ethcmn.Address{}, err + } + + msg.From = &SigCache{ + Address: sender.Bytes(), + } + return sender, nil } @@ -336,21 +307,20 @@ func (msg MsgEthereumTx) GetGas() uint64 { // Fee returns gasprice * gaslimit. func (msg MsgEthereumTx) Fee() *big.Int { - gasPrice := msg.Data.Price.BigInt() + gasPrice := new(big.Int).SetBytes(msg.Data.Price) gasLimit := new(big.Int).SetUint64(msg.Data.GasLimit) return new(big.Int).Mul(gasPrice, gasLimit) } // ChainID returns which chain id this transaction was signed for (if at all) func (msg *MsgEthereumTx) ChainID() *big.Int { - v := new(big.Int).SetBytes(msg.Data.V) - return deriveChainID(v) + return deriveChainID(new(big.Int).SetBytes(msg.Data.V)) } // Cost returns amount + gasprice * gaslimit. func (msg MsgEthereumTx) Cost() *big.Int { total := msg.Fee() - total.Add(total, msg.Data.Amount.BigInt()) + total.Add(total, new(big.Int).SetBytes(msg.Data.Amount)) return total } @@ -369,7 +339,7 @@ func (msg *MsgEthereumTx) GetFrom() sdk.AccAddress { return nil } - return sdk.AccAddress(ethcmn.HexToAddress(msg.From.Address).Bytes()) + return sdk.AccAddress(msg.From.Address) } // deriveChainID derives the chain id from the given v parameter diff --git a/x/evm/types/msg_test.go b/x/evm/types/msg_test.go index 2cc575f2..1a3f6e5e 100644 --- a/x/evm/types/msg_test.go +++ b/x/evm/types/msg_test.go @@ -16,23 +16,12 @@ import ( "github.com/ethereum/go-ethereum/rlp" ) -// GenerateEthAddress generates an Ethereum address. -func GenerateEthAddress() ethcmn.Address { - priv, err := ethsecp256k1.GenerateKey() - if err != nil { - panic(err) - } - - return ethcmn.BytesToAddress(priv.PubKey().Address().Bytes()) -} - func TestMsgEthereumTx(t *testing.T) { addr := GenerateEthAddress() msg := NewMsgEthereumTx(0, &addr, nil, 100000, nil, []byte("test")) require.NotNil(t, msg) - require.NotNil(t, msg.Data.Recipient) - require.Equal(t, msg.Data.Recipient.Address, addr.String()) + require.EqualValues(t, msg.Data.Recipient, addr.Bytes()) require.Equal(t, msg.Route(), RouterKey) require.Equal(t, msg.Type(), TypeMsgEthereumTx) require.NotNil(t, msg.To()) @@ -42,7 +31,7 @@ func TestMsgEthereumTx(t *testing.T) { msg = NewMsgEthereumTxContract(0, nil, 100000, nil, []byte("test")) require.NotNil(t, msg) - require.Empty(t, msg.Data.Recipient) + require.Nil(t, msg.Data.Recipient) require.Nil(t, msg.To()) } @@ -62,11 +51,10 @@ func TestMsgEthereumTxValidation(t *testing.T) { for i, tc := range testCases { msg := NewMsgEthereumTx(0, nil, tc.amount, 0, tc.gasPrice, nil) - err := msg.ValidateBasic() if tc.expectPass { - require.NoError(t, err, "valid test %d failed: %s", i, tc.msg) + require.Nil(t, msg.ValidateBasic(), "valid test %d failed: %s", i, tc.msg) } else { - require.Error(t, err, "invalid test %d passed: %s", i, tc.msg) + require.NotNil(t, msg.ValidateBasic(), "invalid test %d passed: %s", i, tc.msg) } } } diff --git a/x/evm/types/params.go b/x/evm/types/params.go index f7050f3f..a49a6bb6 100644 --- a/x/evm/types/params.go +++ b/x/evm/types/params.go @@ -7,10 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/ethereum/go-ethereum/core/vm" - - ethermint "github.com/cosmos/ethermint/types" ) var _ paramtypes.ParamSet = &Params{} @@ -41,7 +38,7 @@ func NewParams(evmDenom string, enableCreate, enableCall bool, extraEIPs ...int6 // DefaultParams returns default evm parameters func DefaultParams() Params { return Params{ - EvmDenom: ethermint.AttoPhoton, + EvmDenom: "inj", EnableCreate: true, EnableCall: true, ExtraEIPs: []int64(nil), // TODO: define default values diff --git a/x/evm/types/params_test.go b/x/evm/types/params_test.go index aa7cf48c..d9c8fe60 100644 --- a/x/evm/types/params_test.go +++ b/x/evm/types/params_test.go @@ -53,7 +53,7 @@ func TestParamsValidate(t *testing.T) { func TestParamsValidatePriv(t *testing.T) { require.Error(t, validateEVMDenom(false)) - require.NoError(t, validateEVMDenom("aphoton")) + require.NoError(t, validateEVMDenom("inj")) require.Error(t, validateBool("")) require.NoError(t, validateBool(true)) require.Error(t, validateEIPs("")) @@ -61,5 +61,5 @@ func TestParamsValidatePriv(t *testing.T) { } func TestParams_String(t *testing.T) { - require.Equal(t, "evm_denom: aphoton\nenable_create: true\nenable_call: true\nextra_eips: []\n", DefaultParams().String()) + require.Equal(t, "evm_denom: inj\nenable_create: true\nenable_call: true\nextra_eips: []\n", DefaultParams().String()) } diff --git a/x/evm/types/protocol.go b/x/evm/types/protocol.go new file mode 100644 index 00000000..580c344c --- /dev/null +++ b/x/evm/types/protocol.go @@ -0,0 +1,9 @@ +package types + +// Constants to match up protocol versions and messages +const ( + eth65 = 65 + + // ProtocolVersion is the latest supported version of the eth protocol. + ProtocolVersion = eth65 +) diff --git a/x/evm/types/querier_test.go b/x/evm/types/querier_test.go deleted file mode 100644 index 7f66fb22..00000000 --- a/x/evm/types/querier_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/stretchr/testify/require" - "strings" - "testing" -) - -func TestQueryETHLogs_String(t *testing.T) { - const expectedQueryETHLogsStr = `{0x0000000000000000000000000000000000000000 [] [1 2 3 4] 9 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false} -{0x0000000000000000000000000000000000000000 [] [5 6 7 8] 10 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false} -` - logs := []*ethtypes.Log{ - { - Data: []byte{1, 2, 3, 4}, - BlockNumber: 9, - }, - { - Data: []byte{5, 6, 7, 8}, - BlockNumber: 10, - }, - } - - require.True(t, strings.EqualFold(expectedQueryETHLogsStr, QueryETHLogs{logs}.String())) -} diff --git a/x/evm/types/query.pb.go b/x/evm/types/query.pb.go index 874b2e0b..1b1d732c 100644 --- a/x/evm/types/query.pb.go +++ b/x/evm/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/evm/v1alpha1/query.proto +// source: injective/evm/v1beta1/query.proto package types @@ -39,7 +39,7 @@ func (m *QueryAccountRequest) Reset() { *m = QueryAccountRequest{} } func (m *QueryAccountRequest) String() string { return proto.CompactTextString(m) } func (*QueryAccountRequest) ProtoMessage() {} func (*QueryAccountRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{0} + return fileDescriptor_b35cda93d73bda44, []int{0} } func (m *QueryAccountRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -82,7 +82,7 @@ func (m *QueryAccountResponse) Reset() { *m = QueryAccountResponse{} } func (m *QueryAccountResponse) String() string { return proto.CompactTextString(m) } func (*QueryAccountResponse) ProtoMessage() {} func (*QueryAccountResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{1} + return fileDescriptor_b35cda93d73bda44, []int{1} } func (m *QueryAccountResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -132,6 +132,109 @@ func (m *QueryAccountResponse) GetNonce() uint64 { return 0 } +// QueryCosmosAccountRequest is the request type for the Query/CosmosAccount RPC method. +type QueryCosmosAccountRequest struct { + // address is the ethereum hex address to query the account for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryCosmosAccountRequest) Reset() { *m = QueryCosmosAccountRequest{} } +func (m *QueryCosmosAccountRequest) String() string { return proto.CompactTextString(m) } +func (*QueryCosmosAccountRequest) ProtoMessage() {} +func (*QueryCosmosAccountRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{2} +} +func (m *QueryCosmosAccountRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCosmosAccountRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCosmosAccountRequest.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 *QueryCosmosAccountRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCosmosAccountRequest.Merge(m, src) +} +func (m *QueryCosmosAccountRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryCosmosAccountRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCosmosAccountRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCosmosAccountRequest proto.InternalMessageInfo + +// QueryCosmosAccountResponse is the response type for the Query/CosmosAccount RPC method. +type QueryCosmosAccountResponse struct { + // cosmos_address is the cosmos address of the account. + CosmosAddress string `protobuf:"bytes,1,opt,name=cosmos_address,json=cosmosAddress,proto3" json:"cosmos_address,omitempty"` + // sequence is the account's sequence number. + Sequence uint64 `protobuf:"varint,2,opt,name=sequence,proto3" json:"sequence,omitempty"` + // account_number is the account numbert + AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` +} + +func (m *QueryCosmosAccountResponse) Reset() { *m = QueryCosmosAccountResponse{} } +func (m *QueryCosmosAccountResponse) String() string { return proto.CompactTextString(m) } +func (*QueryCosmosAccountResponse) ProtoMessage() {} +func (*QueryCosmosAccountResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{3} +} +func (m *QueryCosmosAccountResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryCosmosAccountResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryCosmosAccountResponse.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 *QueryCosmosAccountResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryCosmosAccountResponse.Merge(m, src) +} +func (m *QueryCosmosAccountResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryCosmosAccountResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryCosmosAccountResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryCosmosAccountResponse proto.InternalMessageInfo + +func (m *QueryCosmosAccountResponse) GetCosmosAddress() string { + if m != nil { + return m.CosmosAddress + } + return "" +} + +func (m *QueryCosmosAccountResponse) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *QueryCosmosAccountResponse) GetAccountNumber() uint64 { + if m != nil { + return m.AccountNumber + } + return 0 +} + // QueryBalanceRequest is the request type for the Query/Balance RPC method. type QueryBalanceRequest struct { // address is the ethereum hex address to query the balance for. @@ -142,7 +245,7 @@ func (m *QueryBalanceRequest) Reset() { *m = QueryBalanceRequest{} } func (m *QueryBalanceRequest) String() string { return proto.CompactTextString(m) } func (*QueryBalanceRequest) ProtoMessage() {} func (*QueryBalanceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{2} + return fileDescriptor_b35cda93d73bda44, []int{4} } func (m *QueryBalanceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -181,7 +284,7 @@ func (m *QueryBalanceResponse) Reset() { *m = QueryBalanceResponse{} } func (m *QueryBalanceResponse) String() string { return proto.CompactTextString(m) } func (*QueryBalanceResponse) ProtoMessage() {} func (*QueryBalanceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{3} + return fileDescriptor_b35cda93d73bda44, []int{5} } func (m *QueryBalanceResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -229,7 +332,7 @@ func (m *QueryStorageRequest) Reset() { *m = QueryStorageRequest{} } func (m *QueryStorageRequest) String() string { return proto.CompactTextString(m) } func (*QueryStorageRequest) ProtoMessage() {} func (*QueryStorageRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{4} + return fileDescriptor_b35cda93d73bda44, []int{6} } func (m *QueryStorageRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -269,7 +372,7 @@ func (m *QueryStorageResponse) Reset() { *m = QueryStorageResponse{} } func (m *QueryStorageResponse) String() string { return proto.CompactTextString(m) } func (*QueryStorageResponse) ProtoMessage() {} func (*QueryStorageResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{5} + return fileDescriptor_b35cda93d73bda44, []int{7} } func (m *QueryStorageResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -315,7 +418,7 @@ func (m *QueryCodeRequest) Reset() { *m = QueryCodeRequest{} } func (m *QueryCodeRequest) String() string { return proto.CompactTextString(m) } func (*QueryCodeRequest) ProtoMessage() {} func (*QueryCodeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{6} + return fileDescriptor_b35cda93d73bda44, []int{8} } func (m *QueryCodeRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -355,7 +458,7 @@ func (m *QueryCodeResponse) Reset() { *m = QueryCodeResponse{} } func (m *QueryCodeResponse) String() string { return proto.CompactTextString(m) } func (*QueryCodeResponse) ProtoMessage() {} func (*QueryCodeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{7} + return fileDescriptor_b35cda93d73bda44, []int{9} } func (m *QueryCodeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -401,7 +504,7 @@ func (m *QueryTxLogsRequest) Reset() { *m = QueryTxLogsRequest{} } func (m *QueryTxLogsRequest) String() string { return proto.CompactTextString(m) } func (*QueryTxLogsRequest) ProtoMessage() {} func (*QueryTxLogsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{8} + return fileDescriptor_b35cda93d73bda44, []int{10} } func (m *QueryTxLogsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +543,7 @@ func (m *QueryTxLogsResponse) Reset() { *m = QueryTxLogsResponse{} } func (m *QueryTxLogsResponse) String() string { return proto.CompactTextString(m) } func (*QueryTxLogsResponse) ProtoMessage() {} func (*QueryTxLogsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{9} + return fileDescriptor_b35cda93d73bda44, []int{11} } func (m *QueryTxLogsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -476,6 +579,261 @@ func (m *QueryTxLogsResponse) GetLogs() []*Log { return nil } +// QueryTxReceiptRequest is the request type for the Query/TxReceipt RPC method. +type QueryTxReceiptRequest struct { + // hash is the ethereum transaction hex hash to query the receipt for. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryTxReceiptRequest) Reset() { *m = QueryTxReceiptRequest{} } +func (m *QueryTxReceiptRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptRequest) ProtoMessage() {} +func (*QueryTxReceiptRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{12} +} +func (m *QueryTxReceiptRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptRequest.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 *QueryTxReceiptRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptRequest.Merge(m, src) +} +func (m *QueryTxReceiptRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptRequest proto.InternalMessageInfo + +// QueryTxReceiptResponse is the response type for the Query/TxReceipt RPC method. +type QueryTxReceiptResponse struct { + // receipt represents the ethereum receipt for the given transaction. + Receipt *TxReceipt `protobuf:"bytes,1,opt,name=receipt,proto3" json:"receipt,omitempty"` +} + +func (m *QueryTxReceiptResponse) Reset() { *m = QueryTxReceiptResponse{} } +func (m *QueryTxReceiptResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptResponse) ProtoMessage() {} +func (*QueryTxReceiptResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{13} +} +func (m *QueryTxReceiptResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptResponse.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 *QueryTxReceiptResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptResponse.Merge(m, src) +} +func (m *QueryTxReceiptResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptResponse proto.InternalMessageInfo + +func (m *QueryTxReceiptResponse) GetReceipt() *TxReceipt { + if m != nil { + return m.Receipt + } + return nil +} + +// QueryTxReceiptsByBlockHeightRequest is the request type for the Query/TxReceiptsByBlockHeight RPC method. +type QueryTxReceiptsByBlockHeightRequest struct { + // height is the block height to query tx receipts for + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryTxReceiptsByBlockHeightRequest) Reset() { *m = QueryTxReceiptsByBlockHeightRequest{} } +func (m *QueryTxReceiptsByBlockHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptsByBlockHeightRequest) ProtoMessage() {} +func (*QueryTxReceiptsByBlockHeightRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{14} +} +func (m *QueryTxReceiptsByBlockHeightRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptsByBlockHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptsByBlockHeightRequest.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 *QueryTxReceiptsByBlockHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptsByBlockHeightRequest.Merge(m, src) +} +func (m *QueryTxReceiptsByBlockHeightRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptsByBlockHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptsByBlockHeightRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptsByBlockHeightRequest proto.InternalMessageInfo + +// QueryTxReceiptsByBlockHeightResponse is the response type for the Query/TxReceiptsByBlockHeight RPC method. +type QueryTxReceiptsByBlockHeightResponse struct { + // tx receipts list for the block + Receipts []*TxReceipt `protobuf:"bytes,1,rep,name=receipts,proto3" json:"receipts,omitempty"` +} + +func (m *QueryTxReceiptsByBlockHeightResponse) Reset() { *m = QueryTxReceiptsByBlockHeightResponse{} } +func (m *QueryTxReceiptsByBlockHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptsByBlockHeightResponse) ProtoMessage() {} +func (*QueryTxReceiptsByBlockHeightResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{15} +} +func (m *QueryTxReceiptsByBlockHeightResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptsByBlockHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptsByBlockHeightResponse.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 *QueryTxReceiptsByBlockHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptsByBlockHeightResponse.Merge(m, src) +} +func (m *QueryTxReceiptsByBlockHeightResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptsByBlockHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptsByBlockHeightResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptsByBlockHeightResponse proto.InternalMessageInfo + +func (m *QueryTxReceiptsByBlockHeightResponse) GetReceipts() []*TxReceipt { + if m != nil { + return m.Receipts + } + return nil +} + +// QueryTxReceiptsByBlockHashRequest is the request type for the Query/TxReceiptsByBlockHash RPC method. +type QueryTxReceiptsByBlockHashRequest struct { + // hash is the ethereum transaction hex hash to query the receipt for. + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryTxReceiptsByBlockHashRequest) Reset() { *m = QueryTxReceiptsByBlockHashRequest{} } +func (m *QueryTxReceiptsByBlockHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptsByBlockHashRequest) ProtoMessage() {} +func (*QueryTxReceiptsByBlockHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{16} +} +func (m *QueryTxReceiptsByBlockHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptsByBlockHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptsByBlockHashRequest.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 *QueryTxReceiptsByBlockHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptsByBlockHashRequest.Merge(m, src) +} +func (m *QueryTxReceiptsByBlockHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptsByBlockHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptsByBlockHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptsByBlockHashRequest proto.InternalMessageInfo + +// QueryTxReceiptsByBlockHashResponse is the response type for the Query/TxReceiptsByBlockHash RPC method. +type QueryTxReceiptsByBlockHashResponse struct { + // tx receipts list for the block + Receipts []*TxReceipt `protobuf:"bytes,1,rep,name=receipts,proto3" json:"receipts,omitempty"` +} + +func (m *QueryTxReceiptsByBlockHashResponse) Reset() { *m = QueryTxReceiptsByBlockHashResponse{} } +func (m *QueryTxReceiptsByBlockHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTxReceiptsByBlockHashResponse) ProtoMessage() {} +func (*QueryTxReceiptsByBlockHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{17} +} +func (m *QueryTxReceiptsByBlockHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTxReceiptsByBlockHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTxReceiptsByBlockHashResponse.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 *QueryTxReceiptsByBlockHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTxReceiptsByBlockHashResponse.Merge(m, src) +} +func (m *QueryTxReceiptsByBlockHashResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTxReceiptsByBlockHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTxReceiptsByBlockHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTxReceiptsByBlockHashResponse proto.InternalMessageInfo + +func (m *QueryTxReceiptsByBlockHashResponse) GetReceipts() []*TxReceipt { + if m != nil { + return m.Receipts + } + return nil +} + // QueryBlockLogsRequest is the request type for the Query/BlockLogs RPC method. type QueryBlockLogsRequest struct { // hash is the block hash to query the logs for. @@ -486,7 +844,7 @@ func (m *QueryBlockLogsRequest) Reset() { *m = QueryBlockLogsRequest{} } func (m *QueryBlockLogsRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockLogsRequest) ProtoMessage() {} func (*QueryBlockLogsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{10} + return fileDescriptor_b35cda93d73bda44, []int{18} } func (m *QueryBlockLogsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -525,7 +883,7 @@ func (m *QueryBlockLogsResponse) Reset() { *m = QueryBlockLogsResponse{} func (m *QueryBlockLogsResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockLogsResponse) ProtoMessage() {} func (*QueryBlockLogsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{11} + return fileDescriptor_b35cda93d73bda44, []int{19} } func (m *QueryBlockLogsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -564,13 +922,14 @@ func (m *QueryBlockLogsResponse) GetTxLogs() []TransactionLogs { // QueryBlockBloomRequest is the request type for the Query/BlockBloom RPC // method. type QueryBlockBloomRequest struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } func (m *QueryBlockBloomRequest) Reset() { *m = QueryBlockBloomRequest{} } func (m *QueryBlockBloomRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockBloomRequest) ProtoMessage() {} func (*QueryBlockBloomRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{12} + return fileDescriptor_b35cda93d73bda44, []int{20} } func (m *QueryBlockBloomRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -599,6 +958,13 @@ func (m *QueryBlockBloomRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBlockBloomRequest proto.InternalMessageInfo +func (m *QueryBlockBloomRequest) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + // QueryBlockBloomResponse is the response type for the Query/BlockBloom RPC // method. type QueryBlockBloomResponse struct { @@ -610,7 +976,7 @@ func (m *QueryBlockBloomResponse) Reset() { *m = QueryBlockBloomResponse func (m *QueryBlockBloomResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockBloomResponse) ProtoMessage() {} func (*QueryBlockBloomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{13} + return fileDescriptor_b35cda93d73bda44, []int{21} } func (m *QueryBlockBloomResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -654,7 +1020,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{14} + return fileDescriptor_b35cda93d73bda44, []int{22} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -693,7 +1059,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_8bbc79ec2b6c5cb2, []int{15} + return fileDescriptor_b35cda93d73bda44, []int{23} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -729,82 +1095,213 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -func init() { - proto.RegisterType((*QueryAccountRequest)(nil), "ethermint.evm.v1alpha1.QueryAccountRequest") - proto.RegisterType((*QueryAccountResponse)(nil), "ethermint.evm.v1alpha1.QueryAccountResponse") - proto.RegisterType((*QueryBalanceRequest)(nil), "ethermint.evm.v1alpha1.QueryBalanceRequest") - proto.RegisterType((*QueryBalanceResponse)(nil), "ethermint.evm.v1alpha1.QueryBalanceResponse") - proto.RegisterType((*QueryStorageRequest)(nil), "ethermint.evm.v1alpha1.QueryStorageRequest") - proto.RegisterType((*QueryStorageResponse)(nil), "ethermint.evm.v1alpha1.QueryStorageResponse") - proto.RegisterType((*QueryCodeRequest)(nil), "ethermint.evm.v1alpha1.QueryCodeRequest") - proto.RegisterType((*QueryCodeResponse)(nil), "ethermint.evm.v1alpha1.QueryCodeResponse") - proto.RegisterType((*QueryTxLogsRequest)(nil), "ethermint.evm.v1alpha1.QueryTxLogsRequest") - proto.RegisterType((*QueryTxLogsResponse)(nil), "ethermint.evm.v1alpha1.QueryTxLogsResponse") - proto.RegisterType((*QueryBlockLogsRequest)(nil), "ethermint.evm.v1alpha1.QueryBlockLogsRequest") - proto.RegisterType((*QueryBlockLogsResponse)(nil), "ethermint.evm.v1alpha1.QueryBlockLogsResponse") - proto.RegisterType((*QueryBlockBloomRequest)(nil), "ethermint.evm.v1alpha1.QueryBlockBloomRequest") - proto.RegisterType((*QueryBlockBloomResponse)(nil), "ethermint.evm.v1alpha1.QueryBlockBloomResponse") - proto.RegisterType((*QueryParamsRequest)(nil), "ethermint.evm.v1alpha1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "ethermint.evm.v1alpha1.QueryParamsResponse") +// QueryStaticCallRequest defines static call request +type QueryStaticCallRequest struct { + // address is the ethereum contract hex address to for static call. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // static call input generated from abi + Input []byte `protobuf:"bytes,2,opt,name=input,proto3" json:"input,omitempty"` +} + +func (m *QueryStaticCallRequest) Reset() { *m = QueryStaticCallRequest{} } +func (m *QueryStaticCallRequest) String() string { return proto.CompactTextString(m) } +func (*QueryStaticCallRequest) ProtoMessage() {} +func (*QueryStaticCallRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{24} +} +func (m *QueryStaticCallRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStaticCallRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStaticCallRequest.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 *QueryStaticCallRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStaticCallRequest.Merge(m, src) +} +func (m *QueryStaticCallRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryStaticCallRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStaticCallRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStaticCallRequest proto.InternalMessageInfo + +func (m *QueryStaticCallRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryStaticCallRequest) GetInput() []byte { + if m != nil { + return m.Input + } + return nil +} + +// // QueryStaticCallRequest defines static call response +type QueryStaticCallResponse struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *QueryStaticCallResponse) Reset() { *m = QueryStaticCallResponse{} } +func (m *QueryStaticCallResponse) String() string { return proto.CompactTextString(m) } +func (*QueryStaticCallResponse) ProtoMessage() {} +func (*QueryStaticCallResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b35cda93d73bda44, []int{25} +} +func (m *QueryStaticCallResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryStaticCallResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryStaticCallResponse.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 *QueryStaticCallResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryStaticCallResponse.Merge(m, src) +} +func (m *QueryStaticCallResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryStaticCallResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryStaticCallResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryStaticCallResponse proto.InternalMessageInfo + +func (m *QueryStaticCallResponse) GetData() []byte { + if m != nil { + return m.Data + } + return nil } func init() { - proto.RegisterFile("ethermint/evm/v1alpha1/query.proto", fileDescriptor_8bbc79ec2b6c5cb2) + proto.RegisterType((*QueryAccountRequest)(nil), "injective.evm.v1beta1.QueryAccountRequest") + proto.RegisterType((*QueryAccountResponse)(nil), "injective.evm.v1beta1.QueryAccountResponse") + proto.RegisterType((*QueryCosmosAccountRequest)(nil), "injective.evm.v1beta1.QueryCosmosAccountRequest") + proto.RegisterType((*QueryCosmosAccountResponse)(nil), "injective.evm.v1beta1.QueryCosmosAccountResponse") + proto.RegisterType((*QueryBalanceRequest)(nil), "injective.evm.v1beta1.QueryBalanceRequest") + proto.RegisterType((*QueryBalanceResponse)(nil), "injective.evm.v1beta1.QueryBalanceResponse") + proto.RegisterType((*QueryStorageRequest)(nil), "injective.evm.v1beta1.QueryStorageRequest") + proto.RegisterType((*QueryStorageResponse)(nil), "injective.evm.v1beta1.QueryStorageResponse") + proto.RegisterType((*QueryCodeRequest)(nil), "injective.evm.v1beta1.QueryCodeRequest") + proto.RegisterType((*QueryCodeResponse)(nil), "injective.evm.v1beta1.QueryCodeResponse") + proto.RegisterType((*QueryTxLogsRequest)(nil), "injective.evm.v1beta1.QueryTxLogsRequest") + proto.RegisterType((*QueryTxLogsResponse)(nil), "injective.evm.v1beta1.QueryTxLogsResponse") + proto.RegisterType((*QueryTxReceiptRequest)(nil), "injective.evm.v1beta1.QueryTxReceiptRequest") + proto.RegisterType((*QueryTxReceiptResponse)(nil), "injective.evm.v1beta1.QueryTxReceiptResponse") + proto.RegisterType((*QueryTxReceiptsByBlockHeightRequest)(nil), "injective.evm.v1beta1.QueryTxReceiptsByBlockHeightRequest") + proto.RegisterType((*QueryTxReceiptsByBlockHeightResponse)(nil), "injective.evm.v1beta1.QueryTxReceiptsByBlockHeightResponse") + proto.RegisterType((*QueryTxReceiptsByBlockHashRequest)(nil), "injective.evm.v1beta1.QueryTxReceiptsByBlockHashRequest") + proto.RegisterType((*QueryTxReceiptsByBlockHashResponse)(nil), "injective.evm.v1beta1.QueryTxReceiptsByBlockHashResponse") + proto.RegisterType((*QueryBlockLogsRequest)(nil), "injective.evm.v1beta1.QueryBlockLogsRequest") + proto.RegisterType((*QueryBlockLogsResponse)(nil), "injective.evm.v1beta1.QueryBlockLogsResponse") + proto.RegisterType((*QueryBlockBloomRequest)(nil), "injective.evm.v1beta1.QueryBlockBloomRequest") + proto.RegisterType((*QueryBlockBloomResponse)(nil), "injective.evm.v1beta1.QueryBlockBloomResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "injective.evm.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "injective.evm.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryStaticCallRequest)(nil), "injective.evm.v1beta1.QueryStaticCallRequest") + proto.RegisterType((*QueryStaticCallResponse)(nil), "injective.evm.v1beta1.QueryStaticCallResponse") } -var fileDescriptor_8bbc79ec2b6c5cb2 = []byte{ - // 803 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x96, 0xcf, 0x6f, 0xd3, 0x48, - 0x14, 0xc7, 0xe3, 0x36, 0x4d, 0x9a, 0x69, 0x0f, 0xdd, 0xd9, 0x6c, 0x37, 0x4a, 0x57, 0x6e, 0xe4, - 0xd5, 0x36, 0x69, 0xd3, 0xf5, 0x90, 0x20, 0x40, 0x20, 0x2e, 0x0d, 0x52, 0x85, 0x44, 0x0f, 0xe0, - 0xf6, 0xc4, 0xa5, 0x4c, 0x9c, 0x91, 0x13, 0x35, 0xf1, 0xa4, 0x19, 0x27, 0x6a, 0x54, 0xf5, 0xc2, - 0x09, 0x24, 0x0e, 0x20, 0x0e, 0x20, 0x24, 0xa4, 0xfe, 0x39, 0x3d, 0x56, 0xe2, 0xc2, 0x09, 0xa1, - 0x96, 0x03, 0x7f, 0x06, 0x9a, 0x1f, 0x4e, 0x9d, 0x50, 0xc7, 0xee, 0x6d, 0x66, 0xfc, 0xde, 0xfb, - 0x7e, 0xe6, 0xc7, 0xfb, 0xca, 0xc0, 0x20, 0x5e, 0x93, 0xf4, 0x3a, 0x2d, 0xd7, 0x43, 0x64, 0xd0, - 0x41, 0x83, 0x0a, 0x6e, 0x77, 0x9b, 0xb8, 0x82, 0x0e, 0xfb, 0xa4, 0x37, 0x34, 0xbb, 0x3d, 0xea, - 0x51, 0xb8, 0x3c, 0x8a, 0x31, 0xc9, 0xa0, 0x63, 0xfa, 0x31, 0xf9, 0xac, 0x43, 0x1d, 0x2a, 0x42, - 0x10, 0x1f, 0xc9, 0xe8, 0xfc, 0x3f, 0x0e, 0xa5, 0x4e, 0x9b, 0x20, 0xdc, 0x6d, 0x21, 0xec, 0xba, - 0xd4, 0xc3, 0x5e, 0x8b, 0xba, 0x4c, 0x7d, 0x2d, 0x84, 0xe8, 0xf1, 0xc2, 0x22, 0xc2, 0xb8, 0x0f, - 0xfe, 0x7c, 0xc6, 0xc5, 0xb7, 0x6c, 0x9b, 0xf6, 0x5d, 0xcf, 0x22, 0x87, 0x7d, 0xc2, 0x3c, 0x98, - 0x03, 0x69, 0xdc, 0x68, 0xf4, 0x08, 0x63, 0x39, 0xad, 0xa0, 0x95, 0x32, 0x96, 0x3f, 0x7d, 0x30, - 0xff, 0xea, 0x74, 0x35, 0xf1, 0xf3, 0x74, 0x35, 0x61, 0xd8, 0x20, 0x3b, 0x9e, 0xca, 0xba, 0xd4, - 0x65, 0x84, 0xe7, 0xd6, 0x71, 0x1b, 0xbb, 0x36, 0xf1, 0x73, 0xd5, 0x14, 0xae, 0x80, 0x8c, 0x4d, - 0x1b, 0x64, 0xbf, 0x89, 0x59, 0x33, 0x37, 0x53, 0xd0, 0x4a, 0x8b, 0xd6, 0x3c, 0x5f, 0x78, 0x8c, - 0x59, 0x13, 0x66, 0xc1, 0x9c, 0x4b, 0x79, 0xd2, 0x6c, 0x41, 0x2b, 0x25, 0x2d, 0x39, 0x19, 0xf1, - 0xd5, 0x64, 0x89, 0x9b, 0xf0, 0xdd, 0x52, 0x7c, 0xa3, 0xd4, 0x28, 0x3e, 0xe3, 0x89, 0x12, 0xdb, - 0xf5, 0x68, 0x0f, 0x3b, 0xd1, 0x62, 0x70, 0x09, 0xcc, 0x1e, 0x90, 0xa1, 0xd8, 0x4a, 0xc6, 0xe2, - 0xc3, 0x80, 0xfc, 0xa6, 0x92, 0x1f, 0x15, 0x53, 0xf2, 0x59, 0x30, 0x37, 0xc0, 0xed, 0xbe, 0x2f, - 0x2e, 0x27, 0xc6, 0x5d, 0xb0, 0x24, 0xa2, 0x1f, 0xd1, 0xc6, 0x8d, 0x36, 0x59, 0x04, 0x7f, 0x04, - 0xf2, 0x94, 0x04, 0x04, 0x49, 0x7e, 0xac, 0x22, 0x6b, 0xd1, 0x12, 0x63, 0xa3, 0x0a, 0xa0, 0x08, - 0xdc, 0x3b, 0xda, 0xa1, 0x0e, 0xf3, 0x25, 0x20, 0x48, 0x8a, 0xcb, 0x90, 0xf5, 0xc5, 0x38, 0x50, - 0x7c, 0x5b, 0x9d, 0x87, 0x9f, 0xa3, 0xca, 0x23, 0x90, 0x6c, 0x53, 0x87, 0x43, 0xcd, 0x96, 0x16, - 0xaa, 0x2b, 0xe6, 0xf5, 0x0f, 0xd6, 0xdc, 0xa1, 0x8e, 0x25, 0x02, 0x8d, 0x3b, 0xe0, 0x2f, 0x79, - 0x13, 0x6d, 0x6a, 0x1f, 0xc4, 0x97, 0x7f, 0x01, 0x96, 0x27, 0xd3, 0x14, 0xc1, 0x36, 0x48, 0x7b, - 0x47, 0xfb, 0x01, 0x88, 0x62, 0x18, 0xc4, 0x5e, 0x0f, 0xbb, 0x0c, 0xdb, 0xbc, 0x29, 0x78, 0x85, - 0x5a, 0xf2, 0xec, 0xdb, 0x6a, 0xc2, 0x4a, 0x79, 0x62, 0x47, 0x46, 0x2e, 0xa8, 0x50, 0x6b, 0x53, - 0xda, 0x51, 0x64, 0x06, 0x02, 0x7f, 0xff, 0xf6, 0xe5, 0xea, 0x02, 0xeb, 0x7c, 0x41, 0x1d, 0xaf, - 0x9c, 0x18, 0x59, 0x75, 0xbe, 0x4f, 0x71, 0x0f, 0x77, 0xfc, 0x0d, 0x1a, 0xbb, 0xea, 0x04, 0xfd, - 0x55, 0x55, 0xe2, 0x21, 0x48, 0x75, 0xc5, 0x8a, 0xa8, 0xb1, 0x50, 0xd5, 0xc3, 0xf0, 0x65, 0x9e, - 0x4f, 0x2d, 0x73, 0xaa, 0x67, 0x19, 0x30, 0x27, 0xaa, 0xc2, 0x0f, 0x1a, 0x48, 0xab, 0xf6, 0x83, - 0xe5, 0xb0, 0x1a, 0xd7, 0xf4, 0x77, 0x7e, 0x33, 0x5e, 0xb0, 0xc4, 0x35, 0x2a, 0x2f, 0xbf, 0xfc, - 0x78, 0x3f, 0x53, 0x86, 0xeb, 0x28, 0xc4, 0x4f, 0xb0, 0x4c, 0x40, 0xc7, 0xea, 0x81, 0x9e, 0xc0, - 0x8f, 0x1a, 0x48, 0xab, 0xc6, 0x8b, 0x20, 0x1b, 0xef, 0xec, 0x08, 0xb2, 0x89, 0x5e, 0x36, 0xaa, - 0x82, 0x6c, 0x13, 0x6e, 0x84, 0x91, 0xa9, 0xd6, 0x66, 0x01, 0xb4, 0xcf, 0x1a, 0x48, 0xab, 0xa6, - 0x8c, 0x40, 0x1b, 0xf7, 0x81, 0x08, 0xb4, 0x89, 0x3e, 0x37, 0xee, 0x09, 0xb4, 0x0a, 0x44, 0x61, - 0x68, 0x4c, 0x26, 0x5c, 0x91, 0xa1, 0xe3, 0x03, 0x32, 0x3c, 0x81, 0x6f, 0x34, 0x90, 0xe4, 0xed, - 0x0c, 0x4b, 0x53, 0xf5, 0x02, 0x4e, 0x91, 0x5f, 0x8f, 0x11, 0xa9, 0xb0, 0x90, 0xc0, 0x5a, 0x87, - 0xc5, 0x30, 0x2c, 0xee, 0x16, 0xc1, 0xe3, 0x7a, 0xa7, 0x81, 0x94, 0x34, 0x00, 0xb8, 0x31, 0x55, - 0x66, 0xcc, 0x59, 0xf2, 0xe5, 0x58, 0xb1, 0x0a, 0xca, 0x14, 0x50, 0x25, 0xb8, 0x16, 0x06, 0xa5, - 0xba, 0x1d, 0x1d, 0x73, 0x8b, 0x10, 0x57, 0x98, 0x19, 0xb9, 0x02, 0xfc, 0x7f, 0xfa, 0x93, 0x99, - 0x30, 0x9d, 0xbc, 0x19, 0x37, 0x3c, 0xee, 0xeb, 0xaf, 0xf3, 0x94, 0x31, 0xbe, 0x4f, 0x1a, 0x00, - 0x57, 0xce, 0x01, 0x63, 0x28, 0x06, 0xcd, 0x27, 0x8f, 0x62, 0xc7, 0x2b, 0xc4, 0xb2, 0x40, 0xfc, - 0x0f, 0xfe, 0x3b, 0x1d, 0x51, 0x38, 0x15, 0x7c, 0xad, 0x81, 0x94, 0xf4, 0x95, 0x88, 0x0b, 0x1d, - 0xb3, 0xb2, 0x88, 0x0b, 0x1d, 0x37, 0x38, 0x63, 0x4d, 0x00, 0x15, 0xa0, 0x1e, 0x06, 0x24, 0xad, - 0xac, 0xb6, 0x75, 0x76, 0xa1, 0x6b, 0xe7, 0x17, 0xba, 0xf6, 0xfd, 0x42, 0xd7, 0xde, 0x5e, 0xea, - 0x89, 0xf3, 0x4b, 0x3d, 0xf1, 0xf5, 0x52, 0x4f, 0x3c, 0x2f, 0x3a, 0x2d, 0xaf, 0xd9, 0xaf, 0x9b, - 0x36, 0xed, 0x20, 0x9b, 0xb2, 0x0e, 0x65, 0x81, 0x52, 0x47, 0xa2, 0x98, 0x37, 0xec, 0x12, 0x56, - 0x4f, 0x89, 0x1f, 0x99, 0xdb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x07, 0x03, 0xa0, 0x17, 0x5c, - 0x09, 0x00, 0x00, +func init() { proto.RegisterFile("injective/evm/v1beta1/query.proto", fileDescriptor_b35cda93d73bda44) } + +var fileDescriptor_b35cda93d73bda44 = []byte{ + // 1175 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xc1, 0x6f, 0x1b, 0xc5, + 0x17, 0xf6, 0x26, 0x8e, 0x9d, 0xbc, 0x36, 0x3f, 0xe5, 0x37, 0x38, 0x6d, 0x58, 0xa8, 0x93, 0x0e, + 0x4d, 0xe3, 0xa6, 0x8d, 0x37, 0x4e, 0x21, 0x90, 0xb4, 0x12, 0x8a, 0xab, 0x8a, 0x54, 0x44, 0x08, + 0xb6, 0x3d, 0x71, 0xb1, 0xc6, 0xeb, 0x91, 0x6d, 0xb2, 0xde, 0x71, 0x3d, 0xeb, 0x28, 0x51, 0x94, + 0x0b, 0x87, 0x0a, 0x2e, 0x08, 0x09, 0x10, 0x12, 0xa7, 0xfe, 0x03, 0xdc, 0xf8, 0x23, 0x2a, 0x24, + 0xa4, 0x4a, 0x5c, 0x38, 0x21, 0x94, 0x70, 0xe0, 0xcf, 0x40, 0x3b, 0xfb, 0xd6, 0xde, 0x8d, 0xbd, + 0x6b, 0x27, 0xe2, 0xb6, 0x33, 0x7e, 0xdf, 0xfb, 0xbe, 0xf7, 0xf6, 0xcd, 0x7c, 0x6b, 0xb8, 0xd9, + 0x74, 0xbe, 0xe0, 0x96, 0xdb, 0x3c, 0xe0, 0x06, 0x3f, 0x68, 0x19, 0x07, 0xa5, 0x2a, 0x77, 0x59, + 0xc9, 0x78, 0xde, 0xe5, 0x9d, 0xa3, 0x62, 0xbb, 0x23, 0x5c, 0x41, 0xe6, 0x7b, 0x21, 0x45, 0x7e, + 0xd0, 0x2a, 0x62, 0x88, 0x9e, 0xab, 0x8b, 0xba, 0x50, 0x11, 0x86, 0xf7, 0xe4, 0x07, 0xeb, 0x6f, + 0xd7, 0x85, 0xa8, 0xdb, 0xdc, 0x60, 0xed, 0xa6, 0xc1, 0x1c, 0x47, 0xb8, 0xcc, 0x6d, 0x0a, 0x47, + 0xe2, 0xaf, 0x8b, 0xc3, 0xd9, 0xbc, 0xb4, 0x2a, 0x80, 0x6e, 0xc1, 0x1b, 0x9f, 0x79, 0xd4, 0x3b, + 0x96, 0x25, 0xba, 0x8e, 0x6b, 0xf2, 0xe7, 0x5d, 0x2e, 0x5d, 0xb2, 0x00, 0x59, 0x56, 0xab, 0x75, + 0xb8, 0x94, 0x0b, 0xda, 0x92, 0x56, 0x98, 0x31, 0x83, 0xe5, 0xf6, 0xf4, 0x57, 0x2f, 0x17, 0x53, + 0xff, 0xbc, 0x5c, 0x4c, 0x51, 0x0b, 0x72, 0x51, 0xa8, 0x6c, 0x0b, 0x47, 0x72, 0x0f, 0x5b, 0x65, + 0x36, 0x73, 0x2c, 0x1e, 0x60, 0x71, 0x49, 0xde, 0x82, 0x19, 0x4b, 0xd4, 0x78, 0xa5, 0xc1, 0x64, + 0x63, 0x61, 0x62, 0x49, 0x2b, 0x5c, 0x35, 0xa7, 0xbd, 0x8d, 0x5d, 0x26, 0x1b, 0x24, 0x07, 0x53, + 0x8e, 0xf0, 0x40, 0x93, 0x4b, 0x5a, 0x21, 0x6d, 0xfa, 0x0b, 0xfa, 0x21, 0xbc, 0xa9, 0x48, 0x1e, + 0x09, 0xd9, 0x12, 0xf2, 0x12, 0x2a, 0x5f, 0x68, 0xa0, 0x0f, 0xcb, 0x80, 0x62, 0x97, 0xe1, 0x7f, + 0x96, 0xfa, 0xa1, 0x12, 0xcd, 0x34, 0xeb, 0xef, 0xee, 0xf8, 0x9b, 0x44, 0x87, 0x69, 0xe9, 0x91, + 0x7a, 0xfa, 0x26, 0x94, 0xbe, 0xde, 0xda, 0x4b, 0xc1, 0xfc, 0xac, 0x15, 0xa7, 0xdb, 0xaa, 0xf2, + 0x0e, 0x56, 0x30, 0x8b, 0xbb, 0x9f, 0xa8, 0xcd, 0x5e, 0xa7, 0xcb, 0x7e, 0x33, 0x2e, 0x52, 0xc3, + 0x3a, 0x76, 0xba, 0x07, 0x1d, 0xd5, 0x69, 0xfa, 0x31, 0x92, 0x3d, 0x75, 0x45, 0x87, 0xd5, 0x47, + 0x93, 0x91, 0x39, 0x98, 0xdc, 0xe7, 0x47, 0xaa, 0xb6, 0x19, 0xd3, 0x7b, 0x0c, 0xd1, 0xdf, 0x43, + 0xfa, 0x5e, 0x32, 0xa4, 0xcf, 0xc1, 0xd4, 0x01, 0xb3, 0xbb, 0x01, 0xb9, 0xbf, 0xa0, 0x9b, 0x30, + 0x87, 0xfd, 0xae, 0x5d, 0xa8, 0xc8, 0x15, 0xf8, 0x7f, 0x08, 0x87, 0x14, 0x04, 0xd2, 0xde, 0x80, + 0x28, 0xd4, 0x55, 0x53, 0x3d, 0xd3, 0x0d, 0x20, 0x2a, 0xf0, 0xd9, 0xe1, 0x9e, 0xa8, 0xcb, 0x80, + 0x82, 0x40, 0x5a, 0x8d, 0x95, 0x9f, 0x5f, 0x3d, 0x87, 0x92, 0x3f, 0xc6, 0x7e, 0x04, 0x18, 0x4c, + 0x5f, 0x84, 0xb4, 0x2d, 0xea, 0x9e, 0xa8, 0xc9, 0xc2, 0x95, 0x0d, 0xbd, 0x38, 0xf4, 0xe0, 0x15, + 0xf7, 0x44, 0xdd, 0x54, 0x71, 0xf4, 0x3d, 0x98, 0xc7, 0x34, 0x26, 0xb7, 0x78, 0xb3, 0xed, 0x8e, + 0xc7, 0xfe, 0x0c, 0xae, 0x9d, 0x87, 0xa1, 0x80, 0x6d, 0xc8, 0x76, 0xfc, 0x2d, 0x05, 0xbd, 0xb2, + 0xb1, 0x14, 0xa3, 0xa1, 0x0f, 0x0d, 0x00, 0xf4, 0x23, 0x78, 0x27, 0x9a, 0x55, 0x96, 0x8f, 0xca, + 0xb6, 0xb0, 0xf6, 0x77, 0x79, 0xb3, 0xde, 0xe8, 0x49, 0xbb, 0x06, 0x99, 0x86, 0xda, 0x50, 0x0c, + 0x93, 0x26, 0xae, 0x42, 0xf2, 0x6a, 0x70, 0x2b, 0x39, 0x11, 0x8a, 0x7d, 0x08, 0xd3, 0xc8, 0x1d, + 0x74, 0x6c, 0xb4, 0xda, 0x1e, 0x82, 0xee, 0xc0, 0xcd, 0x18, 0x16, 0x26, 0x1b, 0xe3, 0xf5, 0xb1, + 0x0a, 0x34, 0x29, 0xc5, 0x7f, 0x22, 0x33, 0x78, 0xc5, 0x2a, 0xef, 0xf8, 0x03, 0x56, 0xc1, 0x57, + 0x1c, 0x82, 0xa1, 0x9c, 0xc7, 0x90, 0x75, 0x0f, 0x2b, 0xa1, 0x31, 0xbb, 0x1d, 0xa7, 0xa6, 0xc3, + 0x1c, 0xc9, 0x2c, 0xef, 0xfa, 0xf6, 0x12, 0x94, 0xd3, 0xaf, 0xfe, 0x5c, 0x4c, 0x99, 0x19, 0x57, + 0x8d, 0x2c, 0x5d, 0x0f, 0x13, 0x94, 0x6d, 0x21, 0x5a, 0x23, 0x5e, 0x30, 0x35, 0xe0, 0xfa, 0x00, + 0xa2, 0x7f, 0x72, 0xab, 0xde, 0x06, 0x9e, 0x2b, 0x7f, 0x41, 0x73, 0x78, 0xb0, 0x3e, 0x65, 0x1d, + 0xd6, 0x0a, 0xea, 0xa6, 0x26, 0x1e, 0x9d, 0x60, 0x17, 0x53, 0x3c, 0x80, 0x4c, 0x5b, 0xed, 0xe0, + 0xe0, 0xde, 0x88, 0xa9, 0xca, 0x87, 0x05, 0xc5, 0xf8, 0x10, 0xba, 0x8b, 0xc5, 0x3c, 0xf5, 0xdc, + 0xca, 0x7a, 0xc4, 0x6c, 0x7b, 0xf4, 0x0d, 0x95, 0x83, 0xa9, 0xa6, 0xd3, 0xee, 0xba, 0x68, 0x1c, + 0xfe, 0x82, 0xae, 0x61, 0x91, 0xe1, 0x4c, 0xfd, 0xbb, 0xa3, 0xc6, 0x5c, 0x16, 0xdc, 0x1d, 0xde, + 0xf3, 0xc6, 0x2f, 0x73, 0x30, 0xa5, 0xe2, 0xc9, 0xf7, 0x1a, 0x64, 0xd1, 0x0c, 0xc8, 0x6a, 0x8c, + 0xf6, 0x21, 0xce, 0xa8, 0xdf, 0x1d, 0x2b, 0xd6, 0x97, 0x40, 0xd7, 0xbf, 0xfc, 0xfd, 0xef, 0xef, + 0x26, 0x56, 0x49, 0xc1, 0x18, 0xee, 0xc3, 0xe8, 0x10, 0xc6, 0x31, 0x16, 0x79, 0x42, 0x7e, 0xd6, + 0x60, 0x36, 0xe2, 0x54, 0x64, 0x3d, 0x89, 0x70, 0x98, 0x2d, 0xea, 0xa5, 0x0b, 0x20, 0x50, 0xe8, + 0xfb, 0x4a, 0x68, 0x89, 0x18, 0x31, 0x42, 0x03, 0x8f, 0x1c, 0xd0, 0xfb, 0x83, 0x06, 0x59, 0xb4, + 0xa5, 0xe4, 0x36, 0x46, 0x6d, 0x2f, 0xb9, 0x8d, 0xe7, 0x7c, 0x8e, 0x96, 0x94, 0xba, 0xbb, 0xe4, + 0x4e, 0x8c, 0x3a, 0x74, 0x3d, 0x19, 0xd2, 0xf5, 0x93, 0x06, 0x59, 0xf4, 0xab, 0x64, 0x5d, 0x51, + 0x87, 0x4c, 0xd6, 0x75, 0xce, 0x00, 0xe9, 0xa6, 0xd2, 0xb5, 0x4e, 0x8a, 0x31, 0xba, 0xa4, 0x1f, + 0xdf, 0x97, 0x65, 0x1c, 0xef, 0xf3, 0xa3, 0x13, 0xf2, 0xb5, 0x06, 0x69, 0xcf, 0xe6, 0xc8, 0x4a, + 0xf2, 0x9b, 0xea, 0x19, 0xa8, 0x5e, 0x18, 0x1d, 0x88, 0x9a, 0x8a, 0x4a, 0x53, 0x81, 0xdc, 0x8e, + 0x7d, 0x93, 0xb5, 0x48, 0xa3, 0xbe, 0xd1, 0x20, 0xe3, 0xbb, 0x22, 0xb9, 0x93, 0x44, 0x12, 0x71, + 0x5b, 0x7d, 0x75, 0x9c, 0x50, 0x54, 0xb4, 0xa6, 0x14, 0xad, 0x90, 0xe5, 0x18, 0x45, 0x78, 0x3b, + 0x1a, 0xc7, 0xde, 0x95, 0xaa, 0xde, 0xdc, 0x4c, 0xef, 0x62, 0x26, 0xf7, 0x92, 0x89, 0xa2, 0x36, + 0xac, 0xaf, 0x8d, 0x19, 0x3d, 0xe6, 0xf1, 0x74, 0x0f, 0x2b, 0xe8, 0x0b, 0x81, 0xb8, 0xdf, 0x34, + 0xb8, 0x1e, 0x63, 0x93, 0x64, 0x7b, 0x2c, 0xf2, 0xa1, 0x26, 0xad, 0x3f, 0xb8, 0x14, 0x16, 0xcb, + 0xd8, 0x52, 0x65, 0xdc, 0x27, 0xa5, 0x91, 0x65, 0xc8, 0x4a, 0xd5, 0xc3, 0x1b, 0xc7, 0xbe, 0x45, + 0x9c, 0x90, 0x5f, 0x35, 0x98, 0x1f, 0xea, 0xa6, 0xe4, 0x83, 0x8b, 0x29, 0xea, 0x7b, 0xb8, 0xbe, + 0x75, 0x09, 0x24, 0x56, 0xf2, 0x50, 0x55, 0xb2, 0x49, 0xde, 0x1d, 0xb7, 0x12, 0xf5, 0x57, 0x22, + 0x3c, 0x39, 0x3d, 0xff, 0x4d, 0x9e, 0x9c, 0xf3, 0xee, 0x9e, 0x3c, 0x39, 0x03, 0xa6, 0x3e, 0x72, + 0x72, 0x7c, 0x71, 0xe1, 0xb1, 0xfe, 0x51, 0x03, 0xe8, 0x3b, 0x31, 0x19, 0xcd, 0x17, 0xf6, 0x78, + 0xbd, 0x38, 0x6e, 0x38, 0xea, 0x5b, 0x55, 0xfa, 0x6e, 0x11, 0x9a, 0xa8, 0x4f, 0xd9, 0x3e, 0x79, + 0xa1, 0x41, 0xc6, 0x77, 0xe9, 0xe4, 0x1b, 0x20, 0xf2, 0x59, 0x90, 0x7c, 0x03, 0x44, 0xbf, 0x15, + 0xe8, 0xb2, 0x52, 0xb3, 0x48, 0x6e, 0xc4, 0xa8, 0xf1, 0xbf, 0x0a, 0x54, 0x8b, 0xfa, 0x3e, 0x9e, + 0xdc, 0xa2, 0x81, 0x2f, 0x87, 0xe4, 0x16, 0x0d, 0x7e, 0x1e, 0x8c, 0x6c, 0x91, 0x54, 0x90, 0x8a, + 0xc5, 0x6c, 0xbb, 0x6c, 0xbd, 0x3a, 0xcd, 0x6b, 0xaf, 0x4f, 0xf3, 0xda, 0x5f, 0xa7, 0x79, 0xed, + 0xdb, 0xb3, 0x7c, 0xea, 0xf5, 0x59, 0x3e, 0xf5, 0xc7, 0x59, 0x3e, 0xf5, 0xf9, 0x93, 0x7a, 0xd3, + 0x6d, 0x74, 0xab, 0x45, 0x4b, 0xb4, 0x8c, 0x27, 0x41, 0x9e, 0x3d, 0x56, 0x95, 0xfd, 0xac, 0x6b, + 0x96, 0xe8, 0xf0, 0xf0, 0xb2, 0xc1, 0x9a, 0x8e, 0xd1, 0x12, 0xb5, 0xae, 0xcd, 0xa5, 0xa2, 0x74, + 0x8f, 0xda, 0x5c, 0x56, 0x33, 0xea, 0x1f, 0xf9, 0xfd, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x86, + 0x4f, 0xfe, 0x3c, 0x22, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -821,6 +1318,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Account queries an Ethereum account. Account(ctx context.Context, in *QueryAccountRequest, opts ...grpc.CallOption) (*QueryAccountResponse, error) + // Account queries an Ethereum account's Cosmos Address. + CosmosAccount(ctx context.Context, in *QueryCosmosAccountRequest, opts ...grpc.CallOption) (*QueryCosmosAccountResponse, error) // Balance queries the balance of a the EVM denomination for a single // EthAccount. Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) @@ -830,12 +1329,20 @@ type QueryClient interface { Code(ctx context.Context, in *QueryCodeRequest, opts ...grpc.CallOption) (*QueryCodeResponse, error) // TxLogs queries ethereum logs from a transaction. TxLogs(ctx context.Context, in *QueryTxLogsRequest, opts ...grpc.CallOption) (*QueryTxLogsResponse, error) + // TxReceipt queries a receipt by a transaction hash. + TxReceipt(ctx context.Context, in *QueryTxReceiptRequest, opts ...grpc.CallOption) (*QueryTxReceiptResponse, error) + // TxReceiptsByBlockHeight queries tx receipts by a block height. + TxReceiptsByBlockHeight(ctx context.Context, in *QueryTxReceiptsByBlockHeightRequest, opts ...grpc.CallOption) (*QueryTxReceiptsByBlockHeightResponse, error) + // TxReceiptsByBlockHash queries tx receipts by a block hash. + TxReceiptsByBlockHash(ctx context.Context, in *QueryTxReceiptsByBlockHashRequest, opts ...grpc.CallOption) (*QueryTxReceiptsByBlockHashResponse, error) // BlockLogs queries all the ethereum logs for a given block hash. BlockLogs(ctx context.Context, in *QueryBlockLogsRequest, opts ...grpc.CallOption) (*QueryBlockLogsResponse, error) // BlockBloom queries the block bloom filter bytes at a given height. BlockBloom(ctx context.Context, in *QueryBlockBloomRequest, opts ...grpc.CallOption) (*QueryBlockBloomResponse, error) // Params queries the parameters of x/evm module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // StaticCall queries the static call value of x/evm module. + StaticCall(ctx context.Context, in *QueryStaticCallRequest, opts ...grpc.CallOption) (*QueryStaticCallResponse, error) } type queryClient struct { @@ -848,7 +1355,16 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Account(ctx context.Context, in *QueryAccountRequest, opts ...grpc.CallOption) (*QueryAccountResponse, error) { out := new(QueryAccountResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/Account", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/Account", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) CosmosAccount(ctx context.Context, in *QueryCosmosAccountRequest, opts ...grpc.CallOption) (*QueryCosmosAccountResponse, error) { + out := new(QueryCosmosAccountResponse) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/CosmosAccount", in, out, opts...) if err != nil { return nil, err } @@ -857,7 +1373,7 @@ func (c *queryClient) Account(ctx context.Context, in *QueryAccountRequest, opts func (c *queryClient) Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) { out := new(QueryBalanceResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/Balance", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/Balance", in, out, opts...) if err != nil { return nil, err } @@ -866,7 +1382,7 @@ func (c *queryClient) Balance(ctx context.Context, in *QueryBalanceRequest, opts func (c *queryClient) Storage(ctx context.Context, in *QueryStorageRequest, opts ...grpc.CallOption) (*QueryStorageResponse, error) { out := new(QueryStorageResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/Storage", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/Storage", in, out, opts...) if err != nil { return nil, err } @@ -875,7 +1391,7 @@ func (c *queryClient) Storage(ctx context.Context, in *QueryStorageRequest, opts func (c *queryClient) Code(ctx context.Context, in *QueryCodeRequest, opts ...grpc.CallOption) (*QueryCodeResponse, error) { out := new(QueryCodeResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/Code", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/Code", in, out, opts...) if err != nil { return nil, err } @@ -884,7 +1400,34 @@ func (c *queryClient) Code(ctx context.Context, in *QueryCodeRequest, opts ...gr func (c *queryClient) TxLogs(ctx context.Context, in *QueryTxLogsRequest, opts ...grpc.CallOption) (*QueryTxLogsResponse, error) { out := new(QueryTxLogsResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/TxLogs", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/TxLogs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TxReceipt(ctx context.Context, in *QueryTxReceiptRequest, opts ...grpc.CallOption) (*QueryTxReceiptResponse, error) { + out := new(QueryTxReceiptResponse) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/TxReceipt", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TxReceiptsByBlockHeight(ctx context.Context, in *QueryTxReceiptsByBlockHeightRequest, opts ...grpc.CallOption) (*QueryTxReceiptsByBlockHeightResponse, error) { + out := new(QueryTxReceiptsByBlockHeightResponse) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/TxReceiptsByBlockHeight", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TxReceiptsByBlockHash(ctx context.Context, in *QueryTxReceiptsByBlockHashRequest, opts ...grpc.CallOption) (*QueryTxReceiptsByBlockHashResponse, error) { + out := new(QueryTxReceiptsByBlockHashResponse) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/TxReceiptsByBlockHash", in, out, opts...) if err != nil { return nil, err } @@ -893,7 +1436,7 @@ func (c *queryClient) TxLogs(ctx context.Context, in *QueryTxLogsRequest, opts . func (c *queryClient) BlockLogs(ctx context.Context, in *QueryBlockLogsRequest, opts ...grpc.CallOption) (*QueryBlockLogsResponse, error) { out := new(QueryBlockLogsResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/BlockLogs", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/BlockLogs", in, out, opts...) if err != nil { return nil, err } @@ -902,7 +1445,7 @@ func (c *queryClient) BlockLogs(ctx context.Context, in *QueryBlockLogsRequest, func (c *queryClient) BlockBloom(ctx context.Context, in *QueryBlockBloomRequest, opts ...grpc.CallOption) (*QueryBlockBloomResponse, error) { out := new(QueryBlockBloomResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/BlockBloom", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/BlockBloom", in, out, opts...) if err != nil { return nil, err } @@ -911,7 +1454,16 @@ func (c *queryClient) BlockBloom(ctx context.Context, in *QueryBlockBloomRequest func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StaticCall(ctx context.Context, in *QueryStaticCallRequest, opts ...grpc.CallOption) (*QueryStaticCallResponse, error) { + out := new(QueryStaticCallResponse) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Query/StaticCall", in, out, opts...) if err != nil { return nil, err } @@ -922,6 +1474,8 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . type QueryServer interface { // Account queries an Ethereum account. Account(context.Context, *QueryAccountRequest) (*QueryAccountResponse, error) + // Account queries an Ethereum account's Cosmos Address. + CosmosAccount(context.Context, *QueryCosmosAccountRequest) (*QueryCosmosAccountResponse, error) // Balance queries the balance of a the EVM denomination for a single // EthAccount. Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) @@ -931,12 +1485,20 @@ type QueryServer interface { Code(context.Context, *QueryCodeRequest) (*QueryCodeResponse, error) // TxLogs queries ethereum logs from a transaction. TxLogs(context.Context, *QueryTxLogsRequest) (*QueryTxLogsResponse, error) + // TxReceipt queries a receipt by a transaction hash. + TxReceipt(context.Context, *QueryTxReceiptRequest) (*QueryTxReceiptResponse, error) + // TxReceiptsByBlockHeight queries tx receipts by a block height. + TxReceiptsByBlockHeight(context.Context, *QueryTxReceiptsByBlockHeightRequest) (*QueryTxReceiptsByBlockHeightResponse, error) + // TxReceiptsByBlockHash queries tx receipts by a block hash. + TxReceiptsByBlockHash(context.Context, *QueryTxReceiptsByBlockHashRequest) (*QueryTxReceiptsByBlockHashResponse, error) // BlockLogs queries all the ethereum logs for a given block hash. BlockLogs(context.Context, *QueryBlockLogsRequest) (*QueryBlockLogsResponse, error) // BlockBloom queries the block bloom filter bytes at a given height. BlockBloom(context.Context, *QueryBlockBloomRequest) (*QueryBlockBloomResponse, error) // Params queries the parameters of x/evm module. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // StaticCall queries the static call value of x/evm module. + StaticCall(context.Context, *QueryStaticCallRequest) (*QueryStaticCallResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -946,6 +1508,9 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Account(ctx context.Context, req *QueryAccountRequest) (*QueryAccountResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Account not implemented") } +func (*UnimplementedQueryServer) CosmosAccount(ctx context.Context, req *QueryCosmosAccountRequest) (*QueryCosmosAccountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CosmosAccount not implemented") +} func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceRequest) (*QueryBalanceResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Balance not implemented") } @@ -958,6 +1523,15 @@ func (*UnimplementedQueryServer) Code(ctx context.Context, req *QueryCodeRequest func (*UnimplementedQueryServer) TxLogs(ctx context.Context, req *QueryTxLogsRequest) (*QueryTxLogsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TxLogs not implemented") } +func (*UnimplementedQueryServer) TxReceipt(ctx context.Context, req *QueryTxReceiptRequest) (*QueryTxReceiptResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TxReceipt not implemented") +} +func (*UnimplementedQueryServer) TxReceiptsByBlockHeight(ctx context.Context, req *QueryTxReceiptsByBlockHeightRequest) (*QueryTxReceiptsByBlockHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TxReceiptsByBlockHeight not implemented") +} +func (*UnimplementedQueryServer) TxReceiptsByBlockHash(ctx context.Context, req *QueryTxReceiptsByBlockHashRequest) (*QueryTxReceiptsByBlockHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TxReceiptsByBlockHash not implemented") +} func (*UnimplementedQueryServer) BlockLogs(ctx context.Context, req *QueryBlockLogsRequest) (*QueryBlockLogsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method BlockLogs not implemented") } @@ -967,6 +1541,9 @@ func (*UnimplementedQueryServer) BlockBloom(ctx context.Context, req *QueryBlock func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) StaticCall(ctx context.Context, req *QueryStaticCallRequest) (*QueryStaticCallResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StaticCall not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -982,7 +1559,7 @@ func _Query_Account_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/Account", + FullMethod: "/injective.evm.v1beta1.Query/Account", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Account(ctx, req.(*QueryAccountRequest)) @@ -990,6 +1567,24 @@ func _Query_Account_Handler(srv interface{}, ctx context.Context, dec func(inter return interceptor(ctx, in, info, handler) } +func _Query_CosmosAccount_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryCosmosAccountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).CosmosAccount(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/injective.evm.v1beta1.Query/CosmosAccount", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).CosmosAccount(ctx, req.(*QueryCosmosAccountRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_Balance_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryBalanceRequest) if err := dec(in); err != nil { @@ -1000,7 +1595,7 @@ func _Query_Balance_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/Balance", + FullMethod: "/injective.evm.v1beta1.Query/Balance", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Balance(ctx, req.(*QueryBalanceRequest)) @@ -1018,7 +1613,7 @@ func _Query_Storage_Handler(srv interface{}, ctx context.Context, dec func(inter } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/Storage", + FullMethod: "/injective.evm.v1beta1.Query/Storage", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Storage(ctx, req.(*QueryStorageRequest)) @@ -1036,7 +1631,7 @@ func _Query_Code_Handler(srv interface{}, ctx context.Context, dec func(interfac } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/Code", + FullMethod: "/injective.evm.v1beta1.Query/Code", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Code(ctx, req.(*QueryCodeRequest)) @@ -1054,7 +1649,7 @@ func _Query_TxLogs_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/TxLogs", + FullMethod: "/injective.evm.v1beta1.Query/TxLogs", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).TxLogs(ctx, req.(*QueryTxLogsRequest)) @@ -1062,6 +1657,60 @@ func _Query_TxLogs_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_TxReceipt_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTxReceiptRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TxReceipt(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/injective.evm.v1beta1.Query/TxReceipt", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TxReceipt(ctx, req.(*QueryTxReceiptRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TxReceiptsByBlockHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTxReceiptsByBlockHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TxReceiptsByBlockHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/injective.evm.v1beta1.Query/TxReceiptsByBlockHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TxReceiptsByBlockHeight(ctx, req.(*QueryTxReceiptsByBlockHeightRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TxReceiptsByBlockHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTxReceiptsByBlockHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TxReceiptsByBlockHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/injective.evm.v1beta1.Query/TxReceiptsByBlockHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TxReceiptsByBlockHash(ctx, req.(*QueryTxReceiptsByBlockHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_BlockLogs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryBlockLogsRequest) if err := dec(in); err != nil { @@ -1072,7 +1721,7 @@ func _Query_BlockLogs_Handler(srv interface{}, ctx context.Context, dec func(int } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/BlockLogs", + FullMethod: "/injective.evm.v1beta1.Query/BlockLogs", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).BlockLogs(ctx, req.(*QueryBlockLogsRequest)) @@ -1090,7 +1739,7 @@ func _Query_BlockBloom_Handler(srv interface{}, ctx context.Context, dec func(in } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/BlockBloom", + FullMethod: "/injective.evm.v1beta1.Query/BlockBloom", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).BlockBloom(ctx, req.(*QueryBlockBloomRequest)) @@ -1108,7 +1757,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Query/Params", + FullMethod: "/injective.evm.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -1116,14 +1765,36 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_StaticCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryStaticCallRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StaticCall(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/injective.evm.v1beta1.Query/StaticCall", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StaticCall(ctx, req.(*QueryStaticCallRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ethermint.evm.v1alpha1.Query", + ServiceName: "injective.evm.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Account", Handler: _Query_Account_Handler, }, + { + MethodName: "CosmosAccount", + Handler: _Query_CosmosAccount_Handler, + }, { MethodName: "Balance", Handler: _Query_Balance_Handler, @@ -1140,6 +1811,18 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TxLogs", Handler: _Query_TxLogs_Handler, }, + { + MethodName: "TxReceipt", + Handler: _Query_TxReceipt_Handler, + }, + { + MethodName: "TxReceiptsByBlockHeight", + Handler: _Query_TxReceiptsByBlockHeight_Handler, + }, + { + MethodName: "TxReceiptsByBlockHash", + Handler: _Query_TxReceiptsByBlockHash_Handler, + }, { MethodName: "BlockLogs", Handler: _Query_BlockLogs_Handler, @@ -1152,9 +1835,13 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "StaticCall", + Handler: _Query_StaticCall_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "ethermint/evm/v1alpha1/query.proto", + Metadata: "injective/evm/v1beta1/query.proto", } func (m *QueryAccountRequest) Marshal() (dAtA []byte, err error) { @@ -1229,6 +1916,76 @@ func (m *QueryAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryCosmosAccountRequest) 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 *QueryCosmosAccountRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCosmosAccountRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryCosmosAccountResponse) 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 *QueryCosmosAccountResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryCosmosAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AccountNumber != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.AccountNumber)) + i-- + dAtA[i] = 0x18 + } + if m.Sequence != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x10 + } + if len(m.CosmosAddress) > 0 { + i -= len(m.CosmosAddress) + copy(dAtA[i:], m.CosmosAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.CosmosAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *QueryBalanceRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1483,6 +2240,203 @@ func (m *QueryTxLogsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryTxReceiptRequest) 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 *QueryTxReceiptRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTxReceiptResponse) 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 *QueryTxReceiptResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Receipt != nil { + { + size, err := m.Receipt.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTxReceiptsByBlockHeightRequest) 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 *QueryTxReceiptsByBlockHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptsByBlockHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QueryTxReceiptsByBlockHeightResponse) 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 *QueryTxReceiptsByBlockHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptsByBlockHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Receipts) > 0 { + for iNdEx := len(m.Receipts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Receipts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryTxReceiptsByBlockHashRequest) 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 *QueryTxReceiptsByBlockHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptsByBlockHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTxReceiptsByBlockHashResponse) 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 *QueryTxReceiptsByBlockHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTxReceiptsByBlockHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Receipts) > 0 { + for iNdEx := len(m.Receipts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Receipts[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryBlockLogsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1570,6 +2524,11 @@ func (m *QueryBlockBloomRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) _ = i var l int _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } return len(dAtA) - i, nil } @@ -1659,6 +2618,73 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryStaticCallRequest) 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 *QueryStaticCallRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStaticCallRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Input) > 0 { + i -= len(m.Input) + copy(dAtA[i:], m.Input) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Input))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryStaticCallResponse) 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 *QueryStaticCallResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryStaticCallResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1703,6 +2729,38 @@ func (m *QueryAccountResponse) Size() (n int) { return n } +func (m *QueryCosmosAccountRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryCosmosAccountResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CosmosAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovQuery(uint64(m.Sequence)) + } + if m.AccountNumber != 0 { + n += 1 + sovQuery(uint64(m.AccountNumber)) + } + return n +} + func (m *QueryBalanceRequest) Size() (n int) { if m == nil { return 0 @@ -1813,6 +2871,87 @@ func (m *QueryTxLogsResponse) Size() (n int) { return n } +func (m *QueryTxReceiptRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTxReceiptResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Receipt != nil { + l = m.Receipt.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTxReceiptsByBlockHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryTxReceiptsByBlockHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Receipts) > 0 { + for _, e := range m.Receipts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryTxReceiptsByBlockHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTxReceiptsByBlockHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Receipts) > 0 { + for _, e := range m.Receipts { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryBlockLogsRequest) Size() (n int) { if m == nil { return 0 @@ -1847,6 +2986,9 @@ func (m *QueryBlockBloomRequest) Size() (n int) { } var l int _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } return n } @@ -1883,6 +3025,36 @@ func (m *QueryParamsResponse) Size() (n int) { return n } +func (m *QueryStaticCallRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Input) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryStaticCallResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1956,10 +3128,7 @@ func (m *QueryAccountRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2094,10 +3263,209 @@ func (m *QueryAccountResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCosmosAccountRequest) 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 ErrIntOverflowQuery + } + 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: QueryCosmosAccountRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCosmosAccountRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryCosmosAccountResponse) 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 ErrIntOverflowQuery + } + 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: QueryCosmosAccountResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryCosmosAccountResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CosmosAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CosmosAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) + } + m.AccountNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AccountNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2179,10 +3547,7 @@ func (m *QueryBalanceRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2264,10 +3629,7 @@ func (m *QueryBalanceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2381,10 +3743,7 @@ func (m *QueryStorageRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2466,10 +3825,7 @@ func (m *QueryStorageResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2551,10 +3907,7 @@ func (m *QueryCodeRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2638,10 +3991,7 @@ func (m *QueryCodeResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2723,10 +4073,7 @@ func (m *QueryTxLogsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2810,10 +4157,494 @@ func (m *QueryTxLogsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptRequest) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptResponse) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipt", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Receipt == nil { + m.Receipt = &TxReceipt{} + } + if err := m.Receipt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptsByBlockHeightRequest) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptsByBlockHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptsByBlockHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptsByBlockHeightResponse) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptsByBlockHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptsByBlockHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receipts = append(m.Receipts, &TxReceipt{}) + if err := m.Receipts[len(m.Receipts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptsByBlockHashRequest) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptsByBlockHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptsByBlockHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTxReceiptsByBlockHashResponse) 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 ErrIntOverflowQuery + } + 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: QueryTxReceiptsByBlockHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTxReceiptsByBlockHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receipts", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Receipts = append(m.Receipts, &TxReceipt{}) + if err := m.Receipts[len(m.Receipts)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2895,10 +4726,7 @@ func (m *QueryBlockLogsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2982,10 +4810,7 @@ func (m *QueryBlockLogsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3029,16 +4854,32 @@ func (m *QueryBlockBloomRequest) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: QueryBlockBloomRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3122,10 +4963,7 @@ func (m *QueryBlockBloomResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3175,10 +5013,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3261,10 +5096,207 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStaticCallRequest) 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 ErrIntOverflowQuery + } + 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: QueryStaticCallRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStaticCallRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Input", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Input = append(m.Input[:0], dAtA[iNdEx:postIndex]...) + if m.Input == nil { + m.Input = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryStaticCallResponse) 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 ErrIntOverflowQuery + } + 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: QueryStaticCallResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryStaticCallResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/x/evm/types/query.pb.gw.go b/x/evm/types/query.pb.gw.go index 012ebba6..66aa762f 100644 --- a/x/evm/types/query.pb.gw.go +++ b/x/evm/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: ethermint/evm/v1alpha1/query.proto +// source: injective/evm/v1beta1/query.proto /* Package types is a reverse proxy. @@ -85,6 +85,60 @@ func local_request_Query_Account_0(ctx context.Context, marshaler runtime.Marsha } +func request_Query_CosmosAccount_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCosmosAccountRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.CosmosAccount(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_CosmosAccount_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryCosmosAccountRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.CosmosAccount(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_Balance_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBalanceRequest var metadata runtime.ServerMetadata @@ -323,6 +377,168 @@ func local_request_Query_TxLogs_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_TxReceipt_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.TxReceipt(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TxReceipt_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.TxReceipt(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_TxReceiptsByBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptsByBlockHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := client.TxReceiptsByBlockHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TxReceiptsByBlockHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptsByBlockHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := server.TxReceiptsByBlockHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_TxReceiptsByBlockHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptsByBlockHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.TxReceiptsByBlockHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TxReceiptsByBlockHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTxReceiptsByBlockHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.TxReceiptsByBlockHash(ctx, &protoReq) + return msg, metadata, err + +} + func request_Query_BlockLogs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockLogsRequest var metadata runtime.ServerMetadata @@ -377,10 +593,21 @@ func local_request_Query_BlockLogs_0(ctx context.Context, marshaler runtime.Mars } +var ( + filter_Query_BlockBloom_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + func request_Query_BlockBloom_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockBloomRequest var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockBloom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.BlockBloom(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -390,6 +617,13 @@ func local_request_Query_BlockBloom_0(ctx context.Context, marshaler runtime.Mar var protoReq QueryBlockBloomRequest var metadata runtime.ServerMetadata + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_BlockBloom_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.BlockBloom(ctx, &protoReq) return msg, metadata, err @@ -413,6 +647,42 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_StaticCall_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_StaticCall_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStaticCallRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StaticCall_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StaticCall(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StaticCall_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryStaticCallRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StaticCall_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StaticCall(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -439,6 +709,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_CosmosAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_CosmosAccount_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CosmosAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -519,6 +809,66 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TxReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TxReceipt_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxReceiptsByBlockHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TxReceiptsByBlockHeight_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceiptsByBlockHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxReceiptsByBlockHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TxReceiptsByBlockHash_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceiptsByBlockHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_BlockLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -579,6 +929,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_StaticCall_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_StaticCall_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_StaticCall_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -640,6 +1010,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_CosmosAccount_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_CosmosAccount_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_CosmosAccount_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_Balance_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -720,6 +1110,66 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TxReceipt_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TxReceipt_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceipt_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxReceiptsByBlockHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TxReceiptsByBlockHeight_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceiptsByBlockHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TxReceiptsByBlockHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TxReceiptsByBlockHash_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TxReceiptsByBlockHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_BlockLogs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -780,30 +1230,62 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_StaticCall_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_StaticCall_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_StaticCall_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( - pattern_Query_Account_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "account", "address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Account_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "account", "address"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_CosmosAccount_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "cosmos_account", "address"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Storage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"ethermint", "evm", "v1alpha1", "storage", "address", "key"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Balance_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Code_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "codes", "address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Storage_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"injective", "evm", "v1beta1", "storage", "address", "key"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_TxLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "tx_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Code_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "codes", "address"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_BlockLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"ethermint", "evm", "v1alpha1", "block_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TxLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "tx_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_BlockBloom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1alpha1", "block_bloom"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TxReceipt_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "tx_receipt", "hash"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"ethermint", "evm", "v1alpha1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TxReceiptsByBlockHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "tx_receipts_block", "height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TxReceiptsByBlockHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "tx_receipts_block_hash", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_BlockLogs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"injective", "evm", "v1beta1", "block_logs", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_BlockBloom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"injective", "evm", "v1beta1", "block_bloom"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"injective", "evm", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StaticCall_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"injective", "evm", "v1beta1", "static_call"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Account_0 = runtime.ForwardResponseMessage + forward_Query_CosmosAccount_0 = runtime.ForwardResponseMessage + forward_Query_Balance_0 = runtime.ForwardResponseMessage forward_Query_Storage_0 = runtime.ForwardResponseMessage @@ -812,9 +1294,17 @@ var ( forward_Query_TxLogs_0 = runtime.ForwardResponseMessage + forward_Query_TxReceipt_0 = runtime.ForwardResponseMessage + + forward_Query_TxReceiptsByBlockHeight_0 = runtime.ForwardResponseMessage + + forward_Query_TxReceiptsByBlockHash_0 = runtime.ForwardResponseMessage + forward_Query_BlockLogs_0 = runtime.ForwardResponseMessage forward_Query_BlockBloom_0 = runtime.ForwardResponseMessage forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_StaticCall_0 = runtime.ForwardResponseMessage ) diff --git a/x/evm/types/state_object.go b/x/evm/types/state_object.go index ac931e38..39a68765 100644 --- a/x/evm/types/state_object.go +++ b/x/evm/types/state_object.go @@ -10,7 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - ethermint "github.com/cosmos/ethermint/types" + "github.com/cosmos/ethermint/types" ethcmn "github.com/ethereum/go-ethereum/common" ethstate "github.com/ethereum/go-ethereum/core/state" @@ -53,7 +53,7 @@ type StateObject interface { // Account values can be accessed and modified through the object. // Finally, call CommitTrie to write the modified storage trie into a database. type stateObject struct { - code ethermint.Code // contract bytecode, which gets set when code is loaded + code types.Code // contract bytecode, which gets set when code is loaded // State objects are used by the consensus core and VM which are // unable to deal with database-level errors. Any error that occurs // during a database read is memoized here and will eventually be returned @@ -64,7 +64,7 @@ type stateObject struct { // DB error dbErr error stateDB *CommitStateDB - account *ethermint.EthAccount + account *types.EthAccount // balance represents the amount of the EVM denom token that an account holds balance sdk.Int @@ -83,21 +83,21 @@ type stateObject struct { } func newStateObject(db *CommitStateDB, accProto authtypes.AccountI, balance sdk.Int) *stateObject { - ethermintAccount, ok := accProto.(*ethermint.EthAccount) + ethAccount, ok := accProto.(*types.EthAccount) if !ok { panic(fmt.Sprintf("invalid account type for state object: %T", accProto)) } // set empty code hash - if ethermintAccount.CodeHash == nil { - ethermintAccount.CodeHash = emptyCodeHash + if ethAccount.CodeHash == nil { + ethAccount.CodeHash = emptyCodeHash } return &stateObject{ stateDB: db, - account: ethermintAccount, + account: ethAccount, balance: balance, - address: ethermintAccount.EthAddress(), + address: ethAccount.EthAddress(), originStorage: Storage{}, dirtyStorage: Storage{}, keyToOriginStorageIndex: make(map[ethcmn.Hash]int), @@ -250,9 +250,8 @@ func (so *stateObject) commitState() { key := ethcmn.HexToHash(state.Key) value := ethcmn.HexToHash(state.Value) - // delete empty values from the store - if ethermint.IsEmptyHash(state.Value) { + if IsEmptyHash(state.Value) { store.Delete(key.Bytes()) } @@ -264,7 +263,7 @@ func (so *stateObject) commitState() { continue } - if ethermint.IsEmptyHash(state.Value) { + if IsEmptyHash(state.Value) { delete(so.keyToOriginStorageIndex, key) continue } diff --git a/x/evm/types/state_transition.go b/x/evm/types/state_transition.go index 0e592076..cf9bebf8 100644 --- a/x/evm/types/state_transition.go +++ b/x/evm/types/state_transition.go @@ -1,18 +1,22 @@ package types import ( - "errors" "math/big" + "os" + "sync" - tmtypes "github.com/tendermint/tendermint/types" + "github.com/pkg/errors" + log "github.com/xlab/suplog" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/ethermint/metrics" ) // StateTransition defines data to transitionDB in evm @@ -30,6 +34,18 @@ type StateTransition struct { TxHash *common.Hash Sender common.Address Simulate bool // i.e CheckTx execution + Debug bool // enable EVM debugging + + once sync.Once + svcTags metrics.Tags +} + +func (st *StateTransition) initOnce() { + st.once.Do(func() { + st.svcTags = metrics.Tags{ + "svc": "evm_state", + } + }) } // GasInfo returns the gas limit, gas consumed and gas refunded from the EVM transition @@ -49,16 +65,16 @@ type ExecutionResult struct { } // GetHashFn implements vm.GetHashFunc for Ethermint. It handles 3 cases: -// 1. The requested height matches the current height (and thus same epoch number) +// 1. The requested height matches the current height from context (and thus same epoch number) // 2. The requested height is from an previous height from the same chain epoch // 3. The requested height is from a height greater than the latest one func GetHashFn(ctx sdk.Context, csdb *CommitStateDB) vm.GetHashFunc { return func(height uint64) common.Hash { switch { case ctx.BlockHeight() == int64(height): - // Case 1: The requested height matches the one from the CommitStateDB so we can retrieve the block - // hash directly from the CommitStateDB. - return csdb.bhash + // Case 1: The requested height matches the one from the context so we can retrieve the header + // hash directly from the context. + return HashFromContext(ctx) case ctx.BlockHeight() > int64(height): // Case 2: if the chain is not the current height we need to retrieve the hash from the store for the @@ -72,7 +88,7 @@ func GetHashFn(ctx sdk.Context, csdb *CommitStateDB) vm.GetHashFunc { } } -func (st StateTransition) newEVM( +func (st *StateTransition) newEVM( ctx sdk.Context, csdb *CommitStateDB, gasLimit uint64, @@ -80,13 +96,14 @@ func (st StateTransition) newEVM( config ChainConfig, extraEIPs []int64, ) *vm.EVM { - // Create context for evm + st.initOnce() + // Create context for evm blockCtx := vm.BlockContext{ CanTransfer: core.CanTransfer, Transfer: core.Transfer, GetHash: GetHashFn(ctx, csdb), - Coinbase: common.Address{}, // there's no beneficiary since we're not mining + Coinbase: common.Address{}, // there's no benefitiary since we're not mining BlockNumber: big.NewInt(ctx.BlockHeight()), Time: big.NewInt(ctx.BlockHeader().Time.Unix()), Difficulty: big.NewInt(0), // unused. Only required in PoW context @@ -106,18 +123,35 @@ func (st StateTransition) newEVM( vmConfig := vm.Config{ ExtraEips: eips, } + + if st.Debug { + vmConfig.Tracer = vm.NewJSONLogger(&vm.LogConfig{ + Debug: true, + }, os.Stderr) + + vmConfig.Debug = true + } + return vm.NewEVM(blockCtx, txCtx, csdb, config.EthereumConfig(st.ChainID), vmConfig) } // TransitionDb will transition the state by applying the current transaction and // returning the evm execution result. // NOTE: State transition checks are run during AnteHandler execution. -func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*ExecutionResult, error) { +func (st *StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (resp *ExecutionResult, err error) { + st.initOnce() + + metrics.ReportFuncCall(st.svcTags) + doneFn := metrics.ReportFuncTiming(st.svcTags) + defer doneFn() + contractCreation := st.Recipient == nil - cost, err := core.IntrinsicGas(st.Payload, contractCreation, config.IsHomestead(), config.IsIstanbul()) + cost, err := core.IntrinsicGas(st.Payload, contractCreation, true, false) if err != nil { - return nil, sdkerrors.Wrap(err, "invalid intrinsic gas for transaction") + metrics.ReportFuncError(st.svcTags) + err = sdkerrors.Wrap(err, "invalid intrinsic gas for transaction") + return nil, err } // This gas limit the the transaction gas limit with intrinsic gas subtracted @@ -149,8 +183,10 @@ func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*Ex params := csdb.GetParams() gasPrice := ctx.MinGasPrices().AmountOf(params.EvmDenom) + //gasPrice := sdk.ZeroDec() if gasPrice.IsNil() { - return nil, errors.New("gas price cannot be nil") + metrics.ReportFuncError(st.svcTags) + return nil, errors.New("min gas price cannot be nil") } evm := st.newEVM(ctx, csdb, gasLimit, gasPrice.BigInt(), config, params.ExtraEIPs) @@ -176,6 +212,24 @@ func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*Ex ret, contractAddress, leftOverGas, err = evm.Create(senderRef, st.Payload, gasLimit, st.Amount) + if err != nil { + log.WithField("simulate?", st.Simulate). + WithField("AccountNonce", st.AccountNonce). + WithField("contract", contractAddress.String()). + WithError(err).Warningln("evm contract creation failed") + } + + gasConsumed := gasLimit - leftOverGas + resp = &ExecutionResult{ + Response: &MsgEthereumTxResponse{ + Ret: ret, + }, + GasInfo: GasInfo{ + GasConsumed: gasConsumed, + GasLimit: gasLimit, + GasRefunded: leftOverGas, + }, + } default: if !params.EnableCall { return nil, ErrCallDisabled @@ -183,15 +237,36 @@ func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*Ex // Increment the nonce for the next transaction (just for evm state transition) csdb.SetNonce(st.Sender, csdb.GetNonce(st.Sender)+1) - ret, leftOverGas, err = evm.Call(senderRef, *st.Recipient, st.Payload, gasLimit, st.Amount) - } - gasConsumed := gasLimit - leftOverGas + ret, leftOverGas, err = evm.Call(senderRef, *st.Recipient, st.Payload, gasLimit, st.Amount) + + // fmt.Println("EVM CALL!!!", senderRef.Address().Hex(), (*st.Recipient).Hex(), gasLimit) + // fmt.Println("EVM CALL RESULT", common.ToHex(ret), leftOverGas, err) + + if err != nil { + log.WithField("recipient", st.Recipient.String()). + WithError(err).Debugln("evm call failed") + } + + gasConsumed := gasLimit - leftOverGas + resp = &ExecutionResult{ + Response: &MsgEthereumTxResponse{ + Ret: ret, + }, + GasInfo: GasInfo{ + GasConsumed: gasConsumed, + GasLimit: gasLimit, + GasRefunded: leftOverGas, + }, + } + } if err != nil { // Consume gas before returning - ctx.GasMeter().ConsumeGas(gasConsumed, "evm execution consumption") - return nil, err + metrics.EVMRevertedTx(st.svcTags) + metrics.EVMGasConsumed(resp.GasInfo.GasConsumed) + ctx.GasMeter().ConsumeGas(resp.GasInfo.GasConsumed, "evm execution consumption") + return resp, err } // Resets nonce to value pre state transition @@ -208,6 +283,8 @@ func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*Ex if st.TxHash != nil && !st.Simulate { logs, err = csdb.GetLogs(*st.TxHash) if err != nil { + metrics.ReportFuncError(st.svcTags) + err = errors.Wrap(err, "failed to get logs") return nil, err } @@ -219,38 +296,70 @@ func (st StateTransition) TransitionDb(ctx sdk.Context, config ChainConfig) (*Ex // Finalise state if not a simulated transaction // TODO: change to depend on config if err := csdb.Finalise(true); err != nil { + metrics.ReportFuncError(st.svcTags) return nil, err } } - res := &MsgEthereumTxResponse{ + resp.Logs = logs + resp.Bloom = bloomInt + resp.Response = &MsgEthereumTxResponse{ Bloom: bloomFilter.Bytes(), TxLogs: NewTransactionLogsFromEth(*st.TxHash, logs), Ret: ret, } if contractCreation { - res.ContractAddress = contractAddress.String() - } - - executionResult := &ExecutionResult{ - Logs: logs, - Bloom: bloomInt, - Response: res, - GasInfo: GasInfo{ - GasConsumed: gasConsumed, - GasLimit: gasLimit, - GasRefunded: leftOverGas, - }, + resp.Response.ContractAddress = contractAddress.String() } // TODO: Refund unused gas here, if intended in future // Consume gas from evm execution // Out of gas check does not need to be done here since it is done within the EVM execution - ctx.WithGasMeter(currentGasMeter).GasMeter().ConsumeGas(gasConsumed, "EVM execution consumption") + metrics.EVMGasConsumed(resp.GasInfo.GasConsumed) + // TODO: @albert, @maxim, decide if can take this out, since InternalEthereumTx may want to continue execution afterwards + // which will use gas. + _ = currentGasMeter + //ctx.WithGasMeter(currentGasMeter).GasMeter().ConsumeGas(resp.GasInfo.GasConsumed, "EVM execution consumption") - return executionResult, nil + return resp, nil +} + +// StaticCall executes the contract associated with the addr with the given input +// as parameters while disallowing any modifications to the state during the call. +// Opcodes that attempt to perform such modifications will result in exceptions +// instead of performing the modifications. +func (st *StateTransition) StaticCall(ctx sdk.Context, config ChainConfig) ([]byte, error) { + st.initOnce() + + // This gas limit the the transaction gas limit with intrinsic gas subtracted + gasLimit := st.GasLimit - ctx.GasMeter().GasConsumed() + csdb := st.Csdb.WithContext(ctx) + + // This gas meter is set up to consume gas from gaskv during evm execution and be ignored + evmGasMeter := sdk.NewInfiniteGasMeter() + csdb.WithContext(ctx.WithGasMeter(evmGasMeter)) + + // Clear cache of accounts to handle changes outside of the EVM + csdb.UpdateAccounts() + + params := csdb.GetParams() + + gasPrice := ctx.MinGasPrices().AmountOf(params.EvmDenom) + if gasPrice.IsNil() { + return []byte{}, errors.New("min gas price cannot be nil") + } + + evm := st.newEVM(ctx, csdb, gasLimit, gasPrice.BigInt(), config, params.ExtraEIPs) + senderRef := vm.AccountRef(st.Sender) + + ret, _, err := evm.StaticCall(senderRef, *st.Recipient, st.Payload, gasLimit) + + // fmt.Println("EVM STATIC CALL!!!", senderRef.Address().Hex(), (*st.Recipient).Hex(), st.Payload, gasLimit) + // fmt.Println("EVM STATIC CALL RESULT", common.ToHex(ret), leftOverGas, err) + + return ret, err } // HashFromContext returns the Ethereum Header hash from the context's Tendermint diff --git a/x/evm/types/state_transition_test.go b/x/evm/types/state_transition_test.go index 905fd6d9..8e8ac92f 100644 --- a/x/evm/types/state_transition_test.go +++ b/x/evm/types/state_transition_test.go @@ -3,127 +3,21 @@ package types_test import ( "math/big" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/tendermint/tendermint/proto/tendermint/version" - tmversion "github.com/tendermint/tendermint/version" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ethermint/crypto/ethsecp256k1" ethermint "github.com/cosmos/ethermint/types" "github.com/cosmos/ethermint/x/evm/types" - "github.com/ethereum/go-ethereum/common" ethcmn "github.com/ethereum/go-ethereum/common" ethcrypto "github.com/ethereum/go-ethereum/crypto" ) -func (suite *StateDBTestSuite) TestGetHashFn() { - testCase := []struct { - name string - height uint64 - malleate func() - expEmptyHash bool - }{ - // { - // "valid hash, case 1", - // 1, - // func() { - // suite.ctx = suite.ctx.WithBlockHeader( - // tmproto.Header{ - // ChainID: "ethermint-1", - // Height: 1, - // ValidatorsHash: []byte("val_hash"), - // Version: version.Consensus{ - // Block: tmversion.BlockProtocol, - // }, - // }, - // ) - // }, - // false, - // }, - { - "case 1, nil tendermint hash", - 1, - func() {}, - true, - }, - // { - // "valid hash, case 2", - // 1, - // func() { - // suite.ctx = suite.ctx.WithBlockHeader( - // tmproto.Header{ - // ChainID: "ethermint-1", - // Height: 100, - // ValidatorsHash: []byte("val_hash"), - // Version: version.Consensus{ - // Block: tmversion.BlockProtocol, - // }, - // }, - // ) - // hash := types.HashFromContext(suite.ctx) - // suite.stateDB.WithContext(suite.ctx).SetHeightHash(1, hash) - // }, - // false, - // }, - { - "height not found, case 2", - 1, - func() { - suite.ctx = suite.ctx.WithBlockHeader( - tmproto.Header{ - ChainID: "ethermint-1", - Height: 100, - ValidatorsHash: []byte("val_hash"), - Version: version.Consensus{ - Block: tmversion.BlockProtocol, - }, - }, - ) - }, - true, - }, - { - "empty hash, case 3", - 1000, - func() { - suite.ctx = suite.ctx.WithBlockHeader( - tmproto.Header{ - ChainID: "ethermint-1", - Height: 100, - ValidatorsHash: []byte("val_hash"), - Version: version.Consensus{ - Block: tmversion.BlockProtocol, - }, - }, - ) - }, - true, - }, - } - - for _, tc := range testCase { - suite.Run(tc.name, func() { - suite.SetupTest() // reset - - tc.malleate() - - hash := types.GetHashFn(suite.ctx, suite.stateDB)(tc.height) - if tc.expEmptyHash { - suite.Require().Equal(common.Hash{}.String(), hash.String()) - } else { - suite.Require().NotEqual(common.Hash{}.String(), hash.String()) - } - }) - } -} - func (suite *StateDBTestSuite) TestTransitionDb() { suite.stateDB.SetNonce(suite.address, 123) addr := sdk.AccAddress(suite.address.Bytes()) - balance := ethermint.NewPhotonCoin(sdk.NewInt(5000)) + balance := ethermint.NewInjectiveCoin(sdk.NewInt(5000)) acc := suite.app.AccountKeeper.GetAccount(suite.ctx, addr) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) suite.app.BankKeeper.SetBalance(suite.ctx, addr, balance) @@ -228,54 +122,11 @@ func (suite *StateDBTestSuite) TestTransitionDb() { }, false, }, - { - "call disabled", - func() { - params := types.NewParams(ethermint.AttoPhoton, true, false) - suite.stateDB.SetParams(params) - }, - types.StateTransition{ - AccountNonce: 123, - Price: big.NewInt(10), - GasLimit: 11, - Recipient: &recipient, - Amount: big.NewInt(50), - Payload: []byte("data"), - ChainID: big.NewInt(1), - Csdb: suite.stateDB, - TxHash: ðcmn.Hash{}, - Sender: suite.address, - Simulate: suite.ctx.IsCheckTx(), - }, - false, - }, - { - "create disabled", - func() { - params := types.NewParams(ethermint.AttoPhoton, false, true) - suite.stateDB.SetParams(params) - }, - types.StateTransition{ - AccountNonce: 123, - Price: big.NewInt(10), - GasLimit: 11, - Recipient: nil, - Amount: big.NewInt(50), - Payload: []byte("data"), - ChainID: big.NewInt(1), - Csdb: suite.stateDB, - TxHash: ðcmn.Hash{}, - Sender: suite.address, - Simulate: suite.ctx.IsCheckTx(), - }, - false, - }, { "nil gas price", func() { - suite.stateDB.SetParams(types.DefaultParams()) invalidGas := sdk.DecCoins{ - {Denom: ethermint.AttoPhoton}, + {Denom: ethermint.InjectiveCoin}, } suite.ctx = suite.ctx.WithMinGasPrices(invalidGas) }, diff --git a/x/evm/types/statedb.go b/x/evm/types/statedb.go index 353cfe8e..66c5e1d9 100644 --- a/x/evm/types/statedb.go +++ b/x/evm/types/statedb.go @@ -122,8 +122,8 @@ func (csdb *CommitStateDB) WithContext(ctx sdk.Context) *CommitStateDB { // SetHeightHash sets the block header hash associated with a given height. func (csdb *CommitStateDB) SetHeightHash(height uint64, hash ethcmn.Hash) { - store := prefix.NewStore(csdb.ctx.KVStore(csdb.storeKey), KeyPrefixHeightHash) - key := HeightHashKey(height) + store := prefix.NewStore(csdb.ctx.KVStore(csdb.storeKey), KeyPrefixBlockHeightHash) + key := KeyBlockHeightHash(height) store.Set(key, hash.Bytes()) } @@ -135,38 +135,49 @@ func (csdb *CommitStateDB) SetParams(params Params) { // SetBalance sets the balance of an account. func (csdb *CommitStateDB) SetBalance(addr ethcmn.Address, amount *big.Int) { so := csdb.GetOrNewStateObject(addr) - so.SetBalance(amount) - + if so != nil { + so.SetBalance(amount) + } } // AddBalance adds amount to the account associated with addr. func (csdb *CommitStateDB) AddBalance(addr ethcmn.Address, amount *big.Int) { so := csdb.GetOrNewStateObject(addr) - so.AddBalance(amount) + if so != nil { + so.AddBalance(amount) + } } // SubBalance subtracts amount from the account associated with addr. func (csdb *CommitStateDB) SubBalance(addr ethcmn.Address, amount *big.Int) { so := csdb.GetOrNewStateObject(addr) - so.SubBalance(amount) + if so != nil { + so.SubBalance(amount) + } } // SetNonce sets the nonce (sequence number) of an account. func (csdb *CommitStateDB) SetNonce(addr ethcmn.Address, nonce uint64) { so := csdb.GetOrNewStateObject(addr) - so.SetNonce(nonce) + if so != nil { + so.SetNonce(nonce) + } } // SetState sets the storage state with a key, value pair for an account. func (csdb *CommitStateDB) SetState(addr ethcmn.Address, key, value ethcmn.Hash) { so := csdb.GetOrNewStateObject(addr) - so.SetState(nil, key, value) + if so != nil { + so.SetState(nil, key, value) + } } // SetCode sets the code for a given account. func (csdb *CommitStateDB) SetCode(addr ethcmn.Address, code []byte) { so := csdb.GetOrNewStateObject(addr) - so.SetCode(ethcrypto.Keccak256Hash(code), code) + if so != nil { + so.SetCode(ethcrypto.Keccak256Hash(code), code) + } } // ---------------------------------------------------------------------------- @@ -289,8 +300,8 @@ func (csdb *CommitStateDB) SlotInAccessList(addr ethcmn.Address, slot ethcmn.Has // GetHeightHash returns the block header hash associated with a given block height and chain epoch number. func (csdb *CommitStateDB) GetHeightHash(height uint64) ethcmn.Hash { - store := prefix.NewStore(csdb.ctx.KVStore(csdb.storeKey), KeyPrefixHeightHash) - key := HeightHashKey(height) + store := prefix.NewStore(csdb.ctx.KVStore(csdb.storeKey), KeyPrefixBlockHeightHash) + key := KeyBlockHeightHash(height) bz := store.Get(key) if len(bz) == 0 { return ethcmn.Hash{} @@ -300,16 +311,8 @@ func (csdb *CommitStateDB) GetHeightHash(height uint64) ethcmn.Hash { } // GetParams returns the total set of evm parameters. -// It will check if every param exists in the Subspace's KVStore before querying by the key, -// the default value of that param will be returned if not exist. func (csdb *CommitStateDB) GetParams() (params Params) { - ps := ¶ms - for _, pair := range ps.ParamSetPairs() { - if csdb.paramSpace.Has(csdb.ctx, pair.Key) { - csdb.paramSpace.Get(csdb.ctx, pair.Key, pair.Value) - } - } - + csdb.paramSpace.GetParamSet(csdb.ctx, ¶ms) return params } @@ -344,10 +347,6 @@ func (csdb *CommitStateDB) BlockHash() ethcmn.Hash { return csdb.bhash } -func (csdb *CommitStateDB) SetBlockHash(hash ethcmn.Hash) { - csdb.bhash = hash -} - // GetCode returns the code for a given account. func (csdb *CommitStateDB) GetCode(addr ethcmn.Address) []byte { so := csdb.getStateObject(addr) @@ -417,7 +416,12 @@ func (csdb *CommitStateDB) GetLogs(hash ethcmn.Hash) ([]*ethtypes.Log, error) { return []*ethtypes.Log{}, err } - return txLogs.EthLogs(), nil + allLogs := []*ethtypes.Log{} + for _, txLog := range txLogs.Logs { + allLogs = append(allLogs, txLog.ToEthereum()) + } + + return allLogs, nil } // AllLogs returns all the current logs in the state. @@ -430,7 +434,10 @@ func (csdb *CommitStateDB) AllLogs() []*ethtypes.Log { for ; iterator.Valid(); iterator.Next() { var txLogs TransactionLogs ModuleCdc.MustUnmarshalBinaryBare(iterator.Value(), &txLogs) - allLogs = append(allLogs, txLogs.EthLogs()...) + + for _, txLog := range txLogs.Logs { + allLogs = append(allLogs, txLog.ToEthereum()) + } } return allLogs @@ -705,7 +712,7 @@ func (csdb *CommitStateDB) UpdateAccounts() { for _, stateEntry := range csdb.stateObjects { address := sdk.AccAddress(stateEntry.address.Bytes()) currAccount := csdb.accountKeeper.GetAccount(csdb.ctx, address) - ethermintAcc, ok := currAccount.(*ethermint.EthAccount) + ethAcc, ok := currAccount.(*ethermint.EthAccount) if !ok { continue } @@ -717,8 +724,8 @@ func (csdb *CommitStateDB) UpdateAccounts() { stateEntry.stateObject.balance = balance.Amount } - if stateEntry.stateObject.Nonce() != ethermintAcc.GetSequence() { - stateEntry.stateObject.account = ethermintAcc + if stateEntry.stateObject.Nonce() != ethAcc.GetSequence() { + stateEntry.stateObject.account = ethAcc } } } @@ -738,8 +745,9 @@ func (csdb *CommitStateDB) clearJournalAndRefund() { // Prepare sets the current transaction hash and index and block hash which is // used when the EVM emits new state logs. -func (csdb *CommitStateDB) Prepare(thash ethcmn.Hash, txi int) { +func (csdb *CommitStateDB) Prepare(thash, bhash ethcmn.Hash, txi int) { csdb.thash = thash + csdb.bhash = bhash csdb.txIndex = txi } @@ -867,7 +875,8 @@ func (csdb *CommitStateDB) ForEachStorage(addr ethcmn.Address, cb func(key, valu return nil } -// GetOrNewStateObject retrieves a state object or create a new state object if nil. +// GetOrNewStateObject retrieves a state object or create a new state object if +// nil. func (csdb *CommitStateDB) GetOrNewStateObject(addr ethcmn.Address) StateObject { so := csdb.getStateObject(addr) if so == nil || so.deleted { diff --git a/x/evm/types/statedb_test.go b/x/evm/types/statedb_test.go index c4bc8520..daa2b106 100644 --- a/x/evm/types/statedb_test.go +++ b/x/evm/types/statedb_test.go @@ -26,7 +26,7 @@ type StateDBTestSuite struct { suite.Suite ctx sdk.Context - app *app.EthermintApp + app *app.InjectiveApp stateDB *types.CommitStateDB address ethcmn.Address stateObject types.StateObject @@ -40,7 +40,7 @@ func (suite *StateDBTestSuite) SetupTest() { checkTx := false suite.app = app.Setup(checkTx) - suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1, ChainID: "ethermint-1"}) + suite.ctx = suite.app.BaseApp.NewContext(checkTx, tmproto.Header{Height: 1}) suite.stateDB = suite.app.EvmKeeper.CommitStateDB.WithContext(suite.ctx) privkey, err := ethsecp256k1.GenerateKey() @@ -48,7 +48,7 @@ func (suite *StateDBTestSuite) SetupTest() { suite.address = ethcmn.BytesToAddress(privkey.PubKey().Address().Bytes()) - balance := ethermint.NewPhotonCoin(sdk.ZeroInt()) + balance := ethermint.NewInjectiveCoin(sdk.ZeroInt()) acc := ðermint.EthAccount{ BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(suite.address.Bytes()), nil, 0, 0), CodeHash: ethcrypto.Keccak256(nil), @@ -64,32 +64,18 @@ func (suite *StateDBTestSuite) SetupTest() { func (suite *StateDBTestSuite) TestParams() { params := suite.stateDB.GetParams() suite.Require().Equal(types.DefaultParams(), params) - params.EvmDenom = "ara" + params.EvmDenom = "inj" suite.stateDB.SetParams(params) newParams := suite.stateDB.GetParams() suite.Require().Equal(newParams, params) } -func (suite *StateDBTestSuite) TestGetHeightHash() { - hash := suite.stateDB.GetHeightHash(0) - suite.Require().Equal(ethcmn.Hash{}.String(), hash.String()) - - expHash := ethcmn.BytesToHash([]byte("hash")) - suite.stateDB.SetHeightHash(10, expHash) - - hash = suite.stateDB.GetHeightHash(10) - suite.Require().Equal(expHash.String(), hash.String()) -} - func (suite *StateDBTestSuite) TestBloomFilter() { // Prepare db for logs tHash := ethcmn.BytesToHash([]byte{0x1}) - suite.stateDB.Prepare(tHash, 0) + suite.stateDB.Prepare(tHash, ethcmn.Hash{}, 0) contractAddress := ethcmn.BigToAddress(big.NewInt(1)) - log := ethtypes.Log{ - Address: contractAddress, - Topics: []ethcmn.Hash{}, - } + log := ethtypes.Log{Address: contractAddress} testCase := []struct { name string @@ -130,8 +116,8 @@ func (suite *StateDBTestSuite) TestBloomFilter() { } } else { // get logs bloom from the log - bloomBytes := ethtypes.LogsBloom(logs) - bloomFilter := ethtypes.BytesToBloom(bloomBytes) + bloomInt := ethtypes.LogsBloom(logs) + bloomFilter := ethtypes.BytesToBloom(bloomInt) suite.Require().True(ethtypes.BloomLookup(bloomFilter, contractAddress), tc.name) suite.Require().False(ethtypes.BloomLookup(bloomFilter, ethcmn.BigToAddress(big.NewInt(2))), tc.name) } @@ -306,7 +292,6 @@ func (suite *StateDBTestSuite) TestStateDB_Logs() { suite.Require().Empty(dbLogs, tc.name) suite.stateDB.AddLog(&tc.log) - tc.log.Index = 0 // reset index suite.Require().Equal(logs, suite.stateDB.AllLogs(), tc.name) //resets state but checking to see if storekey still persists. @@ -433,8 +418,7 @@ func (suite *StateDBTestSuite) TestSuiteDB_Prepare() { bhash := ethcmn.BytesToHash([]byte("bhash")) txi := 1 - suite.stateDB.Prepare(thash, txi) - suite.stateDB.SetBlockHash(bhash) + suite.stateDB.Prepare(thash, bhash, txi) suite.Require().Equal(txi, suite.stateDB.TxIndex()) suite.Require().Equal(bhash, suite.stateDB.BlockHash()) @@ -675,7 +659,7 @@ func (suite *StateDBTestSuite) TestCommitStateDB_ForEachStorage() { name string malleate func() callback func(key, value ethcmn.Hash) (stop bool) - expValues []string + expValues []ethcmn.Hash }{ { "aggregate state", @@ -688,12 +672,12 @@ func (suite *StateDBTestSuite) TestCommitStateDB_ForEachStorage() { storage = append(storage, types.NewState(key, value)) return false }, - []string{ - ethcmn.BytesToHash([]byte("value0")).String(), - ethcmn.BytesToHash([]byte("value1")).String(), - ethcmn.BytesToHash([]byte("value2")).String(), - ethcmn.BytesToHash([]byte("value3")).String(), - ethcmn.BytesToHash([]byte("value4")).String(), + []ethcmn.Hash{ + ethcmn.BytesToHash([]byte("value0")), + ethcmn.BytesToHash([]byte("value1")), + ethcmn.BytesToHash([]byte("value2")), + ethcmn.BytesToHash([]byte("value3")), + ethcmn.BytesToHash([]byte("value4")), }, }, { @@ -709,8 +693,8 @@ func (suite *StateDBTestSuite) TestCommitStateDB_ForEachStorage() { } return false }, - []string{ - ethcmn.BytesToHash([]byte("filtervalue")).String(), + []ethcmn.Hash{ + ethcmn.BytesToHash([]byte("filtervalue")), }, }, } diff --git a/x/evm/types/storage.go b/x/evm/types/storage.go index 77b96fcf..dc48fa40 100644 --- a/x/evm/types/storage.go +++ b/x/evm/types/storage.go @@ -1,12 +1,11 @@ package types import ( + "bytes" "fmt" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - ethermint "github.com/cosmos/ethermint/types" - ethcmn "github.com/ethereum/go-ethereum/common" ) @@ -51,7 +50,7 @@ func (s Storage) Copy() Storage { // Validate performs a basic validation of the State fields. func (s State) Validate() error { - if ethermint.IsEmptyHash(s.Key) { + if bytes.Equal(ethcmn.Hex2Bytes(s.Key), ethcmn.Hash{}.Bytes()) { return sdkerrors.Wrap(ErrInvalidState, "state key hash cannot be empty") } // NOTE: state value can be empty diff --git a/x/evm/types/storage_test.go b/x/evm/types/storage_test.go index 6e661c32..14d7ce84 100644 --- a/x/evm/types/storage_test.go +++ b/x/evm/types/storage_test.go @@ -80,7 +80,6 @@ func TestStorageCopy(t *testing.T) { func TestStorageString(t *testing.T) { storage := Storage{NewState(ethcmn.BytesToHash([]byte("key")), ethcmn.BytesToHash([]byte("value")))} - str := `key:"0x00000000000000000000000000000000000000000000000000000000006b6579" value:"0x00000000000000000000000000000000000000000000000000000076616c7565" -` + str := "key:\"0x00000000000000000000000000000000000000000000000000000000006b6579\" value:\"0x00000000000000000000000000000000000000000000000000000076616c7565\"\n" require.Equal(t, str, storage.String()) } diff --git a/x/evm/types/tx.pb.go b/x/evm/types/tx.pb.go index 10ea0ca5..7aca83fe 100644 --- a/x/evm/types/tx.pb.go +++ b/x/evm/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: ethermint/evm/v1alpha1/tx.proto +// source: injective/evm/v1beta1/tx.proto package types @@ -7,7 +7,6 @@ import ( context "context" encoding_binary "encoding/binary" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -42,7 +41,7 @@ func (m *MsgEthereumTx) Reset() { *m = MsgEthereumTx{} } func (m *MsgEthereumTx) String() string { return proto.CompactTextString(m) } func (*MsgEthereumTx) ProtoMessage() {} func (*MsgEthereumTx) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{0} + return fileDescriptor_9fd15a427dc5b31e, []int{0} } func (m *MsgEthereumTx) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -71,6 +70,78 @@ func (m *MsgEthereumTx) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEthereumTx proto.InternalMessageInfo +type ExtensionOptionsEthereumTx struct { +} + +func (m *ExtensionOptionsEthereumTx) Reset() { *m = ExtensionOptionsEthereumTx{} } +func (m *ExtensionOptionsEthereumTx) String() string { return proto.CompactTextString(m) } +func (*ExtensionOptionsEthereumTx) ProtoMessage() {} +func (*ExtensionOptionsEthereumTx) Descriptor() ([]byte, []int) { + return fileDescriptor_9fd15a427dc5b31e, []int{1} +} +func (m *ExtensionOptionsEthereumTx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExtensionOptionsEthereumTx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExtensionOptionsEthereumTx.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 *ExtensionOptionsEthereumTx) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExtensionOptionsEthereumTx.Merge(m, src) +} +func (m *ExtensionOptionsEthereumTx) XXX_Size() int { + return m.Size() +} +func (m *ExtensionOptionsEthereumTx) XXX_DiscardUnknown() { + xxx_messageInfo_ExtensionOptionsEthereumTx.DiscardUnknown(m) +} + +var xxx_messageInfo_ExtensionOptionsEthereumTx proto.InternalMessageInfo + +type ExtensionOptionsWeb3Tx struct { +} + +func (m *ExtensionOptionsWeb3Tx) Reset() { *m = ExtensionOptionsWeb3Tx{} } +func (m *ExtensionOptionsWeb3Tx) String() string { return proto.CompactTextString(m) } +func (*ExtensionOptionsWeb3Tx) ProtoMessage() {} +func (*ExtensionOptionsWeb3Tx) Descriptor() ([]byte, []int) { + return fileDescriptor_9fd15a427dc5b31e, []int{2} +} +func (m *ExtensionOptionsWeb3Tx) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ExtensionOptionsWeb3Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ExtensionOptionsWeb3Tx.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 *ExtensionOptionsWeb3Tx) XXX_Merge(src proto.Message) { + xxx_messageInfo_ExtensionOptionsWeb3Tx.Merge(m, src) +} +func (m *ExtensionOptionsWeb3Tx) XXX_Size() int { + return m.Size() +} +func (m *ExtensionOptionsWeb3Tx) XXX_DiscardUnknown() { + xxx_messageInfo_ExtensionOptionsWeb3Tx.DiscardUnknown(m) +} + +var xxx_messageInfo_ExtensionOptionsWeb3Tx proto.InternalMessageInfo + // MsgEthereumTxResponse defines the Msg/EthereumTx response type. type MsgEthereumTxResponse struct { // contract_address contains the ethereum address of the created contract (if @@ -84,13 +155,15 @@ type MsgEthereumTxResponse struct { TxLogs TransactionLogs `protobuf:"bytes,3,opt,name=tx_logs,json=txLogs,proto3" json:"tx_logs" yaml:"tx_logs"` // ret defines the bytes from the execution. Ret []byte `protobuf:"bytes,4,opt,name=ret,proto3" json:"ret,omitempty"` + // reverted flag is set to true when the call has been reverted + Reverted bool `protobuf:"varint,5,opt,name=reverted,proto3" json:"reverted,omitempty"` } func (m *MsgEthereumTxResponse) Reset() { *m = MsgEthereumTxResponse{} } func (m *MsgEthereumTxResponse) String() string { return proto.CompactTextString(m) } func (*MsgEthereumTxResponse) ProtoMessage() {} func (*MsgEthereumTxResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{1} + return fileDescriptor_9fd15a427dc5b31e, []int{3} } func (m *MsgEthereumTxResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -119,115 +192,18 @@ func (m *MsgEthereumTxResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEthereumTxResponse proto.InternalMessageInfo -// TxData implements the Ethereum transaction data structure. It is used -// solely as intended in Ethereum abiding by the protocol. -type TxData struct { - // nonce corresponds to the account nonce (transaction sequence). - AccountNonce uint64 `protobuf:"varint,1,opt,name=nonce,proto3" json:"nonce,omitempty"` - // price defines the unsigned integer value of the gas price in bytes. - Price github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=price,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"gasPrice"` - // gas defines the gas limit defined for the transaction. - GasLimit uint64 `protobuf:"varint,3,opt,name=gas,proto3" json:"gas,omitempty"` - Recipient *Recipient `protobuf:"bytes,4,opt,name=to,proto3" json:"to,omitempty" rlp:"nil"` - // value defines the unsigned integer value of the transaction amount. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"value"` - // input defines the data payload bytes of the transaction. - Payload []byte `protobuf:"bytes,6,opt,name=input,proto3" json:"input,omitempty"` - // v defines the signature value - V []byte `protobuf:"bytes,7,opt,name=v,proto3" json:"v,omitempty"` - // r defines the signature value - R []byte `protobuf:"bytes,8,opt,name=r,proto3" json:"r,omitempty"` - // s define the signature value - S []byte `protobuf:"bytes,9,opt,name=s,proto3" json:"s,omitempty"` - // hash defines the tx data hash, which is only used when marshaling to JSON. - Hash string `protobuf:"bytes,10,opt,name=hash,proto3" json:"hash,omitempty" rlp:"-"` -} - -func (m *TxData) Reset() { *m = TxData{} } -func (m *TxData) String() string { return proto.CompactTextString(m) } -func (*TxData) ProtoMessage() {} -func (*TxData) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{2} -} -func (m *TxData) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TxData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TxData.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 *TxData) XXX_Merge(src proto.Message) { - xxx_messageInfo_TxData.Merge(m, src) -} -func (m *TxData) XXX_Size() int { - return m.Size() -} -func (m *TxData) XXX_DiscardUnknown() { - xxx_messageInfo_TxData.DiscardUnknown(m) -} - -var xxx_messageInfo_TxData proto.InternalMessageInfo - -// Recipient defines a protobuf-compatible wrapper for an Ethereum address -// pointer. It is required for RLP encoding. -type Recipient struct { - // address defines the hex-formated ethereum address of the recipient - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` -} - -func (m *Recipient) Reset() { *m = Recipient{} } -func (m *Recipient) String() string { return proto.CompactTextString(m) } -func (*Recipient) ProtoMessage() {} -func (*Recipient) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{3} -} -func (m *Recipient) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Recipient) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Recipient.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 *Recipient) XXX_Merge(src proto.Message) { - xxx_messageInfo_Recipient.Merge(m, src) -} -func (m *Recipient) XXX_Size() int { - return m.Size() -} -func (m *Recipient) XXX_DiscardUnknown() { - xxx_messageInfo_Recipient.DiscardUnknown(m) -} - -var xxx_messageInfo_Recipient proto.InternalMessageInfo - // SigCache is used to cache the derived sender and contains the signer used // to derive it. type SigCache struct { Signer *EIP155Signer `protobuf:"bytes,1,opt,name=signer,proto3" json:"signer,omitempty"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Address []byte `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` } func (m *SigCache) Reset() { *m = SigCache{} } func (m *SigCache) String() string { return proto.CompactTextString(m) } func (*SigCache) ProtoMessage() {} func (*SigCache) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{4} + return fileDescriptor_9fd15a427dc5b31e, []int{4} } func (m *SigCache) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -266,7 +242,7 @@ func (m *EIP155Signer) Reset() { *m = EIP155Signer{} } func (m *EIP155Signer) String() string { return proto.CompactTextString(m) } func (*EIP155Signer) ProtoMessage() {} func (*EIP155Signer) Descriptor() ([]byte, []int) { - return fileDescriptor_6a305e80b084ab0e, []int{5} + return fileDescriptor_9fd15a427dc5b31e, []int{5} } func (m *EIP155Signer) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -296,65 +272,54 @@ func (m *EIP155Signer) XXX_DiscardUnknown() { var xxx_messageInfo_EIP155Signer proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgEthereumTx)(nil), "ethermint.evm.v1alpha1.MsgEthereumTx") - proto.RegisterType((*MsgEthereumTxResponse)(nil), "ethermint.evm.v1alpha1.MsgEthereumTxResponse") - proto.RegisterType((*TxData)(nil), "ethermint.evm.v1alpha1.TxData") - proto.RegisterType((*Recipient)(nil), "ethermint.evm.v1alpha1.Recipient") - proto.RegisterType((*SigCache)(nil), "ethermint.evm.v1alpha1.SigCache") - proto.RegisterType((*EIP155Signer)(nil), "ethermint.evm.v1alpha1.EIP155Signer") + proto.RegisterType((*MsgEthereumTx)(nil), "injective.evm.v1beta1.MsgEthereumTx") + proto.RegisterType((*ExtensionOptionsEthereumTx)(nil), "injective.evm.v1beta1.ExtensionOptionsEthereumTx") + proto.RegisterType((*ExtensionOptionsWeb3Tx)(nil), "injective.evm.v1beta1.ExtensionOptionsWeb3Tx") + proto.RegisterType((*MsgEthereumTxResponse)(nil), "injective.evm.v1beta1.MsgEthereumTxResponse") + proto.RegisterType((*SigCache)(nil), "injective.evm.v1beta1.SigCache") + proto.RegisterType((*EIP155Signer)(nil), "injective.evm.v1beta1.EIP155Signer") } -func init() { proto.RegisterFile("ethermint/evm/v1alpha1/tx.proto", fileDescriptor_6a305e80b084ab0e) } +func init() { proto.RegisterFile("injective/evm/v1beta1/tx.proto", fileDescriptor_9fd15a427dc5b31e) } -var fileDescriptor_6a305e80b084ab0e = []byte{ - // 747 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x6e, 0xeb, 0x44, - 0x14, 0x8e, 0x13, 0xe7, 0x6f, 0x12, 0x2e, 0xd5, 0xe8, 0x72, 0x31, 0x41, 0xf2, 0xe4, 0x5a, 0xd0, - 0x5b, 0x09, 0x25, 0xa1, 0x41, 0x95, 0x50, 0x60, 0x13, 0x43, 0x41, 0x95, 0x9a, 0x2a, 0x9a, 0x76, - 0x81, 0xd8, 0x44, 0x13, 0x67, 0xb0, 0x47, 0xd8, 0x1e, 0xcb, 0x33, 0x89, 0x52, 0x9e, 0x80, 0x25, - 0x8f, 0x00, 0x0f, 0xc1, 0x3b, 0x74, 0xd9, 0x25, 0x62, 0x61, 0x21, 0x77, 0x81, 0xd4, 0x65, 0x9e, - 0x00, 0x79, 0xec, 0xb4, 0x29, 0x34, 0x12, 0x77, 0xe5, 0x39, 0xe7, 0x7c, 0xe7, 0xe7, 0xfb, 0x3c, - 0x73, 0x00, 0xa2, 0xd2, 0xa3, 0x71, 0xc0, 0x42, 0x39, 0xa0, 0xab, 0x60, 0xb0, 0x3a, 0x26, 0x7e, - 0xe4, 0x91, 0xe3, 0x81, 0x5c, 0xf7, 0xa3, 0x98, 0x4b, 0x0e, 0x5f, 0x3d, 0x00, 0xfa, 0x74, 0x15, - 0xf4, 0xb7, 0x80, 0xce, 0x4b, 0x97, 0xbb, 0x5c, 0x41, 0x06, 0xd9, 0x29, 0x47, 0x77, 0xba, 0x7b, - 0xca, 0x65, 0xa9, 0x0a, 0x61, 0xfd, 0xa6, 0x81, 0x77, 0x26, 0xc2, 0x3d, 0xcd, 0x70, 0x74, 0x19, - 0x5c, 0xad, 0xe1, 0x10, 0xe8, 0x0b, 0x22, 0x89, 0xa1, 0x75, 0xb5, 0xa3, 0xd6, 0xd0, 0xec, 0x3f, - 0xdf, 0xb0, 0x7f, 0xb5, 0xfe, 0x9a, 0x48, 0x82, 0x15, 0x16, 0x7e, 0x00, 0x74, 0xc1, 0x7e, 0xa2, - 0x46, 0xb9, 0xab, 0x1d, 0x69, 0x76, 0xf5, 0x3e, 0x41, 0x5a, 0x0f, 0x2b, 0x17, 0xfc, 0x02, 0xe8, - 0x3f, 0xc4, 0x3c, 0x30, 0x2a, 0xaa, 0x5c, 0x77, 0x5f, 0xb9, 0x4b, 0xe6, 0x7e, 0x45, 0x1c, 0x8f, - 0x3e, 0x24, 0x67, 0x49, 0x23, 0xfd, 0xe7, 0x5f, 0x51, 0xc9, 0xfa, 0x5b, 0x03, 0xef, 0x3d, 0x99, - 0x11, 0x53, 0x11, 0xf1, 0x50, 0x50, 0xf8, 0x0d, 0x38, 0x70, 0x78, 0x28, 0x63, 0xe2, 0xc8, 0x19, - 0x59, 0x2c, 0x62, 0x2a, 0x84, 0x9a, 0xbb, 0x69, 0x7f, 0xb8, 0x49, 0xd0, 0xfb, 0xd7, 0x24, 0xf0, - 0x47, 0xd6, 0xbf, 0x11, 0x16, 0x7e, 0x77, 0xeb, 0x1a, 0xe7, 0x1e, 0xf8, 0x12, 0x54, 0xe7, 0x3e, - 0xe7, 0x81, 0x22, 0xd0, 0xc6, 0xb9, 0x01, 0xbf, 0x03, 0x75, 0xb9, 0x9e, 0xf9, 0xdc, 0x15, 0xc5, - 0xf4, 0x6f, 0xf6, 0x8a, 0x11, 0x93, 0x50, 0x10, 0x47, 0x32, 0x1e, 0x9e, 0x73, 0x57, 0xd8, 0xaf, - 0x6e, 0x12, 0x54, 0xda, 0x24, 0xe8, 0x45, 0x3e, 0x41, 0x51, 0xc5, 0xc2, 0x35, 0xb9, 0xce, 0xe2, - 0xf0, 0x00, 0x54, 0x62, 0x2a, 0x0d, 0x5d, 0x75, 0xcb, 0x8e, 0x05, 0xd3, 0xdf, 0x2b, 0xa0, 0x96, - 0x0b, 0x0b, 0x0f, 0x41, 0x35, 0xe4, 0xa1, 0x43, 0x15, 0x1f, 0xdd, 0x3e, 0x48, 0x13, 0xd4, 0x1e, - 0x3b, 0x0e, 0x5f, 0x86, 0xf2, 0x22, 0xf3, 0xe3, 0x3c, 0x0c, 0xa7, 0xa0, 0x1a, 0xc5, 0xcc, 0xc9, - 0xb5, 0x6f, 0xda, 0xa3, 0xac, 0xf3, 0x9f, 0x09, 0x3a, 0x74, 0x99, 0xf4, 0x96, 0xf3, 0xbe, 0xc3, - 0x83, 0x81, 0xc3, 0x45, 0xc0, 0x45, 0xf1, 0xe9, 0x89, 0xc5, 0x8f, 0x03, 0x79, 0x1d, 0x51, 0xd1, - 0x3f, 0x0b, 0xe5, 0x7d, 0x82, 0x1a, 0x2e, 0x11, 0xd3, 0xac, 0x02, 0xce, 0x0b, 0x41, 0x13, 0x54, - 0x5c, 0x92, 0x53, 0xd6, 0xed, 0x76, 0x9a, 0xa0, 0xc6, 0xb7, 0x44, 0x9c, 0xb3, 0x80, 0x49, 0x9c, - 0x05, 0xe0, 0x04, 0x94, 0x25, 0x57, 0xb3, 0xb7, 0x86, 0xaf, 0xf7, 0x29, 0x82, 0xa9, 0xc3, 0x22, - 0x46, 0x43, 0x69, 0x77, 0xd2, 0x04, 0x35, 0x1f, 0xcc, 0x4d, 0x82, 0x9a, 0xb1, 0x1f, 0x8d, 0xac, - 0x90, 0xf9, 0x16, 0x2e, 0x4b, 0x0e, 0x2f, 0x40, 0x75, 0x45, 0xfc, 0x25, 0x35, 0xaa, 0x8a, 0xc0, - 0xe7, 0x6f, 0x47, 0x20, 0x4d, 0x50, 0x6d, 0x1c, 0x64, 0xaa, 0xe0, 0xbc, 0x0c, 0x7c, 0x0d, 0xaa, - 0x2c, 0x8c, 0x96, 0xd2, 0xa8, 0x65, 0xea, 0xda, 0xad, 0x34, 0x41, 0xf5, 0x29, 0xb9, 0xf6, 0x39, - 0x59, 0xe0, 0x3c, 0x02, 0xdb, 0x40, 0x5b, 0x19, 0x75, 0x25, 0xbe, 0xb6, 0xca, 0xac, 0xd8, 0x68, - 0xe4, 0x56, 0x9c, 0x59, 0xc2, 0x68, 0xe6, 0x96, 0x80, 0x08, 0xe8, 0x1e, 0x11, 0x9e, 0x01, 0xd4, - 0x6c, 0xad, 0x4d, 0x82, 0xea, 0x6a, 0xfa, 0x9e, 0x85, 0x55, 0xa0, 0xf8, 0x6f, 0x9f, 0x80, 0x47, - 0x86, 0xd0, 0x00, 0xf5, 0x27, 0x77, 0x11, 0x6f, 0xcd, 0x02, 0xec, 0x81, 0xc6, 0xf6, 0xb6, 0xc3, - 0x2f, 0x41, 0x4d, 0x30, 0x37, 0xa4, 0x71, 0xf1, 0xdc, 0x3e, 0xda, 0xa7, 0xe7, 0xe9, 0xd9, 0xf4, - 0xf8, 0xe4, 0xe4, 0x52, 0x61, 0x71, 0x91, 0xb3, 0xdb, 0xa9, 0xfc, 0x5c, 0xa7, 0x10, 0xb4, 0x77, - 0xf3, 0xe0, 0x21, 0x68, 0x38, 0x1e, 0x61, 0xe1, 0x8c, 0x2d, 0x54, 0xbf, 0x42, 0x1d, 0xe5, 0x3b, - 0x5b, 0xe0, 0xed, 0x01, 0x7e, 0x0a, 0xda, 0x5b, 0xdc, 0x2c, 0x58, 0xfa, 0xf9, 0xab, 0xb0, 0x5f, - 0xa4, 0x09, 0x02, 0x05, 0x64, 0xb2, 0xf4, 0xf1, 0xce, 0x39, 0xef, 0x37, 0x64, 0xa0, 0x32, 0x11, - 0x2e, 0x9c, 0x03, 0xb0, 0xb3, 0x4f, 0x3e, 0xde, 0x47, 0xe9, 0xc9, 0x93, 0xee, 0xf4, 0xfe, 0x17, - 0x6c, 0xfb, 0xf2, 0xed, 0xf1, 0x4d, 0x6a, 0x6a, 0xb7, 0xa9, 0xa9, 0xfd, 0x95, 0x9a, 0xda, 0x2f, - 0x77, 0x66, 0xe9, 0xf6, 0xce, 0x2c, 0xfd, 0x71, 0x67, 0x96, 0xbe, 0x7f, 0xf3, 0xdf, 0x8b, 0xf3, - 0xb8, 0x05, 0xd7, 0x6a, 0x0f, 0xaa, 0xdb, 0x33, 0xaf, 0xa9, 0x0d, 0xf8, 0xd9, 0x3f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xda, 0xb8, 0x27, 0x6a, 0x74, 0x05, 0x00, 0x00, +var fileDescriptor_9fd15a427dc5b31e = []byte{ + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0xdb, 0xb4, 0x0d, 0xd3, 0x50, 0xaa, 0x55, 0x5b, 0x4c, 0x10, 0x76, 0x64, 0x50, 0x95, + 0x03, 0xb5, 0x49, 0xab, 0x5e, 0xc2, 0x09, 0x43, 0x90, 0x22, 0x35, 0x02, 0xb9, 0x95, 0x2a, 0x71, + 0x09, 0x6b, 0x7b, 0x71, 0x8c, 0x6c, 0x6f, 0xe4, 0xdd, 0x44, 0x2e, 0x47, 0x4e, 0x1c, 0x79, 0x03, + 0x78, 0x9c, 0x1e, 0x7b, 0xe4, 0x64, 0xa1, 0xe4, 0xc6, 0xb1, 0x4f, 0x80, 0xbc, 0xb6, 0x43, 0x5a, + 0x35, 0x12, 0xb7, 0xf9, 0xf9, 0xe6, 0x9b, 0x99, 0x6f, 0x67, 0x41, 0xf1, 0xa3, 0xcf, 0xc4, 0xe1, + 0xfe, 0x84, 0x18, 0x64, 0x12, 0x1a, 0x93, 0xb6, 0x4d, 0x38, 0x6e, 0x1b, 0x3c, 0xd1, 0x47, 0x31, + 0xe5, 0x14, 0xed, 0xce, 0xf3, 0x3a, 0x99, 0x84, 0x7a, 0x91, 0x6f, 0xec, 0x78, 0xd4, 0xa3, 0x02, + 0x61, 0x64, 0x56, 0x0e, 0x6e, 0xa8, 0x77, 0x93, 0x65, 0x85, 0x02, 0xa0, 0xfd, 0x90, 0xe0, 0x7e, + 0x9f, 0x79, 0x5d, 0x3e, 0x24, 0x31, 0x19, 0x87, 0x67, 0x09, 0x6a, 0x43, 0xd5, 0xc5, 0x1c, 0xcb, + 0x52, 0x53, 0x6a, 0x6d, 0x1e, 0x3e, 0xd1, 0xef, 0x6c, 0xa7, 0x9f, 0x25, 0x6f, 0x30, 0xc7, 0x96, + 0x80, 0xa2, 0x47, 0x50, 0x65, 0xfe, 0x17, 0x22, 0xaf, 0x34, 0xa5, 0x96, 0x64, 0xae, 0xfd, 0x49, + 0x55, 0xe9, 0xc0, 0x12, 0x21, 0xd4, 0x81, 0xea, 0xa7, 0x98, 0x86, 0xf2, 0xaa, 0x60, 0x53, 0x97, + 0xb0, 0x9d, 0xfa, 0xde, 0x6b, 0xec, 0x0c, 0xc9, 0xbc, 0x36, 0xab, 0xe9, 0x54, 0xbf, 0xfd, 0x54, + 0x2b, 0x9a, 0x06, 0x8d, 0x6e, 0xc2, 0x49, 0xc4, 0x7c, 0x1a, 0xbd, 0x1b, 0x71, 0x9f, 0x46, 0xec, + 0xdf, 0xb4, 0x05, 0x46, 0x81, 0xbd, 0xdb, 0x98, 0x73, 0x62, 0x1f, 0xcd, 0xf3, 0x5f, 0x57, 0x60, + 0xf7, 0xc6, 0x96, 0x16, 0x61, 0x23, 0x1a, 0x31, 0x82, 0xde, 0xc2, 0xb6, 0x43, 0x23, 0x1e, 0x63, + 0x87, 0x0f, 0xb0, 0xeb, 0xc6, 0x84, 0x31, 0xb1, 0xf9, 0x3d, 0xf3, 0xf1, 0x75, 0xaa, 0x3e, 0xbc, + 0xc0, 0x61, 0xd0, 0xd1, 0x6e, 0x23, 0x34, 0xeb, 0x41, 0x19, 0x7a, 0x95, 0x47, 0xd0, 0x0e, 0xac, + 0xd9, 0x01, 0xa5, 0xa1, 0xd0, 0xa0, 0x6e, 0xe5, 0x0e, 0x3a, 0x87, 0x0d, 0x9e, 0x0c, 0x02, 0xea, + 0xb1, 0x42, 0x80, 0xfd, 0x65, 0x72, 0xc6, 0x38, 0x62, 0xd8, 0xc9, 0x26, 0x3f, 0xa1, 0x1e, 0x33, + 0xf7, 0x2e, 0x53, 0xb5, 0x72, 0x9d, 0xaa, 0x5b, 0xf9, 0x00, 0x05, 0x89, 0x66, 0xad, 0xf3, 0x24, + 0xcb, 0xa3, 0x6d, 0x58, 0x8d, 0x09, 0x97, 0xab, 0xa2, 0x59, 0x66, 0xa2, 0x06, 0xd4, 0x62, 0x32, + 0x21, 0x31, 0x27, 0xae, 0xbc, 0xd6, 0x94, 0x5a, 0x35, 0x6b, 0xee, 0x17, 0x22, 0x78, 0x50, 0x2b, + 0x75, 0x46, 0x2f, 0x61, 0x9d, 0xf9, 0x5e, 0x44, 0xe2, 0xe2, 0x99, 0x9f, 0x2e, 0x99, 0xab, 0xdb, + 0x7b, 0xdf, 0x3e, 0x3e, 0x3e, 0x15, 0x50, 0xab, 0x28, 0x41, 0x32, 0x6c, 0x94, 0x52, 0xe5, 0xdb, + 0x96, 0x6e, 0xd1, 0x28, 0x82, 0xfa, 0x62, 0x1d, 0xda, 0x87, 0x9a, 0x33, 0xc4, 0x7e, 0x34, 0xf0, + 0x5d, 0xd1, 0xae, 0x6e, 0x6e, 0x4e, 0x53, 0x75, 0x43, 0xc4, 0x7a, 0xae, 0x55, 0x1a, 0xe8, 0x05, + 0xd4, 0x4b, 0xdc, 0x20, 0x1c, 0x07, 0x39, 0xb9, 0xb9, 0x35, 0x4d, 0x55, 0x28, 0x20, 0xfd, 0x71, + 0x60, 0x2d, 0xd8, 0x79, 0xbf, 0x43, 0x0f, 0x56, 0xfb, 0xcc, 0x43, 0x1f, 0x01, 0x16, 0xce, 0xf8, + 0xd9, 0x92, 0x8d, 0x6e, 0x9c, 0x41, 0xe3, 0xf9, 0xff, 0xa0, 0xca, 0x63, 0x31, 0x9d, 0xcb, 0xa9, + 0x22, 0x5d, 0x4d, 0x15, 0xe9, 0xf7, 0x54, 0x91, 0xbe, 0xcf, 0x94, 0xca, 0xd5, 0x4c, 0xa9, 0xfc, + 0x9a, 0x29, 0x95, 0x0f, 0x3d, 0xcf, 0xe7, 0xc3, 0xb1, 0xad, 0x3b, 0x34, 0x34, 0x7a, 0x25, 0xe3, + 0x09, 0xb6, 0x99, 0x31, 0xe7, 0x3f, 0x70, 0x68, 0x4c, 0x16, 0xdd, 0x6c, 0x0d, 0x23, 0xa4, 0xee, + 0x38, 0x20, 0x4c, 0xfc, 0x4e, 0x7e, 0x31, 0x22, 0xcc, 0x5e, 0x17, 0x1f, 0xf3, 0xe8, 0x6f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0xb3, 0xb6, 0x79, 0x34, 0x08, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -383,7 +348,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) EthereumTx(ctx context.Context, in *MsgEthereumTx, opts ...grpc.CallOption) (*MsgEthereumTxResponse, error) { out := new(MsgEthereumTxResponse) - err := c.cc.Invoke(ctx, "/ethermint.evm.v1alpha1.Msg/EthereumTx", in, out, opts...) + err := c.cc.Invoke(ctx, "/injective.evm.v1beta1.Msg/EthereumTx", in, out, opts...) if err != nil { return nil, err } @@ -418,7 +383,7 @@ func _Msg_EthereumTx_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ethermint.evm.v1alpha1.Msg/EthereumTx", + FullMethod: "/injective.evm.v1beta1.Msg/EthereumTx", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).EthereumTx(ctx, req.(*MsgEthereumTx)) @@ -427,7 +392,7 @@ func _Msg_EthereumTx_Handler(srv interface{}, ctx context.Context, dec func(inte } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "ethermint.evm.v1alpha1.Msg", + ServiceName: "injective.evm.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -436,7 +401,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "ethermint/evm/v1alpha1/tx.proto", + Metadata: "injective/evm/v1beta1/tx.proto", } func (m *MsgEthereumTx) Marshal() (dAtA []byte, err error) { @@ -492,6 +457,52 @@ func (m *MsgEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ExtensionOptionsEthereumTx) 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 *ExtensionOptionsEthereumTx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExtensionOptionsEthereumTx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ExtensionOptionsWeb3Tx) 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 *ExtensionOptionsWeb3Tx) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExtensionOptionsWeb3Tx) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgEthereumTxResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -512,6 +523,16 @@ func (m *MsgEthereumTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Reverted { + i-- + if m.Reverted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } if len(m.Ret) > 0 { i -= len(m.Ret) copy(dAtA[i:], m.Ret) @@ -546,136 +567,6 @@ func (m *MsgEthereumTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *TxData) 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 *TxData) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TxData) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintTx(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x52 - } - if len(m.S) > 0 { - i -= len(m.S) - copy(dAtA[i:], m.S) - i = encodeVarintTx(dAtA, i, uint64(len(m.S))) - i-- - dAtA[i] = 0x4a - } - if len(m.R) > 0 { - i -= len(m.R) - copy(dAtA[i:], m.R) - i = encodeVarintTx(dAtA, i, uint64(len(m.R))) - i-- - dAtA[i] = 0x42 - } - if len(m.V) > 0 { - i -= len(m.V) - copy(dAtA[i:], m.V) - i = encodeVarintTx(dAtA, i, uint64(len(m.V))) - i-- - dAtA[i] = 0x3a - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintTx(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0x32 - } - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.Recipient != nil { - { - size, err := m.Recipient.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.GasLimit != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.GasLimit)) - i-- - dAtA[i] = 0x18 - } - { - size := m.Price.Size() - i -= size - if _, err := m.Price.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.AccountNonce != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.AccountNonce)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Recipient) 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 *Recipient) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Recipient) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *SigCache) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -786,6 +677,24 @@ func (m *MsgEthereumTx) Size() (n int) { return n } +func (m *ExtensionOptionsEthereumTx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ExtensionOptionsWeb3Tx) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgEthereumTxResponse) Size() (n int) { if m == nil { return 0 @@ -806,61 +715,8 @@ func (m *MsgEthereumTxResponse) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} - -func (m *TxData) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AccountNonce != 0 { - n += 1 + sovTx(uint64(m.AccountNonce)) - } - l = m.Price.Size() - n += 1 + l + sovTx(uint64(l)) - if m.GasLimit != 0 { - n += 1 + sovTx(uint64(m.GasLimit)) - } - if m.Recipient != nil { - l = m.Recipient.Size() - n += 1 + l + sovTx(uint64(l)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.V) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.R) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.S) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *Recipient) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if m.Reverted { + n += 2 } return n } @@ -1023,10 +879,107 @@ func (m *MsgEthereumTx) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - if (iNdEx + skippy) < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExtensionOptionsEthereumTx) 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 ErrIntOverflowTx + } + 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: ExtensionOptionsEthereumTx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExtensionOptionsEthereumTx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ExtensionOptionsWeb3Tx) 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 ErrIntOverflowTx + } + 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: ExtensionOptionsWeb3Tx: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ExtensionOptionsWeb3Tx: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1203,172 +1156,11 @@ func (m *MsgEthereumTxResponse) Unmarshal(dAtA []byte) error { m.Ret = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TxData) 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 ErrIntOverflowTx - } - 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: TxData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TxData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountNonce", wireType) - } - m.AccountNonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AccountNonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Price", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Price.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) - } - m.GasLimit = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.GasLimit |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Recipient", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Recipient == nil { - m.Recipient = &Recipient{} - } - if err := m.Recipient.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Reverted", wireType) } - var stringLen uint64 + var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1378,289 +1170,19 @@ func (m *TxData) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + v |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field V", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.V = append(m.V[:0], dAtA[iNdEx:postIndex]...) - if m.V == nil { - m.V = []byte{} - } - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field R", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.R = append(m.R[:0], dAtA[iNdEx:postIndex]...) - if m.R == nil { - m.R = []byte{} - } - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field S", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.S = append(m.S[:0], dAtA[iNdEx:postIndex]...) - if m.S == nil { - m.S = []byte{} - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex + m.Reverted = bool(v != 0) default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Recipient) 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 ErrIntOverflowTx - } - 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: Recipient: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Recipient: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1744,7 +1266,7 @@ func (m *SigCache) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1754,23 +1276,25 @@ func (m *SigCache) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.Address = string(dAtA[iNdEx:postIndex]) + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -1778,10 +1302,7 @@ func (m *SigCache) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1899,10 +1420,7 @@ func (m *EIP155Signer) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/x/evm/types/utils.go b/x/evm/types/utils.go index acc50db2..8d7061f7 100644 --- a/x/evm/types/utils.go +++ b/x/evm/types/utils.go @@ -5,10 +5,13 @@ import ( "fmt" "math/big" + log "github.com/xlab/suplog" + "github.com/gogo/protobuf/proto" "github.com/pkg/errors" "golang.org/x/crypto/sha3" + sdk "github.com/cosmos/cosmos-sdk/types" ethcmn "github.com/ethereum/go-ethereum/common" ethcrypto "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" @@ -44,13 +47,42 @@ func EncodeTxResponse(res *MsgEthereumTxResponse) ([]byte, error) { } // DecodeTxResponse decodes an protobuf-encoded byte slice into TxResponse -func DecodeTxResponse(data []byte) (MsgEthereumTxResponse, error) { - var txResponse MsgEthereumTxResponse - err := proto.Unmarshal(data, &txResponse) - if err != nil { - return MsgEthereumTxResponse{}, err +func DecodeTxResponse(in []byte) (*MsgEthereumTxResponse, error) { + var txMsgData sdk.TxMsgData + if err := proto.Unmarshal(in, &txMsgData); err != nil { + log.WithError(err).Errorln("failed to unmarshal TxMsgData") + return nil, err } - return txResponse, nil + + dataList := txMsgData.GetData() + if len(dataList) == 0 { + return &MsgEthereumTxResponse{}, nil + } + + var res MsgEthereumTxResponse + + err := proto.Unmarshal(dataList[0].GetData(), &res) + if err != nil { + err = errors.Wrap(err, "proto.Unmarshal failed") + return nil, err + } + + return &res, nil +} + +// EncodeTransactionLogs encodes TransactionLogs slice into a protobuf-encoded byte slice. +func EncodeTransactionLogs(res *TransactionLogs) ([]byte, error) { + return proto.Marshal(res) +} + +// DecodeTxResponse decodes an protobuf-encoded byte slice into TransactionLogs +func DecodeTransactionLogs(data []byte) (TransactionLogs, error) { + var logs TransactionLogs + err := proto.Unmarshal(data, &logs) + if err != nil { + return TransactionLogs{}, err + } + return logs, nil } // ---------------------------------------------------------------------------- diff --git a/x/evm/types/utils_test.go b/x/evm/types/utils_test.go index 548df636..aebc7e70 100644 --- a/x/evm/types/utils_test.go +++ b/x/evm/types/utils_test.go @@ -1,15 +1,27 @@ package types import ( - "strings" "testing" + "github.com/cosmos/ethermint/crypto/ethsecp256k1" + "github.com/stretchr/testify/require" ethcmn "github.com/ethereum/go-ethereum/common" ethtypes "github.com/ethereum/go-ethereum/core/types" + ethcrypto "github.com/ethereum/go-ethereum/crypto" ) +// GenerateEthAddress generates an Ethereum address. +func GenerateEthAddress() ethcmn.Address { + priv, err := ethsecp256k1.GenerateKey() + if err != nil { + panic(err) + } + + return ethcrypto.PubkeyToAddress(priv.ToECDSA().PublicKey) +} + func TestEvmDataEncoding(t *testing.T) { addr := "0x5dE8a020088a2D6d0a23c204FFbeD02790466B49" bloom := ethtypes.BytesToBloom([]byte{0x1, 0x3}) @@ -39,34 +51,3 @@ func TestEvmDataEncoding(t *testing.T) { require.Equal(t, data.TxLogs, res.TxLogs) require.Equal(t, ret, res.Ret) } - -func TestResultData_String(t *testing.T) { - const expectedResultDataStr = `ResultData: - ContractAddress: 0x5dE8a020088a2D6d0a23c204FFbeD02790466B49 - Bloom: 259 - Ret: [5 8] - TxHash: 0x0000000000000000000000000000000000000000000000000000000000000000 - Logs: - {0x0000000000000000000000000000000000000000 [] [1 2 3 4] 17 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false} - {0x0000000000000000000000000000000000000000 [] [5 6 7 8] 18 0x0000000000000000000000000000000000000000000000000000000000000000 0 0x0000000000000000000000000000000000000000000000000000000000000000 0 false}` - addr := ethcmn.HexToAddress("0x5dE8a020088a2D6d0a23c204FFbeD02790466B49") - bloom := ethtypes.BytesToBloom([]byte{0x1, 0x3}) - ret := []byte{0x5, 0x8} - - data := ResultData{ - ContractAddress: addr, - Bloom: bloom, - Logs: []*ethtypes.Log{ - { - Data: []byte{1, 2, 3, 4}, - BlockNumber: 17, - }, - { - Data: []byte{5, 6, 7, 8}, - BlockNumber: 18, - }}, - Ret: ret, - } - - require.True(t, strings.EqualFold(expectedResultDataStr, data.String())) -}