From a8c7cff35117826155cc4dad7146cfa417a30c8a Mon Sep 17 00:00:00 2001 From: Luke <129730838+LukeNinjaX@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:23:30 +0800 Subject: [PATCH] staging/0815: add aspect store v1 & fix bugs (#172) --- app/ante/evm/aspect_context.go | 2 +- app/app.go | 9 + app/interfaces/interfaces.go | 1 - common/aspect/aspect_abi_test.go | 53 - docs/static/openapi.yml | 28595 +--------------- ethereum/rpc/account.go | 320 - ethereum/rpc/{ethapi => api}/addrlock.go | 2 +- ethereum/rpc/{ethapi => api}/dbapi.go | 2 +- ethereum/rpc/api/debug.go | 196 +- ethereum/rpc/{ethapi/api.go => api/eth.go} | 578 +- ethereum/rpc/api/net.go | 31 +- ethereum/rpc/api/personal.go | 194 + ethereum/rpc/api/txpool.go | 121 + ethereum/rpc/api/web3.go | 26 +- ethereum/rpc/apis.go | 23 +- ethereum/rpc/backend.go | 433 +- ethereum/rpc/{blocks.go => blockchain.go} | 484 +- ethereum/rpc/{tracing.go => debug.go} | 75 + ethereum/rpc/eth.go | 184 + ethereum/rpc/ethapi/backend.go | 74 - ethereum/rpc/gas_oracle.go | 37 + ethereum/rpc/net.go | 30 + ethereum/rpc/node.go | 1 + ethereum/rpc/personal.go | 74 + ethereum/rpc/service.go | 8 +- ethereum/rpc/tx.go | 522 +- ethereum/rpc/tx_pool.go | 20 + ethereum/rpc/types/backend.go | 125 + ethereum/rpc/types/block.go | 7 +- ethereum/rpc/types/rpc_transacction.go | 146 + .../rpc/{ethapi => types}/transaction_args.go | 32 +- ethereum/rpc/types/types.go | 23 - ethereum/rpc/types/utils.go | 75 - ethereum/rpc/web3.go | 19 + ethereum/rpc/websockets.go | 8 +- ethereum/server/start.go | 23 +- ethereum/server/util.go | 58 +- ethereum/types/protocol.go | 5 +- go.mod | 8 +- go.sum | 16 +- testutil/keeper/evm.go | 2 + testutil/keeper/fee.go | 12 + .../contract => aspect/common}/utils.go | 2 +- x/aspect/cuckoofilter/bucket.go | 45 + x/aspect/cuckoofilter/cuckoofilter.go | 164 + x/aspect/cuckoofilter/util.go | 71 + x/aspect/provider/artela.go | 127 + x/{evm/artela => aspect}/provider/jit_call.go | 0 x/aspect/store/errors.go | 23 + x/aspect/store/keys.go | 58 + x/aspect/store/store.go | 376 + x/aspect/store/v0/account.go | 278 + x/aspect/store/v0/base.go | 90 + x/aspect/store/v0/gas.go | 100 + x/aspect/store/v0/init.go | 9 + x/aspect/store/v0/keys.go | 94 + x/aspect/store/v0/meta.go | 417 + x/aspect/store/v0/state.go | 50 + x/aspect/store/v1/account.go | 198 + x/aspect/store/v1/base.go | 102 + x/aspect/store/v1/init.go | 9 + x/aspect/store/v1/keys.go | 21 + x/aspect/store/v1/meta.go | 850 + x/aspect/store/v1/models.go | 147 + x/aspect/store/v1/state.go | 49 + x/aspect/types/constants.go | 16 + x/aspect/types/context.go | 111 + x/aspect/types/models.go | 58 + x/evm/artela/api/aspect_property_api.go | 9 +- x/evm/artela/api/aspect_runtime_ctx_api.go | 1 - x/evm/artela/api/datactx/block.go | 3 - x/evm/artela/api/datactx/tx.go | 2 +- x/evm/artela/api/evm_api.go | 11 +- x/evm/artela/contract/contract.go | 35 +- x/evm/artela/contract/handlers.go | 608 +- x/evm/artela/contract/service.go | 146 - x/evm/artela/contract/store.go | 663 - x/evm/artela/provider/artela.go | 57 - x/evm/artela/types/aspect_store_key.go | 157 - x/evm/artela/types/context.go | 107 +- x/evm/artela/types/models.go | 36 + x/evm/artela/types/treemap_test.go | 126 - x/evm/keeper/aspect.go | 4 - x/evm/keeper/evm.go | 2 +- x/evm/keeper/keeper.go | 7 +- x/evm/keeper/msg_server_test.go | 2 +- x/evm/module/genesis_test.go | 6 +- x/evm/module/module.go | 2 + x/fee/keeper/msg_update_params_test.go | 4 +- x/fee/types/genesis_test.go | 4 +- 90 files changed, 6169 insertions(+), 31942 deletions(-) delete mode 100644 ethereum/rpc/account.go rename ethereum/rpc/{ethapi => api}/addrlock.go (98%) rename ethereum/rpc/{ethapi => api}/dbapi.go (98%) rename ethereum/rpc/{ethapi/api.go => api/eth.go} (58%) create mode 100644 ethereum/rpc/api/personal.go create mode 100644 ethereum/rpc/api/txpool.go rename ethereum/rpc/{blocks.go => blockchain.go} (75%) rename ethereum/rpc/{tracing.go => debug.go} (70%) create mode 100644 ethereum/rpc/eth.go delete mode 100644 ethereum/rpc/ethapi/backend.go create mode 100644 ethereum/rpc/gas_oracle.go create mode 100644 ethereum/rpc/net.go create mode 100644 ethereum/rpc/personal.go create mode 100644 ethereum/rpc/tx_pool.go create mode 100644 ethereum/rpc/types/backend.go create mode 100644 ethereum/rpc/types/rpc_transacction.go rename ethereum/rpc/{ethapi => types}/transaction_args.go (95%) create mode 100644 ethereum/rpc/web3.go rename x/{evm/artela/contract => aspect/common}/utils.go (99%) create mode 100644 x/aspect/cuckoofilter/bucket.go create mode 100644 x/aspect/cuckoofilter/cuckoofilter.go create mode 100644 x/aspect/cuckoofilter/util.go create mode 100644 x/aspect/provider/artela.go rename x/{evm/artela => aspect}/provider/jit_call.go (100%) create mode 100644 x/aspect/store/errors.go create mode 100644 x/aspect/store/keys.go create mode 100644 x/aspect/store/store.go create mode 100644 x/aspect/store/v0/account.go create mode 100644 x/aspect/store/v0/base.go create mode 100644 x/aspect/store/v0/gas.go create mode 100644 x/aspect/store/v0/init.go create mode 100644 x/aspect/store/v0/keys.go create mode 100644 x/aspect/store/v0/meta.go create mode 100644 x/aspect/store/v0/state.go create mode 100644 x/aspect/store/v1/account.go create mode 100644 x/aspect/store/v1/base.go create mode 100644 x/aspect/store/v1/init.go create mode 100644 x/aspect/store/v1/keys.go create mode 100644 x/aspect/store/v1/meta.go create mode 100644 x/aspect/store/v1/models.go create mode 100644 x/aspect/store/v1/state.go create mode 100644 x/aspect/types/constants.go create mode 100644 x/aspect/types/context.go create mode 100644 x/aspect/types/models.go delete mode 100644 x/evm/artela/contract/service.go delete mode 100644 x/evm/artela/contract/store.go delete mode 100644 x/evm/artela/provider/artela.go delete mode 100644 x/evm/artela/types/aspect_store_key.go create mode 100644 x/evm/artela/types/models.go delete mode 100644 x/evm/artela/types/treemap_test.go diff --git a/app/ante/evm/aspect_context.go b/app/ante/evm/aspect_context.go index d9244b2..40121fb 100644 --- a/app/ante/evm/aspect_context.go +++ b/app/ante/evm/aspect_context.go @@ -13,7 +13,7 @@ import ( inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" "github.com/artela-network/artela-rollkit/app/interfaces" - "github.com/artela-network/artela-rollkit/x/evm/artela/provider" + "github.com/artela-network/artela-rollkit/x/aspect/provider" "github.com/artela-network/artela-rollkit/x/evm/artela/types" "github.com/artela-network/artela-rollkit/x/evm/states" evmmodule "github.com/artela-network/artela-rollkit/x/evm/types" diff --git a/app/app.go b/app/app.go index a139192..13563b0 100644 --- a/app/app.go +++ b/app/app.go @@ -87,9 +87,18 @@ import ( evmmodulekeeper "github.com/artela-network/artela-rollkit/x/evm/keeper" "github.com/artela-network/artela-rollkit/x/evm/types" feemodulekeeper "github.com/artela-network/artela-rollkit/x/fee/keeper" + // this line is used by starport scaffolding # stargate/app/moduleImport "github.com/artela-network/artela-rollkit/docs" + + // do not remove this, this will register the native evm tracers + _ "github.com/artela-network/artela-evm/tracers/native" + _ "github.com/ethereum/go-ethereum/eth/tracers/js" + + // aspect related imports + _ "github.com/artela-network/artela-rollkit/x/aspect/store/v0" + _ "github.com/artela-network/artela-rollkit/x/aspect/store/v1" ) const ( diff --git a/app/interfaces/interfaces.go b/app/interfaces/interfaces.go index 69f375d..6502c08 100644 --- a/app/interfaces/interfaces.go +++ b/app/interfaces/interfaces.go @@ -33,7 +33,6 @@ type EVMKeeper interface { VerifySig(ctx cosmos.Context, tx *ethereum.Transaction) (common.Address, []byte, error) EVMConfigFromCtx(ctx cosmos.Context) (*states.EVMConfig, error) GetBlockContext() *artvmtype.EthBlockContext - GetAspectRuntimeContext() *artvmtype.AspectRuntimeContext MakeSigner(ctx cosmos.Context, tx *ethereum.Transaction, config *params.ChainConfig, blockNumber *big.Int, blockTime uint64) ethereum.Signer } diff --git a/common/aspect/aspect_abi_test.go b/common/aspect/aspect_abi_test.go index 2adc8dd..ff4d658 100644 --- a/common/aspect/aspect_abi_test.go +++ b/common/aspect/aspect_abi_test.go @@ -6,17 +6,13 @@ import ( "reflect" "testing" - pq "github.com/emirpasic/gods/queues/priorityqueue" "github.com/emirpasic/gods/sets/treeset" - "github.com/holiman/uint256" jsoniter "github.com/json-iterator/go" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/rlp" - - "github.com/artela-network/artela-rollkit/x/evm/artela/types" ) func TestAbi(t *testing.T) { @@ -102,55 +98,6 @@ func TestPack(t *testing.T) { fmt.Println(properties) } -func TestAspectsOfPack(t *testing.T) { - ma := make(map[string]interface{}, 2) - ma[types.AspectIDMapKey] = "1111" - ma[types.VersionMapKey] = 0 - ma[types.PriorityMapKey] = 1 - mb := make(map[string]interface{}, 2) - mb[types.AspectIDMapKey] = "2222" - mb[types.VersionMapKey] = 1 - mb[types.PriorityMapKey] = -10 - mc := make(map[string]interface{}, 2) - mc[types.AspectIDMapKey] = "3333" - mc[types.VersionMapKey] = 2 - mc[types.PriorityMapKey] = 3 - - queue := pq.NewWith(types.ByMapKeyPriority) // empty - queue.Enqueue(ma) // {a 1} - queue.Enqueue(mb) // {c 3}, {a 1} - queue.Enqueue(mc) - - outputs := make([]types.AspectMeta, 0) - iterator := queue.Iterator() - - for iterator.Next() { - m := iterator.Value().(map[string]interface{}) - e := types.AspectMeta{ - Id: common.HexToAddress(m[types.AspectIDMapKey].(string)), - Priority: int64(m[types.PriorityMapKey].(int)), - Version: uint256.NewInt(m[types.VersionMapKey].(uint64)), - } - outputs = append(outputs, e) - } - pack, err := methods["AspectsOf"].Outputs.Pack(outputs) - if err != nil { - fmt.Println("pack error", err) - } - maps := make(map[string]interface{}, 0) - err2 := methods["AspectsOf"].Outputs.UnpackIntoMap(maps, pack) - if err2 != nil { - fmt.Println("pack error", err2) - } - fmt.Println("unpack==", maps) - aspects := maps["aspectBoundInfo"].([]struct { - AspectId common.Address `json:"AspectId"` - Version uint64 `json:"Version"` - Priority int8 `json:"Priority"` - }) - fmt.Println(aspects) -} - func TestContractOfPack(t *testing.T) { treeset := treeset.NewWithStringComparator() treeset.Add("aaaaaaa") diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index d2c8cd2..3579e92 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -1,28594 +1 @@ -swagger: '2.0' -info: - title: HTTP API Console - name: '' - description: '' -paths: - /artela/evm/account/{address}: - get: - summary: Account queries an Ethereum account. - operationId: ArtelaEvmQuery_Account - responses: - '200': - description: A successful response. - schema: - type: object - properties: - balance: - type: string - description: balance is the balance of the EVM denomination. - code_hash: - type: string - description: code_hash is the hex-formatted code bytes from the EOA. - nonce: - type: string - format: uint64 - description: nonce is the account's sequence number. - description: >- - QueryAccountResponse is the response type for the Query/Account - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address is the ethereum hex address to query the account for. - in: path - required: true - type: string - tags: - - Query - /artela/evm/balances/{address}: - get: - summary: |- - Balance queries the balance of a the EVM denomination for a single - EthAccount. - operationId: ArtelaEvmQuery_Balance - responses: - '200': - description: A successful response. - schema: - type: object - properties: - balance: - type: string - description: balance is the balance of the EVM denomination. - description: >- - QueryBalanceResponse is the response type for the Query/Balance - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address is the ethereum hex address to query the balance for. - in: path - required: true - type: string - tags: - - Query - /artela/evm/base_fee: - get: - summary: >- - BaseFee queries the base fee of the parent block of the current block, - - it's similar to feemarket module's method, but also checks london - hardfork status. - operationId: ArtelaEvmQuery_BaseFee - responses: - '200': - description: A successful response. - schema: - type: object - properties: - base_fee: - type: string - title: base_fee is the EIP1559 base fee - description: QueryBaseFeeResponse returns the EIP1559 base fee. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - tags: - - Query - /artela/evm/codes/{address}: - get: - summary: Code queries the balance of all coins for a single account. - operationId: ArtelaEvmQuery_Code - responses: - '200': - description: A successful response. - schema: - type: object - properties: - code: - type: string - format: byte - description: code represents the code bytes from an ethereum address. - description: |- - QueryCodeResponse is the response type for the Query/Code RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address is the ethereum hex address to query the code for. - in: path - required: true - type: string - tags: - - Query - /artela/evm/cosmos_account/{address}: - get: - summary: CosmosAccount queries an Ethereum account's Cosmos Address. - operationId: ArtelaEvmQuery_CosmosAccount - responses: - '200': - description: A successful response. - schema: - type: object - properties: - cosmos_address: - type: string - description: cosmos_address is the cosmos address of the account. - sequence: - type: string - format: uint64 - description: sequence is the account's sequence number. - account_number: - type: string - format: uint64 - title: account_number is the account number - description: >- - QueryCosmosAccountResponse is the response type for the - Query/CosmosAccount - - RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address is the ethereum hex address to query the account for. - in: path - required: true - type: string - tags: - - Query - /artela/evm/estimate_gas: - get: - summary: EstimateGas implements the `eth_estimateGas` rpc api - operationId: ArtelaEvmQuery_EstimateGas - responses: - '200': - description: A successful response. - schema: - type: object - properties: - gas: - type: string - format: uint64 - title: gas returns the estimated gas - title: EstimateGasResponse defines EstimateGas response - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: args - description: args uses the same json format as the json rpc api. - in: query - required: false - type: string - format: byte - - name: gas_cap - description: gas_cap defines the default gas cap to be used - in: query - required: false - type: string - format: uint64 - - name: proposer_address - description: proposer_address of the requested block in hex format - in: query - required: false - type: string - format: byte - - name: chain_id - description: >- - chain_id is the eip155 chain id parsed from the requested block - header - in: query - required: false - type: string - format: int64 - tags: - - Query - /artela/evm/eth_call: - get: - summary: EthCall implements the `eth_call` rpc api - operationId: ArtelaEvmQuery_EthCall - responses: - '200': - description: A successful response. - schema: - type: object - properties: - hash: - type: string - title: >- - hash of the ethereum transaction in hex format. This hash - differs from the - - Tendermint sha256 hash of the transaction bytes. See - - https://github.com/tendermint/tendermint/issues/6539 for - reference - logs: - type: array - items: - type: object - properties: - address: - type: string - title: address of the contract that generated the event - topics: - type: array - items: - type: string - description: topics is a list of topics provided by the contract. - data: - type: string - format: byte - title: >- - data which is supplied by the contract, usually - ABI-encoded - block_number: - type: string - format: uint64 - title: >- - block_number of the block in which the transaction was - included - tx_hash: - type: string - title: tx_hash is the transaction hash - tx_index: - type: string - format: uint64 - title: tx_index of the transaction in the block - block_hash: - type: string - title: >- - block_hash of the block in which the transaction was - included - index: - type: string - format: uint64 - title: index of the log in the block - removed: - type: boolean - description: >- - removed is true if this log was reverted due to a chain - - reorganisation. You must pay attention to this field if - you receive logs - - through a filter query. - description: >- - Log represents an protobuf compatible Ethereum Log that - defines a contract - - log event. These events are generated by the LOG opcode and - stored/indexed by - - the node. - - - NOTE: address, topics and data are consensus fields. The - rest of the fields - - are derived, i.e. filled in by the nodes, but not secured by - consensus. - description: >- - logs contains the transaction hash and the proto-compatible - ethereum - - logs. - ret: - type: string - format: byte - title: >- - ret is the returned data from evm function (result or data - supplied with revert - - opcode) - vm_error: - type: string - title: vm_error is the error returned by vm execution - gas_used: - type: string - format: uint64 - title: >- - gas_used specifies how much gas was consumed by the - transaction - cumulative_gas_used: - type: string - format: uint64 - title: cumulative gas used - description: MsgEthereumTxResponse defines the Msg/EthereumTx response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: args - description: args uses the same json format as the json rpc api. - in: query - required: false - type: string - format: byte - - name: gas_cap - description: gas_cap defines the default gas cap to be used - in: query - required: false - type: string - format: uint64 - - name: proposer_address - description: proposer_address of the requested block in hex format - in: query - required: false - type: string - format: byte - - name: chain_id - description: >- - chain_id is the eip155 chain id parsed from the requested block - header - in: query - required: false - type: string - format: int64 - tags: - - Query - /artela/evm/get_sender: - get: - summary: GetSender gets sender the tx - operationId: ArtelaEvmQuery_GetSender - responses: - '200': - description: A successful response. - schema: - type: object - properties: - sender: - type: string - description: sender defines the from address of the tx. - description: GetSenderResponse returns the from address of tx. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: data.type_url - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a canonical - form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types that - they - - expect it to use in the context of Any. However, for URLs which use - the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - in: query - required: false - type: string - - name: data.value - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - in: query - required: false - type: string - format: byte - - name: hash - description: hash of the transaction in hex format - in: query - required: false - type: string - - name: from - description: >- - from is the ethereum signer address in hex format. This address - value is checked - - against the address derived from the signature (V, R, S) using the - - secp256k1 elliptic curve - in: query - required: false - type: string - tags: - - Query - /artela/evm/params: - get: - summary: Params queries the parameters of x/evm module. - operationId: ArtelaEvmQuery_Params - responses: - '200': - description: A successful response. - schema: - type: object - properties: - params: - description: params define the evm module parameters. - type: object - properties: - evm_denom: - type: string - description: >- - evm_denom represents the token denomination used to run - the EVM state - - transitions. - enable_create: - type: boolean - title: >- - enable_create toggles state transitions that use the - vm.Create function - enable_call: - type: boolean - title: >- - enable_call toggles state transitions that use the vm.Call - function - extra_eips: - type: array - items: - type: string - format: int64 - title: extra_eips defines the additional EIPs for the vm.Config - chain_config: - title: >- - chain_config defines the EVM chain configuration - parameters - type: object - properties: - homestead_block: - type: string - title: >- - homestead_block switch (nil no fork, 0 = already - homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch - block (nil no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or - opposes the DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 - HF block (nil no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only - clients as only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, - 0 = already on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil - no fork, 0 = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 - = already on istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block - (nil no fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = - already on berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = - already on london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch - block (nil = no fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block - (nil = no fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to - use as a network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = - already on shanghai) - cancun_block: - type: string - title: >- - cancun_block switch block (nil = no fork, 0 = already - on cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters - using *sdk.Int values - - instead of *big.Int. - allow_unprotected_txs: - type: boolean - description: >- - allow_unprotected_txs defines if replay-protected (i.e non - EIP155 - - signed) transactions can be executed on the state machine. - description: >- - QueryParamsResponse defines the response type for querying x/evm - parameters. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - tags: - - Query - /artela/evm/storage/{address}/{key}: - get: - summary: Storage queries a single slot of evm state for a single account. - operationId: ArtelaEvmQuery_Storage - responses: - '200': - description: A successful response. - schema: - type: object - properties: - value: - type: string - description: >- - value defines the storage state value hash associated with the - given key. - description: >- - QueryStorageResponse is the response type for the Query/Storage - RPC - - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: address - description: address is the ethereum hex address to query the storage state for. - in: path - required: true - type: string - - name: key - description: key defines the key of the storage state - in: path - required: true - type: string - tags: - - Query - /artela/evm/trace_block: - get: - summary: >- - TraceBlock implements the `debug_traceBlockByNumber` and - `debug_traceBlockByHash` rpc api - operationId: ArtelaEvmQuery_TraceBlock - responses: - '200': - description: A successful response. - schema: - type: object - properties: - data: - type: string - format: byte - title: data is the response serialized in bytes - title: QueryTraceBlockResponse defines TraceBlock response - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: trace_config.tracer - description: tracer is a custom javascript tracer - in: query - required: false - type: string - - name: trace_config.timeout - description: >- - timeout overrides the default timeout of 5 seconds for - JavaScript-based tracing - - calls - in: query - required: false - type: string - - name: trace_config.reexec - description: reexec defines the number of blocks the tracer is willing to go back - in: query - required: false - type: string - format: uint64 - - name: trace_config.disable_stack - description: disable_stack switches stack capture - in: query - required: false - type: boolean - - name: trace_config.disable_storage - description: disable_storage switches storage capture - in: query - required: false - type: boolean - - name: trace_config.debug - description: debug can be used to print output during capture end - in: query - required: false - type: boolean - - name: trace_config.limit - description: limit defines the maximum length of output, but zero means unlimited - in: query - required: false - type: integer - format: int32 - - name: trace_config.overrides.homestead_block - description: homestead_block switch (nil no fork, 0 = already homestead) - in: query - required: false - type: string - - name: trace_config.overrides.dao_fork_block - description: >- - dao_fork_block corresponds to TheDAO hard-fork switch block (nil no - fork) - in: query - required: false - type: string - - name: trace_config.overrides.dao_fork_support - description: >- - dao_fork_support defines whether the nodes supports or opposes the - DAO hard-fork - in: query - required: false - type: boolean - - name: trace_config.overrides.eip150_block - description: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil - no fork) - in: query - required: false - type: string - - name: trace_config.overrides.eip150_hash - description: >- - eip150_hash: EIP150 HF hash (needed for header only clients as only - gas pricing changed) - in: query - required: false - type: string - - name: trace_config.overrides.eip155_block - description: 'eip155_block: EIP155Block HF block' - in: query - required: false - type: string - - name: trace_config.overrides.eip158_block - description: 'eip158_block: EIP158 HF block' - in: query - required: false - type: string - - name: trace_config.overrides.byzantium_block - description: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = already on - byzantium) - in: query - required: false - type: string - - name: trace_config.overrides.constantinople_block - description: >- - constantinople_block: Constantinople switch block (nil no fork, 0 = - already activated) - in: query - required: false - type: string - - name: trace_config.overrides.petersburg_block - description: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - in: query - required: false - type: string - - name: trace_config.overrides.istanbul_block - description: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = already on - istanbul) - in: query - required: false - type: string - - name: trace_config.overrides.muir_glacier_block - description: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, - 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.berlin_block - description: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already on - berlin) - in: query - required: false - type: string - - name: trace_config.overrides.london_block - description: >- - london_block: London switch block (nil = no fork, 0 = already on - london) - in: query - required: false - type: string - - name: trace_config.overrides.arrow_glacier_block - description: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no - fork, 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.gray_glacier_block - description: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no - fork, 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.merge_netsplit_block - description: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - in: query - required: false - type: string - - name: trace_config.overrides.shanghai_block - description: shanghai_block switch block (nil = no fork, 0 = already on shanghai) - in: query - required: false - type: string - - name: trace_config.overrides.cancun_block - description: cancun_block switch block (nil = no fork, 0 = already on cancun) - in: query - required: false - type: string - - name: trace_config.enable_memory - description: enable_memory switches memory capture - in: query - required: false - type: boolean - - name: trace_config.enable_return_data - description: enable_return_data switches the capture of return data - in: query - required: false - type: boolean - - name: trace_config.tracer_json_config - description: tracer_json_config configures the tracer using a JSON string - in: query - required: false - type: string - - name: block_number - description: block_number of the traced block - in: query - required: false - type: string - format: int64 - - name: block_hash - description: block_hash (hex) of the traced block - in: query - required: false - type: string - - name: block_time - description: block_time of the traced block - in: query - required: false - type: string - format: date-time - - name: proposer_address - description: proposer_address is the address of the requested block - in: query - required: false - type: string - format: byte - - name: chain_id - description: >- - chain_id is the eip155 chain id parsed from the requested block - header - in: query - required: false - type: string - format: int64 - - name: block_max_gas - description: block_max_gas of the traced block - in: query - required: false - type: string - format: int64 - tags: - - Query - /artela/evm/trace_tx: - get: - summary: TraceTx implements the `debug_traceTransaction` rpc api - operationId: ArtelaEvmQuery_TraceTx - responses: - '200': - description: A successful response. - schema: - type: object - properties: - data: - type: string - format: byte - title: data is the response serialized in bytes - title: QueryTraceTxResponse defines TraceTx response - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: msg.data.type_url - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a canonical - form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types that - they - - expect it to use in the context of Any. However, for URLs which use - the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - in: query - required: false - type: string - - name: msg.data.value - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - in: query - required: false - type: string - format: byte - - name: msg.hash - description: hash of the transaction in hex format - in: query - required: false - type: string - - name: msg.from - description: >- - from is the ethereum signer address in hex format. This address - value is checked - - against the address derived from the signature (V, R, S) using the - - secp256k1 elliptic curve - in: query - required: false - type: string - - name: trace_config.tracer - description: tracer is a custom javascript tracer - in: query - required: false - type: string - - name: trace_config.timeout - description: >- - timeout overrides the default timeout of 5 seconds for - JavaScript-based tracing - - calls - in: query - required: false - type: string - - name: trace_config.reexec - description: reexec defines the number of blocks the tracer is willing to go back - in: query - required: false - type: string - format: uint64 - - name: trace_config.disable_stack - description: disable_stack switches stack capture - in: query - required: false - type: boolean - - name: trace_config.disable_storage - description: disable_storage switches storage capture - in: query - required: false - type: boolean - - name: trace_config.debug - description: debug can be used to print output during capture end - in: query - required: false - type: boolean - - name: trace_config.limit - description: limit defines the maximum length of output, but zero means unlimited - in: query - required: false - type: integer - format: int32 - - name: trace_config.overrides.homestead_block - description: homestead_block switch (nil no fork, 0 = already homestead) - in: query - required: false - type: string - - name: trace_config.overrides.dao_fork_block - description: >- - dao_fork_block corresponds to TheDAO hard-fork switch block (nil no - fork) - in: query - required: false - type: string - - name: trace_config.overrides.dao_fork_support - description: >- - dao_fork_support defines whether the nodes supports or opposes the - DAO hard-fork - in: query - required: false - type: boolean - - name: trace_config.overrides.eip150_block - description: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil - no fork) - in: query - required: false - type: string - - name: trace_config.overrides.eip150_hash - description: >- - eip150_hash: EIP150 HF hash (needed for header only clients as only - gas pricing changed) - in: query - required: false - type: string - - name: trace_config.overrides.eip155_block - description: 'eip155_block: EIP155Block HF block' - in: query - required: false - type: string - - name: trace_config.overrides.eip158_block - description: 'eip158_block: EIP158 HF block' - in: query - required: false - type: string - - name: trace_config.overrides.byzantium_block - description: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = already on - byzantium) - in: query - required: false - type: string - - name: trace_config.overrides.constantinople_block - description: >- - constantinople_block: Constantinople switch block (nil no fork, 0 = - already activated) - in: query - required: false - type: string - - name: trace_config.overrides.petersburg_block - description: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - in: query - required: false - type: string - - name: trace_config.overrides.istanbul_block - description: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = already on - istanbul) - in: query - required: false - type: string - - name: trace_config.overrides.muir_glacier_block - description: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, - 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.berlin_block - description: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already on - berlin) - in: query - required: false - type: string - - name: trace_config.overrides.london_block - description: >- - london_block: London switch block (nil = no fork, 0 = already on - london) - in: query - required: false - type: string - - name: trace_config.overrides.arrow_glacier_block - description: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no - fork, 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.gray_glacier_block - description: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no - fork, 0 = already activated) - in: query - required: false - type: string - - name: trace_config.overrides.merge_netsplit_block - description: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - in: query - required: false - type: string - - name: trace_config.overrides.shanghai_block - description: shanghai_block switch block (nil = no fork, 0 = already on shanghai) - in: query - required: false - type: string - - name: trace_config.overrides.cancun_block - description: cancun_block switch block (nil = no fork, 0 = already on cancun) - in: query - required: false - type: string - - name: trace_config.enable_memory - description: enable_memory switches memory capture - in: query - required: false - type: boolean - - name: trace_config.enable_return_data - description: enable_return_data switches the capture of return data - in: query - required: false - type: boolean - - name: trace_config.tracer_json_config - description: tracer_json_config configures the tracer using a JSON string - in: query - required: false - type: string - - name: block_number - description: block_number of requested transaction - in: query - required: false - type: string - format: int64 - - name: block_hash - description: block_hash of requested transaction - in: query - required: false - type: string - - name: block_time - description: block_time of requested transaction - in: query - required: false - type: string - format: date-time - - name: proposer_address - description: proposer_address is the proposer of the requested block - in: query - required: false - type: string - format: byte - - name: chain_id - description: >- - chain_id is the the eip155 chain id parsed from the requested block - header - in: query - required: false - type: string - format: int64 - - name: block_max_gas - description: block_max_gas of the block of the requested transaction - in: query - required: false - type: string - format: int64 - tags: - - Query - /artela/evm/validator_account/{cons_address}: - get: - summary: >- - ValidatorAccount queries an Ethereum account's from a validator - consensus - - Address. - operationId: ArtelaEvmQuery_ValidatorAccount - responses: - '200': - description: A successful response. - schema: - type: object - properties: - account_address: - type: string - description: >- - account_address is the cosmos address of the account in bech32 - format. - sequence: - type: string - format: uint64 - description: sequence is the account's sequence number. - account_number: - type: string - format: uint64 - title: account_number is the account number - description: |- - QueryValidatorAccountResponse is the response type for the - Query/ValidatorAccount RPC method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: cons_address - description: cons_address is the validator cons address to query the account for. - in: path - required: true - type: string - tags: - - Query - /artela.evm.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines a (governance) operation for updating the module - parameters. The authority defaults to the x/gov module account. - operationId: ArtelaEvmMsg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - evm_denom: - type: string - description: >- - evm_denom represents the token denomination used to run - the EVM state - - transitions. - enable_create: - type: boolean - title: >- - enable_create toggles state transitions that use the - vm.Create function - enable_call: - type: boolean - title: >- - enable_call toggles state transitions that use the vm.Call - function - extra_eips: - type: array - items: - type: string - format: int64 - title: extra_eips defines the additional EIPs for the vm.Config - chain_config: - title: >- - chain_config defines the EVM chain configuration - parameters - type: object - properties: - homestead_block: - type: string - title: >- - homestead_block switch (nil no fork, 0 = already - homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch - block (nil no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or - opposes the DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 - HF block (nil no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only - clients as only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, - 0 = already on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil - no fork, 0 = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 - = already on istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block - (nil no fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = - already on berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = - already on london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch - block (nil = no fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block - (nil = no fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to - use as a network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = - already on shanghai) - cancun_block: - type: string - title: >- - cancun_block switch block (nil = no fork, 0 = already - on cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters - using *sdk.Int values - - instead of *big.Int. - allow_unprotected_txs: - type: boolean - description: >- - allow_unprotected_txs defines if replay-protected (i.e non - EIP155 - - signed) transactions can be executed on the state machine. - description: MsgUpdateParams is the Msg/UpdateParams request type. - tags: - - Msg - /artela/evm/ethereum_tx: - post: - summary: EthereumTx defines a method submitting Ethereum transactions. - operationId: ArtelaEvmMsg_EthereumTx - responses: - '200': - description: A successful response. - schema: - type: object - properties: - hash: - type: string - title: >- - hash of the ethereum transaction in hex format. This hash - differs from the - - Tendermint sha256 hash of the transaction bytes. See - - https://github.com/tendermint/tendermint/issues/6539 for - reference - logs: - type: array - items: - type: object - properties: - address: - type: string - title: address of the contract that generated the event - topics: - type: array - items: - type: string - description: topics is a list of topics provided by the contract. - data: - type: string - format: byte - title: >- - data which is supplied by the contract, usually - ABI-encoded - block_number: - type: string - format: uint64 - title: >- - block_number of the block in which the transaction was - included - tx_hash: - type: string - title: tx_hash is the transaction hash - tx_index: - type: string - format: uint64 - title: tx_index of the transaction in the block - block_hash: - type: string - title: >- - block_hash of the block in which the transaction was - included - index: - type: string - format: uint64 - title: index of the log in the block - removed: - type: boolean - description: >- - removed is true if this log was reverted due to a chain - - reorganisation. You must pay attention to this field if - you receive logs - - through a filter query. - description: >- - Log represents an protobuf compatible Ethereum Log that - defines a contract - - log event. These events are generated by the LOG opcode and - stored/indexed by - - the node. - - - NOTE: address, topics and data are consensus fields. The - rest of the fields - - are derived, i.e. filled in by the nodes, but not secured by - consensus. - description: >- - logs contains the transaction hash and the proto-compatible - ethereum - - logs. - ret: - type: string - format: byte - title: >- - ret is the returned data from evm function (result or data - supplied with revert - - opcode) - vm_error: - type: string - title: vm_error is the error returned by vm execution - gas_used: - type: string - format: uint64 - title: >- - gas_used specifies how much gas was consumed by the - transaction - cumulative_gas_used: - type: string - format: uint64 - title: cumulative gas used - description: MsgEthereumTxResponse defines the Msg/EthereumTx response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: data.type_url - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a canonical - form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types that - they - - expect it to use in the context of Any. However, for URLs which use - the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - in: query - required: false - type: string - - name: data.value - description: >- - Must be a valid serialized protocol buffer of the above specified - type. - in: query - required: false - type: string - format: byte - - name: hash - description: hash of the transaction in hex format - in: query - required: false - type: string - - name: from - description: >- - from is the ethereum signer address in hex format. This address - value is checked - - against the address derived from the signature (V, R, S) using the - - secp256k1 elliptic curve - in: query - required: false - type: string - tags: - - Msg - /artela.fee.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines a (governance) operation for updating the module - parameters. The authority defaults to the x/gov module account. - operationId: ArtelaFeeMsg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - no_base_fee: - type: boolean - title: >- - no_base_fee forces the EIP-1559 base fee to 0 (needed for - 0 price calls) - base_fee_change_denominator: - type: integer - format: int64 - description: >- - base_fee_change_denominator bounds the amount the base fee - can change - - between blocks. - elasticity_multiplier: - type: integer - format: int64 - description: >- - elasticity_multiplier bounds the maximum gas limit an - EIP-1559 block may - - have. - enable_height: - type: string - format: int64 - description: >- - enable_height defines at which block height the base fee - calculation is enabled. - base_fee: - type: string - description: base_fee for EIP-1559 blocks. - min_gas_price: - type: string - title: >- - min_gas_price defines the minimum gas price value for - cosmos and eth transactions - min_gas_multiplier: - type: string - title: >- - min_gas_multiplier bounds the minimum gas used to be - charged - - to senders based on gas limit - description: MsgUpdateParams is the Msg/UpdateParams request type. - tags: - - Msg - /cosmos.auth.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a (governance) operation for updating the x/auth - module - - parameters. The authority defaults to the x/gov module account. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosAuthV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/auth parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - max_memo_characters: - type: string - format: uint64 - tx_sig_limit: - type: string - format: uint64 - tx_size_cost_per_byte: - type: string - format: uint64 - sig_verify_cost_ed25519: - type: string - format: uint64 - sig_verify_cost_secp256k1: - type: string - format: uint64 - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.authz.v1beta1.Msg/Exec: - post: - summary: |- - Exec 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. - operationId: CosmosAuthzV1Beta1Msg_Exec - responses: - '200': - description: A successful response. - schema: - type: object - properties: - results: - type: array - items: - type: string - format: byte - description: MsgExecResponse defines the Msg/MsgExecResponse response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgExec 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. - in: body - required: true - schema: - type: object - properties: - grantee: - type: string - msgs: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: >- - Execute Msg. - - The x/authz will try to find a grant matching (msg.signers[0], - grantee, MsgTypeURL(msg)) - - triple and validate it. - description: >- - MsgExec 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. - tags: - - Msg - /cosmos.authz.v1beta1.Msg/Grant: - post: - summary: |- - Grant grants the provided authorization to the grantee on the granter's - account with the provided expiration time. If there is already a grant - for the given (granter, grantee, Authorization) triple, then the grant - will be overwritten. - operationId: CosmosAuthzV1Beta1Msg_Grant - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgGrantResponse defines the Msg/MsgGrant response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgGrant is a request type for Grant method. It declares - authorization to the grantee - - on behalf of the granter with the provided expiration time. - in: body - required: true - schema: - type: object - properties: - granter: - type: string - grantee: - type: string - grant: - type: object - properties: - authorization: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type - of the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be - in a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can - optionally set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results - based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no - widely used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty - scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any - values in the form - - of utility functions or additional generated methods of - the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a - custom JSON - - representation, that representation will be embedded - adding a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - expiration: - type: string - format: date-time - title: >- - time when the grant will expire and will be pruned. If - null, then the grant - - doesn't have a time expiration (other conditions in - `authorization` - - may apply to invalidate the grant) - description: |- - Grant gives permissions to execute - the provide method with expiration time. - description: >- - MsgGrant is a request type for Grant method. It declares - authorization to the grantee - - on behalf of the granter with the provided expiration time. - tags: - - Msg - /cosmos.authz.v1beta1.Msg/Revoke: - post: - summary: >- - Revoke revokes any authorization corresponding to the provided method - name on the - - granter's account that has been granted to the grantee. - operationId: CosmosAuthzV1Beta1Msg_Revoke - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgRevoke revokes any authorization with the provided sdk.Msg type - on the - - granter's account with that has been granted to the grantee. - in: body - required: true - schema: - type: object - properties: - granter: - type: string - grantee: - type: string - msg_type_url: - type: string - description: >- - MsgRevoke revokes any authorization with the provided sdk.Msg type - on the - - granter's account with that has been granted to the grantee. - tags: - - Msg - /cosmos.bank.v1beta1.Msg/MultiSend: - post: - summary: >- - MultiSend defines a method for sending coins from some accounts to other - accounts. - operationId: CosmosBankV1Beta1Msg_MultiSend - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgMultiSendResponse defines the Msg/MultiSend response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgMultiSend represents an arbitrary multi-in, multi-out send - message. - in: body - required: true - schema: - type: object - properties: - inputs: - type: array - items: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - description: Input models transaction input. - description: >- - Inputs, despite being `repeated`, only allows one sender - input. This is - - checked in MsgMultiSend's ValidateBasic. - outputs: - type: array - items: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - description: Output models transaction outputs. - description: >- - MsgMultiSend represents an arbitrary multi-in, multi-out send - message. - tags: - - Msg - /cosmos.bank.v1beta1.Msg/Send: - post: - summary: >- - Send defines a method for sending coins from one account to another - account. - operationId: CosmosBankV1Beta1Msg_Send - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgSendResponse defines the Msg/Send response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgSend represents a message to send coins from one account to - another. - in: body - required: true - schema: - type: object - properties: - from_address: - type: string - to_address: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgSend represents a message to send coins from one account to - another. - tags: - - Msg - /cosmos.bank.v1beta1.Msg/SetSendEnabled: - post: - summary: >- - SetSendEnabled is a governance operation for setting the SendEnabled - flag - - on any number of Denoms. Only the entries to add or update should be - - included. Entries that already exist in the store, but that aren't - - included in this message, will be left unchanged. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosBankV1Beta1Msg_SetSendEnabled - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgSetSendEnabledResponse defines the Msg/SetSendEnabled response - type. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgSetSendEnabled is the Msg/SetSendEnabled request type. - - Only entries to add/update/delete need to be included. - Existing SendEnabled entries that are not included in this - message are left unchanged. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: authority is the address that controls the module. - send_enabled: - type: array - items: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: >- - SendEnabled maps coin denom to a send_enabled status - (whether a denom is - - sendable). - description: send_enabled is the list of entries to add or update. - use_default_for: - type: array - items: - type: string - description: >- - use_default_for is a list of denoms that should use the - params.default_send_enabled value. - - Denoms listed here will have their SendEnabled entries - deleted. - - If a denom is included that doesn't have a SendEnabled entry, - - it will be ignored. - description: |- - MsgSetSendEnabled is the Msg/SetSendEnabled request type. - - Only entries to add/update/delete need to be included. - Existing SendEnabled entries that are not included in this - message are left unchanged. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.bank.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/bank - module parameters. - - The authority is defined in the keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosBankV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/bank parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - send_enabled: - type: array - items: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: >- - SendEnabled maps coin denom to a send_enabled status - (whether a denom is - - sendable). - description: >- - Deprecated: Use of SendEnabled in params is deprecated. - - For genesis, use the newly added send_enabled field in the - genesis object. - - Storage, lookup, and manipulation of this information is - now in the keeper. - - - As of cosmos-sdk 0.47, this only exists for backwards - compatibility of genesis files. - default_send_enabled: - type: boolean - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos/base/node/v1beta1/config: - get: - summary: Config queries for the operator configuration. - operationId: CosmosBaseNodeV1Beta1Service_Config - responses: - '200': - description: A successful response. - schema: - type: object - properties: - minimum_gas_price: - type: string - pruning_keep_recent: - type: string - pruning_interval: - type: string - halt_height: - type: string - format: uint64 - description: >- - ConfigResponse defines the response structure for the Config gRPC - query. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Service - /cosmos/base/node/v1beta1/status: - get: - summary: Status queries for the node status. - operationId: CosmosBaseNodeV1Beta1Service_Status - responses: - '200': - description: A successful response. - schema: - type: object - properties: - earliest_store_height: - type: string - format: uint64 - title: earliest block height available in the store - height: - type: string - format: uint64 - title: current block height - timestamp: - type: string - format: date-time - title: block height timestamp - app_hash: - type: string - format: byte - title: app hash of the current block - validator_hash: - type: string - format: byte - title: validator hash provided by the consensus header - description: >- - StateResponse defines the response structure for the status of a - node. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Service - /cosmos.consensus.v1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/consensus - module parameters. - - The authority is defined in the keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosConsensusV1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - block: - description: >- - params defines the x/consensus parameters to update. - - VersionsParams is not included in this Msg because it is - tracked - - separarately in x/upgrade. - - - NOTE: All parameters must be supplied. - type: object - properties: - max_bytes: - type: string - format: int64 - title: |- - Max block size, in bytes. - Note: must be greater than 0 - max_gas: - type: string - format: int64 - title: |- - Max gas per block. - Note: must be greater or equal to -1 - evidence: - type: object - properties: - max_age_num_blocks: - type: string - format: int64 - description: >- - Max age of evidence, in blocks. - - - The basic formula for calculating this is: MaxAgeDuration - / {average block - - time}. - max_age_duration: - type: string - description: >- - Max age of evidence, in time. - - - It should correspond with an app's "unbonding period" or - other similar - - 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). - max_bytes: - type: string - format: int64 - title: >- - 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 - description: >- - EvidenceParams determine how we handle evidence of - malfeasance. - validator: - type: object - properties: - pub_key_types: - type: array - items: - type: string - description: >- - ValidatorParams restrict the public key types validators can - use. - - NOTE: uses ABCI pubkey naming, not Amino names. - abci: - title: 'Since: cosmos-sdk 0.50' - type: object - properties: - vote_extensions_enable_height: - type: string - format: int64 - description: >- - vote_extensions_enable_height configures the first height - during which - - vote extensions will be enabled. During this specified - height, and for all - - subsequent heights, precommit messages that do not contain - valid extension data - - will be considered invalid. Prior to this height, vote - extensions will not - - be used or accepted by validators on the network. - - - Once enabled, vote extensions will be created by the - application in ExtendVote, - - passed to the application for validation in - VerifyVoteExtension and given - - to the application to use when proposing a block during - PrepareProposal. - description: >- - ABCIParams configure functionality specific to the Application - Blockchain Interface. - description: MsgUpdateParams is the Msg/UpdateParams request type. - tags: - - Msg - /cosmos.crisis.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/crisis - module - - parameters. The authority is defined in the keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosCrisisV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - constant_fee: - description: constant_fee defines the x/crisis parameter. - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.crisis.v1beta1.Msg/VerifyInvariant: - post: - summary: VerifyInvariant defines a method to verify a particular invariant. - operationId: CosmosCrisisV1Beta1Msg_VerifyInvariant - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgVerifyInvariantResponse defines the Msg/VerifyInvariant - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgVerifyInvariant represents a message to verify a particular - invariance. - in: body - required: true - schema: - type: object - properties: - sender: - type: string - description: >- - sender is the account address of private key to send coins to - fee collector account. - invariant_module_name: - type: string - description: name of the invariant module. - invariant_route: - type: string - description: invariant_route is the msg's invariant route. - description: >- - MsgVerifyInvariant represents a message to verify a particular - invariance. - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/CommunityPoolSpend: - post: - summary: >- - CommunityPoolSpend defines a governance operation for sending tokens - from - - the community pool in the x/distribution module to another account, - which - - could be the governance module itself. The authority is defined in the - - keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosDistributionV1Beta1Msg_CommunityPoolSpend - responses: - '200': - description: A successful response. - schema: - type: object - description: |- - MsgCommunityPoolSpendResponse defines the response to executing a - MsgCommunityPoolSpend message. - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgCommunityPoolSpend defines a message for sending tokens from the - community - - pool to another account. This message is typically executed via a - governance - - proposal with the governance module being the executing authority. - - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - recipient: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgCommunityPoolSpend defines a message for sending tokens from - the community - - pool to another account. This message is typically executed via a - governance - - proposal with the governance module being the executing authority. - - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/DepositValidatorRewardsPool: - post: - summary: >- - DepositValidatorRewardsPool defines a method to provide additional - rewards - - to delegators to a specific validator. - description: 'Since: cosmos-sdk 0.50' - operationId: CosmosDistributionV1Beta1Msg_DepositValidatorRewardsPool - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgDepositValidatorRewardsPoolResponse defines the response to - executing a - - MsgDepositValidatorRewardsPool message. - - - Since: cosmos-sdk 0.50 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - DepositValidatorRewardsPool defines the request structure to provide - additional rewards to delegators from a specific validator. - - Since: cosmos-sdk 0.50 - in: body - required: true - schema: - type: object - properties: - depositor: - type: string - validator_address: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - DepositValidatorRewardsPool defines the request structure to - provide - - additional rewards to delegators from a specific validator. - - - Since: cosmos-sdk 0.50 - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/FundCommunityPool: - post: - summary: |- - FundCommunityPool defines a method to allow an account to directly - fund the community pool. - operationId: CosmosDistributionV1Beta1Msg_FundCommunityPool - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgFundCommunityPool allows an account to directly - fund the community pool. - in: body - required: true - schema: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - depositor: - type: string - description: |- - MsgFundCommunityPool allows an account to directly - fund the community pool. - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/SetWithdrawAddress: - post: - summary: |- - SetWithdrawAddress defines a method to change the withdraw address - for a delegator (or validator self-delegation). - operationId: CosmosDistributionV1Beta1Msg_SetWithdrawAddress - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress - response - - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgSetWithdrawAddress sets the withdraw address for - a delegator (or validator self-delegation). - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - withdraw_address: - type: string - description: |- - MsgSetWithdrawAddress sets the withdraw address for - a delegator (or validator self-delegation). - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the - x/distribution - - module parameters. The authority is defined in the keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosDistributionV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/distribution parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - community_tax: - type: string - base_proposer_reward: - type: string - description: >- - Deprecated: The base_proposer_reward field is deprecated - and is no longer used - - in the x/distribution module's reward mechanism. - bonus_proposer_reward: - type: string - description: >- - Deprecated: The bonus_proposer_reward field is deprecated - and is no longer used - - in the x/distribution module's reward mechanism. - withdraw_addr_enabled: - type: boolean - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/WithdrawDelegatorReward: - post: - summary: >- - WithdrawDelegatorReward defines a method to withdraw rewards of - delegator - - from a single validator. - operationId: CosmosDistributionV1Beta1Msg_WithdrawDelegatorReward - responses: - '200': - description: A successful response. - schema: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: 'Since: cosmos-sdk 0.46' - description: >- - MsgWithdrawDelegatorRewardResponse defines the - Msg/WithdrawDelegatorReward - - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgWithdrawDelegatorReward represents delegation withdrawal to a - delegator - - from a single validator. - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - description: >- - MsgWithdrawDelegatorReward represents delegation withdrawal to a - delegator - - from a single validator. - tags: - - Msg - /cosmos.distribution.v1beta1.Msg/WithdrawValidatorCommission: - post: - summary: |- - WithdrawValidatorCommission defines a method to withdraw the - full commission to the validator address. - operationId: CosmosDistributionV1Beta1Msg_WithdrawValidatorCommission - responses: - '200': - description: A successful response. - schema: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: 'Since: cosmos-sdk 0.46' - description: |- - MsgWithdrawValidatorCommissionResponse defines the - Msg/WithdrawValidatorCommission response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgWithdrawValidatorCommission withdraws the full commission to the - validator - - address. - in: body - required: true - schema: - type: object - properties: - validator_address: - type: string - description: >- - MsgWithdrawValidatorCommission withdraws the full commission to - the validator - - address. - tags: - - Msg - /cosmos.evidence.v1beta1.Msg/SubmitEvidence: - post: - summary: >- - SubmitEvidence submits an arbitrary Evidence of misbehavior such as - equivocation or - - counterfactual signing. - operationId: CosmosEvidenceV1Beta1Msg_SubmitEvidence - responses: - '200': - description: A successful response. - schema: - type: object - properties: - hash: - type: string - format: byte - description: hash defines the hash of the evidence. - description: >- - MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgSubmitEvidence represents a message that supports submitting - arbitrary - - Evidence of misbehavior such as equivocation or counterfactual - signing. - in: body - required: true - schema: - type: object - properties: - submitter: - type: string - description: submitter is the signer account address of evidence. - evidence: - description: evidence defines the evidence of misbehavior. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - MsgSubmitEvidence represents a message that supports submitting - arbitrary - - Evidence of misbehavior such as equivocation or counterfactual - signing. - tags: - - Msg - /cosmos.feegrant.v1beta1.Msg/GrantAllowance: - post: - summary: |- - GrantAllowance grants fee allowance to the grantee on the granter's - account with the provided expiration time. - operationId: CosmosFeegrantV1Beta1Msg_GrantAllowance - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgGrantAllowance adds permission for Grantee to spend up to - Allowance - - of fees from the account of Granter. - in: body - required: true - schema: - type: object - properties: - granter: - type: string - description: >- - granter is the address of the user granting an allowance of - their funds. - grantee: - type: string - description: >- - grantee is the address of the user being granted an allowance - of another user's funds. - allowance: - description: >- - allowance can be any of basic, periodic, allowed fee - allowance. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - MsgGrantAllowance adds permission for Grantee to spend up to - Allowance - - of fees from the account of Granter. - tags: - - Msg - /cosmos.feegrant.v1beta1.Msg/PruneAllowances: - post: - summary: >- - PruneAllowances prunes expired fee allowances, currently up to 75 at a - time. - description: Since cosmos-sdk 0.50 - operationId: CosmosFeegrantV1Beta1Msg_PruneAllowances - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgPruneAllowancesResponse defines the Msg/PruneAllowancesResponse - response type. - - - Since cosmos-sdk 0.50 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgPruneAllowances prunes expired fee allowances. - - Since cosmos-sdk 0.50 - in: body - required: true - schema: - type: object - properties: - pruner: - type: string - description: pruner is the address of the user pruning expired allowances. - description: |- - MsgPruneAllowances prunes expired fee allowances. - - Since cosmos-sdk 0.50 - tags: - - Msg - /cosmos.feegrant.v1beta1.Msg/RevokeAllowance: - post: - summary: |- - RevokeAllowance revokes any fee allowance of granter's account that - has been granted to the grantee. - operationId: CosmosFeegrantV1Beta1Msg_RevokeAllowance - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgRevokeAllowance removes any existing Allowance from Granter to - Grantee. - in: body - required: true - schema: - type: object - properties: - granter: - type: string - description: >- - granter is the address of the user granting an allowance of - their funds. - grantee: - type: string - description: >- - grantee is the address of the user being granted an allowance - of another user's funds. - description: >- - MsgRevokeAllowance removes any existing Allowance from Granter to - Grantee. - tags: - - Msg - /cosmos.gov.v1.Msg/CancelProposal: - post: - summary: CancelProposal defines a method to cancel governance proposal - description: 'Since: cosmos-sdk 0.50' - operationId: CosmosGovV1Msg_CancelProposal - responses: - '200': - description: A successful response. - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - canceled_time: - type: string - format: date-time - description: canceled_time is the time when proposal is canceled. - canceled_height: - type: string - format: uint64 - description: >- - canceled_height defines the block height at which the proposal - is canceled. - description: >- - MsgCancelProposalResponse defines the response structure for - executing a - - MsgCancelProposal message. - - - Since: cosmos-sdk 0.50 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgCancelProposal is the Msg/CancelProposal request type. - - Since: cosmos-sdk 0.50 - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - proposer: - type: string - description: proposer is the account address of the proposer. - description: |- - MsgCancelProposal is the Msg/CancelProposal request type. - - Since: cosmos-sdk 0.50 - tags: - - Msg - /cosmos.gov.v1.Msg/Deposit: - post: - summary: Deposit defines a method to add deposit on a specific proposal. - operationId: CosmosGovV1Msg_Deposit - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgDepositResponse defines the Msg/Deposit response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgDeposit defines a message to submit a deposit to an existing - proposal. - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - depositor: - type: string - description: depositor defines the deposit addresses from the proposals. - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: amount to be deposited by depositor. - description: >- - MsgDeposit defines a message to submit a deposit to an existing - proposal. - tags: - - Msg - /cosmos.gov.v1.Msg/ExecLegacyContent: - post: - summary: |- - ExecLegacyContent defines a Msg to be in included in a MsgSubmitProposal - to execute a legacy content-based proposal. - operationId: CosmosGovV1Msg_ExecLegacyContent - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgExecLegacyContentResponse defines the Msg/ExecLegacyContent - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgExecLegacyContent is used to wrap the legacy content field into a - message. - - This ensures backwards compatibility with v1beta1.MsgSubmitProposal. - in: body - required: true - schema: - type: object - properties: - content: - description: content is the proposal's content. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - authority: - type: string - description: authority must be the gov module address. - description: >- - MsgExecLegacyContent is used to wrap the legacy content field into - a message. - - This ensures backwards compatibility with - v1beta1.MsgSubmitProposal. - tags: - - Msg - /cosmos.gov.v1.Msg/SubmitProposal: - post: - summary: >- - SubmitProposal defines a method to create new proposal given the - messages. - operationId: CosmosGovV1Msg_SubmitProposal - responses: - '200': - description: A successful response. - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - description: >- - MsgSubmitProposalResponse defines the Msg/SubmitProposal response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - in: body - required: true - schema: - type: object - properties: - messages: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: >- - messages are the arbitrary messages to be executed if proposal - passes. - initial_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - initial_deposit is the deposit value that must be paid at - proposal submission. - proposer: - type: string - description: proposer is the account address of the proposer. - metadata: - type: string - description: metadata is any arbitrary metadata attached to the proposal. - title: - type: string - description: |- - title is the title of the proposal. - - Since: cosmos-sdk 0.47 - summary: - type: string - description: 'Since: cosmos-sdk 0.47' - title: summary is the summary of the proposal - expedited: - type: boolean - description: 'Since: cosmos-sdk 0.50' - title: expedited defines if the proposal is expedited or not - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - tags: - - Msg - /cosmos.gov.v1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/gov - module - - parameters. The authority is defined in the keeper. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosGovV1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/gov parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - description: Minimum deposit for a proposal to enter voting period. - max_deposit_period: - type: string - description: >- - Maximum period for Atom holders to deposit on a proposal. - Initial value: 2 - - months. - voting_period: - type: string - description: Duration of the voting period. - quorum: - type: string - description: >- - Minimum percentage of total stake needed to vote for a - result to be - considered valid. - threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. - Default value: 0.5. - veto_threshold: - type: string - description: >- - Minimum value of Veto votes to Total votes ratio for - proposal to be - vetoed. Default value: 1/3. - min_initial_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value - that must be paid at proposal submission. - proposal_cancel_ratio: - type: string - description: >- - The cancel ratio which will not be returned back to the - depositors when a proposal is cancelled. - - - Since: cosmos-sdk 0.50 - proposal_cancel_dest: - type: string - description: >- - The address which will receive (proposal_cancel_ratio * - deposit) proposal deposits. - - If empty, the (proposal_cancel_ratio * deposit) proposal - deposits will be burned. - - - Since: cosmos-sdk 0.50 - expedited_voting_period: - type: string - description: |- - Duration of the voting period of an expedited proposal. - - Since: cosmos-sdk 0.50 - expedited_threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. - Default value: 0.67. - - - Since: cosmos-sdk 0.50 - expedited_min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - description: >- - Minimum expedited deposit for a proposal to enter voting - period. - burn_vote_quorum: - type: boolean - title: burn deposits if a proposal does not meet quorum - burn_proposal_deposit_prevote: - type: boolean - title: burn deposits if the proposal does not enter voting period - burn_vote_veto: - type: boolean - title: burn deposits if quorum with vote type no_veto is met - min_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value - minimum that must be met when making a deposit. - - Default value: 0.01. Meaning that for a chain with a - min_deposit of 100stake, a deposit of 1stake would be - - required. - - - Since: cosmos-sdk 0.50 - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.gov.v1.Msg/Vote: - post: - summary: Vote defines a method to add a vote on a specific proposal. - operationId: CosmosGovV1Msg_Vote - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgVoteResponse defines the Msg/Vote response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: MsgVote defines a message to cast a vote. - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - option: - description: option defines the vote option. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - metadata: - type: string - description: metadata is any arbitrary metadata attached to the Vote. - description: MsgVote defines a message to cast a vote. - tags: - - Msg - /cosmos.gov.v1.Msg/VoteWeighted: - post: - summary: >- - VoteWeighted defines a method to add a weighted vote on a specific - proposal. - operationId: CosmosGovV1Msg_VoteWeighted - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgVoteWeightedResponse defines the Msg/VoteWeighted response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: MsgVoteWeighted defines a message to cast a vote. - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - options: - type: array - items: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not - contain duplicate vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: >- - weight is the vote weight associated with the vote - option. - description: WeightedVoteOption defines a unit of vote for vote split. - description: options defines the weighted vote options. - metadata: - type: string - description: >- - metadata is any arbitrary metadata attached to the - VoteWeighted. - description: MsgVoteWeighted defines a message to cast a vote. - tags: - - Msg - /cosmos.gov.v1beta1.Msg/Deposit: - post: - summary: Deposit defines a method to add deposit on a specific proposal. - operationId: CosmosGovV1Beta1Msg_Deposit - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgDepositResponse defines the Msg/Deposit response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgDeposit defines a message to submit a deposit to an existing - proposal. - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - depositor: - type: string - description: depositor defines the deposit addresses from the proposals. - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: amount to be deposited by depositor. - description: >- - MsgDeposit defines a message to submit a deposit to an existing - proposal. - tags: - - Msg - /cosmos.gov.v1beta1.Msg/SubmitProposal: - post: - summary: SubmitProposal defines a method to create new proposal given a content. - operationId: CosmosGovV1Beta1Msg_SubmitProposal - responses: - '200': - description: A successful response. - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - description: >- - MsgSubmitProposalResponse defines the Msg/SubmitProposal response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - in: body - required: true - schema: - type: object - properties: - content: - description: content is the proposal's content. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - initial_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - initial_deposit is the deposit value that must be paid at - proposal submission. - proposer: - type: string - description: proposer is the account address of the proposer. - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - tags: - - Msg - /cosmos.gov.v1beta1.Msg/Vote: - post: - summary: Vote defines a method to add a vote on a specific proposal. - operationId: CosmosGovV1Beta1Msg_Vote - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgVoteResponse defines the Msg/Vote response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: MsgVote defines a message to cast a vote. - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - option: - description: option defines the vote option. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - description: MsgVote defines a message to cast a vote. - tags: - - Msg - /cosmos.gov.v1beta1.Msg/VoteWeighted: - post: - summary: >- - VoteWeighted defines a method to add a weighted vote on a specific - proposal. - description: 'Since: cosmos-sdk 0.43' - operationId: CosmosGovV1Beta1Msg_VoteWeighted - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgVoteWeightedResponse defines the Msg/VoteWeighted response - type. - - - Since: cosmos-sdk 0.43 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgVoteWeighted defines a message to cast a vote. - - Since: cosmos-sdk 0.43 - in: body - required: true - schema: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - options: - type: array - items: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not - contain duplicate vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: >- - weight is the vote weight associated with the vote - option. - description: |- - WeightedVoteOption defines a unit of vote for vote split. - - Since: cosmos-sdk 0.43 - description: options defines the weighted vote options. - description: |- - MsgVoteWeighted defines a message to cast a vote. - - Since: cosmos-sdk 0.43 - tags: - - Msg - /cosmos.mint.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/mint - module - - parameters. The authority is defaults to the x/gov module account. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosMintV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/mint parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - mint_denom: - type: string - title: type of coin to mint - inflation_rate_change: - type: string - title: maximum annual change in inflation rate - inflation_max: - type: string - title: maximum inflation rate - inflation_min: - type: string - title: minimum inflation rate - goal_bonded: - type: string - title: goal of percent bonded atoms - blocks_per_year: - type: string - format: uint64 - title: expected blocks per year - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.nft.v1beta1.Msg/Send: - post: - summary: Send defines a method to send a nft from one account to another account. - operationId: CosmosNftV1Beta1Msg_Send - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgSendResponse defines the Msg/Send response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: >- - MsgSend represents a message to send a nft from one account to - another account. - in: body - required: true - schema: - type: object - properties: - class_id: - type: string - title: >- - class_id defines the unique identifier of the nft - classification, similar to the contract address of ERC721 - id: - type: string - title: id defines the unique identification of nft - sender: - type: string - title: sender is the address of the owner of nft - receiver: - type: string - title: receiver is the receiver address of nft - description: >- - MsgSend represents a message to send a nft from one account to - another account. - tags: - - Msg - /cosmos/params/v1beta1/params: - get: - summary: |- - Params queries a specific parameter of a module, given its subspace and - key. - operationId: CosmosParamsV1Beta1Query_Params - responses: - '200': - description: A successful response. - schema: - type: object - properties: - param: - description: param defines the queried parameter. - type: object - properties: - subspace: - type: string - key: - type: string - value: - type: string - description: >- - QueryParamsResponse is response type for the Query/Params RPC - method. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: subspace - description: subspace defines the module to query the parameter for. - in: query - required: false - type: string - - name: key - description: key defines the key of the parameter in the subspace. - in: query - required: false - type: string - tags: - - Query - /cosmos/params/v1beta1/subspaces: - get: - summary: >- - Subspaces queries for all registered subspaces and all keys for a - subspace. - description: 'Since: cosmos-sdk 0.46' - operationId: CosmosParamsV1Beta1Query_Subspaces - responses: - '200': - description: A successful response. - schema: - type: object - properties: - subspaces: - type: array - items: - type: object - properties: - subspace: - type: string - keys: - type: array - items: - type: string - description: >- - Subspace defines a parameter subspace name and all the keys - that exist for - - the subspace. - - - Since: cosmos-sdk 0.46 - description: >- - QuerySubspacesResponse defines the response types for querying for - all - - registered subspaces and all keys for a subspace. - - - Since: cosmos-sdk 0.46 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - tags: - - Query - /cosmos.slashing.v1beta1.Msg/Unjail: - post: - summary: >- - 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. - operationId: CosmosSlashingV1Beta1Msg_Unjail - responses: - '200': - description: A successful response. - schema: - type: object - title: MsgUnjailResponse defines the Msg/Unjail response type - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - validator_addr: - type: string - title: MsgUnjail defines the Msg/Unjail request type - tags: - - Msg - /cosmos.slashing.v1beta1.Msg/UpdateParams: - post: - summary: >- - UpdateParams defines a governance operation for updating the x/slashing - module - - parameters. The authority defaults to the x/gov module account. - description: 'Since: cosmos-sdk 0.47' - operationId: CosmosSlashingV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/slashing parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - signed_blocks_window: - type: string - format: int64 - min_signed_per_window: - type: string - format: byte - downtime_jail_duration: - type: string - slash_fraction_double_sign: - type: string - format: byte - slash_fraction_downtime: - type: string - format: byte - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /cosmos.staking.v1beta1.Msg/BeginRedelegate: - post: - summary: >- - BeginRedelegate defines a method for performing a redelegation - - of coins from a delegator and source validator to a destination - validator. - operationId: CosmosStakingV1Beta1Msg_BeginRedelegate - responses: - '200': - description: A successful response. - schema: - type: object - properties: - completion_time: - type: string - format: date-time - description: >- - MsgBeginRedelegateResponse defines the Msg/BeginRedelegate - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgBeginRedelegate defines a SDK message for performing a - redelegation - - of coins from a delegator and source validator to a destination - validator. - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgBeginRedelegate defines a SDK message for performing a - redelegation - - of coins from a delegator and source validator to a destination - validator. - tags: - - Msg - /cosmos.staking.v1beta1.Msg/CancelUnbondingDelegation: - post: - summary: >- - CancelUnbondingDelegation defines a method for performing canceling the - unbonding delegation - - and delegate back to previous validator. - description: 'Since: cosmos-sdk 0.46' - operationId: CosmosStakingV1Beta1Msg_CancelUnbondingDelegation - responses: - '200': - description: A successful response. - schema: - type: object - description: 'Since: cosmos-sdk 0.46' - title: MsgCancelUnbondingDelegationResponse - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: 'Since: cosmos-sdk 0.46' - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: >- - amount is always less than or equal to unbonding delegation - entry balance - creation_height: - type: string - format: int64 - description: creation_height is the height which the unbonding took place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for - performing a cancel unbonding delegation for delegator - tags: - - Msg - /cosmos.staking.v1beta1.Msg/CreateValidator: - post: - summary: CreateValidator defines a method for creating a new validator. - operationId: CosmosStakingV1Beta1Msg_CreateValidator - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgCreateValidatorResponse defines the Msg/CreateValidator - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgCreateValidator defines a SDK message for creating a new - validator. - in: body - required: true - schema: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort - or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for security - contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: >- - rate is the commission rate charged to delegators, as a - fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which - validator can ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the - validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be - used for creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator is - deprecated. - - The validator address bytes and delegator address bytes refer - to the same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - value: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgCreateValidator defines a SDK message for creating a new - validator. - tags: - - Msg - /cosmos.staking.v1beta1.Msg/Delegate: - post: - summary: |- - Delegate defines a method for performing a delegation of coins - from a delegator to a validator. - operationId: CosmosStakingV1Beta1Msg_Delegate - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgDelegateResponse defines the Msg/Delegate response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgDelegate defines a SDK message for performing a delegation of - coins - - from a delegator to a validator. - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgDelegate defines a SDK message for performing a delegation of - coins - - from a delegator to a validator. - tags: - - Msg - /cosmos.staking.v1beta1.Msg/EditValidator: - post: - summary: EditValidator defines a method for editing an existing validator. - operationId: CosmosStakingV1Beta1Msg_EditValidator - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgEditValidatorResponse defines the Msg/EditValidator response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgEditValidator defines a SDK message for editing an existing - validator. - in: body - required: true - schema: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort - or Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: >- - security_contact defines an optional email for security - contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - validator_address: - type: string - commission_rate: - type: string - title: >- - 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 - min_self_delegation: - type: string - description: >- - MsgEditValidator defines a SDK message for editing an existing - validator. - tags: - - Msg - /cosmos.staking.v1beta1.Msg/Undelegate: - post: - summary: |- - Undelegate defines a method for performing an undelegation from a - delegate and a validator. - operationId: CosmosStakingV1Beta1Msg_Undelegate - responses: - '200': - description: A successful response. - schema: - type: object - properties: - completion_time: - type: string - format: date-time - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: amount returns the amount of undelegated coins - description: MsgUndelegateResponse defines the Msg/Undelegate response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgUndelegate defines a SDK message for performing an undelegation - from a - - delegate and a validator. - in: body - required: true - schema: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: >- - MsgUndelegate defines a SDK message for performing an undelegation - from a - - delegate and a validator. - tags: - - Msg - /cosmos.staking.v1beta1.Msg/UpdateParams: - post: - summary: |- - UpdateParams defines an operation for updating the x/staking module - parameters. - Since: cosmos-sdk 0.47 - operationId: CosmosStakingV1Beta1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - - - Since: cosmos-sdk 0.47 - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - in: body - required: true - schema: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to - x/gov unless overwritten). - params: - description: |- - params defines the x/staking parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - unbonding_time: - type: string - description: unbonding_time is the time duration of unbonding. - max_validators: - type: integer - format: int64 - description: max_validators is the maximum number of validators. - max_entries: - type: integer - format: int64 - description: >- - max_entries is the max entries for either unbonding - delegation or redelegation (per pair/trio). - historical_entries: - type: integer - format: int64 - description: >- - historical_entries is the number of historical entries to - persist. - bond_denom: - type: string - description: bond_denom defines the bondable coin denomination. - min_commission_rate: - type: string - title: >- - min_commission_rate is the chain-wide minimum commission - rate that a validator can charge their delegators - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - tags: - - Msg - /ibc.applications.fee.v1.Msg/PayPacketFee: - post: - summary: >- - PayPacketFee defines a rpc handler method for MsgPayPacketFee - - PayPacketFee is an open callback that may be called by any module/user - that wishes to escrow funds in order to - - incentivize the relaying of the packet at the next sequence - - NOTE: This method is intended to be used within a multi msg transaction, - where the subsequent msg that follows - - initiates the lifecycle of the incentivized packet - operationId: IbcApplicationsFeeV1Msg_PayPacketFee - responses: - '200': - description: A successful response. - schema: - type: object - title: >- - MsgPayPacketFeeResponse defines the response type for the - PayPacketFee rpc - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated - with an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the - custom method - - signatures required by gogoproto. - title: the packet timeout fee - source_port_id: - type: string - title: the source port unique identifier - source_channel_id: - type: string - title: the source channel unique identifer - signer: - type: string - title: account address to refund fee if necessary - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to the receive packet fees - title: >- - MsgPayPacketFee defines the request type for the PayPacketFee rpc - - This Msg can be used to pay for a packet at the next sequence send - & should be combined with the Msg that will be - - paid for - tags: - - Msg - /ibc.applications.fee.v1.Msg/PayPacketFeeAsync: - post: - summary: >- - PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync - - PayPacketFeeAsync is an open callback that may be called by any - module/user that wishes to escrow funds in order to - - incentivize the relaying of a known packet (i.e. at a particular - sequence) - operationId: IbcApplicationsFeeV1Msg_PayPacketFeeAsync - responses: - '200': - description: A successful response. - schema: - type: object - title: >- - MsgPayPacketFeeAsyncResponse defines the response type for the - PayPacketFeeAsync rpc - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID - and sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fee: - title: the packet fee associated with a particular IBC packet - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated - with an IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. - - - NOTE: The amount field is an Int which implements - the custom method - - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. - - - NOTE: The amount field is an Int which implements - the custom method - - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an - amount. - - - NOTE: The amount field is an Int which implements - the custom method - - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - MsgPayPacketFeeAsync defines the request type for the - PayPacketFeeAsync rpc - - This Msg can be used to pay for a packet at a specified sequence - (instead of the next sequence send) - tags: - - Msg - /ibc.applications.fee.v1.Msg/RegisterCounterpartyPayee: - post: - summary: >- - RegisterCounterpartyPayee defines a rpc handler method for - MsgRegisterCounterpartyPayee - - RegisterCounterpartyPayee is called by the relayer on each channelEnd - and allows them to specify the counterparty - - payee address before relaying. This ensures they will be properly - compensated for forward relaying since - - the destination chain must include the registered counterparty payee - address in the acknowledgement. This function - - may be called more than once by a relayer, in which case, the latest - counterparty payee address is always used. - operationId: IbcApplicationsFeeV1Msg_RegisterCounterpartyPayee - responses: - '200': - description: A successful response. - schema: - type: object - title: >- - MsgRegisterCounterpartyPayeeResponse defines the response type for - the RegisterCounterpartyPayee rpc - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - relayer: - type: string - title: the relayer address - counterparty_payee: - type: string - title: the counterparty payee address - title: >- - MsgRegisterCounterpartyPayee defines the request type for the - RegisterCounterpartyPayee rpc - tags: - - Msg - /ibc.applications.fee.v1.Msg/RegisterPayee: - post: - summary: >- - RegisterPayee defines a rpc handler method for MsgRegisterPayee - - RegisterPayee is called by the relayer on each channelEnd and allows - them to set an optional - - payee to which reverse and timeout relayer packet fees will be paid out. - The payee should be registered on - - the source chain from which packets originate as this is where fee - distribution takes place. This function may be - - called more than once by a relayer, in which case, the latest payee is - always used. - operationId: IbcApplicationsFeeV1Msg_RegisterPayee - responses: - '200': - description: A successful response. - schema: - type: object - title: >- - MsgRegisterPayeeResponse defines the response type for the - RegisterPayee rpc - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - relayer: - type: string - title: the relayer address - payee: - type: string - title: the payee address - title: >- - MsgRegisterPayee defines the request type for the RegisterPayee - rpc - tags: - - Msg - /ibc.applications.interchain_accounts.controller.v1.Msg/RegisterInterchainAccount: - post: - summary: >- - RegisterInterchainAccount defines a rpc handler for - MsgRegisterInterchainAccount. - operationId: >- - IbcApplicationsInterchainAccountsControllerV1Msg_RegisterInterchainAccount - responses: - '200': - description: A successful response. - schema: - type: object - properties: - channel_id: - type: string - port_id: - type: string - title: >- - MsgRegisterInterchainAccountResponse defines the response for - Msg/RegisterAccount - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - owner: - type: string - connection_id: - type: string - version: - type: string - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - title: >- - MsgRegisterInterchainAccount defines the payload for - Msg/RegisterAccount - tags: - - Msg - /ibc.applications.interchain_accounts.controller.v1.Msg/SendTx: - post: - summary: SendTx defines a rpc handler for MsgSendTx. - operationId: IbcApplicationsInterchainAccountsControllerV1Msg_SendTx - responses: - '200': - description: A successful response. - schema: - type: object - properties: - sequence: - type: string - format: uint64 - title: MsgSendTxResponse defines the response for MsgSendTx - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - owner: - type: string - connection_id: - type: string - packet_data: - type: object - properties: - type: - type: string - enum: - - TYPE_UNSPECIFIED - - TYPE_EXECUTE_TX - default: TYPE_UNSPECIFIED - description: |- - - TYPE_UNSPECIFIED: Default zero value enumeration - - TYPE_EXECUTE_TX: Execute a transaction on an interchain accounts host chain - title: >- - Type defines a classification of message issued from a - controller chain to its associated interchain accounts - - host - data: - type: string - format: byte - memo: - type: string - description: >- - InterchainAccountPacketData is comprised of a raw transaction, - type of transaction and optional memo field. - relative_timeout: - type: string - format: uint64 - description: >- - Relative timeout timestamp provided will be added to the - current block time during transaction execution. - - The timeout timestamp must be non-zero. - title: MsgSendTx defines the payload for Msg/SendTx - tags: - - Msg - /ibc.applications.interchain_accounts.controller.v1.Msg/UpdateParams: - post: - summary: UpdateParams defines a rpc handler for MsgUpdateParams. - operationId: IbcApplicationsInterchainAccountsControllerV1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - title: MsgUpdateParamsResponse defines the response for Msg/UpdateParams - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - signer: - type: string - title: signer address - params: - description: >- - params defines the 27-interchain-accounts/controller - parameters to update. - - - NOTE: All parameters must be supplied. - type: object - properties: - controller_enabled: - type: boolean - description: >- - controller_enabled enables or disables the controller - submodule. - title: MsgUpdateParams defines the payload for Msg/UpdateParams - tags: - - Msg - /ibc.applications.interchain_accounts.host.v1.Msg/UpdateParams: - post: - summary: UpdateParams defines a rpc handler for MsgUpdateParams. - operationId: IbcApplicationsInterchainAccountsHostV1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - title: MsgUpdateParamsResponse defines the response for Msg/UpdateParams - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - additionalProperties: {} - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - signer: - type: string - title: signer address - params: - description: >- - params defines the 27-interchain-accounts/host parameters to - update. - - - NOTE: All parameters must be supplied. - type: object - properties: - host_enabled: - type: boolean - description: host_enabled enables or disables the host submodule. - allow_messages: - type: array - items: - type: string - description: >- - allow_messages defines a list of sdk message typeURLs - allowed to be executed on a host chain. - title: MsgUpdateParams defines the payload for Msg/UpdateParams - tags: - - Msg - /ibc.applications.transfer.v1.Msg/Transfer: - post: - summary: Transfer defines a rpc handler method for MsgTransfer. - operationId: IbcApplicationsTransferV1Msg_Transfer - responses: - '200': - description: A successful response. - schema: - type: object - properties: - sequence: - type: string - format: uint64 - title: sequence number of the transfer packet sent - description: MsgTransferResponse defines the Msg/Transfer response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - source_port: - type: string - title: the port on which the packet will be sent - source_channel: - type: string - title: the channel by which the packet will be sent - token: - title: the tokens to be transferred - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - sender: - type: string - title: the sender address - receiver: - type: string - title: the recipient address on the destination chain - timeout_height: - description: |- - Timeout height relative to the current block height. - The timeout is disabled when set to 0. - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - timeout_timestamp: - type: string - format: uint64 - description: |- - Timeout timestamp in absolute nanoseconds since unix epoch. - The timeout is disabled when set to 0. - memo: - type: string - title: optional memo - title: >- - MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) - between - - ICS20 enabled chains. See ICS Spec here: - - https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures - tags: - - Msg - /ibc.applications.transfer.v1.Msg/UpdateParams: - post: - summary: UpdateParams defines a rpc handler for MsgUpdateParams. - operationId: IbcApplicationsTransferV1Msg_UpdateParams - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateParamsResponse defines the response structure for - executing a - - MsgUpdateParams message. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: MsgUpdateParams is the Msg/UpdateParams request type. - in: body - required: true - schema: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the transfer parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - send_enabled: - type: boolean - description: >- - send_enabled enables or disables all cross-chain token - transfers from this - - chain. - receive_enabled: - type: boolean - description: >- - receive_enabled enables or disables all cross-chain token - transfers to this - - chain. - description: MsgUpdateParams is the Msg/UpdateParams request type. - tags: - - Msg - /ibc.core.client.v1.Msg/CreateClient: - post: - summary: CreateClient defines a rpc handler method for MsgCreateClient. - operationId: IbcCoreClientV1Msg_CreateClient - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgCreateClientResponse defines the Msg/CreateClient response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - client_state: - title: light client state - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - consensus_state: - description: >- - consensus state associated with the client that corresponds to - a given - - height. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - signer: - type: string - title: signer address - title: MsgCreateClient defines a message to create an IBC client - tags: - - Msg - /ibc.core.client.v1.Msg/IBCSoftwareUpgrade: - post: - summary: >- - IBCSoftwareUpgrade defines a rpc handler method for - MsgIBCSoftwareUpgrade. - operationId: IbcCoreClientV1Msg_IBCSoftwareUpgrade - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgIBCSoftwareUpgradeResponse defines the Msg/IBCSoftwareUpgrade - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - plan: - type: object - properties: - name: - type: string - description: >- - 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. - time: - type: string - format: date-time - description: >- - Deprecated: Time based upgrades have been deprecated. Time - based upgrade logic - - has been removed from the SDK. - - If this field is not empty, an error will be thrown. - height: - type: string - format: int64 - description: The height at which the upgrade must be performed. - info: - type: string - title: >- - Any application specific upgrade info to be included - on-chain - - such as a git commit that validators could automatically - upgrade to - upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. - IBC upgrade logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type - of the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be - in a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can - optionally set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results - based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no - widely used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty - scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - Plan specifies information about a planned upgrade and when it - should occur. - upgraded_client_state: - description: >- - An UpgradedClientState must be provided to perform an IBC - breaking upgrade. - - 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. Correspondingly, the - UpgradedClientState field has been - - deprecated in the Cosmos SDK to allow for this logic to exist - solely in - - the 02-client module. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - signer: - type: string - title: signer address - title: >- - MsgIBCSoftwareUpgrade defines the message used to schedule an - upgrade of an IBC client using a v1 governance proposal - tags: - - Msg - /ibc.core.client.v1.Msg/RecoverClient: - post: - summary: RecoverClient defines a rpc handler method for MsgRecoverClient. - operationId: IbcCoreClientV1Msg_RecoverClient - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgRecoverClientResponse defines the Msg/RecoverClient response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgRecoverClient defines the message used to recover a frozen or - expired client. - in: body - required: true - schema: - type: object - properties: - subject_client_id: - type: string - title: >- - the client identifier for the client to be updated if the - proposal passes - substitute_client_id: - type: string - title: >- - the substitute client identifier for the client which will - replace the subject - - client - signer: - type: string - title: signer address - description: >- - MsgRecoverClient defines the message used to recover a frozen or - expired client. - tags: - - Msg - /ibc.core.client.v1.Msg/SubmitMisbehaviour: - post: - summary: >- - SubmitMisbehaviour defines a rpc handler method for - MsgSubmitMisbehaviour. - operationId: IbcCoreClientV1Msg_SubmitMisbehaviour - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour - response - - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence - for - - light client misbehaviour. - - This message has been deprecated. Use MsgUpdateClient instead. - in: body - required: true - schema: - type: object - properties: - client_id: - type: string - title: client unique identifier - misbehaviour: - title: misbehaviour used for freezing the light client - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - signer: - type: string - title: signer address - description: >- - MsgSubmitMisbehaviour defines an sdk.Msg type that submits - Evidence for - - light client misbehaviour. - - This message has been deprecated. Use MsgUpdateClient instead. - tags: - - Msg - /ibc.core.client.v1.Msg/UpdateClient: - post: - summary: UpdateClient defines a rpc handler method for MsgUpdateClient. - operationId: IbcCoreClientV1Msg_UpdateClient - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpdateClientResponse defines the Msg/UpdateClient response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgUpdateClient defines an sdk.Msg to update a IBC client state - using - - the given client message. - in: body - required: true - schema: - type: object - properties: - client_id: - type: string - title: client unique identifier - client_message: - title: client message to update the light client - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - signer: - type: string - title: signer address - description: >- - MsgUpdateClient defines an sdk.Msg to update a IBC client state - using - - the given client message. - tags: - - Msg - /ibc.core.client.v1.Msg/UpdateClientParams: - post: - summary: UpdateClientParams defines a rpc handler method for MsgUpdateParams. - operationId: IbcCoreClientV1Msg_UpdateClientParams - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgUpdateParamsResponse defines the MsgUpdateParams response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgUpdateParams defines the sdk.Msg type to update the client - parameters. - in: body - required: true - schema: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the client parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - allowed_clients: - type: array - items: - type: string - description: >- - allowed_clients defines the list of allowed client state - types which can be created - - and interacted with. If a client type is removed from the - allowed clients list, usage - - of this client will be disabled until it is added again to - the list. - description: >- - MsgUpdateParams defines the sdk.Msg type to update the client - parameters. - tags: - - Msg - /ibc.core.client.v1.Msg/UpgradeClient: - post: - summary: UpgradeClient defines a rpc handler method for MsgUpgradeClient. - operationId: IbcCoreClientV1Msg_UpgradeClient - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgUpgradeClientResponse defines the Msg/UpgradeClient response - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - in: body - required: true - schema: - type: object - properties: - client_id: - type: string - title: client unique identifier - client_state: - title: upgraded client state - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - consensus_state: - title: >- - upgraded consensus state, only contains enough information to - serve as a - - basis of trust in update logic - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - proof_upgrade_client: - type: string - format: byte - title: proof that old chain committed to new client - proof_upgrade_consensus_state: - type: string - format: byte - title: proof that old chain committed to new consensus state - signer: - type: string - title: signer address - title: >- - MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a - new client - - state - tags: - - Msg - /ibc.core.connection.v1.Msg/ConnectionOpenAck: - post: - summary: ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. - operationId: IbcCoreConnectionV1Msg_ConnectionOpenAck - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: |- - MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to - acknowledge the change of connection state to TRYOPEN on Chain B. - in: body - required: true - schema: - type: object - properties: - connection_id: - type: string - counterparty_connection_id: - type: string - version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the - IBC verison in - - the connection handshake. - client_state: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - proof_try: - type: string - format: byte - title: >- - proof of the initialization the connection on Chain B: - `UNITIALIZED -> - - TRYOPEN` - proof_client: - type: string - format: byte - title: proof of client state included in message - proof_consensus: - type: string - format: byte - title: proof of client consensus state - consensus_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - signer: - type: string - host_consensus_state_proof: - type: string - format: byte - title: >- - optional proof data for host state machines that are unable to - introspect their own consensus state - description: |- - MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to - acknowledge the change of connection state to TRYOPEN on Chain B. - tags: - - Msg - /ibc.core.connection.v1.Msg/ConnectionOpenConfirm: - post: - summary: |- - ConnectionOpenConfirm defines a rpc handler method for - MsgConnectionOpenConfirm. - operationId: IbcCoreConnectionV1Msg_ConnectionOpenConfirm - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgConnectionOpenConfirmResponse defines the - Msg/ConnectionOpenConfirm - - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B - to - - acknowledge the change of connection state to OPEN on Chain A. - in: body - required: true - schema: - type: object - properties: - connection_id: - type: string - proof_ack: - type: string - format: byte - title: >- - proof for the change of the connection state on Chain A: `INIT - -> OPEN` - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - signer: - type: string - description: >- - MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain - B to - - acknowledge the change of connection state to OPEN on Chain A. - tags: - - Msg - /ibc.core.connection.v1.Msg/ConnectionOpenInit: - post: - summary: >- - ConnectionOpenInit defines a rpc handler method for - MsgConnectionOpenInit. - operationId: IbcCoreConnectionV1Msg_ConnectionOpenInit - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit - response - - type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgConnectionOpenInit defines the msg sent by an account on Chain A - to - - initialize a connection with Chain B. - in: body - required: true - schema: - type: object - properties: - client_id: - type: string - counterparty: - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated - with a given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain - associated with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - description: >- - Counterparty defines the counterparty chain associated with a - connection end. - version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the - IBC verison in - - the connection handshake. - delay_period: - type: string - format: uint64 - signer: - type: string - description: >- - MsgConnectionOpenInit defines the msg sent by an account on Chain - A to - - initialize a connection with Chain B. - tags: - - Msg - /ibc.core.connection.v1.Msg/ConnectionOpenTry: - post: - summary: ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. - operationId: IbcCoreConnectionV1Msg_ConnectionOpenTry - responses: - '200': - description: A successful response. - schema: - type: object - description: >- - MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry - response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgConnectionOpenTry defines a msg sent by a Relayer to try to open - a - - connection on Chain B. - in: body - required: true - schema: - type: object - properties: - client_id: - type: string - previous_connection_id: - type: string - description: >- - Deprecated: this field is unused. Crossing hellos are no - longer supported in core IBC. - client_state: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in - the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - counterparty: - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated - with a given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain - associated with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - description: >- - Counterparty defines the counterparty chain associated with a - connection end. - delay_period: - type: string - format: uint64 - counterparty_versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: >- - list of features compatible with the specified - identifier - description: >- - Version defines the versioning scheme used to negotiate the - IBC verison in - - the connection handshake. - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - proof_init: - type: string - format: byte - title: >- - proof of the initialization the connection on Chain A: - `UNITIALIZED -> - - INIT` - proof_client: - type: string - format: byte - title: proof of client state included in message - proof_consensus: - type: string - format: byte - title: proof of client consensus state - consensus_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height - while keeping - - RevisionNumber the same. However some consensus algorithms may - choose to - - reset the height in certain conditions e.g. hard forks, - state-machine - - breaking changes In these cases, the RevisionNumber is - incremented so that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes - of updating and - - freezing clients - signer: - type: string - host_consensus_state_proof: - type: string - format: byte - title: >- - optional proof data for host state machines that are unable to - introspect their own consensus state - description: >- - MsgConnectionOpenTry defines a msg sent by a Relayer to try to - open a - - connection on Chain B. - tags: - - Msg - /ibc.core.connection.v1.Msg/UpdateConnectionParams: - post: - summary: |- - UpdateConnectionParams defines a rpc handler method for - MsgUpdateParams. - operationId: IbcCoreConnectionV1Msg_UpdateConnectionParams - responses: - '200': - description: A successful response. - schema: - type: object - description: MsgUpdateParamsResponse defines the MsgUpdateParams response type. - default: - description: An unexpected error response. - schema: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of - the serialized - - protocol buffer message. This string must contain at - least - - one "/" character. The last segment of the URL's path - must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in - a canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary - all types that they - - expect it to use in the context of Any. However, for - URLs which use the - - scheme `http`, `https`, or no scheme, one can optionally - set up a type - - server that maps type URLs to message definitions as - follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a - [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based - on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in - the official - - protobuf release, and it is not used for type URLs - beginning with - - type.googleapis.com. As of May 2023, there are no widely - used type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) - might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer - message along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values - in the form - - of utility functions or additional generated methods of the - Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with - an - - additional field `@type` which contains the type URL. - Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom - JSON - - representation, that representation will be embedded adding - a field - - `value` which holds the custom JSON in addition to the - `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - parameters: - - name: body - description: >- - MsgUpdateParams defines the sdk.Msg type to update the connection - parameters. - in: body - required: true - schema: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the connection parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - max_expected_time_per_block: - type: string - format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to - enforce block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably - take to produce the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per - block. - description: >- - MsgUpdateParams defines the sdk.Msg type to update the connection - parameters. - tags: - - Msg -definitions: - google.protobuf.Any: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a canonical - form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types that - they - - expect it to use in the context of Any. However, for URLs which use - the - - scheme `http`, `https`, or no scheme, one can optionally set up a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along with - a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - google.rpc.Status: - type: object - properties: - code: - type: integer - format: int32 - message: - type: string - details: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up - a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. As of May 2023, there are no widely used - type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - artela.evm.ChainConfig: - type: object - properties: - homestead_block: - type: string - title: homestead_block switch (nil no fork, 0 = already homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch block (nil no - fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or opposes the DAO - hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil no - fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only clients as only - gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = already on - byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil no fork, 0 = - already activated) - petersburg_block: - type: string - title: 'petersburg_block: Petersburg switch block (nil same as Constantinople)' - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = already on - istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no fork, 0 - = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already on - berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = already on - london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no - fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no fork, - 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to use as a network - splitter - shanghai_block: - type: string - title: shanghai_block switch block (nil = no fork, 0 = already on shanghai) - cancun_block: - type: string - title: cancun_block switch block (nil = no fork, 0 = already on cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int - values - - instead of *big.Int. - artela.evm.EstimateGasResponse: - type: object - properties: - gas: - type: string - format: uint64 - title: gas returns the estimated gas - title: EstimateGasResponse defines EstimateGas response - artela.evm.GetSenderResponse: - type: object - properties: - sender: - type: string - description: sender defines the from address of the tx. - description: GetSenderResponse returns the from address of tx. - artela.evm.Log: - type: object - properties: - address: - type: string - title: address of the contract that generated the event - topics: - type: array - items: - type: string - description: topics is a list of topics provided by the contract. - data: - type: string - format: byte - title: data which is supplied by the contract, usually ABI-encoded - block_number: - type: string - format: uint64 - title: block_number of the block in which the transaction was included - tx_hash: - type: string - title: tx_hash is the transaction hash - tx_index: - type: string - format: uint64 - title: tx_index of the transaction in the block - block_hash: - type: string - title: block_hash of the block in which the transaction was included - index: - type: string - format: uint64 - title: index of the log in the block - removed: - type: boolean - description: >- - removed is true if this log was reverted due to a chain - - reorganisation. You must pay attention to this field if you receive - logs - - through a filter query. - description: >- - Log represents an protobuf compatible Ethereum Log that defines a contract - - log event. These events are generated by the LOG opcode and stored/indexed - by - - the node. - - - NOTE: address, topics and data are consensus fields. The rest of the - fields - - are derived, i.e. filled in by the nodes, but not secured by consensus. - artela.evm.MsgEthereumTx: - type: object - properties: - data: - title: data is inner transaction data of the Ethereum transaction - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - hash: - type: string - title: hash of the transaction in hex format - from: - type: string - title: >- - from is the ethereum signer address in hex format. This address value - is checked - - against the address derived from the signature (V, R, S) using the - - secp256k1 elliptic curve - description: MsgEthereumTx encapsulates an Ethereum transaction as an SDK message. - artela.evm.MsgEthereumTxResponse: - type: object - properties: - hash: - type: string - title: >- - hash of the ethereum transaction in hex format. This hash differs from - the - - Tendermint sha256 hash of the transaction bytes. See - - https://github.com/tendermint/tendermint/issues/6539 for reference - logs: - type: array - items: - type: object - properties: - address: - type: string - title: address of the contract that generated the event - topics: - type: array - items: - type: string - description: topics is a list of topics provided by the contract. - data: - type: string - format: byte - title: data which is supplied by the contract, usually ABI-encoded - block_number: - type: string - format: uint64 - title: block_number of the block in which the transaction was included - tx_hash: - type: string - title: tx_hash is the transaction hash - tx_index: - type: string - format: uint64 - title: tx_index of the transaction in the block - block_hash: - type: string - title: block_hash of the block in which the transaction was included - index: - type: string - format: uint64 - title: index of the log in the block - removed: - type: boolean - description: >- - removed is true if this log was reverted due to a chain - - reorganisation. You must pay attention to this field if you - receive logs - - through a filter query. - description: >- - Log represents an protobuf compatible Ethereum Log that defines a - contract - - log event. These events are generated by the LOG opcode and - stored/indexed by - - the node. - - - NOTE: address, topics and data are consensus fields. The rest of the - fields - - are derived, i.e. filled in by the nodes, but not secured by - consensus. - description: |- - logs contains the transaction hash and the proto-compatible ethereum - logs. - ret: - type: string - format: byte - title: >- - ret is the returned data from evm function (result or data supplied - with revert - - opcode) - vm_error: - type: string - title: vm_error is the error returned by vm execution - gas_used: - type: string - format: uint64 - title: gas_used specifies how much gas was consumed by the transaction - cumulative_gas_used: - type: string - format: uint64 - title: cumulative gas used - description: MsgEthereumTxResponse defines the Msg/EthereumTx response type. - artela.evm.Params: - type: object - properties: - evm_denom: - type: string - description: |- - evm_denom represents the token denomination used to run the EVM state - transitions. - enable_create: - type: boolean - title: >- - enable_create toggles state transitions that use the vm.Create - function - enable_call: - type: boolean - title: enable_call toggles state transitions that use the vm.Call function - extra_eips: - type: array - items: - type: string - format: int64 - title: extra_eips defines the additional EIPs for the vm.Config - chain_config: - title: chain_config defines the EVM chain configuration parameters - type: object - properties: - homestead_block: - type: string - title: homestead_block switch (nil no fork, 0 = already homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch block (nil - no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or opposes the - DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil - no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only clients as - only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = already - on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil no fork, 0 - = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = already on - istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no - fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already on - berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = already on - london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no - fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no - fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = already on - shanghai) - cancun_block: - type: string - title: cancun_block switch block (nil = no fork, 0 = already on cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int - values - - instead of *big.Int. - allow_unprotected_txs: - type: boolean - description: |- - allow_unprotected_txs defines if replay-protected (i.e non EIP155 - signed) transactions can be executed on the state machine. - description: Params defines the parameters for the module. - artela.evm.QueryAccountResponse: - type: object - properties: - balance: - type: string - description: balance is the balance of the EVM denomination. - code_hash: - type: string - description: code_hash is the hex-formatted code bytes from the EOA. - nonce: - type: string - format: uint64 - description: nonce is the account's sequence number. - description: >- - QueryAccountResponse is the response type for the Query/Account RPC - method. - artela.evm.QueryBalanceResponse: - type: object - properties: - balance: - type: string - description: balance is the balance of the EVM denomination. - description: >- - QueryBalanceResponse is the response type for the Query/Balance RPC - method. - artela.evm.QueryBaseFeeResponse: - type: object - properties: - base_fee: - type: string - title: base_fee is the EIP1559 base fee - description: QueryBaseFeeResponse returns the EIP1559 base fee. - artela.evm.QueryCodeResponse: - type: object - properties: - code: - type: string - format: byte - description: code represents the code bytes from an ethereum address. - description: |- - QueryCodeResponse is the response type for the Query/Code RPC - method. - artela.evm.QueryCosmosAccountResponse: - type: object - properties: - cosmos_address: - type: string - description: cosmos_address is the cosmos address of the account. - sequence: - type: string - format: uint64 - description: sequence is the account's sequence number. - account_number: - type: string - format: uint64 - title: account_number is the account number - description: >- - QueryCosmosAccountResponse is the response type for the - Query/CosmosAccount - - RPC method. - artela.evm.QueryParamsResponse: - type: object - properties: - params: - description: params define the evm module parameters. - type: object - properties: - evm_denom: - type: string - description: >- - evm_denom represents the token denomination used to run the EVM - state - - transitions. - enable_create: - type: boolean - title: >- - enable_create toggles state transitions that use the vm.Create - function - enable_call: - type: boolean - title: >- - enable_call toggles state transitions that use the vm.Call - function - extra_eips: - type: array - items: - type: string - format: int64 - title: extra_eips defines the additional EIPs for the vm.Config - chain_config: - title: chain_config defines the EVM chain configuration parameters - type: object - properties: - homestead_block: - type: string - title: homestead_block switch (nil no fork, 0 = already homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch block - (nil no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or opposes - the DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block - (nil no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only clients as - only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = - already on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil no - fork, 0 = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = - already on istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no - fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already - on berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = already - on london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = - no fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = - no fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = already on - shanghai) - cancun_block: - type: string - title: >- - cancun_block switch block (nil = no fork, 0 = already on - cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters using - *sdk.Int values - - instead of *big.Int. - allow_unprotected_txs: - type: boolean - description: |- - allow_unprotected_txs defines if replay-protected (i.e non EIP155 - signed) transactions can be executed on the state machine. - description: >- - QueryParamsResponse defines the response type for querying x/evm - parameters. - artela.evm.QueryStorageResponse: - type: object - properties: - value: - type: string - description: >- - value defines the storage state value hash associated with the given - key. - description: |- - QueryStorageResponse is the response type for the Query/Storage RPC - method. - artela.evm.QueryTraceBlockResponse: - type: object - properties: - data: - type: string - format: byte - title: data is the response serialized in bytes - title: QueryTraceBlockResponse defines TraceBlock response - artela.evm.QueryTraceTxResponse: - type: object - properties: - data: - type: string - format: byte - title: data is the response serialized in bytes - title: QueryTraceTxResponse defines TraceTx response - artela.evm.QueryValidatorAccountResponse: - type: object - properties: - account_address: - type: string - description: account_address is the cosmos address of the account in bech32 format. - sequence: - type: string - format: uint64 - description: sequence is the account's sequence number. - account_number: - type: string - format: uint64 - title: account_number is the account number - description: |- - QueryValidatorAccountResponse is the response type for the - Query/ValidatorAccount RPC method. - artela.evm.TraceConfig: - type: object - properties: - tracer: - type: string - title: tracer is a custom javascript tracer - timeout: - type: string - title: >- - timeout overrides the default timeout of 5 seconds for - JavaScript-based tracing - - calls - reexec: - type: string - format: uint64 - title: reexec defines the number of blocks the tracer is willing to go back - disable_stack: - type: boolean - title: disable_stack switches stack capture - disable_storage: - type: boolean - title: disable_storage switches storage capture - debug: - type: boolean - title: debug can be used to print output during capture end - limit: - type: integer - format: int32 - title: limit defines the maximum length of output, but zero means unlimited - overrides: - title: overrides can be used to execute a trace using future fork rules - type: object - properties: - homestead_block: - type: string - title: homestead_block switch (nil no fork, 0 = already homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch block (nil - no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or opposes the - DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block (nil - no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only clients as - only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = already - on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil no fork, 0 - = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = already on - istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no - fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already on - berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = already on - london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = no - fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = no - fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = already on - shanghai) - cancun_block: - type: string - title: cancun_block switch block (nil = no fork, 0 = already on cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters using *sdk.Int - values - - instead of *big.Int. - enable_memory: - type: boolean - title: enable_memory switches memory capture - enable_return_data: - type: boolean - title: enable_return_data switches the capture of return data - tracer_json_config: - type: string - title: tracer_json_config configures the tracer using a JSON string - description: TraceConfig holds extra parameters to trace functions. - artela.evm.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - evm_denom: - type: string - description: >- - evm_denom represents the token denomination used to run the EVM - state - - transitions. - enable_create: - type: boolean - title: >- - enable_create toggles state transitions that use the vm.Create - function - enable_call: - type: boolean - title: >- - enable_call toggles state transitions that use the vm.Call - function - extra_eips: - type: array - items: - type: string - format: int64 - title: extra_eips defines the additional EIPs for the vm.Config - chain_config: - title: chain_config defines the EVM chain configuration parameters - type: object - properties: - homestead_block: - type: string - title: homestead_block switch (nil no fork, 0 = already homestead) - dao_fork_block: - type: string - title: >- - dao_fork_block corresponds to TheDAO hard-fork switch block - (nil no fork) - dao_fork_support: - type: boolean - title: >- - dao_fork_support defines whether the nodes supports or opposes - the DAO hard-fork - eip150_block: - type: string - title: >- - eip150_block: EIP150 implements the Gas price changes - - (https://github.com/ethereum/EIPs/issues/150) EIP150 HF block - (nil no fork) - eip150_hash: - type: string - title: >- - eip150_hash: EIP150 HF hash (needed for header only clients as - only gas pricing changed) - eip155_block: - type: string - title: 'eip155_block: EIP155Block HF block' - eip158_block: - type: string - title: 'eip158_block: EIP158 HF block' - byzantium_block: - type: string - title: >- - byzantium_block: Byzantium switch block (nil no fork, 0 = - already on byzantium) - constantinople_block: - type: string - title: >- - constantinople_block: Constantinople switch block (nil no - fork, 0 = already activated) - petersburg_block: - type: string - title: >- - petersburg_block: Petersburg switch block (nil same as - Constantinople) - istanbul_block: - type: string - title: >- - istanbul_block: Istanbul switch block (nil no fork, 0 = - already on istanbul) - muir_glacier_block: - type: string - title: >- - muir_glacier_block: Eip-2384 (bomb delay) switch block (nil no - fork, 0 = already activated) - berlin_block: - type: string - title: >- - berlin_block: Berlin switch block (nil = no fork, 0 = already - on berlin) - london_block: - type: string - title: >- - london_block: London switch block (nil = no fork, 0 = already - on london) - arrow_glacier_block: - type: string - title: >- - arrow_glacier_block: Eip-4345 (bomb delay) switch block (nil = - no fork, 0 = already activated) - gray_glacier_block: - type: string - title: >- - gray_glacier_block: EIP-5133 (bomb delay) switch block (nil = - no fork, 0 = already activated) - merge_netsplit_block: - type: string - title: >- - merge_netsplit_block: Virtual fork after The Merge to use as a - network splitter - shanghai_block: - type: string - title: >- - shanghai_block switch block (nil = no fork, 0 = already on - shanghai) - cancun_block: - type: string - title: >- - cancun_block switch block (nil = no fork, 0 = already on - cancun) - description: >- - ChainConfig defines the Ethereum ChainConfig parameters using - *sdk.Int values - - instead of *big.Int. - allow_unprotected_txs: - type: boolean - description: |- - allow_unprotected_txs defines if replay-protected (i.e non EIP155 - signed) transactions can be executed on the state machine. - description: MsgUpdateParams is the Msg/UpdateParams request type. - artela.evm.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - artela.fee.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the module parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - no_base_fee: - type: boolean - title: >- - no_base_fee forces the EIP-1559 base fee to 0 (needed for 0 price - calls) - base_fee_change_denominator: - type: integer - format: int64 - description: >- - base_fee_change_denominator bounds the amount the base fee can - change - - between blocks. - elasticity_multiplier: - type: integer - format: int64 - description: >- - elasticity_multiplier bounds the maximum gas limit an EIP-1559 - block may - - have. - enable_height: - type: string - format: int64 - description: >- - enable_height defines at which block height the base fee - calculation is enabled. - base_fee: - type: string - description: base_fee for EIP-1559 blocks. - min_gas_price: - type: string - title: >- - min_gas_price defines the minimum gas price value for cosmos and - eth transactions - min_gas_multiplier: - type: string - title: |- - min_gas_multiplier bounds the minimum gas used to be charged - to senders based on gas limit - description: MsgUpdateParams is the Msg/UpdateParams request type. - artela.fee.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - artela.fee.Params: - type: object - properties: - no_base_fee: - type: boolean - title: >- - no_base_fee forces the EIP-1559 base fee to 0 (needed for 0 price - calls) - base_fee_change_denominator: - type: integer - format: int64 - description: |- - base_fee_change_denominator bounds the amount the base fee can change - between blocks. - elasticity_multiplier: - type: integer - format: int64 - description: >- - elasticity_multiplier bounds the maximum gas limit an EIP-1559 block - may - - have. - enable_height: - type: string - format: int64 - description: >- - enable_height defines at which block height the base fee calculation - is enabled. - base_fee: - type: string - description: base_fee for EIP-1559 blocks. - min_gas_price: - type: string - title: >- - min_gas_price defines the minimum gas price value for cosmos and eth - transactions - min_gas_multiplier: - type: string - title: |- - min_gas_multiplier bounds the minimum gas used to be charged - to senders based on gas limit - description: Params defines the parameters for the module. - cosmos.auth.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/auth parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - max_memo_characters: - type: string - format: uint64 - tx_sig_limit: - type: string - format: uint64 - tx_size_cost_per_byte: - type: string - format: uint64 - sig_verify_cost_ed25519: - type: string - format: uint64 - sig_verify_cost_secp256k1: - type: string - format: uint64 - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.auth.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.auth.v1beta1.Params: - type: object - properties: - max_memo_characters: - type: string - format: uint64 - tx_sig_limit: - type: string - format: uint64 - tx_size_cost_per_byte: - type: string - format: uint64 - sig_verify_cost_ed25519: - type: string - format: uint64 - sig_verify_cost_secp256k1: - type: string - format: uint64 - description: Params defines the parameters for the auth module. - cosmos.authz.v1beta1.Grant: - type: object - properties: - authorization: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - expiration: - type: string - format: date-time - title: >- - time when the grant will expire and will be pruned. If null, then the - grant - - doesn't have a time expiration (other conditions in `authorization` - - may apply to invalidate the grant) - description: |- - Grant gives permissions to execute - the provide method with expiration time. - cosmos.authz.v1beta1.MsgExec: - type: object - properties: - grantee: - type: string - msgs: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up - a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. As of May 2023, there are no widely used - type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: >- - Execute Msg. - - The x/authz will try to find a grant matching (msg.signers[0], - grantee, MsgTypeURL(msg)) - - triple and validate it. - description: |- - MsgExec 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. - cosmos.authz.v1beta1.MsgExecResponse: - type: object - properties: - results: - type: array - items: - type: string - format: byte - description: MsgExecResponse defines the Msg/MsgExecResponse response type. - cosmos.authz.v1beta1.MsgGrant: - type: object - properties: - granter: - type: string - grantee: - type: string - grant: - type: object - properties: - authorization: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally set - up a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on - the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. As of May 2023, there are no widely used - type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message - along with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a - field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - expiration: - type: string - format: date-time - title: >- - time when the grant will expire and will be pruned. If null, then - the grant - - doesn't have a time expiration (other conditions in - `authorization` - - may apply to invalidate the grant) - description: |- - Grant gives permissions to execute - the provide method with expiration time. - description: >- - MsgGrant is a request type for Grant method. It declares authorization to - the grantee - - on behalf of the granter with the provided expiration time. - cosmos.authz.v1beta1.MsgGrantResponse: - type: object - description: MsgGrantResponse defines the Msg/MsgGrant response type. - cosmos.authz.v1beta1.MsgRevoke: - type: object - properties: - granter: - type: string - grantee: - type: string - msg_type_url: - type: string - description: |- - MsgRevoke revokes any authorization with the provided sdk.Msg type on the - granter's account with that has been granted to the grantee. - cosmos.authz.v1beta1.MsgRevokeResponse: - type: object - description: MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. - cosmos.bank.v1beta1.Input: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: Input models transaction input. - cosmos.bank.v1beta1.MsgMultiSend: - type: object - properties: - inputs: - type: array - items: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: Input models transaction input. - description: >- - Inputs, despite being `repeated`, only allows one sender input. This - is - - checked in MsgMultiSend's ValidateBasic. - outputs: - type: array - items: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: Output models transaction outputs. - description: MsgMultiSend represents an arbitrary multi-in, multi-out send message. - cosmos.bank.v1beta1.MsgMultiSendResponse: - type: object - description: MsgMultiSendResponse defines the Msg/MultiSend response type. - cosmos.bank.v1beta1.MsgSend: - type: object - properties: - from_address: - type: string - to_address: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: MsgSend represents a message to send coins from one account to another. - cosmos.bank.v1beta1.MsgSendResponse: - type: object - description: MsgSendResponse defines the Msg/Send response type. - cosmos.bank.v1beta1.MsgSetSendEnabled: - type: object - properties: - authority: - type: string - description: authority is the address that controls the module. - send_enabled: - type: array - items: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: >- - SendEnabled maps coin denom to a send_enabled status (whether a - denom is - - sendable). - description: send_enabled is the list of entries to add or update. - use_default_for: - type: array - items: - type: string - description: >- - use_default_for is a list of denoms that should use the - params.default_send_enabled value. - - Denoms listed here will have their SendEnabled entries deleted. - - If a denom is included that doesn't have a SendEnabled entry, - - it will be ignored. - description: |- - MsgSetSendEnabled is the Msg/SetSendEnabled request type. - - Only entries to add/update/delete need to be included. - Existing SendEnabled entries that are not included in this - message are left unchanged. - - Since: cosmos-sdk 0.47 - cosmos.bank.v1beta1.MsgSetSendEnabledResponse: - type: object - description: |- - MsgSetSendEnabledResponse defines the Msg/SetSendEnabled response type. - - Since: cosmos-sdk 0.47 - cosmos.bank.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/bank parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - send_enabled: - type: array - items: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: >- - SendEnabled maps coin denom to a send_enabled status (whether a - denom is - - sendable). - description: >- - Deprecated: Use of SendEnabled in params is deprecated. - - For genesis, use the newly added send_enabled field in the genesis - object. - - Storage, lookup, and manipulation of this information is now in - the keeper. - - - As of cosmos-sdk 0.47, this only exists for backwards - compatibility of genesis files. - default_send_enabled: - type: boolean - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.bank.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.bank.v1beta1.Output: - type: object - properties: - address: - type: string - coins: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: Output models transaction outputs. - cosmos.bank.v1beta1.Params: - type: object - properties: - send_enabled: - type: array - items: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: >- - SendEnabled maps coin denom to a send_enabled status (whether a - denom is - - sendable). - description: >- - Deprecated: Use of SendEnabled in params is deprecated. - - For genesis, use the newly added send_enabled field in the genesis - object. - - Storage, lookup, and manipulation of this information is now in the - keeper. - - - As of cosmos-sdk 0.47, this only exists for backwards compatibility of - genesis files. - default_send_enabled: - type: boolean - description: Params defines the parameters for the bank module. - cosmos.bank.v1beta1.SendEnabled: - type: object - properties: - denom: - type: string - enabled: - type: boolean - description: |- - SendEnabled maps coin denom to a send_enabled status (whether a denom is - sendable). - cosmos.base.v1beta1.Coin: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - cosmos.base.node.v1beta1.ConfigResponse: - type: object - properties: - minimum_gas_price: - type: string - pruning_keep_recent: - type: string - pruning_interval: - type: string - halt_height: - type: string - format: uint64 - description: ConfigResponse defines the response structure for the Config gRPC query. - cosmos.base.node.v1beta1.StatusResponse: - type: object - properties: - earliest_store_height: - type: string - format: uint64 - title: earliest block height available in the store - height: - type: string - format: uint64 - title: current block height - timestamp: - type: string - format: date-time - title: block height timestamp - app_hash: - type: string - format: byte - title: app hash of the current block - validator_hash: - type: string - format: byte - title: validator hash provided by the consensus header - description: StateResponse defines the response structure for the status of a node. - cosmos.consensus.v1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - block: - description: |- - params defines the x/consensus parameters to update. - VersionsParams is not included in this Msg because it is tracked - separarately in x/upgrade. - - NOTE: All parameters must be supplied. - type: object - properties: - max_bytes: - type: string - format: int64 - title: |- - Max block size, in bytes. - Note: must be greater than 0 - max_gas: - type: string - format: int64 - title: |- - Max gas per block. - Note: must be greater or equal to -1 - evidence: - type: object - properties: - max_age_num_blocks: - type: string - format: int64 - description: >- - Max age of evidence, in blocks. - - - The basic formula for calculating this is: MaxAgeDuration / - {average block - - time}. - max_age_duration: - type: string - description: >- - Max age of evidence, in time. - - - It should correspond with an app's "unbonding period" or other - similar - - 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). - max_bytes: - type: string - format: int64 - title: >- - 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 - description: EvidenceParams determine how we handle evidence of malfeasance. - validator: - type: object - properties: - pub_key_types: - type: array - items: - type: string - description: |- - ValidatorParams restrict the public key types validators can use. - NOTE: uses ABCI pubkey naming, not Amino names. - abci: - title: 'Since: cosmos-sdk 0.50' - type: object - properties: - vote_extensions_enable_height: - type: string - format: int64 - description: >- - vote_extensions_enable_height configures the first height during - which - - vote extensions will be enabled. During this specified height, and - for all - - subsequent heights, precommit messages that do not contain valid - extension data - - will be considered invalid. Prior to this height, vote extensions - will not - - be used or accepted by validators on the network. - - - Once enabled, vote extensions will be created by the application - in ExtendVote, - - passed to the application for validation in VerifyVoteExtension - and given - - to the application to use when proposing a block during - PrepareProposal. - description: >- - ABCIParams configure functionality specific to the Application - Blockchain Interface. - description: MsgUpdateParams is the Msg/UpdateParams request type. - cosmos.consensus.v1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - tendermint.types.ABCIParams: - type: object - properties: - vote_extensions_enable_height: - type: string - format: int64 - description: >- - vote_extensions_enable_height configures the first height during which - - vote extensions will be enabled. During this specified height, and for - all - - subsequent heights, precommit messages that do not contain valid - extension data - - will be considered invalid. Prior to this height, vote extensions will - not - - be used or accepted by validators on the network. - - - Once enabled, vote extensions will be created by the application in - ExtendVote, - - passed to the application for validation in VerifyVoteExtension and - given - - to the application to use when proposing a block during - PrepareProposal. - description: >- - ABCIParams configure functionality specific to the Application Blockchain - Interface. - tendermint.types.BlockParams: - type: object - properties: - max_bytes: - type: string - format: int64 - title: |- - Max block size, in bytes. - Note: must be greater than 0 - max_gas: - type: string - format: int64 - title: |- - Max gas per block. - Note: must be greater or equal to -1 - description: BlockParams contains limits on the block size. - tendermint.types.EvidenceParams: - type: object - properties: - max_age_num_blocks: - type: string - format: int64 - description: >- - Max age of evidence, in blocks. - - - The basic formula for calculating this is: MaxAgeDuration / {average - block - - time}. - max_age_duration: - type: string - description: >- - Max age of evidence, in time. - - - It should correspond with an app's "unbonding period" or other similar - - 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). - max_bytes: - type: string - format: int64 - title: >- - 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 - description: EvidenceParams determine how we handle evidence of malfeasance. - tendermint.types.ValidatorParams: - type: object - properties: - pub_key_types: - type: array - items: - type: string - description: |- - ValidatorParams restrict the public key types validators can use. - NOTE: uses ABCI pubkey naming, not Amino names. - cosmos.crisis.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - constant_fee: - description: constant_fee defines the x/crisis parameter. - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.crisis.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.crisis.v1beta1.MsgVerifyInvariant: - type: object - properties: - sender: - type: string - description: >- - sender is the account address of private key to send coins to fee - collector account. - invariant_module_name: - type: string - description: name of the invariant module. - invariant_route: - type: string - description: invariant_route is the msg's invariant route. - description: MsgVerifyInvariant represents a message to verify a particular invariance. - cosmos.crisis.v1beta1.MsgVerifyInvariantResponse: - type: object - description: MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. - cosmos.distribution.v1beta1.MsgCommunityPoolSpend: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - recipient: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: >- - MsgCommunityPoolSpend defines a message for sending tokens from the - community - - pool to another account. This message is typically executed via a - governance - - proposal with the governance module being the executing authority. - - - Since: cosmos-sdk 0.47 - cosmos.distribution.v1beta1.MsgCommunityPoolSpendResponse: - type: object - description: |- - MsgCommunityPoolSpendResponse defines the response to executing a - MsgCommunityPoolSpend message. - - Since: cosmos-sdk 0.47 - cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPool: - type: object - properties: - depositor: - type: string - validator_address: - type: string - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: |- - DepositValidatorRewardsPool defines the request structure to provide - additional rewards to delegators from a specific validator. - - Since: cosmos-sdk 0.50 - cosmos.distribution.v1beta1.MsgDepositValidatorRewardsPoolResponse: - type: object - description: |- - MsgDepositValidatorRewardsPoolResponse defines the response to executing a - MsgDepositValidatorRewardsPool message. - - Since: cosmos-sdk 0.50 - cosmos.distribution.v1beta1.MsgFundCommunityPool: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - depositor: - type: string - description: |- - MsgFundCommunityPool allows an account to directly - fund the community pool. - cosmos.distribution.v1beta1.MsgFundCommunityPoolResponse: - type: object - description: >- - MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response - type. - cosmos.distribution.v1beta1.MsgSetWithdrawAddress: - type: object - properties: - delegator_address: - type: string - withdraw_address: - type: string - description: |- - MsgSetWithdrawAddress sets the withdraw address for - a delegator (or validator self-delegation). - cosmos.distribution.v1beta1.MsgSetWithdrawAddressResponse: - type: object - description: |- - MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response - type. - cosmos.distribution.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/distribution parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - community_tax: - type: string - base_proposer_reward: - type: string - description: >- - Deprecated: The base_proposer_reward field is deprecated and is no - longer used - - in the x/distribution module's reward mechanism. - bonus_proposer_reward: - type: string - description: >- - Deprecated: The bonus_proposer_reward field is deprecated and is - no longer used - - in the x/distribution module's reward mechanism. - withdraw_addr_enabled: - type: boolean - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.distribution.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - description: |- - MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator - from a single validator. - cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: 'Since: cosmos-sdk 0.46' - description: |- - MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward - response type. - cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission: - type: object - properties: - validator_address: - type: string - description: >- - MsgWithdrawValidatorCommission withdraws the full commission to the - validator - - address. - cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse: - type: object - properties: - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: 'Since: cosmos-sdk 0.46' - description: |- - MsgWithdrawValidatorCommissionResponse defines the - Msg/WithdrawValidatorCommission response type. - cosmos.distribution.v1beta1.Params: - type: object - properties: - community_tax: - type: string - base_proposer_reward: - type: string - description: >- - Deprecated: The base_proposer_reward field is deprecated and is no - longer used - - in the x/distribution module's reward mechanism. - bonus_proposer_reward: - type: string - description: >- - Deprecated: The bonus_proposer_reward field is deprecated and is no - longer used - - in the x/distribution module's reward mechanism. - withdraw_addr_enabled: - type: boolean - description: Params defines the set of params for the distribution module. - cosmos.evidence.v1beta1.MsgSubmitEvidence: - type: object - properties: - submitter: - type: string - description: submitter is the signer account address of evidence. - evidence: - description: evidence defines the evidence of misbehavior. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: |- - MsgSubmitEvidence represents a message that supports submitting arbitrary - Evidence of misbehavior such as equivocation or counterfactual signing. - cosmos.evidence.v1beta1.MsgSubmitEvidenceResponse: - type: object - properties: - hash: - type: string - format: byte - description: hash defines the hash of the evidence. - description: MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. - cosmos.feegrant.v1beta1.MsgGrantAllowance: - type: object - properties: - granter: - type: string - description: >- - granter is the address of the user granting an allowance of their - funds. - grantee: - type: string - description: >- - grantee is the address of the user being granted an allowance of - another user's funds. - allowance: - description: allowance can be any of basic, periodic, allowed fee allowance. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: |- - MsgGrantAllowance adds permission for Grantee to spend up to Allowance - of fees from the account of Granter. - cosmos.feegrant.v1beta1.MsgGrantAllowanceResponse: - type: object - description: >- - MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response - type. - cosmos.feegrant.v1beta1.MsgPruneAllowances: - type: object - properties: - pruner: - type: string - description: pruner is the address of the user pruning expired allowances. - description: |- - MsgPruneAllowances prunes expired fee allowances. - - Since cosmos-sdk 0.50 - cosmos.feegrant.v1beta1.MsgPruneAllowancesResponse: - type: object - description: >- - MsgPruneAllowancesResponse defines the Msg/PruneAllowancesResponse - response type. - - - Since cosmos-sdk 0.50 - cosmos.feegrant.v1beta1.MsgRevokeAllowance: - type: object - properties: - granter: - type: string - description: >- - granter is the address of the user granting an allowance of their - funds. - grantee: - type: string - description: >- - grantee is the address of the user being granted an allowance of - another user's funds. - description: MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. - cosmos.feegrant.v1beta1.MsgRevokeAllowanceResponse: - type: object - description: >- - MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse - response type. - cosmos.gov.v1.MsgCancelProposal: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - proposer: - type: string - description: proposer is the account address of the proposer. - description: |- - MsgCancelProposal is the Msg/CancelProposal request type. - - Since: cosmos-sdk 0.50 - cosmos.gov.v1.MsgCancelProposalResponse: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - canceled_time: - type: string - format: date-time - description: canceled_time is the time when proposal is canceled. - canceled_height: - type: string - format: uint64 - description: >- - canceled_height defines the block height at which the proposal is - canceled. - description: |- - MsgCancelProposalResponse defines the response structure for executing a - MsgCancelProposal message. - - Since: cosmos-sdk 0.50 - cosmos.gov.v1.MsgDeposit: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - depositor: - type: string - description: depositor defines the deposit addresses from the proposals. - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: amount to be deposited by depositor. - description: MsgDeposit defines a message to submit a deposit to an existing proposal. - cosmos.gov.v1.MsgDepositResponse: - type: object - description: MsgDepositResponse defines the Msg/Deposit response type. - cosmos.gov.v1.MsgExecLegacyContent: - type: object - properties: - content: - description: content is the proposal's content. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - authority: - type: string - description: authority must be the gov module address. - description: >- - MsgExecLegacyContent is used to wrap the legacy content field into a - message. - - This ensures backwards compatibility with v1beta1.MsgSubmitProposal. - cosmos.gov.v1.MsgExecLegacyContentResponse: - type: object - description: >- - MsgExecLegacyContentResponse defines the Msg/ExecLegacyContent response - type. - cosmos.gov.v1.MsgSubmitProposal: - type: object - properties: - messages: - type: array - items: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up - a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. As of May 2023, there are no widely used - type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any - type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - description: messages are the arbitrary messages to be executed if proposal passes. - initial_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: >- - initial_deposit is the deposit value that must be paid at proposal - submission. - proposer: - type: string - description: proposer is the account address of the proposer. - metadata: - type: string - description: metadata is any arbitrary metadata attached to the proposal. - title: - type: string - description: |- - title is the title of the proposal. - - Since: cosmos-sdk 0.47 - summary: - type: string - description: 'Since: cosmos-sdk 0.47' - title: summary is the summary of the proposal - expedited: - type: boolean - description: 'Since: cosmos-sdk 0.50' - title: expedited defines if the proposal is expedited or not - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - cosmos.gov.v1.MsgSubmitProposalResponse: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - description: MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. - cosmos.gov.v1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/gov parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: Minimum deposit for a proposal to enter voting period. - max_deposit_period: - type: string - description: >- - Maximum period for Atom holders to deposit on a proposal. Initial - value: 2 - - months. - voting_period: - type: string - description: Duration of the voting period. - quorum: - type: string - description: >- - Minimum percentage of total stake needed to vote for a result to - be - considered valid. - threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. Default - value: 0.5. - veto_threshold: - type: string - description: >- - Minimum value of Veto votes to Total votes ratio for proposal to - be - vetoed. Default value: 1/3. - min_initial_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value that - must be paid at proposal submission. - proposal_cancel_ratio: - type: string - description: >- - The cancel ratio which will not be returned back to the depositors - when a proposal is cancelled. - - - Since: cosmos-sdk 0.50 - proposal_cancel_dest: - type: string - description: >- - The address which will receive (proposal_cancel_ratio * deposit) - proposal deposits. - - If empty, the (proposal_cancel_ratio * deposit) proposal deposits - will be burned. - - - Since: cosmos-sdk 0.50 - expedited_voting_period: - type: string - description: |- - Duration of the voting period of an expedited proposal. - - Since: cosmos-sdk 0.50 - expedited_threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. Default - value: 0.67. - - - Since: cosmos-sdk 0.50 - expedited_min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - description: Minimum expedited deposit for a proposal to enter voting period. - burn_vote_quorum: - type: boolean - title: burn deposits if a proposal does not meet quorum - burn_proposal_deposit_prevote: - type: boolean - title: burn deposits if the proposal does not enter voting period - burn_vote_veto: - type: boolean - title: burn deposits if quorum with vote type no_veto is met - min_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value minimum - that must be met when making a deposit. - - Default value: 0.01. Meaning that for a chain with a min_deposit - of 100stake, a deposit of 1stake would be - - required. - - - Since: cosmos-sdk 0.50 - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.gov.v1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.gov.v1.MsgVote: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - option: - description: option defines the vote option. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - metadata: - type: string - description: metadata is any arbitrary metadata attached to the Vote. - description: MsgVote defines a message to cast a vote. - cosmos.gov.v1.MsgVoteResponse: - type: object - description: MsgVoteResponse defines the Msg/Vote response type. - cosmos.gov.v1.MsgVoteWeighted: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - options: - type: array - items: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not contain - duplicate vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: weight is the vote weight associated with the vote option. - description: WeightedVoteOption defines a unit of vote for vote split. - description: options defines the weighted vote options. - metadata: - type: string - description: metadata is any arbitrary metadata attached to the VoteWeighted. - description: MsgVoteWeighted defines a message to cast a vote. - cosmos.gov.v1.MsgVoteWeightedResponse: - type: object - description: MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. - cosmos.gov.v1.Params: - type: object - properties: - min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: Minimum deposit for a proposal to enter voting period. - max_deposit_period: - type: string - description: >- - Maximum period for Atom holders to deposit on a proposal. Initial - value: 2 - - months. - voting_period: - type: string - description: Duration of the voting period. - quorum: - type: string - description: |- - Minimum percentage of total stake needed to vote for a result to be - considered valid. - threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. Default value: - 0.5. - veto_threshold: - type: string - description: |- - Minimum value of Veto votes to Total votes ratio for proposal to be - vetoed. Default value: 1/3. - min_initial_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value that must - be paid at proposal submission. - proposal_cancel_ratio: - type: string - description: >- - The cancel ratio which will not be returned back to the depositors - when a proposal is cancelled. - - - Since: cosmos-sdk 0.50 - proposal_cancel_dest: - type: string - description: >- - The address which will receive (proposal_cancel_ratio * deposit) - proposal deposits. - - If empty, the (proposal_cancel_ratio * deposit) proposal deposits will - be burned. - - - Since: cosmos-sdk 0.50 - expedited_voting_period: - type: string - description: |- - Duration of the voting period of an expedited proposal. - - Since: cosmos-sdk 0.50 - expedited_threshold: - type: string - description: >- - Minimum proportion of Yes votes for proposal to pass. Default value: - 0.67. - - - Since: cosmos-sdk 0.50 - expedited_min_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: Minimum expedited deposit for a proposal to enter voting period. - burn_vote_quorum: - type: boolean - title: burn deposits if a proposal does not meet quorum - burn_proposal_deposit_prevote: - type: boolean - title: burn deposits if the proposal does not enter voting period - burn_vote_veto: - type: boolean - title: burn deposits if quorum with vote type no_veto is met - min_deposit_ratio: - type: string - description: >- - The ratio representing the proportion of the deposit value minimum - that must be met when making a deposit. - - Default value: 0.01. Meaning that for a chain with a min_deposit of - 100stake, a deposit of 1stake would be - - required. - - - Since: cosmos-sdk 0.50 - description: |- - Params defines the parameters for the x/gov module. - - Since: cosmos-sdk 0.47 - cosmos.gov.v1.VoteOption: - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - description: >- - VoteOption enumerates the valid vote options for a given governance - proposal. - - - VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option. - - VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option. - - VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option. - - VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option. - - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. - cosmos.gov.v1.WeightedVoteOption: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not contain duplicate - vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: weight is the vote weight associated with the vote option. - description: WeightedVoteOption defines a unit of vote for vote split. - cosmos.gov.v1beta1.MsgDeposit: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - depositor: - type: string - description: depositor defines the deposit addresses from the proposals. - amount: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: amount to be deposited by depositor. - description: MsgDeposit defines a message to submit a deposit to an existing proposal. - cosmos.gov.v1beta1.MsgDepositResponse: - type: object - description: MsgDepositResponse defines the Msg/Deposit response type. - cosmos.gov.v1beta1.MsgSubmitProposal: - type: object - properties: - content: - description: content is the proposal's content. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - initial_deposit: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: >- - initial_deposit is the deposit value that must be paid at proposal - submission. - proposer: - type: string - description: proposer is the account address of the proposer. - description: >- - MsgSubmitProposal defines an sdk.Msg type that supports submitting - arbitrary - - proposal Content. - cosmos.gov.v1beta1.MsgSubmitProposalResponse: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - description: MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. - cosmos.gov.v1beta1.MsgVote: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - option: - description: option defines the vote option. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - description: MsgVote defines a message to cast a vote. - cosmos.gov.v1beta1.MsgVoteResponse: - type: object - description: MsgVoteResponse defines the Msg/Vote response type. - cosmos.gov.v1beta1.MsgVoteWeighted: - type: object - properties: - proposal_id: - type: string - format: uint64 - description: proposal_id defines the unique id of the proposal. - voter: - type: string - description: voter is the voter address for the proposal. - options: - type: array - items: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not contain - duplicate vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: weight is the vote weight associated with the vote option. - description: |- - WeightedVoteOption defines a unit of vote for vote split. - - Since: cosmos-sdk 0.43 - description: options defines the weighted vote options. - description: |- - MsgVoteWeighted defines a message to cast a vote. - - Since: cosmos-sdk 0.43 - cosmos.gov.v1beta1.MsgVoteWeightedResponse: - type: object - description: |- - MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. - - Since: cosmos-sdk 0.43 - cosmos.gov.v1beta1.VoteOption: - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - description: >- - VoteOption enumerates the valid vote options for a given governance - proposal. - - - VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option. - - VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option. - - VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option. - - VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option. - - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. - cosmos.gov.v1beta1.WeightedVoteOption: - type: object - properties: - option: - description: >- - option defines the valid vote options, it must not contain duplicate - vote options. - type: string - enum: - - VOTE_OPTION_UNSPECIFIED - - VOTE_OPTION_YES - - VOTE_OPTION_ABSTAIN - - VOTE_OPTION_NO - - VOTE_OPTION_NO_WITH_VETO - default: VOTE_OPTION_UNSPECIFIED - weight: - type: string - description: weight is the vote weight associated with the vote option. - description: |- - WeightedVoteOption defines a unit of vote for vote split. - - Since: cosmos-sdk 0.43 - cosmos.mint.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/mint parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - mint_denom: - type: string - title: type of coin to mint - inflation_rate_change: - type: string - title: maximum annual change in inflation rate - inflation_max: - type: string - title: maximum inflation rate - inflation_min: - type: string - title: minimum inflation rate - goal_bonded: - type: string - title: goal of percent bonded atoms - blocks_per_year: - type: string - format: uint64 - title: expected blocks per year - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.mint.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.mint.v1beta1.Params: - type: object - properties: - mint_denom: - type: string - title: type of coin to mint - inflation_rate_change: - type: string - title: maximum annual change in inflation rate - inflation_max: - type: string - title: maximum inflation rate - inflation_min: - type: string - title: minimum inflation rate - goal_bonded: - type: string - title: goal of percent bonded atoms - blocks_per_year: - type: string - format: uint64 - title: expected blocks per year - description: Params defines the parameters for the x/mint module. - cosmos.nft.v1beta1.MsgSend: - type: object - properties: - class_id: - type: string - title: >- - class_id defines the unique identifier of the nft classification, - similar to the contract address of ERC721 - id: - type: string - title: id defines the unique identification of nft - sender: - type: string - title: sender is the address of the owner of nft - receiver: - type: string - title: receiver is the receiver address of nft - description: >- - MsgSend represents a message to send a nft from one account to another - account. - cosmos.nft.v1beta1.MsgSendResponse: - type: object - description: MsgSendResponse defines the Msg/Send response type. - cosmos.params.v1beta1.ParamChange: - type: object - properties: - subspace: - type: string - key: - type: string - value: - type: string - description: |- - ParamChange defines an individual parameter change, for use in - ParameterChangeProposal. - cosmos.params.v1beta1.QueryParamsResponse: - type: object - properties: - param: - description: param defines the queried parameter. - type: object - properties: - subspace: - type: string - key: - type: string - value: - type: string - description: QueryParamsResponse is response type for the Query/Params RPC method. - cosmos.params.v1beta1.QuerySubspacesResponse: - type: object - properties: - subspaces: - type: array - items: - type: object - properties: - subspace: - type: string - keys: - type: array - items: - type: string - description: >- - Subspace defines a parameter subspace name and all the keys that - exist for - - the subspace. - - - Since: cosmos-sdk 0.46 - description: |- - QuerySubspacesResponse defines the response types for querying for all - registered subspaces and all keys for a subspace. - - Since: cosmos-sdk 0.46 - cosmos.params.v1beta1.Subspace: - type: object - properties: - subspace: - type: string - keys: - type: array - items: - type: string - description: |- - Subspace defines a parameter subspace name and all the keys that exist for - the subspace. - - Since: cosmos-sdk 0.46 - cosmos.slashing.v1beta1.MsgUnjail: - type: object - properties: - validator_addr: - type: string - title: MsgUnjail defines the Msg/Unjail request type - cosmos.slashing.v1beta1.MsgUnjailResponse: - type: object - title: MsgUnjailResponse defines the Msg/Unjail response type - cosmos.slashing.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/slashing parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - signed_blocks_window: - type: string - format: int64 - min_signed_per_window: - type: string - format: byte - downtime_jail_duration: - type: string - slash_fraction_double_sign: - type: string - format: byte - slash_fraction_downtime: - type: string - format: byte - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.slashing.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.slashing.v1beta1.Params: - type: object - properties: - signed_blocks_window: - type: string - format: int64 - min_signed_per_window: - type: string - format: byte - downtime_jail_duration: - type: string - slash_fraction_double_sign: - type: string - format: byte - slash_fraction_downtime: - type: string - format: byte - description: Params represents the parameters used for by the slashing module. - cosmos.staking.v1beta1.CommissionRates: - type: object - properties: - rate: - type: string - description: rate is the commission rate charged to delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which validator can ever - charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the validator - commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be used for - creating - - a validator. - cosmos.staking.v1beta1.Description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: security_contact defines an optional email for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - cosmos.staking.v1beta1.MsgBeginRedelegate: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: |- - MsgBeginRedelegate defines a SDK message for performing a redelegation - of coins from a delegator and source validator to a destination validator. - cosmos.staking.v1beta1.MsgBeginRedelegateResponse: - type: object - properties: - completion_time: - type: string - format: date-time - description: MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. - cosmos.staking.v1beta1.MsgCancelUnbondingDelegation: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: >- - amount is always less than or equal to unbonding delegation entry - balance - creation_height: - type: string - format: int64 - description: creation_height is the height which the unbonding took place. - description: 'Since: cosmos-sdk 0.46' - title: >- - MsgCancelUnbondingDelegation defines the SDK message for performing a - cancel unbonding delegation for delegator - cosmos.staking.v1beta1.MsgCancelUnbondingDelegationResponse: - type: object - description: 'Since: cosmos-sdk 0.46' - title: MsgCancelUnbondingDelegationResponse - cosmos.staking.v1beta1.MsgCreateValidator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: security_contact defines an optional email for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - commission: - type: object - properties: - rate: - type: string - description: rate is the commission rate charged to delegators, as a fraction. - max_rate: - type: string - description: >- - max_rate defines the maximum commission rate which validator can - ever charge, as a fraction. - max_change_rate: - type: string - description: >- - max_change_rate defines the maximum daily increase of the - validator commission, as a fraction. - description: >- - CommissionRates defines the initial commission rates to be used for - creating - - a validator. - min_self_delegation: - type: string - delegator_address: - type: string - description: >- - Deprecated: Use of Delegator Address in MsgCreateValidator is - deprecated. - - The validator address bytes and delegator address bytes refer to the - same account while creating validator (defer - - only in bech32 notation). - validator_address: - type: string - pubkey: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - value: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: MsgCreateValidator defines a SDK message for creating a new validator. - cosmos.staking.v1beta1.MsgCreateValidatorResponse: - type: object - description: MsgCreateValidatorResponse defines the Msg/CreateValidator response type. - cosmos.staking.v1beta1.MsgDelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: |- - MsgDelegate defines a SDK message for performing a delegation of coins - from a delegator to a validator. - cosmos.staking.v1beta1.MsgDelegateResponse: - type: object - description: MsgDelegateResponse defines the Msg/Delegate response type. - cosmos.staking.v1beta1.MsgEditValidator: - type: object - properties: - description: - type: object - properties: - moniker: - type: string - description: moniker defines a human-readable name for the validator. - identity: - type: string - description: >- - identity defines an optional identity signature (ex. UPort or - Keybase). - website: - type: string - description: website defines an optional website link. - security_contact: - type: string - description: security_contact defines an optional email for security contact. - details: - type: string - description: details define other optional details. - description: Description defines a validator description. - validator_address: - type: string - commission_rate: - type: string - title: >- - 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 - min_self_delegation: - type: string - description: MsgEditValidator defines a SDK message for editing an existing validator. - cosmos.staking.v1beta1.MsgEditValidatorResponse: - type: object - description: MsgEditValidatorResponse defines the Msg/EditValidator response type. - cosmos.staking.v1beta1.MsgUndelegate: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - description: |- - MsgUndelegate defines a SDK message for performing an undelegation from a - delegate and a validator. - cosmos.staking.v1beta1.MsgUndelegateResponse: - type: object - properties: - completion_time: - type: string - format: date-time - amount: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: amount returns the amount of undelegated coins - description: MsgUndelegateResponse defines the Msg/Undelegate response type. - cosmos.staking.v1beta1.MsgUpdateParams: - type: object - properties: - authority: - type: string - description: >- - authority is the address that controls the module (defaults to x/gov - unless overwritten). - params: - description: |- - params defines the x/staking parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - unbonding_time: - type: string - description: unbonding_time is the time duration of unbonding. - max_validators: - type: integer - format: int64 - description: max_validators is the maximum number of validators. - max_entries: - type: integer - format: int64 - description: >- - max_entries is the max entries for either unbonding delegation or - redelegation (per pair/trio). - historical_entries: - type: integer - format: int64 - description: historical_entries is the number of historical entries to persist. - bond_denom: - type: string - description: bond_denom defines the bondable coin denomination. - min_commission_rate: - type: string - title: >- - min_commission_rate is the chain-wide minimum commission rate that - a validator can charge their delegators - description: |- - MsgUpdateParams is the Msg/UpdateParams request type. - - Since: cosmos-sdk 0.47 - cosmos.staking.v1beta1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - - Since: cosmos-sdk 0.47 - cosmos.staking.v1beta1.Params: - type: object - properties: - unbonding_time: - type: string - description: unbonding_time is the time duration of unbonding. - max_validators: - type: integer - format: int64 - description: max_validators is the maximum number of validators. - max_entries: - type: integer - format: int64 - description: >- - max_entries is the max entries for either unbonding delegation or - redelegation (per pair/trio). - historical_entries: - type: integer - format: int64 - description: historical_entries is the number of historical entries to persist. - bond_denom: - type: string - description: bond_denom defines the bondable coin denomination. - min_commission_rate: - type: string - title: >- - min_commission_rate is the chain-wide minimum commission rate that a - validator can charge their delegators - description: Params defines the parameters for the x/staking module. - ibc.applications.fee.v1.Fee: - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - title: the packet timeout fee - title: Fee defines the ICS29 receive, acknowledgement and timeout fees - ibc.applications.fee.v1.MsgPayPacketFee: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated with an IBC - packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet timeout fee - source_port_id: - type: string - title: the source port unique identifier - source_channel_id: - type: string - title: the source channel unique identifer - signer: - type: string - title: account address to refund fee if necessary - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to the receive packet fees - title: >- - MsgPayPacketFee defines the request type for the PayPacketFee rpc - - This Msg can be used to pay for a packet at the next sequence send & - should be combined with the Msg that will be - - paid for - ibc.applications.fee.v1.MsgPayPacketFeeAsync: - type: object - properties: - packet_id: - title: >- - unique packet identifier comprised of the channel ID, port ID and - sequence - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - packet_fee: - title: the packet fee associated with a particular IBC packet - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated with an - IBC packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - MsgPayPacketFeeAsync defines the request type for the PayPacketFeeAsync - rpc - - This Msg can be used to pay for a packet at a specified sequence (instead - of the next sequence send) - ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse: - type: object - title: >- - MsgPayPacketFeeAsyncResponse defines the response type for the - PayPacketFeeAsync rpc - ibc.applications.fee.v1.MsgPayPacketFeeResponse: - type: object - title: MsgPayPacketFeeResponse defines the response type for the PayPacketFee rpc - ibc.applications.fee.v1.MsgRegisterCounterpartyPayee: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - relayer: - type: string - title: the relayer address - counterparty_payee: - type: string - title: the counterparty payee address - title: >- - MsgRegisterCounterpartyPayee defines the request type for the - RegisterCounterpartyPayee rpc - ibc.applications.fee.v1.MsgRegisterCounterpartyPayeeResponse: - type: object - title: >- - MsgRegisterCounterpartyPayeeResponse defines the response type for the - RegisterCounterpartyPayee rpc - ibc.applications.fee.v1.MsgRegisterPayee: - type: object - properties: - port_id: - type: string - title: unique port identifier - channel_id: - type: string - title: unique channel identifier - relayer: - type: string - title: the relayer address - payee: - type: string - title: the payee address - title: MsgRegisterPayee defines the request type for the RegisterPayee rpc - ibc.applications.fee.v1.MsgRegisterPayeeResponse: - type: object - title: >- - MsgRegisterPayeeResponse defines the response type for the RegisterPayee - rpc - ibc.applications.fee.v1.PacketFee: - type: object - properties: - fee: - title: >- - fee encapsulates the recv, ack and timeout fees associated with an IBC - packet - type: object - properties: - recv_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet receive fee - ack_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet acknowledgement fee - timeout_fee: - type: array - items: - type: object - properties: - denom: - type: string - amount: - type: string - description: >- - Coin defines a token with a denomination and an amount. - - - NOTE: The amount field is an Int which implements the custom - method - - signatures required by gogoproto. - title: the packet timeout fee - refund_address: - type: string - title: the refund address for unspent fees - relayers: - type: array - items: - type: string - title: optional list of relayers permitted to receive fees - title: >- - PacketFee contains ICS29 relayer fees, refund address and optional list of - permitted relayers - ibc.core.channel.v1.PacketId: - type: object - properties: - port_id: - type: string - title: channel port identifier - channel_id: - type: string - title: channel unique identifier - sequence: - type: string - format: uint64 - title: packet sequence - title: |- - PacketId is an identifer for a unique Packet - Source chains refer to packets by source port/channel - Destination chains refer to packets by destination port/channel - ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccount: - type: object - properties: - owner: - type: string - connection_id: - type: string - version: - type: string - ordering: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - title: MsgRegisterInterchainAccount defines the payload for Msg/RegisterAccount - ibc.applications.interchain_accounts.controller.v1.MsgRegisterInterchainAccountResponse: - type: object - properties: - channel_id: - type: string - port_id: - type: string - title: >- - MsgRegisterInterchainAccountResponse defines the response for - Msg/RegisterAccount - ibc.applications.interchain_accounts.controller.v1.MsgSendTx: - type: object - properties: - owner: - type: string - connection_id: - type: string - packet_data: - type: object - properties: - type: - type: string - enum: - - TYPE_UNSPECIFIED - - TYPE_EXECUTE_TX - default: TYPE_UNSPECIFIED - description: |- - - TYPE_UNSPECIFIED: Default zero value enumeration - - TYPE_EXECUTE_TX: Execute a transaction on an interchain accounts host chain - title: >- - Type defines a classification of message issued from a controller - chain to its associated interchain accounts - - host - data: - type: string - format: byte - memo: - type: string - description: >- - InterchainAccountPacketData is comprised of a raw transaction, type of - transaction and optional memo field. - relative_timeout: - type: string - format: uint64 - description: >- - Relative timeout timestamp provided will be added to the current block - time during transaction execution. - - The timeout timestamp must be non-zero. - title: MsgSendTx defines the payload for Msg/SendTx - ibc.applications.interchain_accounts.controller.v1.MsgSendTxResponse: - type: object - properties: - sequence: - type: string - format: uint64 - title: MsgSendTxResponse defines the response for MsgSendTx - ibc.applications.interchain_accounts.controller.v1.MsgUpdateParams: - type: object - properties: - signer: - type: string - title: signer address - params: - description: >- - params defines the 27-interchain-accounts/controller parameters to - update. - - - NOTE: All parameters must be supplied. - type: object - properties: - controller_enabled: - type: boolean - description: controller_enabled enables or disables the controller submodule. - title: MsgUpdateParams defines the payload for Msg/UpdateParams - ibc.applications.interchain_accounts.controller.v1.MsgUpdateParamsResponse: - type: object - title: MsgUpdateParamsResponse defines the response for Msg/UpdateParams - ibc.applications.interchain_accounts.controller.v1.Params: - type: object - properties: - controller_enabled: - type: boolean - description: controller_enabled enables or disables the controller submodule. - description: |- - Params defines the set of on-chain interchain accounts parameters. - The following parameters may be used to disable the controller submodule. - ibc.applications.interchain_accounts.v1.InterchainAccountPacketData: - type: object - properties: - type: - type: string - enum: - - TYPE_UNSPECIFIED - - TYPE_EXECUTE_TX - default: TYPE_UNSPECIFIED - description: |- - - TYPE_UNSPECIFIED: Default zero value enumeration - - TYPE_EXECUTE_TX: Execute a transaction on an interchain accounts host chain - title: >- - Type defines a classification of message issued from a controller - chain to its associated interchain accounts - - host - data: - type: string - format: byte - memo: - type: string - description: >- - InterchainAccountPacketData is comprised of a raw transaction, type of - transaction and optional memo field. - ibc.applications.interchain_accounts.v1.Type: - type: string - enum: - - TYPE_UNSPECIFIED - - TYPE_EXECUTE_TX - default: TYPE_UNSPECIFIED - description: |- - - TYPE_UNSPECIFIED: Default zero value enumeration - - TYPE_EXECUTE_TX: Execute a transaction on an interchain accounts host chain - title: >- - Type defines a classification of message issued from a controller chain to - its associated interchain accounts - - host - ibc.core.channel.v1.Order: - type: string - enum: - - ORDER_NONE_UNSPECIFIED - - ORDER_UNORDERED - - ORDER_ORDERED - default: ORDER_NONE_UNSPECIFIED - description: |- - - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering - - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in - which they were sent. - - ORDER_ORDERED: packets are delivered exactly in the order which they were sent - title: Order defines if a channel is ORDERED or UNORDERED - ibc.applications.interchain_accounts.host.v1.MsgUpdateParams: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the 27-interchain-accounts/host parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - host_enabled: - type: boolean - description: host_enabled enables or disables the host submodule. - allow_messages: - type: array - items: - type: string - description: >- - allow_messages defines a list of sdk message typeURLs allowed to - be executed on a host chain. - title: MsgUpdateParams defines the payload for Msg/UpdateParams - ibc.applications.interchain_accounts.host.v1.MsgUpdateParamsResponse: - type: object - title: MsgUpdateParamsResponse defines the response for Msg/UpdateParams - ibc.applications.interchain_accounts.host.v1.Params: - type: object - properties: - host_enabled: - type: boolean - description: host_enabled enables or disables the host submodule. - allow_messages: - type: array - items: - type: string - description: >- - allow_messages defines a list of sdk message typeURLs allowed to be - executed on a host chain. - description: |- - Params defines the set of on-chain interchain accounts parameters. - The following parameters may be used to disable the host submodule. - ibc.applications.transfer.v1.MsgTransfer: - type: object - properties: - source_port: - type: string - title: the port on which the packet will be sent - source_channel: - type: string - title: the channel by which the packet will be sent - token: - title: the tokens to be transferred - type: object - properties: - denom: - type: string - amount: - type: string - description: |- - Coin defines a token with a denomination and an amount. - - NOTE: The amount field is an Int which implements the custom method - signatures required by gogoproto. - sender: - type: string - title: the sender address - receiver: - type: string - title: the recipient address on the destination chain - timeout_height: - description: |- - Timeout height relative to the current block height. - The timeout is disabled when set to 0. - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - timeout_timestamp: - type: string - format: uint64 - description: |- - Timeout timestamp in absolute nanoseconds since unix epoch. - The timeout is disabled when set to 0. - memo: - type: string - title: optional memo - title: >- - MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between - - ICS20 enabled chains. See ICS Spec here: - - https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures - ibc.applications.transfer.v1.MsgTransferResponse: - type: object - properties: - sequence: - type: string - format: uint64 - title: sequence number of the transfer packet sent - description: MsgTransferResponse defines the Msg/Transfer response type. - ibc.applications.transfer.v1.MsgUpdateParams: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the transfer parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - send_enabled: - type: boolean - description: >- - send_enabled enables or disables all cross-chain token transfers - from this - - chain. - receive_enabled: - type: boolean - description: >- - receive_enabled enables or disables all cross-chain token - transfers to this - - chain. - description: MsgUpdateParams is the Msg/UpdateParams request type. - ibc.applications.transfer.v1.MsgUpdateParamsResponse: - type: object - description: |- - MsgUpdateParamsResponse defines the response structure for executing a - MsgUpdateParams message. - ibc.applications.transfer.v1.Params: - type: object - properties: - send_enabled: - type: boolean - description: >- - send_enabled enables or disables all cross-chain token transfers from - this - - chain. - receive_enabled: - type: boolean - description: >- - receive_enabled enables or disables all cross-chain token transfers to - this - - chain. - description: >- - Params defines the set of IBC transfer parameters. - - NOTE: To prevent a single token from being transferred, set the - - TransfersEnabled parameter to true and then set the bank module's - SendEnabled - - parameter for the denomination to false. - ibc.core.client.v1.Height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: |- - Normally the RevisionHeight is incremented at each height while keeping - RevisionNumber the same. However some consensus algorithms may choose to - reset the height in certain conditions e.g. hard forks, state-machine - breaking changes In these cases, the RevisionNumber is incremented so that - height continues to be monitonically increasing even as the RevisionHeight - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of updating - and - - freezing clients - cosmos.upgrade.v1beta1.Plan: - type: object - properties: - name: - type: string - description: >- - 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. - time: - type: string - format: date-time - description: >- - Deprecated: Time based upgrades have been deprecated. Time based - upgrade logic - - has been removed from the SDK. - - If this field is not empty, an error will be thrown. - height: - type: string - format: int64 - description: The height at which the upgrade must be performed. - info: - type: string - title: |- - Any application specific upgrade info to be included on-chain - such as a git commit that validators could automatically upgrade to - upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. IBC upgrade - logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - Plan specifies information about a planned upgrade and when it should - occur. - ibc.core.client.v1.MsgCreateClient: - type: object - properties: - client_state: - title: light client state - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - consensus_state: - description: |- - consensus state associated with the client that corresponds to a given - height. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - signer: - type: string - title: signer address - title: MsgCreateClient defines a message to create an IBC client - ibc.core.client.v1.MsgCreateClientResponse: - type: object - description: MsgCreateClientResponse defines the Msg/CreateClient response type. - ibc.core.client.v1.MsgIBCSoftwareUpgrade: - type: object - properties: - plan: - type: object - properties: - name: - type: string - description: >- - 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. - time: - type: string - format: date-time - description: >- - Deprecated: Time based upgrades have been deprecated. Time based - upgrade logic - - has been removed from the SDK. - - If this field is not empty, an error will be thrown. - height: - type: string - format: int64 - description: The height at which the upgrade must be performed. - info: - type: string - title: >- - Any application specific upgrade info to be included on-chain - - such as a git commit that validators could automatically upgrade - to - upgraded_client_state: - description: >- - Deprecated: UpgradedClientState field has been deprecated. IBC - upgrade logic has been - - moved to the IBC module in the sub module 02-client. - - If this field is not empty, an error will be thrown. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all - types that they - - expect it to use in the context of Any. However, for URLs - which use the - - scheme `http`, `https`, or no scheme, one can optionally set - up a type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on - the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning - with - - type.googleapis.com. As of May 2023, there are no widely used - type server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might - be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - Plan specifies information about a planned upgrade and when it should - occur. - upgraded_client_state: - description: >- - An UpgradedClientState must be provided to perform an IBC breaking - upgrade. - - 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. Correspondingly, the UpgradedClientState field - has been - - deprecated in the Cosmos SDK to allow for this logic to exist solely - in - - the 02-client module. - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - signer: - type: string - title: signer address - title: >- - MsgIBCSoftwareUpgrade defines the message used to schedule an upgrade of - an IBC client using a v1 governance proposal - ibc.core.client.v1.MsgIBCSoftwareUpgradeResponse: - type: object - description: >- - MsgIBCSoftwareUpgradeResponse defines the Msg/IBCSoftwareUpgrade response - type. - ibc.core.client.v1.MsgRecoverClient: - type: object - properties: - subject_client_id: - type: string - title: >- - the client identifier for the client to be updated if the proposal - passes - substitute_client_id: - type: string - title: >- - the substitute client identifier for the client which will replace the - subject - - client - signer: - type: string - title: signer address - description: >- - MsgRecoverClient defines the message used to recover a frozen or expired - client. - ibc.core.client.v1.MsgRecoverClientResponse: - type: object - description: MsgRecoverClientResponse defines the Msg/RecoverClient response type. - ibc.core.client.v1.MsgSubmitMisbehaviour: - type: object - properties: - client_id: - type: string - title: client unique identifier - misbehaviour: - title: misbehaviour used for freezing the light client - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - signer: - type: string - title: signer address - description: |- - MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for - light client misbehaviour. - This message has been deprecated. Use MsgUpdateClient instead. - ibc.core.client.v1.MsgSubmitMisbehaviourResponse: - type: object - description: |- - MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response - type. - ibc.core.client.v1.MsgUpdateClient: - type: object - properties: - client_id: - type: string - title: client unique identifier - client_message: - title: client message to update the light client - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - signer: - type: string - title: signer address - description: |- - MsgUpdateClient defines an sdk.Msg to update a IBC client state using - the given client message. - ibc.core.client.v1.MsgUpdateClientResponse: - type: object - description: MsgUpdateClientResponse defines the Msg/UpdateClient response type. - ibc.core.client.v1.MsgUpdateParams: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the client parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - allowed_clients: - type: array - items: - type: string - description: >- - allowed_clients defines the list of allowed client state types - which can be created - - and interacted with. If a client type is removed from the allowed - clients list, usage - - of this client will be disabled until it is added again to the - list. - description: MsgUpdateParams defines the sdk.Msg type to update the client parameters. - ibc.core.client.v1.MsgUpdateParamsResponse: - type: object - description: MsgUpdateParamsResponse defines the MsgUpdateParams response type. - ibc.core.client.v1.MsgUpgradeClient: - type: object - properties: - client_id: - type: string - title: client unique identifier - client_state: - title: upgraded client state - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - consensus_state: - title: >- - upgraded consensus state, only contains enough information to serve as - a - - basis of trust in update logic - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - proof_upgrade_client: - type: string - format: byte - title: proof that old chain committed to new client - proof_upgrade_consensus_state: - type: string - format: byte - title: proof that old chain committed to new consensus state - signer: - type: string - title: signer address - title: >- - MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new - client - - state - ibc.core.client.v1.MsgUpgradeClientResponse: - type: object - description: MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. - ibc.core.client.v1.Params: - type: object - properties: - allowed_clients: - type: array - items: - type: string - description: >- - allowed_clients defines the list of allowed client state types which - can be created - - and interacted with. If a client type is removed from the allowed - clients list, usage - - of this client will be disabled until it is added again to the list. - description: Params defines the set of IBC light client parameters. - ibc.core.commitment.v1.MerklePrefix: - type: object - properties: - key_prefix: - type: string - format: byte - title: |- - MerklePrefix is merkle path prefixed to the key. - The constructed key from the Path and the key will be append(Path.KeyPath, - append(Path.KeyPrefix, key...)) - ibc.core.connection.v1.Counterparty: - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - description: >- - Counterparty defines the counterparty chain associated with a connection - end. - ibc.core.connection.v1.MsgConnectionOpenAck: - type: object - properties: - connection_id: - type: string - counterparty_connection_id: - type: string - version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - verison in - - the connection handshake. - client_state: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - proof_try: - type: string - format: byte - title: |- - proof of the initialization the connection on Chain B: `UNITIALIZED -> - TRYOPEN` - proof_client: - type: string - format: byte - title: proof of client state included in message - proof_consensus: - type: string - format: byte - title: proof of client consensus state - consensus_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - signer: - type: string - host_consensus_state_proof: - type: string - format: byte - title: >- - optional proof data for host state machines that are unable to - introspect their own consensus state - description: |- - MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to - acknowledge the change of connection state to TRYOPEN on Chain B. - ibc.core.connection.v1.MsgConnectionOpenAckResponse: - type: object - description: >- - MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response - type. - ibc.core.connection.v1.MsgConnectionOpenConfirm: - type: object - properties: - connection_id: - type: string - proof_ack: - type: string - format: byte - title: >- - proof for the change of the connection state on Chain A: `INIT -> - OPEN` - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - signer: - type: string - description: |- - MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to - acknowledge the change of connection state to OPEN on Chain A. - ibc.core.connection.v1.MsgConnectionOpenConfirmResponse: - type: object - description: |- - MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm - response type. - ibc.core.connection.v1.MsgConnectionOpenInit: - type: object - properties: - client_id: - type: string - counterparty: - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - description: >- - Counterparty defines the counterparty chain associated with a - connection end. - version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - verison in - - the connection handshake. - delay_period: - type: string - format: uint64 - signer: - type: string - description: |- - MsgConnectionOpenInit defines the msg sent by an account on Chain A to - initialize a connection with Chain B. - ibc.core.connection.v1.MsgConnectionOpenInitResponse: - type: object - description: |- - MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response - type. - ibc.core.connection.v1.MsgConnectionOpenTry: - type: object - properties: - client_id: - type: string - previous_connection_id: - type: string - description: >- - Deprecated: this field is unused. Crossing hellos are no longer - supported in core IBC. - client_state: - type: object - properties: - '@type': - type: string - description: >- - A URL/resource name that uniquely identifies the type of the - serialized - - protocol buffer message. This string must contain at least - - one "/" character. The last segment of the URL's path must - represent - - the fully qualified name of the type (as in - - `path/google.protobuf.Duration`). The name should be in a - canonical form - - (e.g., leading "." is not accepted). - - - In practice, teams usually precompile into the binary all types - that they - - expect it to use in the context of Any. However, for URLs which - use the - - scheme `http`, `https`, or no scheme, one can optionally set up a - type - - server that maps type URLs to message definitions as follows: - - - * If no scheme is provided, `https` is assumed. - - * An HTTP GET on the URL must yield a [google.protobuf.Type][] - value in binary format, or produce an error. - * Applications are allowed to cache lookup results based on the - URL, or have them precompiled into a binary to avoid any - lookup. Therefore, binary compatibility needs to be preserved - on changes to types. (Use versioned type names to manage - breaking changes.) - - Note: this functionality is not currently available in the - official - - protobuf release, and it is not used for type URLs beginning with - - type.googleapis.com. As of May 2023, there are no widely used type - server - - implementations and no plans to implement one. - - - Schemes other than `http`, `https` (or the empty scheme) might be - - used with implementation specific semantics. - additionalProperties: {} - description: >- - `Any` contains an arbitrary serialized protocol buffer message along - with a - - URL that describes the type of the serialized message. - - - Protobuf library provides support to pack/unpack Any values in the - form - - of utility functions or additional generated methods of the Any type. - - - Example 1: Pack and unpack a message in C++. - - Foo foo = ...; - Any any; - any.PackFrom(foo); - ... - if (any.UnpackTo(&foo)) { - ... - } - - Example 2: Pack and unpack a message in Java. - - Foo foo = ...; - Any any = Any.pack(foo); - ... - if (any.is(Foo.class)) { - foo = any.unpack(Foo.class); - } - // or ... - if (any.isSameTypeAs(Foo.getDefaultInstance())) { - foo = any.unpack(Foo.getDefaultInstance()); - } - - Example 3: Pack and unpack a message in Python. - - foo = Foo(...) - any = Any() - any.Pack(foo) - ... - if any.Is(Foo.DESCRIPTOR): - any.Unpack(foo) - ... - - Example 4: Pack and unpack a message in Go - - foo := &pb.Foo{...} - any, err := anypb.New(foo) - if err != nil { - ... - } - ... - foo := &pb.Foo{} - if err := any.UnmarshalTo(foo); err != nil { - ... - } - - 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 - - name "y.z". - - - JSON - - ==== - - The JSON representation of an `Any` value uses the regular - - representation of the deserialized, embedded message, with an - - additional field `@type` which contains the type URL. Example: - - package google.profile; - message Person { - string first_name = 1; - string last_name = 2; - } - - { - "@type": "type.googleapis.com/google.profile.Person", - "firstName": , - "lastName": - } - - If the embedded message type is well-known and has a custom JSON - - representation, that representation will be embedded adding a field - - `value` which holds the custom JSON in addition to the `@type` - - field. Example (for message [google.protobuf.Duration][]): - - { - "@type": "type.googleapis.com/google.protobuf.Duration", - "value": "1.212s" - } - counterparty: - type: object - properties: - client_id: - type: string - description: >- - identifies the client on the counterparty chain associated with a - given - - connection. - connection_id: - type: string - description: >- - identifies the connection end on the counterparty chain associated - with a - - given connection. - prefix: - description: commitment merkle prefix of the counterparty chain. - type: object - properties: - key_prefix: - type: string - format: byte - title: >- - MerklePrefix is merkle path prefixed to the key. - - The constructed key from the Path and the key will be - append(Path.KeyPath, - - append(Path.KeyPrefix, key...)) - description: >- - Counterparty defines the counterparty chain associated with a - connection end. - delay_period: - type: string - format: uint64 - counterparty_versions: - type: array - items: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: >- - Version defines the versioning scheme used to negotiate the IBC - verison in - - the connection handshake. - proof_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - proof_init: - type: string - format: byte - title: |- - proof of the initialization the connection on Chain A: `UNITIALIZED -> - INIT` - proof_client: - type: string - format: byte - title: proof of client state included in message - proof_consensus: - type: string - format: byte - title: proof of client consensus state - consensus_height: - type: object - properties: - revision_number: - type: string - format: uint64 - title: the revision that the client is currently on - revision_height: - type: string - format: uint64 - title: the height within the given revision - description: >- - Normally the RevisionHeight is incremented at each height while - keeping - - RevisionNumber the same. However some consensus algorithms may choose - to - - reset the height in certain conditions e.g. hard forks, state-machine - - breaking changes In these cases, the RevisionNumber is incremented so - that - - height continues to be monitonically increasing even as the - RevisionHeight - - gets reset - title: >- - Height is a monotonically increasing data type - - that can be compared against another Height for the purposes of - updating and - - freezing clients - signer: - type: string - host_consensus_state_proof: - type: string - format: byte - title: >- - optional proof data for host state machines that are unable to - introspect their own consensus state - description: |- - MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a - connection on Chain B. - ibc.core.connection.v1.MsgConnectionOpenTryResponse: - type: object - description: >- - MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response - type. - ibc.core.connection.v1.MsgUpdateParams: - type: object - properties: - signer: - type: string - title: signer address - params: - description: |- - params defines the connection parameters to update. - - NOTE: All parameters must be supplied. - type: object - properties: - max_expected_time_per_block: - type: string - format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably take to - produce the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per block. - description: >- - MsgUpdateParams defines the sdk.Msg type to update the connection - parameters. - ibc.core.connection.v1.MsgUpdateParamsResponse: - type: object - description: MsgUpdateParamsResponse defines the MsgUpdateParams response type. - ibc.core.connection.v1.Params: - type: object - properties: - max_expected_time_per_block: - type: string - format: uint64 - description: >- - maximum expected time per block (in nanoseconds), used to enforce - block delay. This parameter should reflect the - - largest amount of time that the chain might reasonably take to produce - the next block under normal operating - - conditions. A safe choice is 3-5x the expected time per block. - description: Params defines the set of Connection parameters. - ibc.core.connection.v1.Version: - type: object - properties: - identifier: - type: string - title: unique version identifier - features: - type: array - items: - type: string - title: list of features compatible with the specified identifier - description: |- - Version defines the versioning scheme used to negotiate the IBC verison in - the connection handshake. +{"id":"github.com/artela-network/artela-rollkit","consumes":["application/json"],"produces":["application/json"],"swagger":"2.0","info":{"description":"Chain github.com/artela-network/artela-rollkit REST API","title":"HTTP API Console","contact":{"name":"github.com/artela-network/artela-rollkit"},"version":"version not set"},"paths":{},"definitions":{"google.protobuf.Any":{"type":"object","properties":{"@type":{"type":"string"}},"additionalProperties":{}},"google.rpc.Status":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"details":{"type":"array","items":{"type":"object","$ref":"#/definitions/google.protobuf.Any"}},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/ethereum/rpc/account.go b/ethereum/rpc/account.go deleted file mode 100644 index 37d8076..0000000 --- a/ethereum/rpc/account.go +++ /dev/null @@ -1,320 +0,0 @@ -package rpc - -import ( - "errors" - "fmt" - "math/big" - "time" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - sdkmath "cosmossdk.io/math" - sdkcrypto "github.com/cosmos/cosmos-sdk/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - sdktypes "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/ethereum/go-ethereum/accounts/keystore" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - ethtypes "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/crypto" - "github.com/ethereum/go-ethereum/rpc" - - "github.com/artela-network/artela-rollkit/ethereum/crypto/ethsecp256k1" - "github.com/artela-network/artela-rollkit/ethereum/crypto/hd" - ethapi2 "github.com/artela-network/artela-rollkit/ethereum/rpc/ethapi" - "github.com/artela-network/artela-rollkit/ethereum/rpc/types" - types2 "github.com/artela-network/artela-rollkit/ethereum/types" - "github.com/artela-network/artela-rollkit/ethereum/utils" - evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" -) - -func (b *BackendImpl) Accounts() []common.Address { - addresses := make([]common.Address, 0) // return [] instead of nil if empty - - infos, err := b.clientCtx.Keyring.List() - if err != nil { - b.logger.Info("keying list failed", "error", err) - return nil - } - - for _, info := range infos { - pubKey, err := info.GetPubKey() - if err != nil { - b.logger.Info("getPubKey failed", "info", info, "error", err) - return nil - } - addressBytes := pubKey.Address().Bytes() - addresses = append(addresses, common.BytesToAddress(addressBytes)) - } - - return addresses -} - -func (b *BackendImpl) NewAccount(password string) (common.AddressEIP55, error) { - name := "key_" + time.Now().UTC().Format(time.RFC3339) - - cfg := sdktypes.GetConfig() - basePath := cfg.GetFullBIP44Path() - - hdPathIter, err := types2.NewHDPathIterator(basePath, true) - if err != nil { - b.logger.Info("NewHDPathIterator failed", "error", err) - return common.AddressEIP55{}, err - } - // create the mnemonic and save the account - hdPath := hdPathIter() - - info, _, err := b.clientCtx.Keyring.NewMnemonic(name, keyring.English, hdPath.String(), password, hd.EthSecp256k1) - if err != nil { - b.logger.Info("NewMnemonic failed", "error", err) - return common.AddressEIP55{}, err - } - - pubKey, err := info.GetPubKey() - if err != nil { - b.logger.Info("GetPubKey failed", "error", err) - return common.AddressEIP55{}, err - } - addr := common.BytesToAddress(pubKey.Address().Bytes()) - return common.AddressEIP55(addr), nil -} - -func (b *BackendImpl) ImportRawKey(privkey, password string) (common.Address, error) { - priv, err := crypto.HexToECDSA(privkey) - if err != nil { - return common.Address{}, err - } - - privKey := ðsecp256k1.PrivKey{Key: crypto.FromECDSA(priv)} - - addr := sdktypes.AccAddress(privKey.PubKey().Address().Bytes()) - ethereumAddr := common.BytesToAddress(addr) - - // return if the key has already been imported - if _, err := b.clientCtx.Keyring.KeyByAddress(addr); err == nil { - return ethereumAddr, nil - } - - // ignore error as we only care about the length of the list - list, _ := b.clientCtx.Keyring.List() // #nosec G703 - privKeyName := fmt.Sprintf("personal_%d", len(list)) - - armor := sdkcrypto.EncryptArmorPrivKey(privKey, password, ethsecp256k1.KeyType) - - if err := b.clientCtx.Keyring.ImportPrivKey(privKeyName, armor, password); err != nil { - return common.Address{}, err - } - - return ethereumAddr, nil -} - -func (b *BackendImpl) SignTransaction(args *ethapi2.TransactionArgs) (*ethtypes.Transaction, error) { - _, err := b.clientCtx.Keyring.KeyByAddress(sdktypes.AccAddress(args.From.Bytes())) - if err != nil { - return nil, fmt.Errorf("failed to find key in the node's keyring; %s; %s", keystore.ErrNoMatch, err.Error()) - } - - if args.ChainID != nil && (b.chainID).Cmp((*big.Int)(args.ChainID)) != 0 { - return nil, fmt.Errorf("chainId does not match node's (have=%v, want=%v)", args.ChainID, (*hexutil.Big)(b.chainID)) - } - - bn, err := b.BlockNumber() - if err != nil { - return nil, err - } - - bt, err := b.BlockTimeByNumber(int64(bn)) - if err != nil { - return nil, err - } - - cfg, err := b.chainConfig() - if err != nil { - return nil, err - } - signer := ethtypes.MakeSigner(cfg, new(big.Int).SetUint64(uint64(bn)), bt) - - // LegacyTx derives chainID from the signature. To make sure the msg.ValidateBasic makes - // the corresponding chainID validation, we need to sign the transaction before calling it - - // Sign transaction - msg := args.ToEVMTransaction() - return msg.SignEthereumTx(signer, b.clientCtx.Keyring) -} - -// Sign signs the provided data using the private key of address via Geth's signature standard. -func (b *BackendImpl) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { - from := sdktypes.AccAddress(address.Bytes()) - - _, err := b.clientCtx.Keyring.KeyByAddress(from) - if err != nil { - return nil, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error()) - } - - // Sign the requested hash with the wallet - signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data, signing.SignMode_SIGN_MODE_DIRECT) - if err != nil { - return nil, err - } - - signature[crypto.RecoveryIDOffset] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper - return signature, nil -} - -func (b *BackendImpl) GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) { - n := hexutil.Uint64(0) - height, err := b.blockNumberFromCosmos(blockNrOrHash) - if err != nil { - return &n, err - } - header, err := b.CurrentHeader() - if err != nil { - return &n, err - } - if height.Int64() > header.Number.Int64() { - return &n, fmt.Errorf( - "cannot query with height in the future (current: %d, queried: %d); please provide a valid height", - header.Number, height) - } - // Get nonce (sequence) from account - from := sdktypes.AccAddress(address.Bytes()) - accRet := b.clientCtx.AccountRetriever - - if err = accRet.EnsureExists(b.clientCtx, from); err != nil { - // account doesn't exist yet, return 0 - b.logger.Info("GetTransactionCount faild, return 0. Account doesn't exist yet", "account", address.Hex(), "error", err) - return &n, nil - } - - includePending := height == rpc.PendingBlockNumber - nonce, err := b.getAccountNonce(address, includePending, height.Int64()) - if err != nil { - return nil, err - } - - n = hexutil.Uint64(nonce) - return &n, nil -} - -func (b *BackendImpl) getAccountNonce(accAddr common.Address, pending bool, height int64) (uint64, error) { - queryClient := authtypes.NewQueryClient(b.clientCtx) - adr := sdktypes.AccAddress(accAddr.Bytes()).String() - ctx := types.ContextWithHeight(height) - res, err := queryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: adr}) - if err != nil { - st, ok := status.FromError(err) - // treat as account doesn't exist yet - if ok && st.Code() == codes.NotFound { - b.logger.Info("getAccountNonce faild, account not found", "error", err) - return 0, nil - } - return 0, err - } - var acc authtypes.AccountI - if err := b.clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { - return 0, err - } - - nonce := acc.GetSequence() - - if !pending { - return nonce, nil - } - - // the account retriever doesn't include the uncommitted transactions on the nonce so we need to - // to manually add them. - pendingTxs, err := b.PendingTransactions() - if err != nil { - return nonce, nil - } - - // add the uncommitted txs to the nonce counter - // only supports `MsgEthereumTx` style tx - for _, tx := range pendingTxs { - for _, msg := range (*tx).GetMsgs() { - ethMsg, ok := msg.(*evmtypes.MsgEthereumTx) - if !ok { - // not ethereum tx - break - } - - sender, err := b.GetSender(ethMsg, b.chainID) - if err != nil { - continue - } - if sender == accAddr { - nonce++ - } - } - } - - return nonce, nil -} - -func (b *BackendImpl) GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) { - blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) - if err != nil { - return nil, err - } - - req := &evmtypes.QueryBalanceRequest{ - Address: address.String(), - } - - _, err = b.CosmosBlockByNumber(blockNum) - if err != nil { - return nil, err - } - - res, err := b.queryClient.Balance(types.ContextWithHeight(blockNum.Int64()), req) - if err != nil { - return nil, err - } - - val, ok := sdkmath.NewIntFromString(res.Balance) - if !ok { - return nil, errors.New("invalid balance") - } - - if val.IsNegative() { - return nil, errors.New("couldn't fetch balance. Node state is pruned") - } - - return (*hexutil.Big)(val.BigInt()), nil -} - -// GetSender extracts the sender address from the signature values using the latest signer for the given chainID. -func (b *BackendImpl) GetSender(msg *evmtypes.MsgEthereumTx, chainID *big.Int) (from common.Address, err error) { - if msg.From != "" { - return common.HexToAddress(msg.From), nil - } - - tx := msg.AsTransaction() - // retrieve sender info from aspect if tx is not signed - if utils.IsCustomizedVerification(tx) { - bn, err := b.BlockNumber() - if err != nil { - return common.Address{}, err - } - ctx := types.ContextWithHeight(int64(bn)) - - res, err := b.queryClient.GetSender(ctx, msg) - if err != nil { - return common.Address{}, err - } - - from = common.HexToAddress(res.Sender) - } else { - signer := ethtypes.LatestSignerForChainID(chainID) - from, err = signer.Sender(tx) - if err != nil { - return common.Address{}, err - } - } - - msg.From = from.Hex() - return from, nil -} diff --git a/ethereum/rpc/ethapi/addrlock.go b/ethereum/rpc/api/addrlock.go similarity index 98% rename from ethereum/rpc/ethapi/addrlock.go rename to ethereum/rpc/api/addrlock.go index 5bc5bbc..05471a5 100644 --- a/ethereum/rpc/ethapi/addrlock.go +++ b/ethereum/rpc/api/addrlock.go @@ -1,4 +1,4 @@ -package ethapi +package api import ( "sync" diff --git a/ethereum/rpc/ethapi/dbapi.go b/ethereum/rpc/api/dbapi.go similarity index 98% rename from ethereum/rpc/ethapi/dbapi.go rename to ethereum/rpc/api/dbapi.go index 1675375..f78b84e 100644 --- a/ethereum/rpc/ethapi/dbapi.go +++ b/ethereum/rpc/api/dbapi.go @@ -1,4 +1,4 @@ -package ethapi +package api import ( "errors" diff --git a/ethereum/rpc/api/debug.go b/ethereum/rpc/api/debug.go index 059df60..1044d8b 100644 --- a/ethereum/rpc/api/debug.go +++ b/ethereum/rpc/api/debug.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "fmt" "io" "os" "os/user" @@ -18,33 +19,20 @@ import ( stderrors "github.com/pkg/errors" - "github.com/cometbft/cometbft/libs/log" - tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" "github.com/cosmos/cosmos-sdk/server" "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" - evmsupport "github.com/artela-network/artela-rollkit/x/evm/types" - + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" evmtxs "github.com/artela-network/artela-rollkit/x/evm/txs" + evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" ) -type DebugBackend interface { - TraceTransaction(hash common.Hash, config *evmsupport.TraceConfig) (interface{}, error) - TraceBlock(height rpc.BlockNumber, - config *evmsupport.TraceConfig, - block *tmrpctypes.ResultBlock, - ) ([]*evmtxs.TxTraceResult, error) - CosmosBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) - CosmosBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error) - HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Header, error) - BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Block, error) -} - // HandlerT keeps track of the cpu profiler and trace execution type HandlerT struct { cpuFilename string @@ -58,49 +46,179 @@ type HandlerT struct { type DebugAPI struct { ctx *server.Context logger log.Logger - backend DebugBackend + b rpctypes.DebugBackend handler *HandlerT } // NewDebugAPI creates a new DebugAPI definition for the tracing methods of the Ethereum service. func NewDebugAPI( - backend DebugBackend, + backend rpctypes.DebugBackend, + logger log.Logger, + ctx *server.Context, ) *DebugAPI { return &DebugAPI{ - backend: backend, + b: backend, handler: new(HandlerT), + logger: logger, + ctx: ctx, + } +} + +// GetRawHeader retrieves the RLP encoding for a single header. +func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + header, err := api.b.HeaderByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return nil, err + } + if header == nil { + return nil, fmt.Errorf("block not found") + } + return rlp.EncodeToBytes(header) +} + +// GetRawBlock retrieves the RLP encoded for a single block. +func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + block, err := api.b.ArtBlockByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return nil, err + } + if block == nil { + return nil, fmt.Errorf("block not found") + } + + // marshal the eth block, be care that the block hash is not matched to + // what was saved in cosmos db. + return rlp.EncodeToBytes(block.EthBlock()) +} + +func (api *DebugAPI) GetReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (types.Receipts, error) { + block, err := api.b.ArtBlockByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return nil, err + } + if block == nil { + return nil, fmt.Errorf("block not found") + } + + return api.b.GetReceipts(ctx, block.Hash()) +} + +// GetRawReceipts retrieves the binary-encoded receipts of a single block. +func (api *DebugAPI) GetRawReceipts(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) { + block, err := api.b.ArtBlockByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return nil, err + } + if block == nil { + return nil, fmt.Errorf("block not found") + } + + receipts, err := api.b.GetReceipts(ctx, block.Hash()) + if err != nil { + return nil, err + } + result := make([]hexutil.Bytes, len(receipts)) + for i, receipt := range receipts { + b, err := receipt.MarshalBinary() + if err != nil { + return nil, err + } + result[i] = b + } + return result, nil +} + +// GetRawTransaction returns the bytes of the transaction for the given hash. +func (api *DebugAPI) GetRawTransaction(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { + txMsg, err := api.b.GetTxMsg(ctx, hash) + if err != nil { + return nil, err + } + if txMsg == nil { + pendingTxs, err := api.b.PendingTransactions() + if err != nil { + return nil, nil + } + + cfg := api.b.ChainConfig() + if cfg == nil { + return nil, nil + } + + for _, pendingTx := range pendingTxs { + for _, msg := range (*pendingTx).GetMsgs() { + if ethMsg, ok := msg.(*evmtypes.MsgEthereumTx); ok { + if ethMsg.AsTransaction().Hash() == hash { + txMsg = ethMsg + } + } + } + } + } + return txMsg.AsTransaction().MarshalBinary() +} + +// PrintBlock retrieves a block and returns its pretty printed form. +func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) { + block, _ := api.b.ArtBlockByNumber(ctx, rpc.BlockNumber(number)) + if block == nil { + return "", fmt.Errorf("block #%d not found", number) } + return spew.Sdump(block), nil +} + +// ChaindbProperty returns leveldb properties of the key-value database. +func (api *DebugAPI) ChaindbProperty(property string) (string, error) { + return api.b.DBProperty(property) +} + +// ChaindbCompact flattens the entire key-value database into a single level, +// removing all unused slots and merging all keys. +func (api *DebugAPI) ChaindbCompact() error { + for b := byte(0); b < 255; b++ { + api.logger.Info("Compacting chain database", "range", fmt.Sprintf("0x%0.2X-0x%0.2X", b, b+1)) + if err := api.b.DBCompact([]byte{b}, []byte{b + 1}); err != nil { + api.logger.Error("Database compaction failed", "err", err) + return err + } + } + return nil +} + +// SetHead rewinds the head of the blockchain to a previous block. +func (api *DebugAPI) SetHead(_ hexutil.Uint64) { + // not support, for a cosmos chain, use rollback instead } // TraceTransaction returns the structured logs created during the execution of EVM // and returns them as a JSON object. -func (a *DebugAPI) TraceTransaction(hash common.Hash, config evmsupport.TraceConfig) (interface{}, error) { - return a.backend.TraceTransaction(hash, &config) +func (a *DebugAPI) TraceTransaction(hash common.Hash, config evmtypes.TraceConfig) (interface{}, error) { + return a.b.TraceTransaction(hash, &config) } // TraceBlockByNumber returns the structured logs created during the execution of // EVM and returns them as a JSON object. -func (a *DebugAPI) TraceBlockByNumber(height rpc.BlockNumber, config evmsupport.TraceConfig) ([]*evmtxs.TxTraceResult, error) { +func (a *DebugAPI) TraceBlockByNumber(height rpc.BlockNumber, config evmtypes.TraceConfig) ([]*evmtxs.TxTraceResult, error) { a.logger.Debug("debug_traceBlockByNumber", "height", height) if height == 0 { return nil, errors.New("genesis is not traceable") } // Get Tendermint Block - resBlock, err := a.backend.CosmosBlockByNumber(height) + resBlock, err := a.b.CosmosBlockByNumber(height) if err != nil { a.logger.Debug("get block failed", "height", height, "error", err.Error()) return nil, err } - return a.backend.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), &config, resBlock) + return a.b.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), &config, resBlock) } // TraceBlockByHash returns the structured logs created during the execution of // EVM and returns them as a JSON object. -func (a *DebugAPI) TraceBlockByHash(hash common.Hash, config evmsupport.TraceConfig) ([]*evmtxs.TxTraceResult, error) { +func (a *DebugAPI) TraceBlockByHash(hash common.Hash, config evmtypes.TraceConfig) ([]*evmtxs.TxTraceResult, error) { a.logger.Debug("debug_traceBlockByHash", "hash", hash) // Get Tendermint Block - resBlock, err := a.backend.CosmosBlockByHash(hash) + resBlock, err := a.b.CosmosBlockByHash(hash) if err != nil { a.logger.Debug("get block failed", "hash", hash.Hex(), "error", err.Error()) return nil, err @@ -111,7 +229,7 @@ func (a *DebugAPI) TraceBlockByHash(hash common.Hash, config evmsupport.TraceCon return nil, errors.New("block not found") } - return a.backend.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), &config, resBlock) + return a.b.TraceBlock(rpc.BlockNumber(resBlock.Block.Height), &config, resBlock) } // BlockProfile turns on goroutine profiling for nsec seconds and writes profile data to @@ -300,7 +418,7 @@ func (a *DebugAPI) SetGCPercent(v int) int { // GetHeaderRlp retrieves the RLP encoded for of a single header. func (a *DebugAPI) GetHeaderRlp(number uint64) (hexutil.Bytes, error) { - header, err := a.backend.HeaderByNumber(context.TODO(), rpc.BlockNumber(number)) + header, err := a.b.HeaderByNumber(context.TODO(), rpc.BlockNumber(number)) if err != nil { return nil, err } @@ -310,32 +428,24 @@ func (a *DebugAPI) GetHeaderRlp(number uint64) (hexutil.Bytes, error) { // GetBlockRlp retrieves the RLP encoded for of a single block. func (a *DebugAPI) GetBlockRlp(number uint64) (hexutil.Bytes, error) { - block, err := a.backend.BlockByNumber(context.TODO(), rpc.BlockNumber(number)) + block, err := a.b.ArtBlockByNumber(context.TODO(), rpc.BlockNumber(number)) if err != nil { return nil, err } - return rlp.EncodeToBytes(block) -} - -// PrintBlock retrieves a block and returns its pretty printed form. -func (a *DebugAPI) PrintBlock(number uint64) (string, error) { - block, err := a.backend.BlockByNumber(context.TODO(), rpc.BlockNumber(number)) - if err != nil { - return "", err - } - - return spew.Sdump(block), nil + // marshal the eth block, be care that the block hash is not matched to + // what was saved in cosmos db. + return rlp.EncodeToBytes(block.EthBlock()) } // SeedHash retrieves the seed hash of a block. func (a *DebugAPI) SeedHash(_ uint64) (string, error) { - return "", errors.New("SeedHash is not implemented") + return "", errors.New("SeedHash is not valid") } // IntermediateRoots executes a block, and returns a list // of intermediate roots: the stateroot after each transaction. -func (a *DebugAPI) IntermediateRoots(hash common.Hash, _ *evmsupport.TraceConfig) ([]common.Hash, error) { +func (a *DebugAPI) IntermediateRoots(hash common.Hash, _ *evmtypes.TraceConfig) ([]common.Hash, error) { a.logger.Debug("debug_intermediateRoots", "hash", hash) return ([]common.Hash)(nil), nil } diff --git a/ethereum/rpc/ethapi/api.go b/ethereum/rpc/api/eth.go similarity index 58% rename from ethereum/rpc/ethapi/api.go rename to ethereum/rpc/api/eth.go index 78a5234..cc1a8e6 100644 --- a/ethereum/rpc/ethapi/api.go +++ b/ethereum/rpc/api/eth.go @@ -1,28 +1,20 @@ -package ethapi +package api import ( "context" "errors" "fmt" "math/big" - "time" - "github.com/davecgh/go-spew/spew" - - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/p2p" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/artela-network/artela-evm/vm" @@ -34,12 +26,12 @@ import ( // EthereumAPI provides an API to access Ethereum related information. type EthereumAPI struct { - b Backend + b rpctypes.EthereumBackend logger log.Logger } // NewEthereumAPI creates a new Ethereum protocol API. -func NewEthereumAPI(b Backend, logger log.Logger) *EthereumAPI { +func NewEthereumAPI(b rpctypes.EthereumBackend, logger log.Logger) *EthereumAPI { return &EthereumAPI{b, logger} } @@ -57,7 +49,15 @@ func (s *EthereumAPI) GasPrice(ctx context.Context) (*hexutil.Big, error) { // MaxPriorityFeePerGas returns a suggestion for a gas tip cap for dynamic fee transactions. func (s *EthereumAPI) MaxPriorityFeePerGas(_ context.Context) (*hexutil.Big, error) { - return nil, errors.New("MaxPriorityFeePerGas is not implemented") + head, err := s.b.CurrentHeader() + if err != nil { + return nil, err + } + tipcap, err := s.b.SuggestGasTipCap(head.BaseFee) + if err != nil { + return nil, err + } + return (*hexutil.Big)(tipcap), nil } // FeeHistory returns the fee market history. @@ -77,49 +77,14 @@ func (s *EthereumAPI) Syncing() (interface{}, error) { return s.b.Syncing() } -// TxPoolAPI offers and API for the transaction pool. It only operates on data that is non-confidential. -type TxPoolAPI struct { - b Backend -} - -// NewTxPoolAPI creates a new tx pool service that gives information about the transaction pool. -func NewTxPoolAPI(b Backend) *TxPoolAPI { - return &TxPoolAPI{b} -} - -// Content returns the transactions contained within the transaction pool. -func (s *TxPoolAPI) Content() map[string]map[string]map[string]*RPCTransaction { - // not implemented - return nil -} - -// ContentFrom returns the transactions contained within the transaction pool. -func (s *TxPoolAPI) ContentFrom(_ common.Address) map[string]map[string]*RPCTransaction { - // not implemented - return nil -} - -// Status returns the number of pending and queued transaction in the pool. -func (s *TxPoolAPI) Status() map[string]hexutil.Uint { - // not implemented - return nil -} - -// Inspect retrieves the content of the transaction pool and flattens it into an -// easily inspectable list. -func (s *TxPoolAPI) Inspect() map[string]map[string]map[string]string { - // not implemented - return nil -} - // EthereumAccountAPI provides an API to access accounts managed by this node. // It offers only methods that can retrieve accounts. type EthereumAccountAPI struct { - b Backend + b rpctypes.EthereumBackend } // NewEthereumAccountAPI creates a new EthereumAccountAPI. -func NewEthereumAccountAPI(b Backend) *EthereumAccountAPI { +func NewEthereumAccountAPI(b rpctypes.EthereumBackend) *EthereumAccountAPI { return &EthereumAccountAPI{b} } @@ -128,178 +93,14 @@ func (s *EthereumAccountAPI) Accounts() []common.Address { return s.b.Accounts() } -// PersonalAccountAPI provides an API to access accounts managed by this node. -// It offers methods to create, (un)lock en list accounts. Some methods accept -// passwords and are therefore considered private by default. -type PersonalAccountAPI struct { - nonceLock *AddrLocker - logger log.Logger - b Backend -} - -// NewPersonalAccountAPI create a new PersonalAccountAPI. -func NewPersonalAccountAPI(b Backend, logger log.Logger, nonceLock *AddrLocker) *PersonalAccountAPI { - return &PersonalAccountAPI{ - nonceLock: nonceLock, - logger: logger, - b: b, - } -} - -// ListAccounts will return a list of addresses for accounts this node manages. -func (s *PersonalAccountAPI) ListAccounts() []common.Address { - return s.b.Accounts() -} - -// rawWallet is a JSON representation of an accounts.Wallet interface, with its -// data contents extracted into plain fields. -type rawWallet struct { - URL string `json:"url"` - Status string `json:"status"` - Failure string `json:"failure,omitempty"` - Accounts []accounts.Account `json:"accounts,omitempty"` -} - -// ListWallets will return a list of wallets this node manages. -func (s *PersonalAccountAPI) ListWallets() []rawWallet { - // not implemented - wallets := make([]rawWallet, 0) // return [] instead of nil if empty - return wallets -} - -// OpenWallet initiates a hardware wallet opening procedure, establishing a USB -// connection and attempting to authenticate via the provided passphrase. Note, -// the method may return an extra challenge requiring a second open (e.g. the -// Trezor PIN matrix challenge). -func (s *PersonalAccountAPI) OpenWallet(_ string, _ *string) error { - return errors.New("OpenWallet is not implemented") -} - -// DeriveAccount requests an HD wallet to derive a new account, optionally pinning -// it for later reuse. -func (s *PersonalAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) { - return accounts.Account{}, errors.New("DeriveAccount is not implemented") -} - -// NewAccount will create a new account and returns the address for the new account. -func (s *PersonalAccountAPI) NewAccount(password string) (common.AddressEIP55, error) { - return s.b.NewAccount(password) -} - -// ImportRawKey stores the given hex encoded ECDSA key into the key directory, -// encrypting it with the passphrase. -func (s *PersonalAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { - return s.b.ImportRawKey(privkey, password) -} - -// UnlockAccount will unlock the account associated with the given address with -// the given password for duration seconds. If duration is nil it will use a -// default of 300 seconds. It returns an indication if the account was unlocked. -func (s *PersonalAccountAPI) UnlockAccount(_ context.Context, _ common.Address, _ string, duration *uint64) (bool, error) { - // not implemented - return false, errors.New("UnlockAccount is not implemented") -} - -// LockAccount will lock the account associated with the given address when it's unlocked. -func (s *PersonalAccountAPI) LockAccount(_ common.Address) bool { - // not implemented" - return false -} - -// signTransaction sets defaults and signs the given transaction -// NOTE: the caller needs to ensure that the nonceLock is held, if applicable, -// and release it after the transaction has been submitted to the tx pool -func (s *PersonalAccountAPI) signTransaction(_ context.Context, args *TransactionArgs, passwd string) (*types.Transaction, error) { - // return s.b.SignTransaction(args, passwd) - // TODO - return nil, fmt.Errorf("signTransaction is not implemented, args: %v, passwd: %s", args, passwd) -} - -// SendTransaction will create a transaction from the given arguments and -// tries to sign it with the key associated with args.From. If the given -// passwd isn't able to decrypt the key it fails. -func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args TransactionArgs, passwd string) (common.Hash, error) { - if args.Nonce == nil { - // Hold the mutex around signing to prevent concurrent assignment of - // the same nonce to multiple accounts. - s.nonceLock.LockAddr(args.from()) - defer s.nonceLock.UnlockAddr(args.from()) - } - signed, err := s.signTransaction(ctx, &args, passwd) - if err != nil { - log.Warn("Failed transaction send attempt", "from", args.from(), "to", args.To, "value", args.Value.ToInt(), "err", err) - return common.Hash{}, err - } - return SubmitTransaction(ctx, s.logger, s.b, signed) -} - -// SignTransaction will create a transaction from the given arguments and -// tries to sign it with the key associated with args.From. If the given passwd isn't -// able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast -// to other nodes -func (s *PersonalAccountAPI) SignTransaction(_ context.Context, args TransactionArgs, passwd string) (*SignTransactionResult, error) { - // TODO - return nil, fmt.Errorf("SignTransaction is not implemented, args: %v, passwd: %s", args, passwd) -} - -// Sign calculates an Ethereum ECDSA signature for: -// keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)) -// -// Note, the produced signature conforms to the secp256k1 curve R, S and V values, -// where the V value will be 27 or 28 for legacy reasons. -// -// The key used to calculate the signature is decrypted with the given password. -// -// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign -func (s *PersonalAccountAPI) Sign(_ context.Context, _ hexutil.Bytes, _ common.Address, _ string) (hexutil.Bytes, error) { - // TODO - return nil, errors.New("Sign is not implemented") -} - -// EcRecover returns the address for the account that was used to create the signature. -// Note, this function is compatible with eth_sign and personal_sign. As such it recovers -// the address of: -// hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) -// addr = ecrecover(hash, signature) -// -// Note, the signature must conform to the secp256k1 curve R, S and V values, where -// the V value must be 27 or 28 for legacy reasons. -// -// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover -func (s *PersonalAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error) { - if len(sig) != crypto.SignatureLength { - return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength) - } - if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 { - return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)") - } - sig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1 - - rpk, err := crypto.SigToPub(accounts.TextHash(data), sig) - if err != nil { - return common.Address{}, err - } - return crypto.PubkeyToAddress(*rpk), nil -} - -// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key. -func (s *PersonalAccountAPI) InitializeWallet(_ context.Context, _ string) (string, error) { - return "", errors.New("InitializeWallet is not implemented") -} - -// Unpair deletes a pairing between wallet and geth. -func (s *PersonalAccountAPI) Unpair(_ context.Context, _ string, _ string) error { - return errors.New("unpair is not implemented") -} - // BlockChainAPI provides an API to access Ethereum blockchain data. type BlockChainAPI struct { logger log.Logger - b Backend + b rpctypes.BlockChainBackend } // NewBlockChainAPI creates a new Ethereum blockchain API. -func NewBlockChainAPI(b Backend, logger log.Logger) *BlockChainAPI { +func NewBlockChainAPI(b rpctypes.BlockChainBackend, logger log.Logger) *BlockChainAPI { return &BlockChainAPI{logger, b} } @@ -313,8 +114,14 @@ func (s *BlockChainAPI) ChainId() *hexutil.Big { return (*hexutil.Big)(s.b.ChainConfig().ChainID) } -func (s *BlockChainAPI) Coinbase() (sdktypes.AccAddress, error) { - return s.b.GetCoinbase() +func (s *BlockChainAPI) Coinbase() (common.Address, error) { + // coinbase return the operator address of the validator node + coinbase, err := s.b.GetCoinbase() + if err != nil { + return common.Address{}, err + } + ethAddr := common.BytesToAddress(coinbase.Bytes()) + return ethAddr, nil } // BlockNumber returns the block number of the chain head. @@ -613,7 +420,7 @@ func (context *ChainContext) GetHeader(hash common.Hash, number uint64) *types.H // // Note, this function doesn't make and changes in the states/blockchain and is // useful to execute and retrieve values. -func (s *BlockChainAPI) Call(_ context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, _ *StateOverride, _ *BlockOverrides) (hexutil.Bytes, error) { +func (s *BlockChainAPI) Call(_ context.Context, args rpctypes.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, _ *StateOverride, _ *BlockOverrides) (hexutil.Bytes, error) { data, err := s.b.DoCall(args, blockNrOrHash) if err != nil { return hexutil.Bytes{}, err @@ -624,7 +431,7 @@ func (s *BlockChainAPI) Call(_ context.Context, args TransactionArgs, blockNrOrH // EstimateGas returns an estimate of the amount of gas needed to execute the // given transaction against the current pending block. -func (s *BlockChainAPI) EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { +func (s *BlockChainAPI) EstimateGas(ctx context.Context, args rpctypes.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { return s.b.EstimateGas(ctx, args, blockNrOrHash) } @@ -674,7 +481,7 @@ func RPCMarshalBlock(block *rpctypes.Block, inclTx bool, fullTx bool, config *pa } if fullTx { formatTx = func(idx int, tx *types.Transaction) interface{} { - return newRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(idx), config) + return rpctypes.NewRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(idx), config) } } txs := block.Transactions() @@ -710,138 +517,6 @@ func (s *BlockChainAPI) rpcMarshalBlock(_ context.Context, b *rpctypes.Block, in return RPCMarshalBlock(b, inclTx, fullTx, s.b.ChainConfig()) } -// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction -type RPCTransaction struct { - BlockHash *common.Hash `json:"blockHash"` - BlockNumber *hexutil.Big `json:"blockNumber"` - From common.Address `json:"from"` - Gas hexutil.Uint64 `json:"gas"` - GasPrice *hexutil.Big `json:"gasPrice"` - GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` - GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` - Hash common.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` - Nonce hexutil.Uint64 `json:"nonce"` - To *common.Address `json:"to"` - TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` - Value *hexutil.Big `json:"value"` - Type hexutil.Uint64 `json:"type"` - Accesses *types.AccessList `json:"accessList,omitempty"` - ChainID *hexutil.Big `json:"chainId,omitempty"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` -} - -// newRPCTransaction returns a transaction that will serialize to the RPC -// representation, with the given location metadata set (if available). -func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { - signer := types.MakeSigner(config, new(big.Int).SetUint64(blockNumber), blockTime) - from, _ := types.Sender(signer, tx) - - return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, from) -} - -func newRPCTransactionWithFrom(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, from common.Address) *RPCTransaction { - v, r, s := tx.RawSignatureValues() - result := &RPCTransaction{ - Type: hexutil.Uint64(tx.Type()), - From: from, - Gas: hexutil.Uint64(tx.Gas()), - GasPrice: (*hexutil.Big)(tx.GasPrice()), - Hash: tx.Hash(), - Input: hexutil.Bytes(tx.Data()), - Nonce: hexutil.Uint64(tx.Nonce()), - To: tx.To(), - Value: (*hexutil.Big)(tx.Value()), - V: (*hexutil.Big)(v), - R: (*hexutil.Big)(r), - S: (*hexutil.Big)(s), - } - if blockHash != (common.Hash{}) { - result.BlockHash = &blockHash - result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) - result.TransactionIndex = (*hexutil.Uint64)(&index) - } - switch tx.Type() { - case types.LegacyTxType: - // if a legacy transaction has an EIP-155 chain id, include it explicitly - if id := tx.ChainId(); id.Sign() != 0 { - result.ChainID = (*hexutil.Big)(id) - } - case types.AccessListTxType: - al := tx.AccessList() - result.Accesses = &al - result.ChainID = (*hexutil.Big)(tx.ChainId()) - case types.DynamicFeeTxType: - al := tx.AccessList() - result.Accesses = &al - result.ChainID = (*hexutil.Big)(tx.ChainId()) - result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap()) - result.GasTipCap = (*hexutil.Big)(tx.GasTipCap()) - // if the transaction has been mined, compute the effective gas price - if baseFee != nil && blockHash != (common.Hash{}) { - // price = min(tip, gasFeeCap - baseFee) + baseFee - price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap()) - result.GasPrice = (*hexutil.Big)(price) - } else { - result.GasPrice = (*hexutil.Big)(tx.GasFeeCap()) - } - } - return result -} - -// NewTransactionFromMsg returns a txs that will serialize to the RPC -// representation, with the given location metadata set (if available). -func NewTransactionFromMsg( - msg *evmtypes.MsgEthereumTx, - blockHash common.Hash, - blockNumber, index uint64, - baseFee *big.Int, - cfg *params.ChainConfig, -) *RPCTransaction { - tx := msg.AsTransaction() - // use latest singer, so use time.now as block time. - if msg.From != "" { - return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, common.HexToAddress(msg.From)) - } - return newRPCTransaction(tx, blockHash, blockNumber, uint64(time.Now().Unix()), index, baseFee, cfg) -} - -// NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation -func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction { - var ( - baseFee *big.Int - blockNumber = uint64(0) - blockTime = uint64(0) - ) - if current != nil { - baseFee = misc.CalcBaseFee(config, current) - blockNumber = current.Number.Uint64() - blockTime = current.Time - } - return newRPCTransaction(tx, common.Hash{}, blockNumber, blockTime, 0, baseFee, config) -} - -// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation. -func newRPCTransactionFromBlockIndex(b *types.Block, blockHash common.Hash, index uint64, config *params.ChainConfig) *RPCTransaction { - txs := b.Transactions() - if index >= uint64(len(txs)) { - return nil - } - return newRPCTransaction(txs[index], blockHash, b.NumberU64(), b.Time(), index, b.BaseFee(), config) -} - -// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index. -func newRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.Bytes { - txs := b.Transactions() - if index >= uint64(len(txs)) { - return nil - } - blob, _ := txs[index].MarshalBinary() - return blob -} - // AccessListResult returns an optional access list // It's the result of the `debug_createAccessList` RPC call. // It contains an error if the transaction itself failed. @@ -853,19 +528,19 @@ type AccessListResult struct { // CreateAccessList creates an EIP-2930 type AccessList for the given transaction. // Reexec and BlockNrOrHash can be specified to create the accessList on top of a certain states. -func (s *BlockChainAPI) CreateAccessList(_ context.Context, _ TransactionArgs, _ *rpc.BlockNumberOrHash) (*AccessListResult, error) { +func (s *BlockChainAPI) CreateAccessList(_ context.Context, _ rpctypes.TransactionArgs, _ *rpc.BlockNumberOrHash) (*AccessListResult, error) { return nil, errors.New("CreateAccessList is not implemented") } // TransactionAPI exposes methods for reading and creating transaction data. type TransactionAPI struct { - b Backend + b rpctypes.TrancsactionBackend logger log.Logger nonceLock *AddrLocker } // NewTransactionAPI creates a new RPC service with methods for interacting with transactions. -func NewTransactionAPI(b Backend, logger log.Logger, nonceLock *AddrLocker) *TransactionAPI { +func NewTransactionAPI(b rpctypes.TrancsactionBackend, logger log.Logger, nonceLock *AddrLocker) *TransactionAPI { // The signer used by the API should always be the 'latest' known one because we expect // signers to be backwards-compatible with old transactions. return &TransactionAPI{b, logger, nonceLock} @@ -890,17 +565,17 @@ func (s *TransactionAPI) GetBlockTransactionCountByHash(ctx context.Context, blo } // GetTransactionByBlockNumberAndIndex returns the transaction for the given block number and index. -func (s *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *RPCTransaction { +func (s *TransactionAPI) GetTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) *rpctypes.RPCTransaction { if block, _ := s.b.ArtBlockByNumber(ctx, blockNr); block != nil { - return newRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(index), s.b.ChainConfig()) + return rpctypes.NewRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(index), s.b.ChainConfig()) } return nil } // GetTransactionByBlockHashAndIndex returns the transaction for the given block hash and index. -func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *RPCTransaction { +func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) *rpctypes.RPCTransaction { if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { - return newRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(index), s.b.ChainConfig()) + return rpctypes.NewRPCTransactionFromBlockIndex(block.EthBlock(), block.Hash(), uint64(index), s.b.ChainConfig()) } return nil } @@ -908,7 +583,7 @@ func (s *TransactionAPI) GetTransactionByBlockHashAndIndex(ctx context.Context, // GetRawTransactionByBlockNumberAndIndex returns the bytes of the transaction for the given block number and index. func (s *TransactionAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Context, blockNr rpc.BlockNumber, index hexutil.Uint) hexutil.Bytes { if block, _ := s.b.ArtBlockByNumber(ctx, blockNr); block != nil { - return newRPCRawTransactionFromBlockIndex(block.EthBlock(), uint64(index)) + return rpctypes.NewRPCRawTransactionFromBlockIndex(block.EthBlock(), uint64(index)) } return nil } @@ -916,7 +591,7 @@ func (s *TransactionAPI) GetRawTransactionByBlockNumberAndIndex(ctx context.Cont // GetRawTransactionByBlockHashAndIndex returns the bytes of the transaction for the given block hash and index. func (s *TransactionAPI) GetRawTransactionByBlockHashAndIndex(ctx context.Context, blockHash common.Hash, index hexutil.Uint) hexutil.Bytes { if block, _ := s.b.BlockByHash(ctx, blockHash); block != nil { - return newRPCRawTransactionFromBlockIndex(block.EthBlock(), uint64(index)) + return rpctypes.NewRPCRawTransactionFromBlockIndex(block.EthBlock(), uint64(index)) } return nil } @@ -927,14 +602,22 @@ func (s *TransactionAPI) GetTransactionCount(_ context.Context, address common.A } // GetTransactionByHash returns the transaction for the given hash -func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*RPCTransaction, error) { +func (s *TransactionAPI) GetTransactionByHash(ctx context.Context, hash common.Hash) (*rpctypes.RPCTransaction, error) { return s.b.GetTransaction(ctx, hash) } // GetRawTransactionByHash returns the bytes of the transaction for the given hash. -func (s *TransactionAPI) GetRawTransactionByHash(_ context.Context, _ common.Hash) (hexutil.Bytes, error) { - // TODO - return nil, errors.New("GetRawTransactionByHash is not implemented") +func (s *TransactionAPI) GetRawTransactionByHash(ctx context.Context, hash common.Hash) (hexutil.Bytes, error) { + msg, err := s.b.GetTxMsg(ctx, hash) + if err != nil { + return nil, err + } + + if msg == nil { + return nil, nil + } + + return msg.AsTransaction().MarshalBinary() } // GetTransactionReceipt returns the transaction receipt for the given transaction hash. @@ -943,7 +626,7 @@ func (s *TransactionAPI) GetTransactionReceipt(ctx context.Context, hash common. } // SubmitTransaction is a helper function that submits tx to txPool and logs a message. -func SubmitTransaction(ctx context.Context, logger log.Logger, b Backend, tx *types.Transaction) (common.Hash, error) { +func SubmitTransaction(ctx context.Context, logger log.Logger, b rpctypes.TrancsactionBackend, tx *types.Transaction) (common.Hash, error) { // If the transaction fee cap is already specified, ensure the // fee of the given transaction is _reasonable_. if err := checkTxFee(tx.GasPrice(), tx.Gas(), b.RPCTxFeeCap()); err != nil { @@ -986,13 +669,13 @@ func SubmitTransaction(ctx context.Context, logger log.Logger, b Backend, tx *ty // SendTransaction creates a transaction for the given argument, sign it and submit it to the // transaction pool. -func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionArgs) (common.Hash, error) { - if err := args.setDefaults(ctx, s.b); err != nil { +func (s *TransactionAPI) SendTransaction(ctx context.Context, args rpctypes.TransactionArgs) (common.Hash, error) { + if err := args.SetDefaults(ctx, s.b); err != nil { return common.Hash{}, err } signed, err := s.b.SignTransaction(&args) if err != nil { - log.Warn("Failed transaction send attempt", "from", args.from(), "to", args.To, "value", args.Value.ToInt(), "err", err) + log.Warn("Failed transaction send attempt", "from", args.FromAddr(), "to", args.To, "value", args.Value.ToInt(), "err", err) return common.Hash{}, err } return SubmitTransaction(ctx, s.logger, s.b, signed) @@ -1001,13 +684,13 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr // FillTransaction fills the defaults (nonce, gas, gasPrice or 1559 fields) // on a given unsigned transaction, and returns it to the caller for further // processing (signing + broadcast). -func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { +func (s *TransactionAPI) FillTransaction(ctx context.Context, args rpctypes.TransactionArgs) (*SignTransactionResult, error) { // Set some sanity defaults and terminate on failure - if err := args.setDefaults(ctx, s.b); err != nil { + if err := args.SetDefaults(ctx, s.b); err != nil { return nil, err } // Assemble the transaction and obtain rlp - tx := args.toTransaction() + tx := args.ToTransaction() data, err := tx.MarshalBinary() if err != nil { return nil, err @@ -1048,7 +731,7 @@ type SignTransactionResult struct { // SignTransaction will sign the given transaction with the from account. // The node needs to have the private key of the account corresponding with // the given from address and it needs to be unlocked. -func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionArgs) (*SignTransactionResult, error) { +func (s *TransactionAPI) SignTransaction(ctx context.Context, args rpctypes.TransactionArgs) (*SignTransactionResult, error) { // gas, gas limit, nonce checking are made in SignTransaction signed, err := s.b.SignTransaction(&args) if err != nil { @@ -1064,131 +747,58 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr // PendingTransactions returns the transactions that are in the transaction pool // and have a from address that is one of the accounts this node manages. -func (s *TransactionAPI) PendingTransactions() ([]*RPCTransaction, error) { - // TODO - return nil, errors.New("PendingTransactions is not implemented") -} - -// Resend accepts an existing transaction and a new gas price and limit. It will remove -// the given transaction from the pool and reinsert it with the new gas price and limit. -func (s *TransactionAPI) Resend(_ context.Context, _ TransactionArgs, _ *hexutil.Big, _ *hexutil.Uint64) (common.Hash, error) { - // TODO - return common.Hash{}, errors.New("Resend is not implemented") -} - -// DebugAPI is the collection of Ethereum APIs exposed over the debugging -// namespace. -type DebugAPI struct { - b Backend -} - -// NewDebugAPI creates a new instance of DebugAPI. -func NewDebugAPI(b Backend) *DebugAPI { - return &DebugAPI{b: b} -} - -// GetRawHeader retrieves the RLP encoding for a single header. -func (api *DebugAPI) GetRawHeader(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { - var hash common.Hash - if h, ok := blockNrOrHash.Hash(); ok { - hash = h - } else { - block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash) - if err != nil { - return nil, err - } - hash = block.Hash() - } - header, _ := api.b.HeaderByHash(ctx, hash) - if header == nil { - return nil, fmt.Errorf("header #%d not found", hash) +func (s *TransactionAPI) PendingTransactions() ([]*rpctypes.RPCTransaction, error) { + pendingTxs, err := s.b.PendingTransactions() + if err != nil { + return nil, err } - return rlp.EncodeToBytes(header) -} -// GetRawBlock retrieves the RLP encoded for a single block. -func (api *DebugAPI) GetRawBlock(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { - var hash common.Hash - if h, ok := blockNrOrHash.Hash(); ok { - hash = h - } else { - block, err := api.b.BlockByNumberOrHash(ctx, blockNrOrHash) - if err != nil { - return nil, err - } - hash = block.Hash() + cfg := s.b.ChainConfig() + if cfg == nil { + return nil, errors.New("failed to get chain config") } - block, _ := api.b.BlockByHash(ctx, hash) - if block == nil { - return nil, fmt.Errorf("block #%d not found", hash) + result := make([]*rpctypes.RPCTransaction, 0, len(pendingTxs)) + for _, tx := range pendingTxs { + for _, msg := range (*tx).GetMsgs() { + if ethMsg, ok := msg.(*evmtypes.MsgEthereumTx); ok { + rpctx := rpctypes.NewTransactionFromMsg(ethMsg, common.Hash{}, uint64(0), uint64(0), nil, cfg) + result = append(result, rpctx) + } + } } - return rlp.EncodeToBytes(block) -} - -// GetRawReceipts retrieves the binary-encoded receipts of a single block. -func (api *DebugAPI) GetRawReceipts(_ context.Context, _ rpc.BlockNumberOrHash) ([]hexutil.Bytes, error) { - return nil, errors.New("GetRawReceipts is not implemented") -} -// GetRawTransaction returns the bytes of the transaction for the given hash. -func (api *DebugAPI) GetRawTransaction(_ context.Context, _ common.Hash) (hexutil.Bytes, error) { - // TODO - return hexutil.Bytes{}, errors.New("GetRawTransaction is not implemented") + return result, nil } -// PrintBlock retrieves a block and returns its pretty printed form. -func (api *DebugAPI) PrintBlock(ctx context.Context, number uint64) (string, error) { - block, _ := api.b.ArtBlockByNumber(ctx, rpc.BlockNumber(number)) - if block == nil { - return "", fmt.Errorf("block #%d not found", number) +// Resend accepts an existing transaction and a new gas price and limit. It will remove +// the given transaction from the pool and reinsert it with the new gas price and limit. +func (s *TransactionAPI) Resend(ctx context.Context, args rpctypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (common.Hash, error) { + if args.Nonce == nil { + return common.Hash{}, fmt.Errorf("missing transaction nonce in transaction spec") } - return spew.Sdump(block), nil -} - -// ChaindbProperty returns leveldb properties of the key-value database. -func (api *DebugAPI) ChaindbProperty(_ string) (string, error) { - return "", errors.New("ChaindbProperty is not implemented") -} - -// ChaindbCompact flattens the entire key-value database into a single level, -// removing all unused slots and merging all keys. -func (api *DebugAPI) ChaindbCompact() error { - return errors.New("ChaindbCompact is not implemented") -} - -// SetHead rewinds the head of the blockchain to a previous block. -func (api *DebugAPI) SetHead(_ hexutil.Uint64) { - // TODO -} -// NetAPI offers network related RPC methods -type NetAPI struct { - net *p2p.Server - networkVersion uint64 -} + if err := args.SetDefaults(ctx, s.b); err != nil { + return common.Hash{}, err + } -// NewNetAPI creates a new net API instance. -func NewNetAPI(net *p2p.Server, networkVersion uint64) *NetAPI { - return &NetAPI{net, networkVersion} -} + fixedArgs, err := s.b.GetResendArgs(args, gasPrice, gasLimit) + if err != nil { + return common.Hash{}, err + } -// Listening returns an indication if the node is listening for network connections. -func (s *NetAPI) Listening() bool { - return true // always listening + return s.SendTransaction(ctx, fixedArgs) } -// PeerCount returns the number of connected peers -func (s *NetAPI) PeerCount() hexutil.Uint { - if s.net == nil { - return 0 - } - return hexutil.Uint(s.net.PeerCount()) -} +// // DebugAPI is the collection of Ethereum APIs exposed over the debugging +// // namespace. +// type DebugAPI struct { +// b Backend +// } -// Version returns the current ethereum protocol version. -func (s *NetAPI) Version() string { - return fmt.Sprintf("%d", s.networkVersion) -} +// // NewDebugAPI creates a new instance of DebugAPI. +// func NewDebugAPI(b Backend) *DebugAPI { +// return &DebugAPI{b: b} +// } // checkTxFee is an internal function used to check whether the fee of // the given transaction is _reasonable_(under the cap). diff --git a/ethereum/rpc/api/net.go b/ethereum/rpc/api/net.go index a4c312f..500e0cd 100644 --- a/ethereum/rpc/api/net.go +++ b/ethereum/rpc/api/net.go @@ -2,42 +2,31 @@ package api import ( "github.com/ethereum/go-ethereum/common/hexutil" -) - -// NetBackend is the collection of methods required to satisfy the net -// RPC DebugAPI. -type NetBackend interface { - NetAPI -} -// NetAPI is the collection of net RPC DebugAPI methods. -type NetAPI interface { - PeerCount() hexutil.Uint - Listening() bool - Version() string -} + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" +) -// netAPI offers network related RPC methods. -type netAPI struct { - b NetBackend +// NetAPI offers network related RPC methods. +type NetAPI struct { + b rpctypes.NetBackend } // NewNetAPI creates a new net DebugAPI instance. -func NewNetAPI(b NetBackend) NetAPI { - return &netAPI{b} +func NewNetAPI(b rpctypes.NetBackend) *NetAPI { + return &NetAPI{b} } // Listening returns an indication if the node is listening for network connections. -func (api *netAPI) Listening() bool { +func (api *NetAPI) Listening() bool { return api.b.Listening() } // PeerCount returns the number of connected peers. -func (api *netAPI) PeerCount() hexutil.Uint { +func (api *NetAPI) PeerCount() hexutil.Uint { return api.b.PeerCount() } // Version returns the current ethereum protocol version. -func (api *netAPI) Version() string { +func (api *NetAPI) Version() string { return api.b.Version() } diff --git a/ethereum/rpc/api/personal.go b/ethereum/rpc/api/personal.go new file mode 100644 index 0000000..11e037a --- /dev/null +++ b/ethereum/rpc/api/personal.go @@ -0,0 +1,194 @@ +package api + +import ( + "context" + "errors" + "fmt" + + "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/log" + + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" +) + +// PersonalAccountAPI provides an API to access accounts managed by this node. +// It offers methods to create, (un)lock en list accounts. Some methods accept +// passwords and are therefore considered private by default. +type PersonalAccountAPI struct { + nonceLock *AddrLocker + logger log.Logger + b rpctypes.PersonalBackend +} + +// NewPersonalAccountAPI create a new PersonalAccountAPI. +func NewPersonalAccountAPI(b rpctypes.PersonalBackend, logger log.Logger, nonceLock *AddrLocker) *PersonalAccountAPI { + return &PersonalAccountAPI{ + nonceLock: nonceLock, + logger: logger, + b: b, + } +} + +// ListAccounts will return a list of addresses for accounts this node manages. +func (s *PersonalAccountAPI) ListAccounts() []common.Address { + return s.b.Accounts() +} + +// rawWallet is a JSON representation of an accounts.Wallet interface, with its +// data contents extracted into plain fields. +type rawWallet struct { + URL string `json:"url"` + Status string `json:"status"` + Failure string `json:"failure,omitempty"` + Accounts []accounts.Account `json:"accounts,omitempty"` +} + +// ListWallets will return a list of wallets this node manages. +func (s *PersonalAccountAPI) ListWallets() []rawWallet { + // not implemented + wallets := make([]rawWallet, 0) // return [] instead of nil if empty + return wallets +} + +// OpenWallet initiates a hardware wallet opening procedure, establishing a USB +// connection and attempting to authenticate via the provided passphrase. Note, +// the method may return an extra challenge requiring a second open (e.g. the +// Trezor PIN matrix challenge). +func (s *PersonalAccountAPI) OpenWallet(_ string, _ *string) error { + return errors.New("OpenWallet is not valid") +} + +// DeriveAccount requests an HD wallet to derive a new account, optionally pinning +// it for later reuse. +func (s *PersonalAccountAPI) DeriveAccount(url string, path string, pin *bool) (accounts.Account, error) { + return accounts.Account{}, errors.New("DeriveAccount is not valid") +} + +// NewAccount will create a new account and returns the address for the new account. +func (s *PersonalAccountAPI) NewAccount(password string) (common.AddressEIP55, error) { + return s.b.NewAccount(password) +} + +// ImportRawKey stores the given hex encoded ECDSA key into the key directory, +// encrypting it with the passphrase. +func (s *PersonalAccountAPI) ImportRawKey(privkey string, password string) (common.Address, error) { + return s.b.ImportRawKey(privkey, password) +} + +// UnlockAccount will unlock the account associated with the given address with +// the given password for duration seconds. If duration is nil it will use a +// default of 300 seconds. It returns an indication if the account was unlocked. +func (s *PersonalAccountAPI) UnlockAccount(_ context.Context, _ common.Address, _ string, duration *uint64) (bool, error) { + // not implemented + return false, errors.New("UnlockAccount is not valid") +} + +// LockAccount will lock the account associated with the given address when it's unlocked. +func (s *PersonalAccountAPI) LockAccount(_ common.Address) bool { + // not implemented" + return false +} + +// signTransaction sets defaults and signs the given transaction +// NOTE: the caller needs to ensure that the nonceLock is held, if applicable, +// and release it after the transaction has been submitted to the tx pool +func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *rpctypes.TransactionArgs, _ string) (*types.Transaction, error) { + if err := args.SetDefaults(ctx, s.b); err != nil { + return nil, err + } + signed, err := s.b.SignTransaction(args) + if err != nil { + log.Warn("Failed transaction send attempt", "from", args.FromAddr(), "to", args.To, "value", args.Value.ToInt(), "err", err) + return nil, err + } + return signed, err +} + +// SendTransaction will create a transaction from the given arguments and +// tries to sign it with the key associated with args.From. If the given +// passwd isn't able to decrypt the key it fails. +func (s *PersonalAccountAPI) SendTransaction(ctx context.Context, args rpctypes.TransactionArgs, passwd string) (common.Hash, error) { + if args.Nonce == nil { + // Hold the mutex around signing to prevent concurrent assignment of + // the same nonce to multiple accounts. + s.nonceLock.LockAddr(args.FromAddr()) + defer s.nonceLock.UnlockAddr(args.FromAddr()) + } + + signed, err := s.signTransaction(ctx, &args, passwd) + if err != nil { + log.Warn("Failed transaction send attempt", "from", args.FromAddr(), "to", args.To, "value", args.Value.ToInt(), "err", err) + return common.Hash{}, err + } + return SubmitTransaction(ctx, s.logger, s.b, signed) +} + +// SignTransaction will create a transaction from the given arguments and +// tries to sign it with the key associated with args.From. If the given passwd isn't +// able to decrypt the key it fails. The transaction is returned in RLP-form, not broadcast +// to other nodes +func (s *PersonalAccountAPI) SignTransaction(ctx context.Context, args rpctypes.TransactionArgs, passwd string) (*SignTransactionResult, error) { + signed, err := s.signTransaction(ctx, &args, passwd) + if err != nil { + return nil, err + } + + data, err := signed.MarshalBinary() + if err != nil { + return nil, err + } + return &SignTransactionResult{data, signed}, nil +} + +// Sign calculates an Ethereum ECDSA signature for: +// keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)) +// +// Note, the produced signature conforms to the secp256k1 curve R, S and V values, +// where the V value will be 27 or 28 for legacy reasons. +// +// The key used to calculate the signature is decrypted with the given password. +// +// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign +func (s *PersonalAccountAPI) Sign(_ context.Context, data hexutil.Bytes, addr common.Address, _ string) (hexutil.Bytes, error) { + return s.b.Sign(addr, data) +} + +// EcRecover returns the address for the account that was used to create the signature. +// Note, this function is compatible with eth_sign and personal_sign. As such it recovers +// the address of: +// hash = keccak256("\x19Ethereum Signed Message:\n"${message length}${message}) +// addr = ecrecover(hash, signature) +// +// Note, the signature must conform to the secp256k1 curve R, S and V values, where +// the V value must be 27 or 28 for legacy reasons. +// +// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_ecRecover +func (s *PersonalAccountAPI) EcRecover(_ context.Context, data, sig hexutil.Bytes) (common.Address, error) { + if len(sig) != crypto.SignatureLength { + return common.Address{}, fmt.Errorf("signature must be %d bytes long", crypto.SignatureLength) + } + if sig[crypto.RecoveryIDOffset] != 27 && sig[crypto.RecoveryIDOffset] != 28 { + return common.Address{}, errors.New("invalid Ethereum signature (V is not 27 or 28)") + } + sig[crypto.RecoveryIDOffset] -= 27 // Transform yellow paper V from 27/28 to 0/1 + + rpk, err := crypto.SigToPub(accounts.TextHash(data), sig) + if err != nil { + return common.Address{}, err + } + return crypto.PubkeyToAddress(*rpk), nil +} + +// InitializeWallet initializes a new wallet at the provided URL, by generating and returning a new private key. +func (s *PersonalAccountAPI) InitializeWallet(_ context.Context, _ string) (string, error) { + return "", errors.New("InitializeWallet is not valid") +} + +// Unpair deletes a pairing between wallet and geth. +func (s *PersonalAccountAPI) Unpair(_ context.Context, _ string, _ string) error { + return errors.New("unpair is not valid") +} diff --git a/ethereum/rpc/api/txpool.go b/ethereum/rpc/api/txpool.go new file mode 100644 index 0000000..f32fa12 --- /dev/null +++ b/ethereum/rpc/api/txpool.go @@ -0,0 +1,121 @@ +package api + +import ( + "fmt" + "strconv" + + evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/log" + + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" +) + +// TxPoolAPI offers and API for the transaction pool. It only operates on data that is non-confidential. +type TxPoolAPI struct { + b rpctypes.TxPoolBackend + logger log.Logger +} + +// NewTxPoolAPI creates a new tx pool service that gives information about the transaction pool. +func NewTxPoolAPI(b rpctypes.TxPoolBackend, logger log.Logger) *TxPoolAPI { + return &TxPoolAPI{b, logger} +} + +// Content returns the transactions contained within the transaction pool. +func (s *TxPoolAPI) Content() map[string]map[string]map[string]*rpctypes.RPCTransaction { + content := map[string]map[string]map[string]*rpctypes.RPCTransaction{ + "pending": make(map[string]map[string]*rpctypes.RPCTransaction), + "queued": s.getPendingContent(common.Address{}), + } + + return content +} + +// ContentFrom returns the transactions contained within the transaction pool. +func (s *TxPoolAPI) ContentFrom(address common.Address) map[string]map[string]*rpctypes.RPCTransaction { + return s.getPendingContent(address) +} + +// Status returns the number of pending and queued transaction in the pool. +func (s *TxPoolAPI) Status() map[string]hexutil.Uint { + pending, err := s.b.PendingTransactionsCount() + if err != nil { + s.logger.Debug("get pending transaction count failed", "error", err.Error()) + } + return map[string]hexutil.Uint{ + "pending": hexutil.Uint(pending), + "queued": hexutil.Uint(0), + } +} + +// Inspect retrieves the content of the transaction pool and flattens it into an +// easily inspectable list. +func (s *TxPoolAPI) Inspect() map[string]map[string]map[string]string { + content := map[string]map[string]map[string]string{ + "pending": make(map[string]map[string]string), + "queued": make(map[string]map[string]string), + } + pending := s.getPendingContent(common.Address{}) + + // Define a formatter to flatten a transaction into a string + var format = func(tx *rpctypes.RPCTransaction) string { + if to := tx.To; to != nil { + return fmt.Sprintf("%s: %v wei + %v gas × %v wei", tx.To.Hex(), tx.Value, tx.Gas, tx.GasPrice) + } + return fmt.Sprintf("contract creation: %v wei + %v gas × %v wei", tx.Value, tx.Gas, tx.GasPrice) + } + // Flatten the pending transactions + for account, txs := range pending { + dump := make(map[string]string) + for _, tx := range txs { + dump[fmt.Sprintf("%d", tx.Nonce)] = format(tx) + } + content["pending"][account] = dump + } + return content +} + +func (s *TxPoolAPI) getPendingContent(addr common.Address) map[string]map[string]*rpctypes.RPCTransaction { + pendingContent := make(map[string]map[string]*rpctypes.RPCTransaction) + pendingTxs, err := s.b.PendingTransactions() + if err != nil { + s.logger.Debug("txpool_context, get pending transactions failed", "err", err.Error()) + return pendingContent + } + + cfg := s.b.ChainConfig() + if cfg == nil { + s.logger.Debug("txpool_context, failed to get chain config") + return pendingContent + } + for _, tx := range pendingTxs { + for _, msg := range (*tx).GetMsgs() { + if ethMsg, ok := msg.(*evmtypes.MsgEthereumTx); ok { + sender, err := s.b.GetSender(ethMsg, cfg.ChainID) + if err != nil { + s.logger.Debug("txpool_context, get pending transaction sender", "err", err.Error()) + continue + } + + if (addr != common.Address{} && addr != sender) { + continue + } + + txData, err := evmtypes.UnpackTxData(ethMsg.Data) + if err != nil { + s.logger.Debug("txpool_context, unpack pending transaction failed", "err", err.Error()) + continue + } + + rpctx := rpctypes.NewTransactionFromMsg(ethMsg, common.Hash{}, uint64(0), uint64(0), nil, cfg) + if pendingContent[sender.String()] == nil { + pendingContent[sender.String()] = make(map[string]*rpctypes.RPCTransaction) + } + pendingContent[sender.String()][strconv.FormatUint(txData.GetNonce(), 10)] = rpctx + } + } + } + return pendingContent +} diff --git a/ethereum/rpc/api/web3.go b/ethereum/rpc/api/web3.go index 61b2179..d4db617 100644 --- a/ethereum/rpc/api/web3.go +++ b/ethereum/rpc/api/web3.go @@ -3,37 +3,27 @@ package api import ( "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" -) - -// Web3Backend is the collection of methods required to satisfy the net -// RPC DebugAPI. -type Web3Backend interface { - ClientVersion() string -} -// Web3API is the collection of net RPC DebugAPI methods. -type Web3API interface { - ClientVersion() string - Sha3(input hexutil.Bytes) hexutil.Bytes -} + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" +) // web3Api offers network related RPC methods. -type web3API struct { - b Web3Backend +type Web3API struct { + b rpctypes.Web3Backend } // NewWeb3API creates a new web3 DebugAPI instance. -func NewWeb3API(b Web3Backend) Web3Backend { - return &web3API{b} +func NewWeb3API(b rpctypes.Web3Backend) rpctypes.Web3Backend { + return &Web3API{b} } // ClientVersion returns the node name. -func (api *web3API) ClientVersion() string { +func (api *Web3API) ClientVersion() string { return api.b.ClientVersion() } // Sha3 applies the ethereum sha3 implementation on the input. // It assumes the input is hex encoded. -func (*web3API) Sha3(input hexutil.Bytes) hexutil.Bytes { +func (*Web3API) Sha3(input hexutil.Bytes) hexutil.Bytes { return crypto.Keccak256(input) } diff --git a/ethereum/rpc/apis.go b/ethereum/rpc/apis.go index ab4acba..5376f2a 100644 --- a/ethereum/rpc/apis.go +++ b/ethereum/rpc/apis.go @@ -3,41 +3,38 @@ package rpc import ( rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" "github.com/artela-network/artela-rollkit/ethereum/rpc/api" - "github.com/artela-network/artela-rollkit/ethereum/rpc/ethapi" "github.com/artela-network/artela-rollkit/ethereum/rpc/filters" ) -func GetAPIs(clientCtx client.Context, wsClient *rpcclient.WSClient, logger log.Logger, apiBackend *BackendImpl) []rpc.API { - nonceLock := new(ethapi.AddrLocker) +func GetAPIs(clientCtx client.Context, serverCtx *server.Context, wsClient *rpcclient.WSClient, logger log.Logger, apiBackend *BackendImpl) []rpc.API { + nonceLock := new(api.AddrLocker) return []rpc.API{ { Namespace: "eth", - Service: ethapi.NewEthereumAPI(apiBackend, logger), + Service: api.NewEthereumAPI(apiBackend, logger), }, { Namespace: "eth", - Service: ethapi.NewBlockChainAPI(apiBackend, logger), + Service: api.NewBlockChainAPI(apiBackend, logger), }, { Namespace: "eth", - Service: ethapi.NewTransactionAPI(apiBackend, logger, nonceLock), + Service: api.NewTransactionAPI(apiBackend, logger, nonceLock), }, { Namespace: "txpool", - Service: ethapi.NewTxPoolAPI(apiBackend), + Service: api.NewTxPoolAPI(apiBackend, logger), }, { Namespace: "debug", - Service: ethapi.NewDebugAPI(apiBackend), - }, { - Namespace: "debug", - Service: api.NewDebugAPI(apiBackend), + Service: api.NewDebugAPI(apiBackend, logger, serverCtx), }, { Namespace: "eth", - Service: ethapi.NewEthereumAccountAPI(apiBackend), + Service: api.NewEthereumAccountAPI(apiBackend), }, { Namespace: "personal", - Service: ethapi.NewPersonalAccountAPI(apiBackend, logger, nonceLock), + Service: api.NewPersonalAccountAPI(apiBackend, logger, nonceLock), }, { Namespace: "net", Service: api.NewNetAPI(apiBackend), diff --git a/ethereum/rpc/backend.go b/ethereum/rpc/backend.go index a511734..316d853 100644 --- a/ethereum/rpc/backend.go +++ b/ethereum/rpc/backend.go @@ -4,20 +4,15 @@ import ( "context" "errors" "fmt" - "math" "math/big" - "runtime" "strconv" "time" sdkmath "cosmossdk.io/math" - bftclient "github.com/cometbft/cometbft/rpc/client" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" + db "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" - sdktypes "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -31,11 +26,8 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" - "github.com/artela-network/artela-rollkit/ethereum/rpc/api" - ethapi2 "github.com/artela-network/artela-rollkit/ethereum/rpc/ethapi" "github.com/artela-network/artela-rollkit/ethereum/rpc/filters" rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" - "github.com/artela-network/artela-rollkit/ethereum/rpc/utils" "github.com/artela-network/artela-rollkit/ethereum/server/config" ethereumtypes "github.com/artela-network/artela-rollkit/ethereum/types" evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" @@ -44,10 +36,17 @@ import ( var ( _ gasprice.OracleBackend = (*BackendImpl)(nil) - _ ethapi2.Backend = (*BackendImpl)(nil) _ filters.Backend = (*BackendImpl)(nil) - _ api.NetBackend = (*BackendImpl)(nil) - _ api.DebugBackend = (*BackendImpl)(nil) + + _ rpctypes.Backend = (*BackendImpl)(nil) + _ rpctypes.EthereumBackend = (*BackendImpl)(nil) + _ rpctypes.BlockChainBackend = (*BackendImpl)(nil) + _ rpctypes.TrancsactionBackend = (*BackendImpl)(nil) + _ rpctypes.DebugBackend = (*BackendImpl)(nil) + _ rpctypes.PersonalBackend = (*BackendImpl)(nil) + _ rpctypes.TxPoolBackend = (*BackendImpl)(nil) + _ rpctypes.NetBackend = (*BackendImpl)(nil) + _ rpctypes.Web3Backend = (*BackendImpl)(nil) ) // backend represents the backend for the JSON-RPC service. @@ -72,14 +71,11 @@ type BackendImpl struct { ctx context.Context clientCtx client.Context queryClient *rpctypes.QueryClient -} -func (b *BackendImpl) EthBlockByNumber(blockNum rpc.BlockNumber) (*ethtypes.Block, error) { - // TODO implement me - panic("implement me") + db db.DB } -// NewBackend create the backend instance +// NewBackend create the backend implements func NewBackend( ctx *server.Context, clientCtx client.Context, @@ -87,6 +83,7 @@ func NewBackend( extRPCEnabled bool, cfg *Config, logger log.Logger, + db db.DB, ) *BackendImpl { b := &BackendImpl{ ctx: context.Background(), @@ -98,6 +95,7 @@ func NewBackend( queryClient: rpctypes.NewQueryClient(clientCtx), scope: event.SubscriptionScope{}, + db: db, } var err error @@ -118,153 +116,129 @@ func NewBackend( return b } -// General Ethereum DebugAPI - -func (b *BackendImpl) SyncProgress() ethereum.SyncProgress { - return ethereum.SyncProgress{ - CurrentBlock: 0, - HighestBlock: 0, - } -} - -func (b *BackendImpl) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { - if baseFee == nil { - // london hardfork not enabled or feemarket not enabled - return big.NewInt(0), nil - } - - params, err := b.queryClient.FeeMarket.Params(b.ctx, &feetypes.QueryParamsRequest{}) +func (b *BackendImpl) CurrentHeader() (*ethtypes.Header, error) { + block, err := b.ArtBlockByNumber(context.Background(), rpc.LatestBlockNumber) if err != nil { return nil, err } - // calculate the maximum base fee delta in current block, assuming all block gas limit is consumed - // ``` - // GasTarget = GasLimit / ElasticityMultiplier - // Delta = BaseFee * (GasUsed - GasTarget) / GasTarget / Denominator - // ``` - // The delta is at maximum when `GasUsed` is equal to `GasLimit`, which is: - // ``` - // MaxDelta = BaseFee * (GasLimit - GasLimit / ElasticityMultiplier) / (GasLimit / ElasticityMultiplier) / Denominator - // = BaseFee * (ElasticityMultiplier - 1) / Denominator - // ```t - maxDelta := baseFee.Int64() * (int64(params.Params.ElasticityMultiplier) - 1) / int64(params.Params.BaseFeeChangeDenominator) // #nosec G701 - if maxDelta < 0 { - // impossible if the parameter validation passed. - maxDelta = 0 + if block == nil || block.Header() == nil { + return nil, errors.New("current block header not found") } - return big.NewInt(maxDelta), nil + return block.Header(), nil } -func (b *BackendImpl) ChainConfig() *params.ChainConfig { - cfg, err := b.chainConfig() +func (b *BackendImpl) Accounts() []common.Address { + addresses := make([]common.Address, 0) // return [] instead of nil if empty + + infos, err := b.clientCtx.Keyring.List() if err != nil { + b.logger.Info("keying list failed", "error", err) return nil } - return cfg + + for _, info := range infos { + pubKey, err := info.GetPubKey() + if err != nil { + b.logger.Info("getPubKey failed", "info", info, "error", err) + return nil + } + addressBytes := pubKey.Address().Bytes() + addresses = append(addresses, common.BytesToAddress(addressBytes)) + } + + return addresses } -func (b *BackendImpl) chainConfig() (*params.ChainConfig, error) { - params, err := b.queryClient.Params(b.ctx, &evmtypes.QueryParamsRequest{}) +func (b *BackendImpl) GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) if err != nil { - b.logger.Info("queryClient.Params failed", err) return nil, err } - currentHeader, err := b.CurrentHeader() + req := &evmtypes.QueryBalanceRequest{ + Address: address.String(), + } + + _, err = b.CosmosBlockByNumber(blockNum) if err != nil { return nil, err } - return params.Params.ChainConfig.EthereumConfig(currentHeader.Number.Int64(), b.chainID), nil -} + res, err := b.queryClient.Balance(rpctypes.ContextWithHeight(blockNum.Int64()), req) + if err != nil { + return nil, err + } -func (b *BackendImpl) FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, - rewardPercentiles []float64, -) (*rpctypes.FeeHistoryResult, error) { - blockEnd := int64(lastBlock) + val, ok := sdkmath.NewIntFromString(res.Balance) + if !ok { + return nil, errors.New("invalid balance") + } - if blockEnd < 0 { - blockNumber, err := b.BlockNumber() - if err != nil { - return nil, err - } - blockEnd = int64(blockNumber) + if val.IsNegative() { + return nil, errors.New("couldn't fetch balance. Node state is pruned") } - blocks := int64(blockCount) - maxBlockCount := int64(b.cfg.AppCfg.JSONRPC.FeeHistoryCap) - if blocks > maxBlockCount { - return nil, fmt.Errorf("FeeHistory user block count %d higher than %d", blocks, maxBlockCount) + return (*hexutil.Big)(val.BigInt()), nil +} + +func (b *BackendImpl) ArtBlockByNumber(_ context.Context, number rpc.BlockNumber) (*rpctypes.Block, error) { + resBlock, err := b.CosmosBlockByNumber(number) + if err != nil || resBlock == nil { + return nil, fmt.Errorf("query block failed, block number %d, %w", number, err) } - if blockEnd+1 < blocks { - blocks = blockEnd + 1 + blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + if err != nil { + return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) } - blockStart := blockEnd + 1 - blocks - oldestBlock := (*hexutil.Big)(big.NewInt(blockStart)) + return b.BlockFromCosmosBlock(resBlock, blockRes) +} - reward := make([][]*hexutil.Big, blocks) - rewardCount := len(rewardPercentiles) - for i := 0; i < int(blocks); i++ { - reward[i] = make([]*hexutil.Big, rewardCount) +func (b *BackendImpl) BlockByHash(_ context.Context, hash common.Hash) (*rpctypes.Block, error) { + resBlock, err := b.CosmosBlockByHash(hash) + if err != nil || resBlock == nil { + return nil, fmt.Errorf("failed to get block by hash %s, %w", hash.Hex(), err) } - thisBaseFee := make([]*hexutil.Big, blocks+1) - thisGasUsedRatio := make([]float64, blocks) - calculateRewards := rewardCount != 0 - - for blockID := blockStart; blockID <= blockEnd; blockID++ { - index := int32(blockID - blockStart) // #nosec G701 - // tendermint block - tendermintblock, err := b.CosmosBlockByNumber(rpc.BlockNumber(blockID)) - if tendermintblock == nil { - return nil, err - } + blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + if err != nil { + return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) + } - // eth block - ethBlock, err := b.GetBlockByNumber(rpc.BlockNumber(blockID), true) - if ethBlock == nil { - return nil, err - } + return b.BlockFromCosmosBlock(resBlock, blockRes) +} - // tendermint block result - tendermintBlockResult, err := b.CosmosBlockResultByNumber(&tendermintblock.Block.Height) - if tendermintBlockResult == nil { - b.logger.Debug("block result not found", "height", tendermintblock.Block.Height, "error", err.Error()) - return nil, err - } +func (b *BackendImpl) ChainConfig() *params.ChainConfig { + cfg, err := b.chainConfig() + if err != nil { + return nil + } + return cfg +} - oneFeeHistory, err := b.processBlock(tendermintblock, ðBlock, rewardPercentiles, tendermintBlockResult) - if err != nil { - return nil, err - } +// General Ethereum DebugAPI - // copy - thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee) - thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee) - thisGasUsedRatio[index] = oneFeeHistory.GasUsedRatio - if calculateRewards { - for j := 0; j < rewardCount; j++ { - reward[index][j] = (*hexutil.Big)(oneFeeHistory.Reward[j]) - if reward[index][j] == nil { - reward[index][j] = (*hexutil.Big)(big.NewInt(0)) - } - } - } +func (b *BackendImpl) SyncProgress() ethereum.SyncProgress { + return ethereum.SyncProgress{ + CurrentBlock: 0, + HighestBlock: 0, } +} - feeHistory := rpctypes.FeeHistoryResult{ - OldestBlock: oldestBlock, - BaseFee: thisBaseFee, - GasUsedRatio: thisGasUsedRatio, +func (b *BackendImpl) chainConfig() (*params.ChainConfig, error) { + params, err := b.queryClient.Params(b.ctx, &evmtypes.QueryParamsRequest{}) + if err != nil { + b.logger.Info("queryClient.Params failed", err) + return nil, err } - if calculateRewards { - feeHistory.Reward = reward + currentHeader, err := b.CurrentHeader() + if err != nil { + return nil, err } - return &feeHistory, nil + return params.Params.ChainConfig.EthereumConfig(currentHeader.Number.Int64(), b.chainID), nil } func (b *BackendImpl) ChainDb() ethdb.Database { @@ -283,17 +257,6 @@ func (b *BackendImpl) RPCEVMTimeout() time.Duration { return b.cfg.RPCEVMTimeout } -func (b *BackendImpl) RPCTxFeeCap() float64 { - return b.cfg.RPCTxFeeCap -} - -func (b *BackendImpl) UnprotectedAllowed() bool { - if b.cfg.AppCfg == nil { - return false - } - return b.cfg.AppCfg.JSONRPC.AllowUnprotectedTxs -} - // This is copied from filters.Backend // eth/filters needs to be initialized from this backend type, so methods needed by // it must also be included here. @@ -331,45 +294,6 @@ func (b *BackendImpl) BloomStatus() (uint64, uint64) { func (b *BackendImpl) ServiceFilter(_ context.Context, _ *bloombits.MatcherSession) { } -// artela rpc DebugAPI - -// artela rpc DebugAPI - -func (b *BackendImpl) Listening() bool { - tmClient := b.clientCtx.Client.(bftclient.Client) - netInfo, err := tmClient.NetInfo(b.ctx) - if err != nil { - return false - } - return netInfo.Listening -} - -func (b *BackendImpl) PeerCount() hexutil.Uint { - tmClient := b.clientCtx.Client.(bftclient.Client) - netInfo, err := tmClient.NetInfo(b.ctx) - if err != nil { - return 0 - } - return hexutil.Uint(len(netInfo.Peers)) -} - -// ClientVersion returns the current client version. -func (b *BackendImpl) ClientVersion() string { - return fmt.Sprintf( - "%s/%s/%s/%s", - version.AppName, - version.Version, - runtime.GOOS+"-"+runtime.GOARCH, - runtime.Version(), - ) -} - -// func (b *BackendImpl) GetBlockContext( -// _ context.Context, header *ethtypes.Header, -// ) *vm.BlockContext { -// return nil -// } - func (b *BackendImpl) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int, error) { // return BaseFee if London hard fork is activated and feemarket is enabled res, err := b.queryClient.BaseFee(rpctypes.ContextWithHeight(blockRes.Height), &evmtypes.QueryBaseFeeRequest{}) @@ -398,38 +322,6 @@ func (b *BackendImpl) BaseFee(blockRes *tmrpctypes.ResultBlockResults) (*big.Int return res.BaseFee.BigInt(), nil } -func (b *BackendImpl) PendingTransactions() ([]*sdktypes.Tx, error) { - return nil, errors.New("PendingTransactions is not implemented") -} - -func (b *BackendImpl) GasPrice(ctx context.Context) (*hexutil.Big, error) { - var ( - result *big.Int - err error - ) - if head, err := b.CurrentHeader(); err == nil && head.BaseFee != nil { - result, err = b.SuggestGasTipCap(head.BaseFee) - if err != nil { - return nil, err - } - result = result.Add(result, head.BaseFee) - } else { - result = big.NewInt(b.RPCMinGasPrice()) - } - - // return at least GlobalMinGasPrice from FeeMarket module - minGasPrice, err := b.GlobalMinGasPrice() - if err != nil { - return nil, err - } - minGasPriceInt := minGasPrice.TruncateInt().BigInt() - if result.Cmp(minGasPriceInt) < 0 { - result = minGasPriceInt - } - - return (*hexutil.Big)(result), nil -} - func (b *BackendImpl) RPCMinGasPrice() int64 { evmParams, err := b.queryClient.Params(b.ctx, &evmtypes.QueryParamsRequest{}) if err != nil { @@ -469,132 +361,3 @@ func (b *BackendImpl) RPCFilterCap() int32 { func (b *BackendImpl) RPCLogsCap() int32 { return b.appConf.JSONRPC.LogsCap } - -func (b *BackendImpl) Syncing() (interface{}, error) { - status, err := b.clientCtx.Client.Status(b.ctx) - if err != nil { - return false, err - } - - if !status.SyncInfo.CatchingUp { - return false, nil - } - - return map[string]interface{}{ - "startingBlock": hexutil.Uint64(status.SyncInfo.EarliestBlockHeight), - "currentBlock": hexutil.Uint64(status.SyncInfo.LatestBlockHeight), - // "highestBlock": nil, // NA - // "pulledStates": nil, // NA - // "knownStates": nil, // NA - }, nil -} -func (b *BackendImpl) GetCoinbase() (sdktypes.AccAddress, error) { - node, err := b.clientCtx.GetNode() - if err != nil { - return nil, err - } - - status, err := node.Status(b.ctx) - if err != nil { - return nil, err - } - - req := &evmtypes.QueryValidatorAccountRequest{ - ConsAddress: sdktypes.ConsAddress(status.ValidatorInfo.Address).String(), - } - - res, err := b.queryClient.ValidatorAccount(b.ctx, req) - if err != nil { - return nil, err - } - - address, _ := sdktypes.AccAddressFromBech32(res.AccountAddress) // #nosec G703 - return address, nil -} - -// GetProof returns an account object with proof and any storage proofs -func (b *BackendImpl) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { - numberOrHash := rpc.BlockNumberOrHash{ - BlockNumber: (*rpc.BlockNumber)(blockNrOrHash.BlockNumber), - BlockHash: blockNrOrHash.BlockHash, - RequireCanonical: false, - } - blockNum, err := b.blockNumberFromCosmos(numberOrHash) - if err != nil { - return nil, err - } - - height := blockNum.Int64() - - _, err = b.CosmosBlockByNumber(blockNum) - if err != nil { - // the error message imitates geth behavior - return nil, errors.New("header not found") - } - ctx := rpctypes.ContextWithHeight(height) - - // if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest" - if height == 0 { - bn, err := b.BlockNumber() - if err != nil { - return nil, err - } - - if bn > math.MaxInt64 { - return nil, fmt.Errorf("not able to query block number greater than MaxInt64") - } - - height = int64(bn) // #nosec G701 -- checked for int overflow already - } - - clientCtx := b.clientCtx.WithHeight(height) - - // query storage proofs - storageProofs := make([]rpctypes.StorageResult, len(storageKeys)) - - for i, key := range storageKeys { - hexKey := common.HexToHash(key) - valueBz, proof, err := b.queryClient.GetProof(clientCtx, evmtypes.StoreKey, evmtypes.StateKey(address, hexKey.Bytes())) - if err != nil { - return nil, err - } - - storageProofs[i] = rpctypes.StorageResult{ - Key: key, - Value: (*hexutil.Big)(new(big.Int).SetBytes(valueBz)), - Proof: utils.GetHexProofs(proof), - } - } - - // query EVM account - req := &evmtypes.QueryAccountRequest{ - Address: address.String(), - } - - res, err := b.queryClient.Account(ctx, req) - if err != nil { - return nil, err - } - - // query account proofs - accountKey := append(authtypes.AddressStoreKeyPrefix, sdktypes.AccAddress(address.Bytes()).Bytes()...) - _, proof, err := b.queryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey) - if err != nil { - return nil, err - } - - balance, ok := sdkmath.NewIntFromString(res.Balance) - if !ok { - return nil, errors.New("invalid balance") - } - - return &rpctypes.AccountResult{ - Address: address, - AccountProof: utils.GetHexProofs(proof), - Balance: (*hexutil.Big)(balance.BigInt()), - CodeHash: common.HexToHash(res.CodeHash), - Nonce: hexutil.Uint64(res.Nonce), - StorageHash: common.Hash{}, // NOTE: Evmos doesn't have a storage hash. TODO: implement? - StorageProof: storageProofs, - }, nil -} diff --git a/ethereum/rpc/blocks.go b/ethereum/rpc/blockchain.go similarity index 75% rename from ethereum/rpc/blocks.go rename to ethereum/rpc/blockchain.go index a6b4fa5..e4a2dee 100644 --- a/ethereum/rpc/blocks.go +++ b/ethereum/rpc/blockchain.go @@ -11,14 +11,15 @@ import ( "sort" "strconv" + sdkmath "cosmossdk.io/math" tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdktypes "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/consensus/misc" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rpc" @@ -29,8 +30,7 @@ import ( "google.golang.org/grpc/status" "github.com/artela-network/artela-evm/vm" - - "github.com/artela-network/artela-rollkit/ethereum/rpc/ethapi" + "github.com/artela-network/artela-rollkit/ethereum/rpc/api" rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" "github.com/artela-network/artela-rollkit/ethereum/rpc/utils" evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" @@ -38,162 +38,250 @@ import ( // Blockchain API -func (b *BackendImpl) SetHead(_ uint64) { - b.logger.Error("SetHead is not implemented") -} - -func (b *BackendImpl) HeaderByNumber(_ context.Context, number rpc.BlockNumber) (*ethtypes.Header, error) { - resBlock, err := b.CosmosBlockByNumber(number) +// GetProof returns an account object with proof and any storage proofs +func (b *BackendImpl) GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) { + numberOrHash := rpc.BlockNumberOrHash{ + BlockNumber: (*rpc.BlockNumber)(blockNrOrHash.BlockNumber), + BlockHash: blockNrOrHash.BlockHash, + RequireCanonical: false, + } + blockNum, err := b.blockNumberFromCosmos(numberOrHash) if err != nil { return nil, err } - if resBlock == nil { - return nil, fmt.Errorf("block not found for height %d", number) - } + height := blockNum.Int64() - blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + _, err = b.CosmosBlockByNumber(blockNum) if err != nil { - return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) + // the error message imitates geth behavior + return nil, fmt.Errorf("block not valid, %v", err) } + ctx := rpctypes.ContextWithHeight(height) - bloom, err := b.blockBloom(blockRes) - if err != nil { - b.logger.Debug("HeaderByNumber BlockBloom failed", "height", resBlock.Block.Height) - } + // if the height is equal to zero, meaning the query condition of the block is either "pending" or "latest" + if height == 0 { + bn, err := b.BlockNumber() + if err != nil { + return nil, err + } - baseFee, err := b.BaseFee(blockRes) - if err != nil { - // handle the error for pruned node. - b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", resBlock.Block.Height, "error", err) + if bn > math.MaxInt64 { + return nil, fmt.Errorf("not able to query block number greater than MaxInt64") + } + + height = int64(bn) // #nosec G701 -- checked for int overflow already } - ethHeader := rpctypes.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee) - return ethHeader, nil -} + clientCtx := b.clientCtx.WithHeight(height) -func (b *BackendImpl) HeaderByHash(_ context.Context, hash common.Hash) (*ethtypes.Header, error) { - return nil, nil -} + // query storage proofs + storageProofs := make([]rpctypes.StorageResult, len(storageKeys)) -func (b *BackendImpl) HeaderByNumberOrHash(ctx context.Context, - blockNrOrHash rpc.BlockNumberOrHash, -) (*ethtypes.Header, error) { - return nil, errors.New("HeaderByNumberOrHash is not implemented") -} + for i, key := range storageKeys { + hexKey := common.HexToHash(key) + valueBz, proof, err := b.queryClient.GetProof(clientCtx, evmtypes.StoreKey, evmtypes.StateKey(address, hexKey.Bytes())) + if err != nil { + return nil, err + } + + storageProofs[i] = rpctypes.StorageResult{ + Key: key, + Value: (*hexutil.Big)(new(big.Int).SetBytes(valueBz)), + Proof: utils.GetHexProofs(proof), + } + } -func (b *BackendImpl) CurrentHeader() (*ethtypes.Header, error) { - block, err := b.BlockByNumber(context.Background(), rpc.LatestBlockNumber) + // query EVM account + req := &evmtypes.QueryAccountRequest{ + Address: address.String(), + } + + res, err := b.queryClient.Account(ctx, req) if err != nil { return nil, err } - if block == nil || block.Header() == nil { - return nil, errors.New("current block header not found") + + // query account proofs + accountKey := append(authtypes.AddressStoreKeyPrefix, sdktypes.AccAddress(address.Bytes()).Bytes()...) + _, proof, err := b.queryClient.GetProof(clientCtx, authtypes.StoreKey, accountKey) + if err != nil { + return nil, err } - return block.Header(), nil -} -func (b *BackendImpl) CurrentBlock() *rpctypes.Block { - block, _ := b.currentBlock() - return block + balance, ok := sdkmath.NewIntFromString(res.Balance) + if !ok { + return nil, errors.New("invalid balance") + } + + return &rpctypes.AccountResult{ + Address: address, + AccountProof: utils.GetHexProofs(proof), + Balance: (*hexutil.Big)(balance.BigInt()), + CodeHash: common.HexToHash(res.CodeHash), + Nonce: hexutil.Uint64(res.Nonce), + StorageHash: common.Hash{}, // NOTE: Evmos doesn't have a storage hash. TODO: implement? + StorageProof: storageProofs, + }, nil } -func (b *BackendImpl) currentBlock() (*rpctypes.Block, error) { - block, err := b.ArtBlockByNumber(context.Background(), rpc.LatestBlockNumber) +func (b *BackendImpl) DoCall(args rpctypes.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash) (*evmtypes.MsgEthereumTxResponse, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) if err != nil { - b.logger.Error("get CurrentBlock failed", "error", err) return nil, err } - return block, nil -} -func (b *BackendImpl) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Block, error) { - block, err := b.ArtBlockByNumber(ctx, number) + bz, err := json.Marshal(&args) if err != nil { return nil, err } - return block.EthBlock(), nil -} + header, err := b.CosmosBlockByNumber(blockNum) + if err != nil { + // the error message imitates geth behavior + return nil, errors.New("header not found") + } -func (b *BackendImpl) ArtBlockByNumber(_ context.Context, number rpc.BlockNumber) (*rpctypes.Block, error) { - resBlock, err := b.CosmosBlockByNumber(number) - if err != nil || resBlock == nil { - return nil, fmt.Errorf("query block failed, block number %d, %w", number, err) + req := evmtypes.EthCallRequest{ + Args: bz, + GasCap: b.RPCGasCap(), + ProposerAddress: sdktypes.ConsAddress(header.Block.ProposerAddress), + ChainId: b.chainID.Int64(), } - blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + // From ContextWithHeight: if the provided height is 0, + // it will return an empty context and the gRPC query will use + // the latest block height for querying. + ctx := rpctypes.ContextWithHeight(blockNum.Int64()) + timeout := b.RPCEVMTimeout() + + // Setup context so it may be canceled the call has completed + // or, in case of unmetered gas, setup a context with a timeout. + var cancel context.CancelFunc + if timeout > 0 { + ctx, cancel = context.WithTimeout(ctx, timeout) + } else { + ctx, cancel = context.WithCancel(ctx) + } + + // Make sure the context is canceled when the call has completed + // this makes sure resources are cleaned up. + defer cancel() + + res, err := b.queryClient.EthCall(ctx, &req) if err != nil { - return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) + return nil, err + } + + if res.Failed() { + if res.VmError != vm.ErrExecutionReverted.Error() { + return nil, status.Error(codes.Internal, res.VmError) + } + return nil, evmtypes.NewExecErrorWithReason(res.Ret) } - return b.BlockFromCosmosBlock(resBlock, blockRes) + return res, nil } -func (b *BackendImpl) BlockByHash(_ context.Context, hash common.Hash) (*rpctypes.Block, error) { - resBlock, err := b.CosmosBlockByHash(hash) - if err != nil || resBlock == nil { - return nil, fmt.Errorf("failed to get block by hash %s, %w", hash.Hex(), err) +func (b *BackendImpl) EstimateGas(ctx context.Context, args rpctypes.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { + blockNum := rpc.LatestBlockNumber + if blockNrOrHash != nil { + blockNum, _ = b.blockNumberFromCosmos(*blockNrOrHash) } - blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + bz, err := json.Marshal(&args) if err != nil { - return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) + return 0, err } - return b.BlockFromCosmosBlock(resBlock, blockRes) -} + header, err := b.CosmosBlockByNumber(blockNum) + if err != nil { + // the error message imitates geth behavior + return 0, errors.New("header not found") + } -func (b *BackendImpl) BlockByNumberOrHash(_ context.Context, _ rpc.BlockNumberOrHash) (*rpctypes.Block, error) { - return nil, errors.New("BlockByNumberOrHash is not implemented") -} + req := evmtypes.EthCallRequest{ + Args: bz, + GasCap: b.RPCGasCap(), + ProposerAddress: sdktypes.ConsAddress(header.Block.ProposerAddress), + ChainId: b.chainID.Int64(), + } -func (b *BackendImpl) StateAndHeaderByNumber( - _ context.Context, number rpc.BlockNumber, -) (*state.StateDB, *ethtypes.Header, error) { - return nil, nil, errors.New("StateAndHeaderByNumber is not implemented") + // From ContextWithHeight: if the provided height is 0, + // it will return an empty context and the gRPC query will use + // the latest block height for querying. + res, err := b.queryClient.EstimateGas(rpctypes.ContextWithHeight(blockNum.Int64()), &req) + if err != nil { + return 0, err + } + return hexutil.Uint64(res.Gas), nil } -func (b *BackendImpl) StateAndHeaderByNumberOrHash( - _ context.Context, _ rpc.BlockNumberOrHash, -) (*state.StateDB, *ethtypes.Header, error) { - return nil, nil, errors.New("invalid arguments; neither block nor hash specified") -} +func (b *BackendImpl) HeaderByNumber(_ context.Context, number rpc.BlockNumber) (*ethtypes.Header, error) { + resBlock, err := b.CosmosBlockByNumber(number) + if err != nil { + return nil, err + } -func (b *BackendImpl) PendingBlockAndReceipts() (*ethtypes.Block, ethtypes.Receipts) { - b.logger.Error("PendingBlockAndReceipts is not implemented") - return nil, nil -} + if resBlock == nil { + return nil, fmt.Errorf("block not found for height %d", number) + } -// GetReceipts get receipts by block hash -func (b *BackendImpl) GetReceipts(_ context.Context, _ common.Hash) (ethtypes.Receipts, error) { - return nil, errors.New("GetReceipts is not implemented") -} + blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + if err != nil { + return nil, fmt.Errorf("block result not found for height %d", resBlock.Block.Height) + } + + bloom, err := b.blockBloom(blockRes) + if err != nil { + b.logger.Debug("HeaderByNumber BlockBloom failed", "height", resBlock.Block.Height) + } -func (b *BackendImpl) GetTd(_ context.Context, _ common.Hash) *big.Int { - b.logger.Error("GetTd is not implemented") - return nil + baseFee, err := b.BaseFee(blockRes) + if err != nil { + // handle the error for pruned node. + b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", resBlock.Block.Height, "error", err) + } + + ethHeader := rpctypes.EthHeaderFromTendermint(resBlock.Block.Header, bloom, baseFee) + return ethHeader, nil } -func (b *BackendImpl) GetEVM(_ context.Context, _ *core.Message, _ *state.StateDB, - _ *ethtypes.Header, _ *vm.Config, _ *vm.BlockContext, -) (*vm.EVM, func() error) { - return nil, func() error { - return errors.New("GetEVM is not impelemted") +func (b *BackendImpl) HeaderByHash(ctx context.Context, hash common.Hash) (*ethtypes.Header, error) { + block, err := b.BlockByHash(ctx, hash) + if err != nil { + return nil, err + } + if block == nil { + return nil, errors.New("block not found") } + return block.Header(), nil } -func (b *BackendImpl) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { - return b.scope.Track(b.chainFeed.Subscribe(ch)) +func (b *BackendImpl) HeaderByNumberOrHash(ctx context.Context, + blockNrOrHash rpc.BlockNumberOrHash, +) (*ethtypes.Header, error) { + block, err := b.ArtBlockByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return nil, err + } + if block == nil { + return nil, errors.New("block not found") + } + return block.Header(), nil } -func (b *BackendImpl) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription { - b.logger.Debug("called eth.rpc.backend.SubscribeChainHeadEvent", "ch", ch) - return b.scope.Track(b.chainHeadFeed.Subscribe(ch)) +func (b *BackendImpl) CurrentBlock() *rpctypes.Block { + block, _ := b.currentBlock() + return block } -func (b *BackendImpl) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription { - b.logger.Debug("called eth.rpc.backend.SubscribeChainSideEvent", "ch", ch) - return b.scope.Track(b.chainSideFeed.Subscribe(ch)) +func (b *BackendImpl) ArtBlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*rpctypes.Block, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) + if err != nil { + return nil, err + } + + return b.ArtBlockByNumber(ctx, blockNum) } func (b *BackendImpl) CosmosBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) { @@ -235,6 +323,92 @@ func (b *BackendImpl) CosmosBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes return resBlock, nil } +func (b *BackendImpl) GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) + if err != nil { + return nil, err + } + + req := &evmtypes.QueryCodeRequest{ + Address: address.String(), + } + + res, err := b.queryClient.Code(rpctypes.ContextWithHeight(blockNum.Int64()), req) + if err != nil { + return nil, err + } + + return res.Code, nil +} + +// GetStorageAt returns the contract storage at the given address, block number, and key. +func (b *BackendImpl) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) + if err != nil { + return nil, err + } + + req := &evmtypes.QueryStorageRequest{ + Address: address.String(), + Key: key, + } + + res, err := b.queryClient.Storage(rpctypes.ContextWithHeight(blockNum.Int64()), req) + if err != nil { + return nil, err + } + + value := common.HexToHash(res.Value) + return value.Bytes(), nil +} + +func (b *BackendImpl) GetCoinbase() (sdktypes.AccAddress, error) { + node, err := b.clientCtx.GetNode() + if err != nil { + return nil, err + } + + status, err := node.Status(b.ctx) + if err != nil { + return nil, err + } + + req := &evmtypes.QueryValidatorAccountRequest{ + ConsAddress: sdktypes.ConsAddress(status.ValidatorInfo.Address).String(), + } + + res, err := b.queryClient.ValidatorAccount(b.ctx, req) + if err != nil { + return nil, err + } + + address, _ := sdktypes.AccAddressFromBech32(res.AccountAddress) // #nosec G703 + return address, nil +} + +func (b *BackendImpl) currentBlock() (*rpctypes.Block, error) { + block, err := b.ArtBlockByNumber(context.Background(), rpc.LatestBlockNumber) + if err != nil { + b.logger.Error("get CurrentBlock failed", "error", err) + return nil, err + } + return block, nil +} + +func (b *BackendImpl) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription { + return b.scope.Track(b.chainFeed.Subscribe(ch)) +} + +func (b *BackendImpl) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription { + b.logger.Debug("called eth.rpc.rpctypes.SubscribeChainHeadEvent", "ch", ch) + return b.scope.Track(b.chainHeadFeed.Subscribe(ch)) +} + +func (b *BackendImpl) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription { + b.logger.Debug("called eth.rpc.rpctypes.SubscribeChainSideEvent", "ch", ch) + return b.scope.Track(b.chainSideFeed.Subscribe(ch)) +} + // BlockNumberFromTendermint returns the BlockNumber from BlockNumberOrHash func (b *BackendImpl) blockNumberFromCosmos(blockNrOrHash rpc.BlockNumberOrHash) (rpc.BlockNumber, error) { switch { @@ -297,45 +471,6 @@ func (b *BackendImpl) CosmosBlockResultByNumber(height *int64) (*tmrpctypes.Resu return b.clientCtx.Client.BlockResults(b.ctx, height) } -func (b *BackendImpl) GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { - blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) - if err != nil { - return nil, err - } - - req := &evmtypes.QueryCodeRequest{ - Address: address.String(), - } - - res, err := b.queryClient.Code(rpctypes.ContextWithHeight(blockNum.Int64()), req) - if err != nil { - return nil, err - } - - return res.Code, nil -} - -// GetStorageAt returns the contract storage at the given address, block number, and key. -func (b *BackendImpl) GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) { - blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) - if err != nil { - return nil, err - } - - req := &evmtypes.QueryStorageRequest{ - Address: address.String(), - Key: key, - } - - res, err := b.queryClient.Storage(rpctypes.ContextWithHeight(blockNum.Int64()), req) - if err != nil { - return nil, err - } - - value := common.HexToHash(res.Value) - return value.Bytes(), nil -} - // BlockBloom query block bloom filter from block results func (b *BackendImpl) blockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) { for _, event := range blockRes.FinalizeBlockEvents { @@ -396,12 +531,8 @@ func (b *BackendImpl) BlockFromCosmosBlock(resBlock *tmrpctypes.ResultBlock, blo ethHeader.GasLimit = uint64(gasLimit) blockHash := common.BytesToHash(block.Hash().Bytes()) - receipts, err := b.GetReceipts(context.Background(), blockHash) - if err != nil { - b.logger.Debug(fmt.Sprintf("failed to fetch receipts, block hash %s, block number %d", blockHash.Hex(), height)) - } - ethBlock := ethtypes.NewBlock(ethHeader, txs, nil, receipts, trie.NewStackTrie(nil)) + ethBlock := ethtypes.NewBlock(ethHeader, txs, nil, nil, trie.NewStackTrie(nil)) res := rpctypes.EthBlockToBlock(ethBlock) res.SetHash(blockHash) return res, nil @@ -442,74 +573,17 @@ func (b *BackendImpl) EthMsgsFromCosmosBlock(resBlock *tmrpctypes.ResultBlock, b return result } -func (b *BackendImpl) DoCall(args ethapi.TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash) (*evmtypes.MsgEthereumTxResponse, error) { - blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) - if err != nil { - return nil, err - } - - bz, err := json.Marshal(&args) - if err != nil { - return nil, err - } - header, err := b.CosmosBlockByNumber(blockNum) - if err != nil { - // the error message imitates geth behavior - return nil, errors.New("header not found") - } - - req := evmtypes.EthCallRequest{ - Args: bz, - GasCap: b.RPCGasCap(), - ProposerAddress: sdktypes.ConsAddress(header.Block.ProposerAddress), - ChainId: b.chainID.Int64(), - } - - // From ContextWithHeight: if the provided height is 0, - // it will return an empty context and the gRPC query will use - // the latest block height for querying. - ctx := rpctypes.ContextWithHeight(blockNum.Int64()) - timeout := b.RPCEVMTimeout() - - // Setup context so it may be canceled the call has completed - // or, in case of unmetered gas, setup a context with a timeout. - var cancel context.CancelFunc - if timeout > 0 { - ctx, cancel = context.WithTimeout(ctx, timeout) - } else { - ctx, cancel = context.WithCancel(ctx) - } - - // Make sure the context is canceled when the call has completed - // this makes sure resources are cleaned up. - defer cancel() - - res, err := b.queryClient.EthCall(ctx, &req) - if err != nil { - return nil, err - } - - if res.Failed() { - if res.VmError != vm.ErrExecutionReverted.Error() { - return nil, status.Error(codes.Internal, res.VmError) - } - return nil, evmtypes.NewExecErrorWithReason(res.Ret) - } - - return res, nil -} - func (b *BackendImpl) BlockBloom(blockRes *tmrpctypes.ResultBlockResults) (ethtypes.Bloom, error) { return b.blockBloom(blockRes) } func (b *BackendImpl) GetBlockByNumber(blockNum rpc.BlockNumber, fullTx bool) (map[string]interface{}, error) { - block, err := b.BlockByNumber(context.Background(), blockNum) + block, err := b.ArtBlockByNumber(context.Background(), blockNum) if err != nil { return nil, err } - return ethapi.RPCMarshalHeader(block.Header(), block.Hash()), nil + return api.RPCMarshalHeader(block.Header(), block.Hash()), nil } func (b *BackendImpl) processBlock( diff --git a/ethereum/rpc/tracing.go b/ethereum/rpc/debug.go similarity index 70% rename from ethereum/rpc/tracing.go rename to ethereum/rpc/debug.go index bfa9014..4bb04b7 100644 --- a/ethereum/rpc/tracing.go +++ b/ethereum/rpc/debug.go @@ -1,9 +1,12 @@ package rpc import ( + "context" "encoding/json" "fmt" "math" + "math/big" + "strings" "github.com/pkg/errors" @@ -11,6 +14,8 @@ import ( tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rpc" rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" @@ -210,3 +215,73 @@ func (b *BackendImpl) TraceBlock(height rpc.BlockNumber, return decodedResults, nil } + +// GetReceipts get receipts by block hash +func (b *BackendImpl) GetReceipts(ctx context.Context, hash common.Hash) (ethtypes.Receipts, error) { + resBlock, err := b.CosmosBlockByHash(hash) + if err != nil || resBlock == nil || resBlock.Block == nil { + return nil, fmt.Errorf("query block failed, block hash %s, %w", hash.String(), err) + } + + blockRes, err := b.CosmosBlockResultByNumber(&resBlock.Block.Height) + if err != nil { + b.logger.Debug("GetTransactionReceipt failed", "error", err) + return nil, nil + } + + msgs := b.EthMsgsFromCosmosBlock(resBlock, blockRes) + + receipts := make([]*ethtypes.Receipt, 0, len(msgs)) + for _, msg := range msgs { + receipt, err := b.GetTransactionReceipt(ctx, common.HexToHash(msg.Hash)) + if err != nil || receipt == nil { + errMsg := "" + if err != nil { + errMsg = err.Error() + } + b.logger.Error("eth_getReceipts failed", "error", errMsg, "txHash", msg.Hash) + continue + } + var contractAddress common.Address + if receipt["contractAddress"] != nil { + contractAddress = receipt["contractAddress"].(common.Address) + } + var effectiveGasPrice big.Int + if receipt["effectiveGasPrice"] != nil { + effectiveGasPrice = big.Int(receipt["effectiveGasPrice"].(hexutil.Big)) + } + receipts = append(receipts, ðtypes.Receipt{ + Type: uint8(receipt["type"].(hexutil.Uint)), + PostState: []byte{}, + Status: uint64(receipt["status"].(hexutil.Uint)), + CumulativeGasUsed: uint64(receipt["cumulativeGasUsed"].(hexutil.Uint64)), + Bloom: receipt["logsBloom"].(ethtypes.Bloom), + Logs: receipt["logs"].([]*ethtypes.Log), + TxHash: receipt["transactionHash"].(common.Hash), + ContractAddress: contractAddress, + GasUsed: uint64(receipt["gasUsed"].(hexutil.Uint64)), + EffectiveGasPrice: &effectiveGasPrice, + BlockHash: common.BytesToHash(resBlock.BlockID.Hash.Bytes()), + BlockNumber: big.NewInt(resBlock.Block.Height), + TransactionIndex: uint(receipt["transactionIndex"].(hexutil.Uint64)), + }) + } + return receipts, nil +} + +func (b *BackendImpl) DBProperty(property string) (string, error) { + if b.db == nil || b.db.Stats() == nil { + return "", errors.New("property is not valid") + } + if property == "" { + property = "leveldb.stats" + } else if !strings.HasPrefix(property, "leveldb.") { + property = "leveldb." + property + } + + return (b.db.Stats())[property], nil +} + +func (b *BackendImpl) DBCompact(start []byte, limit []byte) error { + return errors.New("compact is not valid") +} diff --git a/ethereum/rpc/eth.go b/ethereum/rpc/eth.go new file mode 100644 index 0000000..5214152 --- /dev/null +++ b/ethereum/rpc/eth.go @@ -0,0 +1,184 @@ +package rpc + +import ( + "context" + "fmt" + "math/big" + + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/rpc" + + rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" + feetypes "github.com/artela-network/artela-rollkit/x/fee/types" +) + +func (b *BackendImpl) SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) { + if baseFee == nil { + // london hardfork not enabled or feemarket not enabled + return big.NewInt(0), nil + } + + params, err := b.queryClient.FeeMarket.Params(b.ctx, &feetypes.QueryParamsRequest{}) + if err != nil { + return nil, err + } + // calculate the maximum base fee delta in current block, assuming all block gas limit is consumed + // ``` + // GasTarget = GasLimit / ElasticityMultiplier + // Delta = BaseFee * (GasUsed - GasTarget) / GasTarget / Denominator + // ``` + // The delta is at maximum when `GasUsed` is equal to `GasLimit`, which is: + // ``` + // MaxDelta = BaseFee * (GasLimit - GasLimit / ElasticityMultiplier) / (GasLimit / ElasticityMultiplier) / Denominator + // = BaseFee * (ElasticityMultiplier - 1) / Denominator + // ```t + maxDelta := baseFee.Int64() * (int64(params.Params.ElasticityMultiplier) - 1) / int64(params.Params.BaseFeeChangeDenominator) // #nosec G701 + if maxDelta < 0 { + // impossible if the parameter validation passed. + maxDelta = 0 + } + return big.NewInt(maxDelta), nil +} + +func (b *BackendImpl) GasPrice(ctx context.Context) (*hexutil.Big, error) { + var ( + result *big.Int + err error + ) + if head, err := b.CurrentHeader(); err == nil && head.BaseFee != nil { + result, err = b.SuggestGasTipCap(head.BaseFee) + if err != nil { + return nil, err + } + result = result.Add(result, head.BaseFee) + } else { + result = big.NewInt(b.RPCMinGasPrice()) + } + + // return at least GlobalMinGasPrice from FeeMarket module + minGasPrice, err := b.GlobalMinGasPrice() + if err != nil { + return nil, err + } + minGasPriceInt := minGasPrice.TruncateInt().BigInt() + if result.Cmp(minGasPriceInt) < 0 { + result = minGasPriceInt + } + + return (*hexutil.Big)(result), nil +} + +func (b *BackendImpl) FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, + rewardPercentiles []float64, +) (*rpctypes.FeeHistoryResult, error) { + blockEnd := int64(lastBlock) + + if blockEnd < 0 { + blockNumber, err := b.BlockNumber() + if err != nil { + return nil, err + } + blockEnd = int64(blockNumber) + } + + blocks := int64(blockCount) + maxBlockCount := int64(b.cfg.AppCfg.JSONRPC.FeeHistoryCap) + if blocks > maxBlockCount { + return nil, fmt.Errorf("FeeHistory user block count %d higher than %d", blocks, maxBlockCount) + } + + if blockEnd+1 < blocks { + blocks = blockEnd + 1 + } + + blockStart := blockEnd + 1 - blocks + oldestBlock := (*hexutil.Big)(big.NewInt(blockStart)) + + reward := make([][]*hexutil.Big, blocks) + rewardCount := len(rewardPercentiles) + for i := 0; i < int(blocks); i++ { + reward[i] = make([]*hexutil.Big, rewardCount) + } + + thisBaseFee := make([]*hexutil.Big, blocks+1) + thisGasUsedRatio := make([]float64, blocks) + calculateRewards := rewardCount != 0 + + for blockID := blockStart; blockID <= blockEnd; blockID++ { + index := int32(blockID - blockStart) // #nosec G701 + // tendermint block + tendermintblock, err := b.CosmosBlockByNumber(rpc.BlockNumber(blockID)) + if tendermintblock == nil { + return nil, err + } + + // eth block + ethBlock, err := b.GetBlockByNumber(rpc.BlockNumber(blockID), true) + if ethBlock == nil { + return nil, err + } + + // tendermint block result + tendermintBlockResult, err := b.CosmosBlockResultByNumber(&tendermintblock.Block.Height) + if tendermintBlockResult == nil { + b.logger.Debug("block result not found", "height", tendermintblock.Block.Height, "error", err.Error()) + return nil, err + } + + oneFeeHistory, err := b.processBlock(tendermintblock, ðBlock, rewardPercentiles, tendermintBlockResult) + if err != nil { + return nil, err + } + + // copy + thisBaseFee[index] = (*hexutil.Big)(oneFeeHistory.BaseFee) + thisBaseFee[index+1] = (*hexutil.Big)(oneFeeHistory.NextBaseFee) + thisGasUsedRatio[index] = oneFeeHistory.GasUsedRatio + if calculateRewards { + for j := 0; j < rewardCount; j++ { + reward[index][j] = (*hexutil.Big)(oneFeeHistory.Reward[j]) + if reward[index][j] == nil { + reward[index][j] = (*hexutil.Big)(big.NewInt(0)) + } + } + } + } + + feeHistory := rpctypes.FeeHistoryResult{ + OldestBlock: oldestBlock, + BaseFee: thisBaseFee, + GasUsedRatio: thisGasUsedRatio, + } + + if calculateRewards { + feeHistory.Reward = reward + } + + return &feeHistory, nil +} + +func (b *BackendImpl) Engine() consensus.Engine { + // only for ethereum, pow -> pos + b.logger.Error("Engine is not valid") + return nil +} + +func (b *BackendImpl) Syncing() (interface{}, error) { + status, err := b.clientCtx.Client.Status(b.ctx) + if err != nil { + return false, err + } + + if !status.SyncInfo.CatchingUp { + return false, nil + } + + return map[string]interface{}{ + "startingBlock": hexutil.Uint64(status.SyncInfo.EarliestBlockHeight), + "currentBlock": hexutil.Uint64(status.SyncInfo.LatestBlockHeight), + // "highestBlock": nil, // NA + // "pulledStates": nil, // NA + // "knownStates": nil, // NA + }, nil +} diff --git a/ethereum/rpc/ethapi/backend.go b/ethereum/rpc/ethapi/backend.go deleted file mode 100644 index 2a7b431..0000000 --- a/ethereum/rpc/ethapi/backend.go +++ /dev/null @@ -1,74 +0,0 @@ -package ethapi - -import ( - "context" - "math/big" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/consensus" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/rpc" - - "github.com/artela-network/artela-evm/vm" - - rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" - evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" -) - -// Backend interface provides the common API services (that are provided by -// both full and light clients) with access to necessary functions. -type Backend interface { - // General Ethereum API - SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) - GasPrice(ctx context.Context) (*hexutil.Big, error) - - // Account releated - Accounts() []common.Address - NewAccount(password string) (common.AddressEIP55, error) - ImportRawKey(privkey, password string) (common.Address, error) - GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) - GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) - - // Blockchain API - HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) - HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) - HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) - CurrentHeader() (*types.Header, error) - CurrentBlock() *rpctypes.Block - BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Block, error) - ArtBlockByNumber(ctx context.Context, number rpc.BlockNumber) (*rpctypes.Block, error) - BlockByHash(ctx context.Context, hash common.Hash) (*rpctypes.Block, error) - BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*rpctypes.Block, error) - StateAndHeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*state.StateDB, *types.Header, error) - StateAndHeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*state.StateDB, *types.Header, error) - GetEVM(ctx context.Context, msg *core.Message, state *state.StateDB, header *types.Header, vmConfig *vm.Config, blockCtx *vm.BlockContext) (*vm.EVM, func() error) - GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) - GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) - FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*rpctypes.FeeHistoryResult, error) - - // Transaction pool API - SendTx(ctx context.Context, signedTx *types.Transaction) error - GetTransaction(ctx context.Context, txHash common.Hash) (*RPCTransaction, error) - SignTransaction(args *TransactionArgs) (*types.Transaction, error) - GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) - RPCTxFeeCap() float64 - UnprotectedAllowed() bool - EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) - DoCall(args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash) (*evmtypes.MsgEthereumTxResponse, error) - - ChainConfig() *params.ChainConfig - Engine() consensus.Engine - - Syncing() (interface{}, error) - // This is copied from filters.Backend - Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) - - GetCoinbase() (sdk.AccAddress, error) - - GetProof(address common.Address, storageKeys []string, blockNrOrHash rpctypes.BlockNumberOrHash) (*rpctypes.AccountResult, error) -} diff --git a/ethereum/rpc/gas_oracle.go b/ethereum/rpc/gas_oracle.go new file mode 100644 index 0000000..631f78c --- /dev/null +++ b/ethereum/rpc/gas_oracle.go @@ -0,0 +1,37 @@ +package rpc + +import ( + "context" + + "github.com/ethereum/go-ethereum/core/types" + ethtypes "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/rpc" +) + +// BlockByNumber for OracleBackend, should not use it anywhere, unless you know about the block hash diffs. +// Use ArtBlockByNumber instead. +func (b *BackendImpl) BlockByNumber(ctx context.Context, number rpc.BlockNumber) (*ethtypes.Block, error) { + // DO NOT USE THIS METHOD, THIS JUST FOR OracleBackend + block, err := b.ArtBlockByNumber(ctx, number) + if err != nil { + return nil, err + } + // BEWARE THE HASH OF THIS BLOCK IS NOT MATCH TO WHAT WAS STORED IN COSMOS DB + return block.EthBlock(), nil +} + +// BlockByNumberOrHash for OracleBackend, should not use it anywhere, unless you know about the block hash diffs. +// Use ArtBlockByNumberOrHash instead. +func (b *BackendImpl) BlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*ethtypes.Block, error) { + blockNum, err := b.blockNumberFromCosmos(blockNrOrHash) + if err != nil { + return nil, err + } + + // BEWARE THE HASH OF THIS BLOCK IS NOT MATCH TO WHAT WAS STORED IN COSMOS DB + return b.BlockByNumber(ctx, blockNum) +} + +func (b *BackendImpl) PendingBlockAndReceipts() (*types.Block, types.Receipts) { + return nil, nil +} diff --git a/ethereum/rpc/net.go b/ethereum/rpc/net.go new file mode 100644 index 0000000..863340b --- /dev/null +++ b/ethereum/rpc/net.go @@ -0,0 +1,30 @@ +package rpc + +import ( + "github.com/cometbft/cometbft/rpc/client" + "github.com/ethereum/go-ethereum/common/hexutil" +) + +func (b *BackendImpl) Listening() bool { + tmClient := b.clientCtx.Client.(client.Client) + netInfo, err := tmClient.NetInfo(b.ctx) + if err != nil { + return false + } + return netInfo.Listening +} + +func (b *BackendImpl) PeerCount() hexutil.Uint { + tmClient := b.clientCtx.Client.(client.Client) + netInfo, err := tmClient.NetInfo(b.ctx) + if err != nil { + return 0 + } + return hexutil.Uint(len(netInfo.Peers)) +} + +// Version returns the current ethereum protocol version. +func (b *BackendImpl) Version() string { + v, _ := b.version() + return v +} diff --git a/ethereum/rpc/node.go b/ethereum/rpc/node.go index 9ad5bdc..0d4437c 100644 --- a/ethereum/rpc/node.go +++ b/ethereum/rpc/node.go @@ -51,5 +51,6 @@ func DefaultGethNodeConfig() *node.Config { nodeCfg.HTTPVirtualHosts = []string{"*"} nodeCfg.GraphQLCors = []string{"*"} nodeCfg.GraphQLVirtualHosts = []string{"*"} + nodeCfg.EnablePersonal = true return &nodeCfg } diff --git a/ethereum/rpc/personal.go b/ethereum/rpc/personal.go new file mode 100644 index 0000000..9c13f3b --- /dev/null +++ b/ethereum/rpc/personal.go @@ -0,0 +1,74 @@ +package rpc + +import ( + "fmt" + "time" + + sdkcrypto "github.com/cosmos/cosmos-sdk/crypto" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdktypes "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/crypto" + + "github.com/artela-network/artela-rollkit/ethereum/crypto/ethsecp256k1" + "github.com/artela-network/artela-rollkit/ethereum/crypto/hd" + types2 "github.com/artela-network/artela-rollkit/ethereum/types" +) + +func (b *BackendImpl) NewAccount(password string) (common.AddressEIP55, error) { + name := "key_" + time.Now().UTC().Format(time.RFC3339) + + cfg := sdktypes.GetConfig() + basePath := cfg.GetFullBIP44Path() + + hdPathIter, err := types2.NewHDPathIterator(basePath, true) + if err != nil { + b.logger.Info("NewHDPathIterator failed", "error", err) + return common.AddressEIP55{}, err + } + // create the mnemonic and save the account + hdPath := hdPathIter() + + info, _, err := b.clientCtx.Keyring.NewMnemonic(name, keyring.English, hdPath.String(), password, hd.EthSecp256k1) + if err != nil { + b.logger.Info("NewMnemonic failed", "error", err) + return common.AddressEIP55{}, err + } + + pubKey, err := info.GetPubKey() + if err != nil { + b.logger.Info("GetPubKey failed", "error", err) + return common.AddressEIP55{}, err + } + addr := common.BytesToAddress(pubKey.Address().Bytes()) + return common.AddressEIP55(addr), nil +} + +func (b *BackendImpl) ImportRawKey(privkey, password string) (common.Address, error) { + priv, err := crypto.HexToECDSA(privkey) + if err != nil { + return common.Address{}, err + } + + privKey := ðsecp256k1.PrivKey{Key: crypto.FromECDSA(priv)} + + addr := sdktypes.AccAddress(privKey.PubKey().Address().Bytes()) + ethereumAddr := common.BytesToAddress(addr) + + // return if the key has already been imported + if _, err := b.clientCtx.Keyring.KeyByAddress(addr); err == nil { + return ethereumAddr, nil + } + + // ignore error as we only care about the length of the list + list, _ := b.clientCtx.Keyring.List() // #nosec G703 + privKeyName := fmt.Sprintf("personal_%d", len(list)) + + armor := sdkcrypto.EncryptArmorPrivKey(privKey, password, ethsecp256k1.KeyType) + + if err := b.clientCtx.Keyring.ImportPrivKey(privKeyName, armor, password); err != nil { + return common.Address{}, err + } + + return ethereumAddr, nil +} diff --git a/ethereum/rpc/service.go b/ethereum/rpc/service.go index 1610718..27afa84 100644 --- a/ethereum/rpc/service.go +++ b/ethereum/rpc/service.go @@ -2,6 +2,7 @@ package rpc import ( rpcclient "github.com/cometbft/cometbft/rpc/jsonrpc/client" + db "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/server" "github.com/ethereum/go-ethereum/log" @@ -12,6 +13,7 @@ import ( type ArtelaService struct { clientCtx client.Context + serverCtx *server.Context wsClient *rpcclient.WSClient cfg *Config stack types.NetworkingStack @@ -26,21 +28,23 @@ func NewArtelaService( cfg *Config, stack types.NetworkingStack, logger log.Logger, + db db.DB, ) *ArtelaService { art := &ArtelaService{ cfg: cfg, stack: stack, clientCtx: clientCtx, + serverCtx: ctx, wsClient: wsClient, logger: logger, } - art.backend = NewBackend(ctx, clientCtx, art, stack.ExtRPCEnabled(), cfg, logger) + art.backend = NewBackend(ctx, clientCtx, art, stack.ExtRPCEnabled(), cfg, logger, db) return art } func (art *ArtelaService) APIs() []rpc.API { - return GetAPIs(art.clientCtx, art.wsClient, art.logger, art.backend) + return GetAPIs(art.clientCtx, art.serverCtx, art.wsClient, art.logger, art.backend) } // Start start the ethereum JsonRPC service diff --git a/ethereum/rpc/tx.go b/ethereum/rpc/tx.go index 3a0ebcd..c61bd47 100644 --- a/ethereum/rpc/tx.go +++ b/ethereum/rpc/tx.go @@ -2,31 +2,36 @@ package rpc import ( "context" - "encoding/json" "errors" "fmt" + "math/big" errorsmod "cosmossdk.io/errors" + rpcclient "github.com/cometbft/cometbft/rpc/client" "github.com/cosmos/cosmos-sdk/client/flags" sdktypes "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/consensus" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/rpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/artela-network/artela-rollkit/common/aspect" - "github.com/artela-network/artela-rollkit/ethereum/rpc/ethapi" rpctypes "github.com/artela-network/artela-rollkit/ethereum/rpc/types" - "github.com/artela-network/artela-rollkit/ethereum/rpc/utils" + rpcutils "github.com/artela-network/artela-rollkit/ethereum/rpc/utils" "github.com/artela-network/artela-rollkit/ethereum/types" + "github.com/artela-network/artela-rollkit/ethereum/utils" evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" ) -// Transaction pool API +// Transaction API func (b *BackendImpl) SendTx(ctx context.Context, signedTx *ethtypes.Transaction) error { // verify the ethereum tx @@ -84,148 +89,83 @@ func (b *BackendImpl) SendTx(ctx context.Context, signedTx *ethtypes.Transaction return nil } -func (b *BackendImpl) GetTransaction(ctx context.Context, txHash common.Hash) (*ethapi.RPCTransaction, error) { - res, err := b.GetTxByEthHash(txHash) - hexTx := txHash.Hex() +func (b *BackendImpl) GetTransaction(ctx context.Context, txHash common.Hash) (*rpctypes.RPCTransaction, error) { + _, tx, err := b.getTransaction(ctx, txHash) + return tx, err +} +func (b *BackendImpl) GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) { + n := hexutil.Uint64(0) + height, err := b.blockNumberFromCosmos(blockNrOrHash) if err != nil { - b.logger.Debug("GetTxByEthHash failed, try to getTransactionByHashPending", "error", err) - return b.getTransactionByHashPending(txHash) + return &n, err } - - block, err := b.CosmosBlockByNumber(rpc.BlockNumber(res.Height)) + header, err := b.CurrentHeader() if err != nil { - return nil, err + return &n, err + } + if height.Int64() > header.Number.Int64() { + return &n, fmt.Errorf( + "cannot query with height in the future (current: %d, queried: %d); please provide a valid height", + header.Number, height) } + // Get nonce (sequence) from account + from := sdktypes.AccAddress(address.Bytes()) + accRet := b.clientCtx.AccountRetriever - tx, err := b.clientCtx.TxConfig.TxDecoder()(block.Block.Txs[res.TxIndex]) + if err = accRet.EnsureExists(b.clientCtx, from); err != nil { + // account doesn't exist yet, return 0 + b.logger.Info("GetTransactionCount faild, return 0. Account doesn't exist yet", "account", address.Hex(), "error", err) + return &n, nil + } + + includePending := height == rpc.PendingBlockNumber + nonce, err := b.getAccountNonce(address, includePending, height.Int64()) if err != nil { return nil, err } - // the `res.MsgIndex` is inferred from tx index, should be within the bound. - msg, ok := tx.GetMsgs()[res.MsgIndex].(*evmtypes.MsgEthereumTx) - if !ok { - return nil, errors.New("invalid ethereum tx") - } - msg.From = res.Sender + n = hexutil.Uint64(nonce) + return &n, nil +} - blockRes, err := b.CosmosBlockResultByNumber(&block.Block.Height) +func (b *BackendImpl) GetTxMsg(ctx context.Context, txHash common.Hash) (*evmtypes.MsgEthereumTx, error) { + msg, _, err := b.getTransaction(ctx, txHash) + return msg, err +} + +func (b *BackendImpl) SignTransaction(args *rpctypes.TransactionArgs) (*ethtypes.Transaction, error) { + _, err := b.clientCtx.Keyring.KeyByAddress(sdktypes.AccAddress(args.From.Bytes())) if err != nil { - b.logger.Debug("block result not found", "height", block.Block.Height, "error", err.Error()) - return nil, nil + return nil, fmt.Errorf("failed to find key in the node's keyring; %s; %s", keystore.ErrNoMatch, err.Error()) } - if res.EthTxIndex == -1 { - // Fallback to find tx index by iterating all valid eth transactions - msgs := b.EthMsgsFromCosmosBlock(block, blockRes) - for i := range msgs { - if msgs[i].Hash == hexTx { - res.EthTxIndex = int32(i) - break - } - } - } - // if we still unable to find the eth tx index, return error, shouldn't happen. - if res.EthTxIndex == -1 { - return nil, errors.New("can't find index of ethereum tx") + if args.ChainID != nil && (b.chainID).Cmp((*big.Int)(args.ChainID)) != 0 { + return nil, fmt.Errorf("chainId does not match node's (have=%v, want=%v)", args.ChainID, (*hexutil.Big)(b.chainID)) } - baseFee, err := b.BaseFee(blockRes) + bn, err := b.BlockNumber() if err != nil { - // handle the error for pruned node. - b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", blockRes.Height, "error", err) + return nil, err } - cfg, err := b.chainConfig() + bt, err := b.BlockTimeByNumber(int64(bn)) if err != nil { return nil, err } - return ethapi.NewTransactionFromMsg( - msg, - common.BytesToHash(block.BlockID.Hash.Bytes()), - uint64(res.Height), - uint64(res.EthTxIndex), - baseFee, - cfg, - ), nil -} - -func (b *BackendImpl) GetPoolTransactions() (ethtypes.Transactions, error) { - b.logger.Debug("called eth.rpc.backend.GetPoolTransactions") - return nil, errors.New("GetPoolTransactions is not implemented") -} - -func (b *BackendImpl) GetPoolTransaction(txHash common.Hash) *ethtypes.Transaction { - b.logger.Error("GetPoolTransaction is not implemented") - return nil -} - -func (b *BackendImpl) GetPoolNonce(_ context.Context, addr common.Address) (uint64, error) { - return 0, errors.New("GetPoolNonce is not implemented") -} - -func (b *BackendImpl) Stats() (int, int) { - b.logger.Error("Stats is not implemented") - return 0, 0 -} - -func (b *BackendImpl) TxPoolContent() ( - map[common.Address]ethtypes.Transactions, map[common.Address]ethtypes.Transactions, -) { - b.logger.Error("TxPoolContent is not implemented") - return nil, nil -} - -func (b *BackendImpl) TxPoolContentFrom(addr common.Address) ( - ethtypes.Transactions, ethtypes.Transactions, -) { - return nil, nil -} - -func (b *BackendImpl) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription { - return b.scope.Track(b.newTxsFeed.Subscribe(ch)) -} - -// Version returns the current ethereum protocol version. -func (b *BackendImpl) Version() string { - v, _ := b.version() - return v -} - -func (b *BackendImpl) version() (string, error) { cfg, err := b.chainConfig() if err != nil { - return "", err - } - - if cfg.ChainID == nil { - b.logger.Error("eth.rpc.backend.Version", "ChainID is nil") - return "", errors.New("chain id is not valid") + return nil, err } - return cfg.ChainID.String(), nil -} - -func (b *BackendImpl) Engine() consensus.Engine { - b.logger.Error("Engine is not implemented") - return nil -} + signer := ethtypes.MakeSigner(cfg, new(big.Int).SetUint64(uint64(bn)), bt) -func (b *BackendImpl) GetTxByEthHash(hash common.Hash) (*types.TxResult, error) { - // if b.indexer != nil { - // return b.indexer.GetByTxHash(hash) - // } + // LegacyTx derives chainID from the signature. To make sure the msg.ValidateBasic makes + // the corresponding chainID validation, we need to sign the transaction before calling it - // fallback to tendermint tx indexer - query := fmt.Sprintf("%s.%s='%s'", evmtypes.TypeMsgEthereumTx, evmtypes.AttributeKeyEthereumTxHash, hash.Hex()) - txResult, err := b.queryCosmosTxIndexer(query, func(txs *rpctypes.ParsedTxs) *rpctypes.ParsedTx { - return txs.GetTxByHash(hash) - }) - if err != nil { - return nil, fmt.Errorf("GetTxByEthHash %s, %w", hash.Hex(), err) - } - return txResult, nil + // Sign transaction + msg := args.ToEVMTransaction() + return msg.SignEthereumTx(signer, b.clientCtx.Keyring) } // GetTransactionReceipt get receipt by transaction hash @@ -271,7 +211,7 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has // parse tx logs from events msgIndex := int(res.MsgIndex) - logs, _ := utils.TxLogsFromEvents(blockRes.TxsResults[res.TxIndex].Events, msgIndex) + logs, _ := rpcutils.TxLogsFromEvents(blockRes.TxsResults[res.TxIndex].Events, msgIndex) if res.EthTxIndex == -1 { // Fallback to find tx index by iterating all valid eth transactions @@ -299,7 +239,7 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has // They are stored in the chain database. "transactionHash": hash, "contractAddress": nil, - "gasUsed": hexutil.Uint64(txData.GetGas()), + "gasUsed": hexutil.Uint64(res.GasUsed), // Inclusion information: These fields provide information about the inclusion of the // transaction corresponding to this receipt. @@ -314,7 +254,7 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has } if logs == nil { - receipt["logs"] = [][]*ethtypes.Log{} + receipt["logs"] = []*ethtypes.Log{} } // If the ContractAddress is 20 0x0 bytes, assume it is not a contract creation @@ -332,6 +272,263 @@ func (b *BackendImpl) GetTransactionReceipt(ctx context.Context, hash common.Has return receipt, nil } +func (b *BackendImpl) RPCTxFeeCap() float64 { + return b.cfg.RPCTxFeeCap +} + +func (b *BackendImpl) UnprotectedAllowed() bool { + if b.cfg.AppCfg == nil { + return false + } + return b.cfg.AppCfg.JSONRPC.AllowUnprotectedTxs +} + +func (b *BackendImpl) PendingTransactions() ([]*sdktypes.Tx, error) { + client, ok := b.clientCtx.Client.(rpcclient.MempoolClient) + if !ok { + return nil, errors.New("failed to assert MempoolClient") + } + + res, err := client.UnconfirmedTxs(b.ctx, nil) + if err != nil { + return nil, err + } + + result := make([]*sdktypes.Tx, 0, res.Count) + for _, txBz := range res.Txs { + tx, err := b.clientCtx.TxConfig.TxDecoder()(txBz) + if err != nil { + return nil, err + } + result = append(result, &tx) + } + + return result, nil +} + +func (b *BackendImpl) GetResendArgs(args rpctypes.TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (rpctypes.TransactionArgs, error) { + chainID, err := types.ParseChainID(b.clientCtx.ChainID) + if err != nil { + return rpctypes.TransactionArgs{}, err + } + + cfg := b.ChainConfig() + if cfg == nil { + header, err := b.CurrentHeader() + if err != nil { + return rpctypes.TransactionArgs{}, err + } + cfg = evmtypes.DefaultChainConfig().EthereumConfig(header.Number.Int64(), chainID) + } + + // use the latest signer for the new tx + signer := ethtypes.LatestSigner(cfg) + + matchTx := args.ToTransaction() + + // Before replacing the old transaction, ensure the _new_ transaction fee is reasonable. + price := matchTx.GasPrice() + if gasPrice != nil { + price = gasPrice.ToInt() + } + gas := matchTx.Gas() + if gasLimit != nil { + gas = uint64(*gasLimit) + } + if err := rpctypes.CheckTxFee(price, gas, b.RPCTxFeeCap()); err != nil { + return rpctypes.TransactionArgs{}, err + } + + pending, err := b.PendingTransactions() + if err != nil { + return rpctypes.TransactionArgs{}, err + } + + for _, tx := range pending { + wantSigHash := signer.Hash(matchTx) + + // TODO, wantSigHash? + msg, err := evmtypes.UnwrapEthereumMsg(tx, wantSigHash) + if err != nil { + // not ethereum tx + continue + } + + pendingTx := msg.AsTransaction() + pFrom, err := ethtypes.Sender(signer, pendingTx) + if err != nil { + continue + } + + if pFrom == *args.From && signer.Hash(pendingTx) == wantSigHash { + // Match. Re-sign and send the transaction. + if gasPrice != nil && (*big.Int)(gasPrice).Sign() != 0 { + args.GasPrice = gasPrice + } + if gasLimit != nil && *gasLimit != 0 { + args.Gas = gasLimit + } + + return args, nil + } + } + + return rpctypes.TransactionArgs{}, fmt.Errorf("transaction %s not found", matchTx.Hash().String()) +} + +// Sign signs the provided data using the private key of address via Geth's signature standard. +func (b *BackendImpl) Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) { + from := sdktypes.AccAddress(address.Bytes()) + + _, err := b.clientCtx.Keyring.KeyByAddress(from) + if err != nil { + return nil, fmt.Errorf("%s; %s", keystore.ErrNoMatch, err.Error()) + } + + // Sign the requested hash with the wallet + signature, _, err := b.clientCtx.Keyring.SignByAddress(from, data, signing.SignMode_SIGN_MODE_DIRECT) + if err != nil { + return nil, err + } + + signature[crypto.RecoveryIDOffset] += 27 // Transform V from 0/1 to 27/28 according to the yellow paper + return signature, nil +} + +// GetSender extracts the sender address from the signature values using the latest signer for the given chainID. +func (b *BackendImpl) GetSender(msg *evmtypes.MsgEthereumTx, chainID *big.Int) (from common.Address, err error) { + if msg.From != "" { + return common.HexToAddress(msg.From), nil + } + + tx := msg.AsTransaction() + // retrieve sender info from aspect if tx is not signed + if utils.IsCustomizedVerification(tx) { + bn, err := b.BlockNumber() + if err != nil { + return common.Address{}, err + } + ctx := rpctypes.ContextWithHeight(int64(bn)) + + res, err := b.queryClient.GetSender(ctx, msg) + if err != nil { + return common.Address{}, err + } + + from = common.HexToAddress(res.Sender) + } else { + signer := ethtypes.LatestSignerForChainID(chainID) + from, err = signer.Sender(tx) + if err != nil { + return common.Address{}, err + } + } + + msg.From = from.Hex() + return from, nil +} + +func (b *BackendImpl) getTransaction(_ context.Context, txHash common.Hash) (*evmtypes.MsgEthereumTx, *rpctypes.RPCTransaction, error) { + res, err := b.GetTxByEthHash(txHash) + hexTx := txHash.Hex() + + if err != nil { + b.logger.Debug("GetTxByEthHash failed, try to getTransactionByHashPending", "error", err) + return b.getTransactionByHashPending(txHash) + } + + block, err := b.CosmosBlockByNumber(rpc.BlockNumber(res.Height)) + if err != nil { + return nil, nil, err + } + + tx, err := b.clientCtx.TxConfig.TxDecoder()(block.Block.Txs[res.TxIndex]) + if err != nil { + return nil, nil, err + } + + // the `res.MsgIndex` is inferred from tx index, should be within the bound. + msg, ok := tx.GetMsgs()[res.MsgIndex].(*evmtypes.MsgEthereumTx) + if !ok { + return nil, nil, errors.New("invalid ethereum tx") + } + msg.From = res.Sender + + blockRes, err := b.CosmosBlockResultByNumber(&block.Block.Height) + if err != nil { + b.logger.Debug("block result not found", "height", block.Block.Height, "error", err.Error()) + return nil, nil, nil + } + + if res.EthTxIndex == -1 { + // Fallback to find tx index by iterating all valid eth transactions + msgs := b.EthMsgsFromCosmosBlock(block, blockRes) + for i := range msgs { + if msgs[i].Hash == hexTx { + res.EthTxIndex = int32(i) + break + } + } + } + // if we still unable to find the eth tx index, return error, shouldn't happen. + if res.EthTxIndex == -1 { + return msg, nil, errors.New("can't find index of ethereum tx") + } + + baseFee, err := b.BaseFee(blockRes) + if err != nil { + // handle the error for pruned node. + b.logger.Error("failed to fetch Base Fee from prunned block. Check node prunning configuration", "height", blockRes.Height, "error", err) + } + + cfg, err := b.chainConfig() + if err != nil { + return msg, nil, err + } + + return msg, rpctypes.NewTransactionFromMsg( + msg, + common.BytesToHash(block.BlockID.Hash.Bytes()), + uint64(res.Height), + uint64(res.EthTxIndex), + baseFee, + cfg, + ), nil +} + +func (b *BackendImpl) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription { + return b.scope.Track(b.newTxsFeed.Subscribe(ch)) +} + +func (b *BackendImpl) version() (string, error) { + cfg, err := b.chainConfig() + if err != nil { + return "", err + } + + if cfg.ChainID == nil { + b.logger.Error("eth.rpc.rpctypes.Version", "ChainID is nil") + return "", errors.New("chain id is not valid") + } + return cfg.ChainID.String(), nil +} + +func (b *BackendImpl) GetTxByEthHash(hash common.Hash) (*types.TxResult, error) { + // if b.indexer != nil { + // return b.indexer.GetByTxHash(hash) + // } + + // fallback to tendermint tx indexer + query := fmt.Sprintf("%s.%s='%s'", evmtypes.TypeMsgEthereumTx, evmtypes.AttributeKeyEthereumTxHash, hash.Hex()) + txResult, err := b.queryCosmosTxIndexer(query, func(txs *rpctypes.ParsedTxs) *rpctypes.ParsedTx { + return txs.GetTxByHash(hash) + }) + if err != nil { + return nil, fmt.Errorf("GetTxByEthHash %s, %w", hash.Hex(), err) + } + return txResult, nil +} + func (b *BackendImpl) queryCosmosTxIndexer(query string, txGetter func(*rpctypes.ParsedTxs) *rpctypes.ParsedTx) (*types.TxResult, error) { resTxs, err := b.clientCtx.Client.TxSearch(b.ctx, query, false, nil, nil, "") if err != nil { @@ -358,13 +555,13 @@ func (b *BackendImpl) queryCosmosTxIndexer(query string, txGetter func(*rpctypes } // getTransactionByHashPending find pending tx from mempool -func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.RPCTransaction, error) { +func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*evmtypes.MsgEthereumTx, *rpctypes.RPCTransaction, error) { hexTx := txHash.Hex() // try to find tx in mempool ptxs, err := b.PendingTransactions() if err != nil { - b.logger.Debug("tx not found", "hash", hexTx, "error", err.Error()) - return nil, nil + b.logger.Debug("pending tx not found", "hash", hexTx, "error", err.Error()) + return nil, nil, nil } for _, tx := range ptxs { @@ -376,11 +573,11 @@ func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.R cfg, err := b.chainConfig() if err != nil { - return nil, err + return msg, nil, err } if msg.Hash == hexTx { // use zero block values since it's not included in a block yet - rpctx := ethapi.NewTransactionFromMsg( + rpctx := rpctypes.NewTransactionFromMsg( msg, common.Hash{}, uint64(0), @@ -388,44 +585,65 @@ func (b *BackendImpl) getTransactionByHashPending(txHash common.Hash) (*ethapi.R nil, cfg, ) - return rpctx, nil + return msg, rpctx, nil } } b.logger.Debug("tx not found", "hash", hexTx) - return nil, nil + return nil, nil, nil } -func (b *BackendImpl) EstimateGas(ctx context.Context, args ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) { - blockNum := rpc.LatestBlockNumber - if blockNrOrHash != nil { - blockNum, _ = b.blockNumberFromCosmos(*blockNrOrHash) - } - - bz, err := json.Marshal(&args) +func (b *BackendImpl) getAccountNonce(accAddr common.Address, pending bool, height int64) (uint64, error) { + queryClient := authtypes.NewQueryClient(b.clientCtx) + adr := sdktypes.AccAddress(accAddr.Bytes()).String() + ctx := rpctypes.ContextWithHeight(height) + res, err := queryClient.Account(ctx, &authtypes.QueryAccountRequest{Address: adr}) if err != nil { + st, ok := status.FromError(err) + // treat as account doesn't exist yet + if ok && st.Code() == codes.NotFound { + b.logger.Info("getAccountNonce faild, account not found", "error", err) + return 0, nil + } return 0, err } - - header, err := b.CosmosBlockByNumber(blockNum) - if err != nil { - // the error message imitates geth behavior - return 0, errors.New("header not found") + var acc authtypes.AccountI + if err := b.clientCtx.InterfaceRegistry.UnpackAny(res.Account, &acc); err != nil { + return 0, err } - req := evmtypes.EthCallRequest{ - Args: bz, - GasCap: b.RPCGasCap(), - ProposerAddress: sdktypes.ConsAddress(header.Block.ProposerAddress), - ChainId: b.chainID.Int64(), + nonce := acc.GetSequence() + + if !pending { + return nonce, nil } - // From ContextWithHeight: if the provided height is 0, - // it will return an empty context and the gRPC query will use - // the latest block height for querying. - res, err := b.queryClient.EstimateGas(rpctypes.ContextWithHeight(blockNum.Int64()), &req) + // the account retriever doesn't include the uncommitted transactions on the nonce so we need to + // to manually add them. + pendingTxs, err := b.PendingTransactions() if err != nil { - return 0, err + return nonce, nil } - return hexutil.Uint64(res.Gas), nil + + // add the uncommitted txs to the nonce counter + // only supports `MsgEthereumTx` style tx + for _, tx := range pendingTxs { + for _, msg := range (*tx).GetMsgs() { + ethMsg, ok := msg.(*evmtypes.MsgEthereumTx) + if !ok { + // not ethereum tx + break + } + + sender, err := b.GetSender(ethMsg, b.chainID) + if err != nil { + continue + } + if sender == accAddr { + nonce++ + } + } + } + + return nonce, nil } diff --git a/ethereum/rpc/tx_pool.go b/ethereum/rpc/tx_pool.go new file mode 100644 index 0000000..a1a5bba --- /dev/null +++ b/ethereum/rpc/tx_pool.go @@ -0,0 +1,20 @@ +package rpc + +import ( + "errors" + + rpcclient "github.com/cometbft/cometbft/rpc/client" +) + +func (b *BackendImpl) PendingTransactionsCount() (int, error) { + client, ok := b.clientCtx.Client.(rpcclient.MempoolClient) + if !ok { + return 0, errors.New("failed to assert MempoolClient") + } + + res, err := client.UnconfirmedTxs(b.ctx, nil) + if err != nil { + return 0, err + } + return res.Count, nil +} diff --git a/ethereum/rpc/types/backend.go b/ethereum/rpc/types/backend.go new file mode 100644 index 0000000..aa66ff4 --- /dev/null +++ b/ethereum/rpc/types/backend.go @@ -0,0 +1,125 @@ +package types + +import ( + "context" + "math/big" + + tmrpctypes "github.com/cometbft/cometbft/rpc/core/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/consensus" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/rpc" + + "github.com/artela-network/artela-rollkit/x/evm/txs" + evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" +) + +type ( + // Backend defines the common interfaces + Backend interface { + CurrentHeader() (*types.Header, error) + + Accounts() []common.Address + GetBalance(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Big, error) + ArtBlockByNumber(ctx context.Context, number rpc.BlockNumber) (*Block, error) + BlockByHash(ctx context.Context, hash common.Hash) (*Block, error) + ChainConfig() *params.ChainConfig + } + + // EthereumBackend defines the chain related interfaces + EthereumBackend interface { + Backend + + SuggestGasTipCap(baseFee *big.Int) (*big.Int, error) + GasPrice(ctx context.Context) (*hexutil.Big, error) + FeeHistory(blockCount uint64, lastBlock rpc.BlockNumber, rewardPercentiles []float64) (*FeeHistoryResult, error) + + Engine() consensus.Engine + Syncing() (interface{}, error) + } + + // BlockChainBackend defines the block chain interfaces + BlockChainBackend interface { + Backend + + GetProof(address common.Address, storageKeys []string, blockNrOrHash BlockNumberOrHash) (*AccountResult, error) + DoCall(args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash) (*evmtypes.MsgEthereumTxResponse, error) + EstimateGas(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash) (hexutil.Uint64, error) + + HeaderByNumber(ctx context.Context, number rpc.BlockNumber) (*types.Header, error) + HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) + HeaderByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*types.Header, error) + CurrentBlock() *Block + ArtBlockByNumberOrHash(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash) (*Block, error) + CosmosBlockByHash(blockHash common.Hash) (*tmrpctypes.ResultBlock, error) + CosmosBlockByNumber(blockNum rpc.BlockNumber) (*tmrpctypes.ResultBlock, error) + GetCode(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) + GetStorageAt(address common.Address, key string, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error) + GetCoinbase() (sdk.AccAddress, error) + } + + // TrancsactionBackend defines the block chain interfaces + TrancsactionBackend interface { + BlockChainBackend + EthereumBackend + + SendTx(ctx context.Context, signedTx *types.Transaction) error + GetTransaction(ctx context.Context, txHash common.Hash) (*RPCTransaction, error) + GetTransactionCount(address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (*hexutil.Uint64, error) + GetTxMsg(ctx context.Context, txHash common.Hash) (*evmtypes.MsgEthereumTx, error) + SignTransaction(args *TransactionArgs) (*types.Transaction, error) + GetTransactionReceipt(ctx context.Context, hash common.Hash) (map[string]interface{}, error) + RPCTxFeeCap() float64 + UnprotectedAllowed() bool + + PendingTransactions() ([]*sdk.Tx, error) + GetResendArgs(args TransactionArgs, gasPrice *hexutil.Big, gasLimit *hexutil.Uint64) (TransactionArgs, error) + Sign(address common.Address, data hexutil.Bytes) (hexutil.Bytes, error) + GetSender(msg *evmtypes.MsgEthereumTx, chainID *big.Int) (from common.Address, err error) + } + + DebugBackend interface { + BlockChainBackend + TrancsactionBackend + + TraceTransaction(hash common.Hash, config *evmtypes.TraceConfig) (interface{}, error) + TraceBlock(height rpc.BlockNumber, + config *evmtypes.TraceConfig, + block *tmrpctypes.ResultBlock, + ) ([]*txs.TxTraceResult, error) + GetReceipts(ctx context.Context, hash common.Hash) (types.Receipts, error) + + DBProperty(property string) (string, error) + DBCompact(start []byte, limit []byte) error + } + + PersonalBackend interface { + TrancsactionBackend + + NewAccount(password string) (common.AddressEIP55, error) + ImportRawKey(privkey, password string) (common.Address, error) + } + + TxPoolBackend interface { + TrancsactionBackend + + PendingTransactionsCount() (int, error) + } + + // NetBackend is the collection of methods required to satisfy the net + // RPC DebugAPI. + NetBackend interface { + PeerCount() hexutil.Uint + Listening() bool + Version() string + } + + // Web3Backend is the collection of methods required to satisfy the net + // RPC DebugAPI. + Web3Backend interface { + ClientVersion() string + } +) diff --git a/ethereum/rpc/types/block.go b/ethereum/rpc/types/block.go index 0c08141..737058f 100644 --- a/ethereum/rpc/types/block.go +++ b/ethereum/rpc/types/block.go @@ -77,8 +77,11 @@ func EthBlockToBlock(block *ethtypes.Block) *Block { type BlockNumber int64 const ( - EthPendingBlockNumber = BlockNumber(-2) - EthLatestBlockNumber = BlockNumber(-1) + // adjust the order to match ethereum + // the order was changed in ethereum at: + // https://github.com/ethereum/go-ethereum/pull/27219/files#diff-064c12cf00b0f549b40fa9dff4231b1d1d3c143a2e47cd051a87f5b04d429949R68 + EthLatestBlockNumber = BlockNumber(-2) + EthPendingBlockNumber = BlockNumber(-1) EthEarliestBlockNumber = BlockNumber(0) ) diff --git a/ethereum/rpc/types/rpc_transacction.go b/ethereum/rpc/types/rpc_transacction.go new file mode 100644 index 0000000..ea09b30 --- /dev/null +++ b/ethereum/rpc/types/rpc_transacction.go @@ -0,0 +1,146 @@ +package types + +import ( + "math/big" + "time" + + evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common/math" + "github.com/ethereum/go-ethereum/consensus/misc" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/params" +) + +// RPCTransaction represents a transaction that will serialize to the RPC representation of a transaction +type RPCTransaction struct { + BlockHash *common.Hash `json:"blockHash"` + BlockNumber *hexutil.Big `json:"blockNumber"` + From common.Address `json:"from"` + Gas hexutil.Uint64 `json:"gas"` + GasPrice *hexutil.Big `json:"gasPrice"` + GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` + GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` + Hash common.Hash `json:"hash"` + Input hexutil.Bytes `json:"input"` + Nonce hexutil.Uint64 `json:"nonce"` + To *common.Address `json:"to"` + TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` + Value *hexutil.Big `json:"value"` + Type hexutil.Uint64 `json:"type"` + Accesses *types.AccessList `json:"accessList,omitempty"` + ChainID *hexutil.Big `json:"chainId,omitempty"` + V *hexutil.Big `json:"v"` + R *hexutil.Big `json:"r"` + S *hexutil.Big `json:"s"` +} + +// newRPCTransaction returns a transaction that will serialize to the RPC +// representation, with the given location metadata set (if available). +func newRPCTransaction(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, blockTime uint64, index uint64, baseFee *big.Int, config *params.ChainConfig) *RPCTransaction { + signer := types.MakeSigner(config, new(big.Int).SetUint64(blockNumber), blockTime) + from, _ := types.Sender(signer, tx) + + return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, from) +} + +func newRPCTransactionWithFrom(tx *types.Transaction, blockHash common.Hash, blockNumber uint64, index uint64, baseFee *big.Int, from common.Address) *RPCTransaction { + v, r, s := tx.RawSignatureValues() + result := &RPCTransaction{ + Type: hexutil.Uint64(tx.Type()), + From: from, + Gas: hexutil.Uint64(tx.Gas()), + GasPrice: (*hexutil.Big)(tx.GasPrice()), + Hash: tx.Hash(), + Input: hexutil.Bytes(tx.Data()), + Nonce: hexutil.Uint64(tx.Nonce()), + To: tx.To(), + Value: (*hexutil.Big)(tx.Value()), + V: (*hexutil.Big)(v), + R: (*hexutil.Big)(r), + S: (*hexutil.Big)(s), + } + if blockHash != (common.Hash{}) { + result.BlockHash = &blockHash + result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) + result.TransactionIndex = (*hexutil.Uint64)(&index) + } + switch tx.Type() { + case types.LegacyTxType: + // if a legacy transaction has an EIP-155 chain id, include it explicitly + if id := tx.ChainId(); id.Sign() != 0 { + result.ChainID = (*hexutil.Big)(id) + } + case types.AccessListTxType: + al := tx.AccessList() + result.Accesses = &al + result.ChainID = (*hexutil.Big)(tx.ChainId()) + case types.DynamicFeeTxType: + al := tx.AccessList() + result.Accesses = &al + result.ChainID = (*hexutil.Big)(tx.ChainId()) + result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap()) + result.GasTipCap = (*hexutil.Big)(tx.GasTipCap()) + // if the transaction has been mined, compute the effective gas price + if baseFee != nil && blockHash != (common.Hash{}) { + // price = min(tip, gasFeeCap - baseFee) + baseFee + price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap()) + result.GasPrice = (*hexutil.Big)(price) + } else { + result.GasPrice = (*hexutil.Big)(tx.GasFeeCap()) + } + } + return result +} + +// NewTransactionFromMsg returns a txs that will serialize to the RPC +// representation, with the given location metadata set (if available). +func NewTransactionFromMsg( + msg *evmtypes.MsgEthereumTx, + blockHash common.Hash, + blockNumber, index uint64, + baseFee *big.Int, + cfg *params.ChainConfig, +) *RPCTransaction { + tx := msg.AsTransaction() + // use latest singer, so use time.now as block time. + if msg.From != "" { + return newRPCTransactionWithFrom(tx, blockHash, blockNumber, index, baseFee, common.HexToAddress(msg.From)) + } + return newRPCTransaction(tx, blockHash, blockNumber, uint64(time.Now().Unix()), index, baseFee, cfg) +} + +// NewRPCPendingTransaction returns a pending transaction that will serialize to the RPC representation +func NewRPCPendingTransaction(tx *types.Transaction, current *types.Header, config *params.ChainConfig) *RPCTransaction { + var ( + baseFee *big.Int + blockNumber = uint64(0) + blockTime = uint64(0) + ) + if current != nil { + baseFee = misc.CalcBaseFee(config, current) + blockNumber = current.Number.Uint64() + blockTime = current.Time + } + return newRPCTransaction(tx, common.Hash{}, blockNumber, blockTime, 0, baseFee, config) +} + +// newRPCTransactionFromBlockIndex returns a transaction that will serialize to the RPC representation. +func NewRPCTransactionFromBlockIndex(b *types.Block, blockHash common.Hash, index uint64, config *params.ChainConfig) *RPCTransaction { + txs := b.Transactions() + if index >= uint64(len(txs)) { + return nil + } + return newRPCTransaction(txs[index], blockHash, b.NumberU64(), b.Time(), index, b.BaseFee(), config) +} + +// newRPCRawTransactionFromBlockIndex returns the bytes of a transaction given a block and a transaction index. +func NewRPCRawTransactionFromBlockIndex(b *types.Block, index uint64) hexutil.Bytes { + txs := b.Transactions() + if index >= uint64(len(txs)) { + return nil + } + blob, _ := txs[index].MarshalBinary() + return blob +} diff --git a/ethereum/rpc/ethapi/transaction_args.go b/ethereum/rpc/types/transaction_args.go similarity index 95% rename from ethereum/rpc/ethapi/transaction_args.go rename to ethereum/rpc/types/transaction_args.go index 610b6c3..68c128a 100644 --- a/ethereum/rpc/ethapi/transaction_args.go +++ b/ethereum/rpc/types/transaction_args.go @@ -1,4 +1,4 @@ -package ethapi +package types import ( "bytes" @@ -43,7 +43,7 @@ type TransactionArgs struct { } // from retrieves the transaction sender address. -func (args *TransactionArgs) from() common.Address { +func (args *TransactionArgs) FromAddr() common.Address { if args.From == nil { return common.Address{} } @@ -62,7 +62,7 @@ func (args *TransactionArgs) data() []byte { } // setDefaults fills in default values for unspecified tx fields. -func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { +func (args *TransactionArgs) SetDefaults(ctx context.Context, b TrancsactionBackend) error { if err := args.setFeeDefaults(ctx, b); err != nil { return err } @@ -70,7 +70,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { args.Value = new(hexutil.Big) } if args.Nonce == nil { - nonce, err := b.GetTransactionCount(args.from(), rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)) + nonce, err := b.GetTransactionCount(args.FromAddr(), rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)) if err != nil { return err } @@ -98,15 +98,15 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { Data: (*hexutil.Bytes)(&data), AccessList: args.AccessList, } - pendingBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.PendingBlockNumber) - // estimated, err := DoEstimateGas(ctx, b, callArgs, pendingBlockNr, b.RPCGasCap()) - // if err != nil { - // return err - // } - // args.Gas = &estimated - // TODO set gas - _ = callArgs - _ = pendingBlockNr + + latestBlockNumber := rpc.LatestBlockNumber + estimated, err := b.EstimateGas(ctx, callArgs, &rpc.BlockNumberOrHash{ + BlockNumber: &latestBlockNumber, + }) + if err != nil { + return err + } + args.Gas = &estimated log.Trace("Estimate gas usage automatically", "gas", args.Gas) } @@ -124,7 +124,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error { } // setFeeDefaults fills in default fee values for unspecified tx fields. -func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) error { +func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b TrancsactionBackend) error { // If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error. if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) { return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") @@ -166,7 +166,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro } // setLondonFeeDefaults fills in reasonable default fee values for unspecified fields. -func (args *TransactionArgs) setLondonFeeDefaults(_ context.Context, head *types.Header, b Backend) error { +func (args *TransactionArgs) setLondonFeeDefaults(_ context.Context, head *types.Header, b TrancsactionBackend) error { // Set maxPriorityFeePerGas if it is missing. if args.MaxPriorityFeePerGas == nil { tip, err := b.SuggestGasTipCap(head.BaseFee) @@ -202,7 +202,7 @@ func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (* return nil, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified") } // Set sender address or use zero address if none specified. - addr := args.from() + addr := args.FromAddr() // Set default gas & gas price if none were set gas := globalGasCap diff --git a/ethereum/rpc/types/types.go b/ethereum/rpc/types/types.go index 9df3626..ccb093a 100644 --- a/ethereum/rpc/types/types.go +++ b/ethereum/rpc/types/types.go @@ -29,29 +29,6 @@ type StorageResult struct { Proof []string `json:"proof"` } -// RPCTransaction represents a txs that will serialize to the RPC representation of a txs -type RPCTransaction struct { - BlockHash *common.Hash `json:"blockHash"` - BlockNumber *hexutil.Big `json:"blockNumber"` - From common.Address `json:"from"` - Gas hexutil.Uint64 `json:"gas"` - GasPrice *hexutil.Big `json:"gasPrice"` - GasFeeCap *hexutil.Big `json:"maxFeePerGas,omitempty"` - GasTipCap *hexutil.Big `json:"maxPriorityFeePerGas,omitempty"` - Hash common.Hash `json:"hash"` - Input hexutil.Bytes `json:"input"` - Nonce hexutil.Uint64 `json:"nonce"` - To *common.Address `json:"to"` - TransactionIndex *hexutil.Uint64 `json:"transactionIndex"` - Value *hexutil.Big `json:"value"` - Type hexutil.Uint64 `json:"type"` - Accesses *ethtypes.AccessList `json:"accessList,omitempty"` - ChainID *hexutil.Big `json:"chainId,omitempty"` - V *hexutil.Big `json:"v"` - R *hexutil.Big `json:"r"` - S *hexutil.Big `json:"s"` -} - // StateOverride is the collection of overridden accounts. type StateOverride map[common.Address]OverrideAccount diff --git a/ethereum/rpc/types/utils.go b/ethereum/rpc/types/utils.go index ab295ef..a3014f2 100644 --- a/ethereum/rpc/types/utils.go +++ b/ethereum/rpc/types/utils.go @@ -14,7 +14,6 @@ import ( errortypes "github.com/cosmos/cosmos-sdk/types/errors" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/common/math" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" @@ -139,80 +138,6 @@ func FormatBlock( return result } -// NewTransactionFromMsg returns a txs that will serialize to the RPC -// representation, with the given location metadata set (if available). -func NewTransactionFromMsg( - msg *evmtypes.MsgEthereumTx, - blockHash common.Hash, - blockNumber, index uint64, - baseFee *big.Int, - chainID *big.Int, -) (*RPCTransaction, error) { - tx := msg.AsTransaction() - return NewRPCTransaction(tx, blockHash, blockNumber, index, baseFee, chainID) -} - -// NewTransactionFromData returns a txs that will serialize to the RPC -// representation, with the given location metadata set (if available). -func NewRPCTransaction( - tx *ethtypes.Transaction, blockHash common.Hash, blockNumber, index uint64, baseFee *big.Int, - chainID *big.Int, -) (*RPCTransaction, error) { - // Determine the signer. For replay-protected transactions, use the most permissive - // signer, because we assume that signers are backwards-compatible with old - // transactions. For non-protected transactions, the homestead signer signer is used - // because the return value of ChainId is zero for those transactions. - var signer ethtypes.Signer - if tx.Protected() { - signer = ethtypes.LatestSignerForChainID(tx.ChainId()) - } else { - signer = ethtypes.HomesteadSigner{} - } - from, _ := ethtypes.Sender(signer, tx) // #nosec G703 - v, r, s := tx.RawSignatureValues() - result := &RPCTransaction{ - Type: hexutil.Uint64(tx.Type()), - From: from, - Gas: hexutil.Uint64(tx.Gas()), - GasPrice: (*hexutil.Big)(tx.GasPrice()), - Hash: tx.Hash(), - Input: hexutil.Bytes(tx.Data()), - Nonce: hexutil.Uint64(tx.Nonce()), - To: tx.To(), - Value: (*hexutil.Big)(tx.Value()), - V: (*hexutil.Big)(v), - R: (*hexutil.Big)(r), - S: (*hexutil.Big)(s), - ChainID: (*hexutil.Big)(chainID), - } - if blockHash != (common.Hash{}) { - result.BlockHash = &blockHash - result.BlockNumber = (*hexutil.Big)(new(big.Int).SetUint64(blockNumber)) - result.TransactionIndex = (*hexutil.Uint64)(&index) - } - switch tx.Type() { - case ethtypes.AccessListTxType: - al := tx.AccessList() - result.Accesses = &al - result.ChainID = (*hexutil.Big)(tx.ChainId()) - case ethtypes.DynamicFeeTxType: - al := tx.AccessList() - result.Accesses = &al - result.ChainID = (*hexutil.Big)(tx.ChainId()) - result.GasFeeCap = (*hexutil.Big)(tx.GasFeeCap()) - result.GasTipCap = (*hexutil.Big)(tx.GasTipCap()) - // if the txs has been mined, compute the effective gas price - if baseFee != nil && blockHash != (common.Hash{}) { - // price = min(tip, gasFeeCap - baseFee) + baseFee - price := math.BigMin(new(big.Int).Add(tx.GasTipCap(), baseFee), tx.GasFeeCap()) - result.GasPrice = (*hexutil.Big)(price) - } else { - result.GasPrice = (*hexutil.Big)(tx.GasFeeCap()) - } - } - return result, nil -} - // BaseFeeFromEvents parses the fee basefee from cosmos events func BaseFeeFromEvents(events []abci.Event) *big.Int { for _, event := range events { diff --git a/ethereum/rpc/web3.go b/ethereum/rpc/web3.go new file mode 100644 index 0000000..ec89f3a --- /dev/null +++ b/ethereum/rpc/web3.go @@ -0,0 +1,19 @@ +package rpc + +import ( + "fmt" + "runtime" + + "github.com/cosmos/cosmos-sdk/version" +) + +// ClientVersion returns the current client version. +func (b *BackendImpl) ClientVersion() string { + return fmt.Sprintf( + "%s/%s/%s/%s", + version.Name, + version.Version, + runtime.GOOS+"-"+runtime.GOARCH, + runtime.Version(), + ) +} diff --git a/ethereum/rpc/websockets.go b/ethereum/rpc/websockets.go index 2289542..f1ae67f 100644 --- a/ethereum/rpc/websockets.go +++ b/ethereum/rpc/websockets.go @@ -443,7 +443,6 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un } } - // TODO: Eth TransactionsRoot unable to obtain ,now remove transactionsRoot, result := map[string]interface{}{ "parentHash": header.ParentHash, "sha3Uncles": header.UncleHash, @@ -453,8 +452,8 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un "logsBloom": bloom, "difficulty": header.Difficulty, "number": header.Number, - "gasLimit": header.GasLimit, - "gasUsed": header.GasUsed, + "gasLimit": data.ResultFinalizeBlock.ConsensusParamUpdates.Block.MaxGas, + "gasUsed": header.GasUsed, // TODO emit the txs and calculte it. "timestamp": header.Time, "extraData": header.Extra, "mixHash": header.MixDigest, @@ -463,7 +462,8 @@ func (api *pubSubAPI) subscribeNewHeads(wsConn *wsConn, subID rpc.ID) (pubsub.Un "withdrawalsRoot": header.WithdrawalsHash, "excessDataGas": header.ExcessDataGas, "hash": hexutil.Encode(cosmosHash.Bytes()), - "size": 0, + "size": 0, // TODO calculted with total block, emit the txs and calculte it. + // "transactionRoot" // TODO emit the txs and calculte it. } // write to ws conn diff --git a/ethereum/server/start.go b/ethereum/server/start.go index 19e4623..5e2ac46 100644 --- a/ethereum/server/start.go +++ b/ethereum/server/start.go @@ -12,6 +12,7 @@ import ( pvm "github.com/cometbft/cometbft/privval" "github.com/cometbft/cometbft/proxy" cmttypes "github.com/cometbft/cometbft/types" + dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" @@ -54,7 +55,13 @@ func StartHandler[T sdktypes.Application](svrCtx *server.Context, clientCtx clie return err } - app, appCleanupFn, err := startApp[T](svrCtx, appCreator, opts) + home := svrCtx.Config.RootDir + db, err := opts.DBOpener(home, server.GetAppDBBackend(svrCtx.Viper)) + if err != nil { + return err + } + + app, appCleanupFn, err := startApp[T](svrCtx, db, appCreator, opts) if err != nil { return err } @@ -67,21 +74,15 @@ func StartHandler[T sdktypes.Application](svrCtx *server.Context, clientCtx clie emitServerInfoMetrics() - return startInProcess[T](svrCtx, svrCfg, clientCtx, app, metrics, opts) + return startInProcess[T](svrCtx, db, svrCfg, clientCtx, app, metrics, opts) } -func startApp[T sdktypes.Application](svrCtx *server.Context, appCreator sdktypes.AppCreator, opts server.StartCmdOptions) (app sdktypes.Application, cleanupFn func(), err error) { +func startApp[T sdktypes.Application](svrCtx *server.Context, db dbm.DB, appCreator sdktypes.AppCreator, opts server.StartCmdOptions) (app sdktypes.Application, cleanupFn func(), err error) { traceWriter, traceCleanupFn, err := setupTraceWriter(svrCtx) if err != nil { return app, traceCleanupFn, err } - home := svrCtx.Config.RootDir - db, err := opts.DBOpener(home, server.GetAppDBBackend(svrCtx.Viper)) - if err != nil { - return app, traceCleanupFn, err - } - app = appCreator(svrCtx.Logger, db, traceWriter, svrCtx.Viper) cleanupFn = func() { @@ -93,7 +94,7 @@ func startApp[T sdktypes.Application](svrCtx *server.Context, appCreator sdktype return app, cleanupFn, nil } -func startInProcess[T sdktypes.Application](svrCtx *server.Context, svrCfg serverconfig.Config, clientCtx client.Context, app sdktypes.Application, +func startInProcess[T sdktypes.Application](svrCtx *server.Context, db dbm.DB, svrCfg serverconfig.Config, clientCtx client.Context, app sdktypes.Application, metrics *telemetry.Metrics, opts server.StartCmdOptions, ) error { cmtCfg := svrCtx.Config @@ -152,7 +153,7 @@ func startInProcess[T sdktypes.Application](svrCtx *server.Context, svrCfg serve if appcfg.JSONRPC.Enable { tmEndpoint := "/websocket" tmRPCAddr := cmtCfg.RPC.ListenAddress - jsonrpcSrv, err = CreateJSONRPC(svrCtx, clientCtx, tmRPCAddr, tmEndpoint, &appcfg) + jsonrpcSrv, err = CreateJSONRPC(svrCtx, clientCtx, tmRPCAddr, tmEndpoint, &appcfg, db) if err != nil { return err } diff --git a/ethereum/server/util.go b/ethereum/server/util.go index 0779090..e48c177 100644 --- a/ethereum/server/util.go +++ b/ethereum/server/util.go @@ -15,6 +15,7 @@ import ( ethrpc "github.com/artela-network/artela-rollkit/ethereum/rpc" "github.com/artela-network/artela-rollkit/ethereum/server/config" + ethNode "github.com/ethereum/go-ethereum/node" ) // CreateJSONRPC starts the JSON-RPC server @@ -23,14 +24,38 @@ func CreateJSONRPC(ctx *sdkserver.Context, tmRPCAddr, tmEndpoint string, config *config.Config, + db dbm.DB, ) (*ethrpc.ArtelaService, error) { - cfg := ethrpc.DefaultConfig() - cfg.RPCGasCap = config.JSONRPC.GasCap - cfg.RPCEVMTimeout = config.JSONRPC.EVMTimeout - cfg.RPCTxFeeCap = config.JSONRPC.TxFeeCap - cfg.AppCfg = config + cfg := getRpcConfig(config) + + nodeCfg, err := getNodeConfig(ctx, config) + if err != nil { + return nil, err + } + stack, err := ethrpc.NewNode(nodeCfg) + if err != nil { + return nil, err + } + + wsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) + + serv := ethrpc.NewArtelaService(ctx, clientCtx, wsClient, cfg, stack, nodeCfg.Logger, db) + + // allocate separate WS connection to Tendermint + tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) + wsSrv := ethrpc.NewWebsocketsServer(clientCtx, tmWsClient, config, nodeCfg.Logger) + wsSrv.Start() + + return serv, nil +} + +func getNodeConfig(ctx *sdkserver.Context, config *config.Config) (*ethNode.Config, error) { nodeCfg := ethrpc.DefaultGethNodeConfig() + // if not define, use default value + if len(config.JSONRPC.API) > 0 { + nodeCfg.HTTPModules = config.JSONRPC.API + } address := strings.Split(config.JSONRPC.Address, ":") if len(address) > 0 { nodeCfg.HTTPHost = address[0] @@ -58,21 +83,16 @@ func CreateJSONRPC(ctx *sdkserver.Context, })) // do not start websocket nodeCfg.WSHost = "" - stack, err := ethrpc.NewNode(nodeCfg) - if err != nil { - return nil, err - } - - wsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) - - serv := ethrpc.NewArtelaService(ctx, clientCtx, wsClient, cfg, stack, nodeCfg.Logger) - - // allocate separate WS connection to Tendermint - tmWsClient := ConnectTmWS(tmRPCAddr, tmEndpoint, nodeCfg.Logger) - wsSrv := ethrpc.NewWebsocketsServer(clientCtx, tmWsClient, config, nodeCfg.Logger) - wsSrv.Start() + return nodeCfg, nil +} - return serv, nil +func getRpcConfig(config *config.Config) *ethrpc.Config { + cfg := ethrpc.DefaultConfig() + cfg.RPCGasCap = config.JSONRPC.GasCap + cfg.RPCEVMTimeout = config.JSONRPC.EVMTimeout + cfg.RPCTxFeeCap = config.JSONRPC.TxFeeCap + cfg.AppCfg = config + return cfg } func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) { diff --git a/ethereum/types/protocol.go b/ethereum/types/protocol.go index 580c344..e43107a 100644 --- a/ethereum/types/protocol.go +++ b/ethereum/types/protocol.go @@ -2,8 +2,9 @@ package types // Constants to match up protocol versions and messages const ( - eth65 = 65 + eth68 = 68 // ProtocolVersion is the latest supported version of the eth protocol. - ProtocolVersion = eth65 + // ethereum 1.12 match to 68 + ProtocolVersion = eth68 ) diff --git a/go.mod b/go.mod index 1c447a2..5575ec7 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/BurntSushi/toml v1.4.0 github.com/andybalholm/brotli v1.1.0 github.com/artela-network/artela-evm v0.4.8-rc8 - github.com/artela-network/aspect-core v0.4.8-rc8 + github.com/artela-network/aspect-core v0.4.9-rc9 github.com/artela-network/aspect-runtime v0.4.8-rc8 github.com/btcsuite/btcd v0.23.0 github.com/btcsuite/btcd/btcutil v1.1.3 @@ -47,6 +47,7 @@ require ( github.com/cosmos/ibc-go/modules/capability v1.0.0 github.com/cosmos/ibc-go/v8 v8.2.0 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc + github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 github.com/dvsekhvalnov/jose2go v1.6.0 github.com/emirpasic/gods v1.18.1 github.com/ethereum/go-ethereum v1.12.0 @@ -69,7 +70,6 @@ require ( github.com/tidwall/gjson v1.14.2 github.com/tidwall/sjson v1.2.5 github.com/tyler-smith/go-bip39 v1.1.0 - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 golang.org/x/sync v0.7.0 golang.org/x/text v0.16.0 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d @@ -145,12 +145,14 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/distribution/reference v0.5.0 // indirect + github.com/dlclark/regexp2 v1.7.0 // indirect github.com/docker/cli v25.0.4+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker v25.0.4+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 // indirect github.com/dustin/go-humanize v1.0.1 // indirect github.com/elastic/gosigar v0.14.2 // indirect github.com/emicklei/dot v1.6.1 // indirect @@ -172,6 +174,7 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-ole/go-ole v1.2.6 // indirect + github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect @@ -376,6 +379,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.25.0 // indirect + golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.27.0 // indirect golang.org/x/oauth2 v0.20.0 // indirect diff --git a/go.sum b/go.sum index 5e34d2e..4ae426c 100644 --- a/go.sum +++ b/go.sum @@ -329,8 +329,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/artela-network/artela-evm v0.4.8-rc8 h1:4saDqBKnVmaEvSBEveVwRi/vnXVERz5YvRXr3gAzB3E= github.com/artela-network/artela-evm v0.4.8-rc8/go.mod h1:eYeoqd8pOAX/HcKVKnqxqwJki0qyIoQwSGgYTyFZQ/M= -github.com/artela-network/aspect-core v0.4.8-rc8 h1:7KSb/NcD3HhOTirVg7mVPmknxSO1xQooNjPHe4bryZc= -github.com/artela-network/aspect-core v0.4.8-rc8/go.mod h1:hve/4ibuIgt0HaAQrBYez1O8BQGceK8O8rGeyHoMAwg= +github.com/artela-network/aspect-core v0.4.9-rc9 h1:TC27Al1l/e0yjPTZ2F1b9VhoGw/8cCD9uxCimRBHq4k= +github.com/artela-network/aspect-core v0.4.9-rc9/go.mod h1:hve/4ibuIgt0HaAQrBYez1O8BQGceK8O8rGeyHoMAwg= github.com/artela-network/aspect-runtime v0.4.8-rc8 h1:48dbWs+4wUAL52U6JUN+hPQ7u7lDTkajoI0EcZYtwL4= github.com/artela-network/aspect-runtime v0.4.8-rc8/go.mod h1:GiDB2+LUbl2b2Z8+v/83LFbUKs5DqQ3ACxLUWY8zMdU= github.com/artela-network/wasmtime-go/v20 v20.0.3 h1:A4/KrrCQiXhDibc3bUlvD7vzohV4saWiAA3MIFz11Yo= @@ -588,8 +588,13 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 h1:y7y0Oa6UawqTFPCDw9JG6pdKt4F9pAhHv0B7FMGaGD0= +github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= +github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/cli v20.10.14+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= @@ -609,6 +614,11 @@ github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6 github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 h1:kgvzE5wLsLa7XKfV85VZl40QXaMCaeFtHpPwJ8fhotY= +github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7/go.mod h1:yRkwfj0CBpOGre+TwBsqPV0IH0Pk73e4PXJOeNDboGs= +github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= +github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= @@ -746,6 +756,8 @@ github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= diff --git a/testutil/keeper/evm.go b/testutil/keeper/evm.go index 3772742..788cac8 100644 --- a/testutil/keeper/evm.go +++ b/testutil/keeper/evm.go @@ -23,6 +23,7 @@ import ( func EvmKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) + transientStoreKey := storetypes.NewTransientStoreKey(types.StoreKey) db := dbm.NewMemDB() stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) @@ -36,6 +37,7 @@ func EvmKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { k := keeper.NewKeeper( cdc, runtime.NewKVStoreService(storeKey), + mockTransientStoreService{transientStoreKey}, log.NewNopLogger(), authority.String(), ) diff --git a/testutil/keeper/fee.go b/testutil/keeper/fee.go index ee552da..e0f7c32 100644 --- a/testutil/keeper/fee.go +++ b/testutil/keeper/fee.go @@ -1,6 +1,7 @@ package keeper import ( + "context" "testing" "cosmossdk.io/log" @@ -17,12 +18,22 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/stretchr/testify/require" + coreStore "cosmossdk.io/core/store" "github.com/artela-network/artela-rollkit/x/fee/keeper" "github.com/artela-network/artela-rollkit/x/fee/types" ) +type mockTransientStoreService struct { + key *storetypes.TransientStoreKey +} + +func (t mockTransientStoreService) OpenTransientStore(ctx context.Context) coreStore.KVStore { + return nil +} + func FeeKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { storeKey := storetypes.NewKVStoreKey(types.StoreKey) + transientStoreKey := storetypes.NewTransientStoreKey(types.StoreKey) db := dbm.NewMemDB() stateStore := store.NewCommitMultiStore(db, log.NewNopLogger(), metrics.NewNoOpMetrics()) @@ -36,6 +47,7 @@ func FeeKeeper(t testing.TB) (keeper.Keeper, sdk.Context) { k := keeper.NewKeeper( cdc, runtime.NewKVStoreService(storeKey), + mockTransientStoreService{transientStoreKey}, log.NewNopLogger(), authority.String(), ) diff --git a/x/evm/artela/contract/utils.go b/x/aspect/common/utils.go similarity index 99% rename from x/evm/artela/contract/utils.go rename to x/aspect/common/utils.go index 7afa03b..fd3ac0a 100644 --- a/x/evm/artela/contract/utils.go +++ b/x/aspect/common/utils.go @@ -1,4 +1,4 @@ -package contract +package common import ( "bytes" diff --git a/x/aspect/cuckoofilter/bucket.go b/x/aspect/cuckoofilter/bucket.go new file mode 100644 index 0000000..4a83fc5 --- /dev/null +++ b/x/aspect/cuckoofilter/bucket.go @@ -0,0 +1,45 @@ +package cuckoo + +type fingerprint byte + +type bucket [bucketSize]fingerprint + +const ( + nullFp = 0 + bucketSize = 4 +) + +func (b *bucket) insert(fp fingerprint) bool { + for i, tfp := range b { + if tfp == nullFp { + b[i] = fp + return true + } + } + return false +} + +func (b *bucket) delete(fp fingerprint) bool { + for i, tfp := range b { + if tfp == fp { + b[i] = nullFp + return true + } + } + return false +} + +func (b *bucket) getFingerprintIndex(fp fingerprint) int { + for i, tfp := range b { + if tfp == fp { + return i + } + } + return -1 +} + +func (b *bucket) reset() { + for i := range b { + b[i] = nullFp + } +} diff --git a/x/aspect/cuckoofilter/cuckoofilter.go b/x/aspect/cuckoofilter/cuckoofilter.go new file mode 100644 index 0000000..c6ce79e --- /dev/null +++ b/x/aspect/cuckoofilter/cuckoofilter.go @@ -0,0 +1,164 @@ +package cuckoo + +import ( + "fmt" + "math/bits" +) + +const maxCuckooCount = 500 + +// Filter is a probabilistic counter +type Filter struct { + buckets []bucket + count uint + bucketPow uint +} + +// NewFilter returns a new cuckoofilter with a given capacity. +// A capacity of 1000000 is a normal default, which allocates +// about ~1MB on 64-bit machines. +func NewFilter(capacity uint) *Filter { + capacity = getNextPow2(uint64(capacity)) / bucketSize + if capacity == 0 { + capacity = 1 + } + buckets := make([]bucket, capacity) + return &Filter{ + buckets: buckets, + count: 0, + bucketPow: uint(bits.TrailingZeros(capacity)), + } +} + +// Lookup returns true if data is in the counter +func (cf *Filter) Lookup(data []byte) bool { + i1, fp := getIndexAndFingerprint(data, cf.bucketPow) + if cf.buckets[i1].getFingerprintIndex(fp) > -1 { + return true + } + i2 := getAltIndex(fp, i1, cf.bucketPow) + return cf.buckets[i2].getFingerprintIndex(fp) > -1 +} + +// Reset ... +func (cf *Filter) Reset() { + for i := range cf.buckets { + cf.buckets[i].reset() + } + cf.count = 0 +} + +func (cf *Filter) decide(i1, i2 uint) uint { + if cf.count%2 == 0 { + return i1 + } + return i2 +} + +// Insert inserts data into the counter and returns true upon success +func (cf *Filter) Insert(data []byte) bool { + i1, fp := getIndexAndFingerprint(data, cf.bucketPow) + if cf.insert(fp, i1) { + return true + } + i2 := getAltIndex(fp, i1, cf.bucketPow) + if cf.insert(fp, i2) { + return true + } + return cf.reinsert(fp, cf.decide(i1, i2)) +} + +// InsertUnique inserts data into the counter if not exists and returns true upon success +func (cf *Filter) InsertUnique(data []byte) bool { + if cf.Lookup(data) { + return false + } + return cf.Insert(data) +} + +func (cf *Filter) insert(fp fingerprint, i uint) bool { + if cf.buckets[i].insert(fp) { + cf.count++ + return true + } + return false +} + +func (cf *Filter) reinsert(fp fingerprint, i uint) bool { + for k := 0; k < maxCuckooCount; k++ { + j := (cf.count + uint(k)) % bucketSize + oldfp := fp + fp = cf.buckets[i][j] + cf.buckets[i][j] = oldfp + + // look in the alternate location for that random element + i = getAltIndex(fp, i, cf.bucketPow) + if cf.insert(fp, i) { + return true + } + } + return false +} + +// Delete data from counter if exists and return if deleted or not +func (cf *Filter) Delete(data []byte) bool { + i1, fp := getIndexAndFingerprint(data, cf.bucketPow) + if cf.delete(fp, i1) { + return true + } + i2 := getAltIndex(fp, i1, cf.bucketPow) + return cf.delete(fp, i2) +} + +func (cf *Filter) delete(fp fingerprint, i uint) bool { + if cf.buckets[i].delete(fp) { + if cf.count > 0 { + cf.count-- + } + return true + } + return false +} + +// Count returns the number of items in the counter +func (cf *Filter) Count() uint { + return cf.count +} + +// Encode returns a byte slice representing a Cuckoofilter +func (cf *Filter) Encode() []byte { + bytes := make([]byte, len(cf.buckets)*bucketSize) + for i, b := range cf.buckets { + for j, f := range b { + index := (i * len(b)) + j + bytes[index] = byte(f) + } + } + return bytes +} + +// Decode returns a Cuckoofilter from a byte slice +func Decode(bytes []byte) (*Filter, error) { + var count uint + if len(bytes)%bucketSize != 0 { + return nil, fmt.Errorf("expected bytes to be multiple of %d, got %d", bucketSize, len(bytes)) + } + if len(bytes) == 0 { + return nil, fmt.Errorf("bytes can not be empty") + } + buckets := make([]bucket, len(bytes)/4) + for i, b := range buckets { + for j := range b { + index := (i * len(b)) + j + if bytes[index] != 0 { + buckets[i][j] = fingerprint(bytes[index]) + count++ + } + } + } + return &Filter{ + buckets: buckets, + count: count, + bucketPow: uint(bits.TrailingZeros(uint(len(buckets)))), + }, nil +} diff --git a/x/aspect/cuckoofilter/util.go b/x/aspect/cuckoofilter/util.go new file mode 100644 index 0000000..840932e --- /dev/null +++ b/x/aspect/cuckoofilter/util.go @@ -0,0 +1,71 @@ +package cuckoo + +import ( + metro "github.com/dgryski/go-metro" +) + +var ( + altHash = [256]uint{} + masks = [65]uint{} +) + +func init() { + for i := 0; i < 256; i++ { + altHash[i] = (uint(metro.Hash64([]byte{byte(i)}, 1337))) + } + for i := uint(0); i <= 64; i++ { + masks[i] = (1 << i) - 1 + } +} + +func getAltIndex(fp fingerprint, i uint, bucketPow uint) uint { + mask := masks[bucketPow] + hash := altHash[fp] & mask + return (i & mask) ^ hash +} + +func getFingerprint(hash uint64) byte { + // Use least significant bits for fingerprint. + fp := byte(hash%255 + 1) + return fp +} + +// getIndicesAndFingerprint returns the 2 bucket indices and fingerprint to be used +func getIndexAndFingerprint(data []byte, bucketPow uint) (uint, fingerprint) { + hash := defaultHasher.Hash64(data) + fp := getFingerprint(hash) + // Use most significant bits for deriving index. + i1 := uint(hash>>32) & masks[bucketPow] + return i1, fingerprint(fp) +} + +func getNextPow2(n uint64) uint { + n-- + n |= n >> 1 + n |= n >> 2 + n |= n >> 4 + n |= n >> 8 + n |= n >> 16 + n |= n >> 32 + n++ + return uint(n) +} + +var defaultHasher Hasher = new(metrotHasher) + +func SetDefaultHasher(hasher Hasher) { + defaultHasher = hasher +} + +type Hasher interface { + Hash64([]byte) uint64 +} + +var _ Hasher = new(metrotHasher) + +type metrotHasher struct{} + +func (h *metrotHasher) Hash64(data []byte) uint64 { + hash := metro.Hash64(data, 1337) + return hash +} diff --git a/x/aspect/provider/artela.go b/x/aspect/provider/artela.go new file mode 100644 index 0000000..15e25d4 --- /dev/null +++ b/x/aspect/provider/artela.go @@ -0,0 +1,127 @@ +package provider + +import ( + "context" + "errors" + "slices" + + cstore "cosmossdk.io/core/store" + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + aspectmoduletypes "github.com/artela-network/artela-rollkit/x/aspect/types" + "github.com/artela-network/artela-rollkit/x/evm/artela/types" + asptypes "github.com/artela-network/aspect-core/types" +) + +var _ asptypes.AspectProvider = (*ArtelaProvider)(nil) + +type ArtelaProvider struct { + getBlockHeight types.GetLastBlockHeight + + storeService cstore.KVStoreService +} + +func NewArtelaProvider( + storeService cstore.KVStoreService, + getBlockHeight types.GetLastBlockHeight, +) *ArtelaProvider { + return &ArtelaProvider{ + storeService: storeService, + getBlockHeight: getBlockHeight, + } +} + +func (j *ArtelaProvider) GetTxBondAspects(ctx context.Context, address common.Address, point asptypes.PointCut) ([]*asptypes.AspectCode, error) { + return j.getCodes(ctx, address, point) +} + +func (j *ArtelaProvider) GetAccountVerifiers(ctx context.Context, address common.Address) ([]*asptypes.AspectCode, error) { + return j.getCodes(ctx, address, asptypes.VERIFY_TX) +} + +func (j *ArtelaProvider) GetLatestBlock() int64 { + return j.getBlockHeight() +} + +func (j *ArtelaProvider) getCodes(ctx context.Context, address common.Address, point asptypes.PointCut) ([]*asptypes.AspectCode, error) { + if ctx == nil { + return nil, errors.New("invalid Context") + } + aspectCtx, ok := ctx.(*types.AspectRuntimeContext) + if !ok { + return nil, errors.New("failed to unwrap AspectRuntimeContext from context.Context") + } + + accountStore, _, err := store.GetAccountStore(j.buildAccountStoreCtx(aspectCtx, address)) + if err != nil { + return nil, err + } + + bindings, err := accountStore.LoadAccountBoundAspects(aspectmoduletypes.NewJoinPointFilter(point)) + if err != nil { + return nil, err + } + + codes := make([]*asptypes.AspectCode, 0, len(bindings)) + for _, binding := range bindings { + metaStore, _, err := store.GetAspectMetaStore(j.buildAspectStoreCtx(aspectCtx, binding.Account)) + if err != nil { + return nil, err + } + code, err := metaStore.GetCode(binding.Version) + if err != nil { + return nil, err + } + + var isExpectedJP bool + if binding.JoinPoint == 0 { + meta, err := metaStore.GetVersionMeta(binding.Version) + if err != nil { + return nil, err + } + isExpectedJP = asptypes.CanExecPoint(int64(meta.JoinPoint), point) + } else { + isExpectedJP = asptypes.CanExecPoint(int64(binding.JoinPoint), point) + } + + // filter matched aspect with given join point + if !isExpectedJP { + continue + } + + codes = append(codes, &asptypes.AspectCode{ + AspectId: binding.Account.Hex(), + Version: binding.Version, + Priority: binding.Priority, + Code: code, + }) + } + + // sort the codes by priority + slices.SortFunc(codes, func(a, b *asptypes.AspectCode) int { + if a.Priority == b.Priority { + return 0 + } else if a.Priority < b.Priority { + return -1 + } else { + return 1 + } + }) + + return codes, nil +} + +func (j *ArtelaProvider) buildAspectStoreCtx(ctx *types.AspectRuntimeContext, aspectID common.Address) *aspectmoduletypes.AspectStoreContext { + return &aspectmoduletypes.AspectStoreContext{ + StoreContext: aspectmoduletypes.NewGasFreeStoreContext(ctx.CosmosContext(), j.storeService), + AspectID: aspectID, + } +} + +func (j *ArtelaProvider) buildAccountStoreCtx(ctx *types.AspectRuntimeContext, account common.Address) *aspectmoduletypes.AccountStoreContext { + return &aspectmoduletypes.AccountStoreContext{ + StoreContext: aspectmoduletypes.NewGasFreeStoreContext(ctx.CosmosContext(), j.storeService), + Account: account, + } +} diff --git a/x/evm/artela/provider/jit_call.go b/x/aspect/provider/jit_call.go similarity index 100% rename from x/evm/artela/provider/jit_call.go rename to x/aspect/provider/jit_call.go diff --git a/x/aspect/store/errors.go b/x/aspect/store/errors.go new file mode 100644 index 0000000..d5a15e8 --- /dev/null +++ b/x/aspect/store/errors.go @@ -0,0 +1,23 @@ +package store + +import "errors" + +var ( + ErrInvalidProtocolInfo = errors.New("invalid protocol info") + ErrUnknownProtocolVersion = errors.New("unknown protocol version") + ErrCodeNotFound = errors.New("code not found") + ErrInvalidStorageKey = errors.New("invalid storage key") + ErrTooManyProperties = errors.New("aspect property limit exceeds") + ErrInvalidBinding = errors.New("invalid binding") + ErrStorageCorrupted = errors.New("storage corrupted") + ErrNoJoinPoint = errors.New("cannot bind with no-joinpoint aspect") + ErrBindingLimitExceeded = errors.New("binding limit exceeded") + ErrAlreadyBound = errors.New("aspect already bound") + ErrInvalidStoreContext = errors.New("invalid store context") + ErrPropertyReserved = errors.New("property key reserved") + ErrInvalidExtension = errors.New("invalid extension") + ErrInvalidVersionMeta = errors.New("invalid version meta") + ErrSerdeFail = errors.New("serialize or deserialize fail") + ErrBoundNonVerifierWithEOA = errors.New("binding non-verifier aspect with EOA") + ErrInvalidJoinPoint = errors.New("invalid join point") +) diff --git a/x/aspect/store/keys.go b/x/aspect/store/keys.go new file mode 100644 index 0000000..76840b6 --- /dev/null +++ b/x/aspect/store/keys.go @@ -0,0 +1,58 @@ +package store + +import ( + "encoding/binary" + "encoding/hex" +) + +// scope prefixes +var ( + GlobalScope = byte(0xff) + AccountScope = byte(0xee) + AspectScope = byte(0xdd) +) + +// global keys, shouldn't be changed in the future +var ( + AspectProtocolInfoKeyPrefix = []byte{GlobalScope, 0x01} +) + +type KeyBuilder struct { + key []byte +} + +func NewKeyBuilder(prefix []byte) *KeyBuilder { + buffer := make([]byte, len(prefix)) + copy(buffer, prefix) + return &KeyBuilder{key: buffer} +} + +func (k *KeyBuilder) AppendBytes(key []byte) *KeyBuilder { + return NewKeyBuilder(append(k.key, key...)) +} + +func (k *KeyBuilder) AppendUint64(key uint64) *KeyBuilder { + buffer := make([]byte, 8) + binary.BigEndian.PutUint64(buffer, key) + return NewKeyBuilder(append(k.key, buffer...)) +} + +func (k *KeyBuilder) AppendString(key string) *KeyBuilder { + return NewKeyBuilder(append(k.key, key...)) +} + +func (k *KeyBuilder) AppendByte(key byte) *KeyBuilder { + return NewKeyBuilder(append(k.key, key)) +} + +func (k *KeyBuilder) AppendUint8(key uint8) *KeyBuilder { + return NewKeyBuilder(append(k.key, key)) +} + +func (k *KeyBuilder) Build() []byte { + return k.key +} + +func (k *KeyBuilder) String() string { + return hex.EncodeToString(k.key) +} diff --git a/x/aspect/store/store.go b/x/aspect/store/store.go new file mode 100644 index 0000000..4596252 --- /dev/null +++ b/x/aspect/store/store.go @@ -0,0 +1,376 @@ +package store + +import ( + "encoding/binary" + "encoding/hex" + + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/ethereum/go-ethereum/common" + + aspectmoduletypes "github.com/artela-network/artela-rollkit/x/aspect/types" +) + +const ( + ProtocolVersionLen = 2 + ProtocolInfoLen = 4 +) + +type ProtocolVersion uint16 + +func (p ProtocolVersion) MarshalText() ([]byte, error) { + bytes := make([]byte, 2) + binary.BigEndian.PutUint16(bytes, uint16(p)) + return bytes, nil +} + +func (p *ProtocolVersion) UnmarshalText(text []byte) error { + if len(text) < 2 { + *p = 0 + } else { + *p = ProtocolVersion(binary.BigEndian.Uint16(text[:2])) + } + + return nil +} + +func (p ProtocolVersion) Offset() uint64 { + if p == 0 { + return 0 + } else { + return ProtocolVersionLen + } +} + +type AspectInfo struct { + MetaVersion ProtocolVersion + StateVersion ProtocolVersion + + offset uint64 +} + +func (a *AspectInfo) Offset() uint64 { + return a.offset +} + +func (a AspectInfo) MarshalText() ([]byte, error) { + bytes := make([]byte, ProtocolInfoLen) + // next 2 bytes saves meta version + binary.BigEndian.PutUint16(bytes[0:2], uint16(a.MetaVersion)) + // next 2 bytes saves state version + binary.BigEndian.PutUint16(bytes[2:4], uint16(a.StateVersion)) + return bytes, nil +} + +func (a *AspectInfo) UnmarshalText(text []byte) error { + if len(text) == 0 { + // v0 store does not have aspect info, so we just return nil here + // so that all versions of aspect info is 0, which is compatible with v0 store + a.offset = 0 + return nil + } + + if len(text) < ProtocolInfoLen { + return ErrInvalidProtocolInfo + } + + a.MetaVersion = ProtocolVersion(binary.BigEndian.Uint16(text[0:2])) + a.StateVersion = ProtocolVersion(binary.BigEndian.Uint16(text[2:4])) + a.offset = ProtocolInfoLen + + return nil +} + +type ( + AspectStateStoreConstructor = func(ctx *aspectmoduletypes.AspectStoreContext) AspectStateStore + AspectMetaStoreConstructor = func(ctx *aspectmoduletypes.AspectStoreContext, protocolExtension []byte) AspectMetaStore + AccountStoreConstructor = func(ctx *aspectmoduletypes.AccountStoreContext) AccountStore +) + +// aspect initializer registry +var ( + aspectStateStoreRegistry = make(map[ProtocolVersion]AspectStateStoreConstructor) + aspectMetaStoreRegistry = make(map[ProtocolVersion]AspectMetaStoreConstructor) + accountStoreRegistry = make(map[ProtocolVersion]AccountStoreConstructor) +) + +func RegisterAspectStateStore(version ProtocolVersion, constructor AspectStateStoreConstructor) { + aspectStateStoreRegistry[version] = constructor +} + +func RegisterAspectMetaStore(version ProtocolVersion, constructor AspectMetaStoreConstructor) { + aspectMetaStoreRegistry[version] = constructor +} + +func RegisterAccountStore(version ProtocolVersion, constructor AccountStoreConstructor) { + accountStoreRegistry[version] = constructor +} + +type GasMeteredStore interface { + // Gas returns the gas remains in the store + Gas() uint64 + // TransferGasFrom transfers the gas from another store + TransferGasFrom(store GasMeteredStore) +} + +// AccountStore is the store for each account that using aspect +type AccountStore interface { + // LoadAccountBoundAspects returns the aspects bound to the account, + LoadAccountBoundAspects(filter aspectmoduletypes.BindingFilter) ([]aspectmoduletypes.Binding, error) + // StoreBinding adds the binding of the given aspect to the account + StoreBinding(aspectID common.Address, version uint64, joinPoint uint64, priority int8, isCA bool) error + // RemoveBinding removes the binding of the given aspect from the account + RemoveBinding(aspectID common.Address, joinPoint uint64, isCA bool) error + + // Used returns true if this given version of store has been used before + Used() (bool, error) + // MigrateFrom migrates the data from the old store to the new store + MigrateFrom(old AccountStore) error + // Init initializes the store + Init() error + // Version returns the version of the store + Version() ProtocolVersion + + GasMeteredStore +} + +// AspectStateStore is the store for aspect state related info +type AspectStateStore interface { + // GetState returns the value for the given key + GetState(key []byte) []byte + // SetState sets the value for the given key + SetState(key []byte, value []byte) + // Version returns the version of the store + Version() ProtocolVersion +} + +// AspectMetaStore is the store for aspect metadata +type AspectMetaStore interface { + // GetCode returns the code for the given version + GetCode(version uint64) ([]byte, error) + // GetVersionMeta returns the meta for the given version + GetVersionMeta(version uint64) (*aspectmoduletypes.VersionMeta, error) + // GetMeta returns the meta for the aspect + GetMeta() (*aspectmoduletypes.AspectMeta, error) + // GetLatestVersion returns the latest version of the aspect + GetLatestVersion() (uint64, error) + // GetProperty returns the properties for the given version + GetProperty(version uint64, key string) ([]byte, error) + // LoadAspectBoundAccounts returns the accounts bound to the aspect + LoadAspectBoundAccounts() ([]aspectmoduletypes.Binding, error) + + // BumpVersion bumps the version of the aspect + BumpVersion() (uint64, error) + // StoreVersionMeta stores the meta for the given version + StoreVersionMeta(version uint64, meta *aspectmoduletypes.VersionMeta) error + // StoreMeta stores the meta for the aspect + StoreMeta(meta *aspectmoduletypes.AspectMeta) error + // StoreCode stores the code for the given version + StoreCode(version uint64, code []byte) error + // StoreProperties stores the properties for the given version + StoreProperties(version uint64, properties []aspectmoduletypes.Property) error + // StoreBinding stores the binding for the given account + StoreBinding(account common.Address, version uint64, joinPoint uint64, priority int8) error + // RemoveBinding removes the binding for the given account + RemoveBinding(account common.Address) error + + // Version returns the version of the store + Version() ProtocolVersion + // MigrateFrom migrates the data from the old store to the new store + MigrateFrom(old AspectMetaStore) error + // Used returns true if this given version of store has been used before + Used() (bool, error) + // Init initializes the store + Init() error + + GasMeteredStore +} + +// loadProtocolInfo loads the protocol info for the given address +func loadProtocolInfo(ctx aspectmoduletypes.StoreContext) (ProtocolVersion, []byte, error) { + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + var address common.Address + switch ctx := ctx.(type) { + case *aspectmoduletypes.AccountStoreContext: + address = ctx.Account + case *aspectmoduletypes.AspectStoreContext: + address = ctx.AspectID + default: + return 0, nil, ErrInvalidStoreContext + } + + key := NewKeyBuilder(AspectProtocolInfoKeyPrefix).AppendBytes(address.Bytes()).Build() + protoInfo := store.Get(key) + + var protocolVersion ProtocolVersion + if err := protocolVersion.UnmarshalText(protoInfo); err != nil { + ctx.Logger().Error("unmarshal aspect protocol info failed", + "address", address.Hex(), "data", hex.EncodeToString(protoInfo)) + return 0, protoInfo, err + } + + return protocolVersion, protoInfo[protocolVersion.Offset():], nil +} + +// parseAspectInfo parses +func parseAspectInfo(raw []byte) (*AspectInfo, error) { + aspectInfo := &AspectInfo{} + if err := aspectInfo.UnmarshalText(raw); err != nil { + return nil, err + } + + return aspectInfo, nil +} + +// GetAccountStore returns the account store for the given account, +// account store is used to store account related info like bound aspects. +// This function will return 2 stores, the current store and the new store. +// New store will be nil if no migration needed, otherwise it will be the instance of the new version store. +func GetAccountStore(ctx *aspectmoduletypes.AccountStoreContext) (current AccountStore, new AccountStore, err error) { + // load protocol version + protocolVersion, _, err := loadProtocolInfo(ctx) + if err != nil { + return nil, nil, err + } + + // load protocol storage constructor + constructor, ok := accountStoreRegistry[protocolVersion] + if !ok { + ctx.Logger().Error("unsupported protocol version", "version", protocolVersion) + return nil, nil, ErrUnknownProtocolVersion + } + + // if latest version is greater than the used version, + // we also init an instance of the latest version of store to let the caller func + // decides whether to migrate the data or not + var latestStore AccountStore + latestVersion := latestStoreVersion(accountStoreRegistry) + if latestVersion > protocolVersion { + // init the latest store version + latestStore = accountStoreRegistry[latestVersion](ctx) + } + + // if this protocol version is 0, we have 2 cases here: + // 1. the account has never used aspect before + // 2. the account was using aspect at protocol version 0, but not migrated to the new version + // the following is just the special case for processing v0 store + if protocolVersion == 0 { + // init v0 store first + v0Store := constructor(ctx) + // so first we need to check whether this account has used aspect before + if used, err := v0Store.Used(); err != nil { + return nil, nil, err + } else if used { + // if v0 store used, we need to migrate the data to the latest version + return v0Store, latestStore, nil + } else { + // otherwise, we just return the latest store + if latestStore == nil { + // set the latest store to v0 store if no migration needed + latestStore = v0Store + } + + return latestStore, nil, nil + } + } + + // build the aspect store + return constructor(ctx), latestStore, nil +} + +// GetAspectMetaStore returns the aspect meta store for the given aspect id +func GetAspectMetaStore(ctx *aspectmoduletypes.AspectStoreContext) (current AspectMetaStore, new AspectMetaStore, err error) { + // load protocol version + protocolVersion, rawAspectInfo, err := loadProtocolInfo(ctx) + if err != nil { + return nil, nil, err + } + + return getAspectMetaStore(ctx, protocolVersion, rawAspectInfo) +} + +func getAspectMetaStore(ctx *aspectmoduletypes.AspectStoreContext, protocolVersion ProtocolVersion, rawAspectInfo []byte) (current AspectMetaStore, new AspectMetaStore, err error) { + // load aspect info if protocol version is not 0 + aspectInfo, err := parseAspectInfo(rawAspectInfo) + if err != nil { + ctx.Logger().Error("parse aspect info failed", "aspectId", ctx.AspectID.Hex()) + return nil, nil, err + } + protocolExtension := rawAspectInfo[aspectInfo.Offset():] + metaVersion := aspectInfo.MetaVersion + + // load protocol storage constructor + constructor, ok := aspectMetaStoreRegistry[metaVersion] + if !ok { + ctx.Logger().Error("unsupported meta version", "version", metaVersion) + return nil, nil, ErrUnknownProtocolVersion + } + + // if latest version is greater than the used version, + // we also init an instance of the latest version of store to let the caller func + // decides whether to migrate the data or not + var latestStore AspectMetaStore + latestVersion := latestStoreVersion(aspectMetaStoreRegistry) + if latestVersion > protocolVersion { + // init the latest store version + latestStore = aspectMetaStoreRegistry[latestVersion](ctx, protocolExtension) + } + + // if this protocol version is 0, we have 2 cases here: + // 1. the aspect has not been deployed yet + // 2. the aspect is deployed at protocol version 0, but not migrated to the new version + if protocolVersion == 0 { + // init v0 store first + v0Store := constructor(ctx, protocolExtension) + // so first we need to check whether this account has used aspect before + if used, err := v0Store.Used(); err != nil { + // check fail + return nil, nil, err + } else if used { + // if v0 store used, we need to migrate the data to the latest version + return v0Store, latestStore, nil + } else { + // otherwise, we just return the latest store + if latestStore == nil { + // set the latest store to v0 store if no migration needed + latestStore = v0Store + } + + return latestStore, nil, nil + } + } + + // build the aspect store + return constructor(ctx, protocolExtension), latestStore, nil +} + +func GetAspectStateStore(ctx *aspectmoduletypes.AspectStoreContext) (AspectStateStore, error) { + // load protocol version + _, rawAspectInfo, err := loadProtocolInfo(ctx) + if err != nil { + return nil, err + } + + // aspect info must have been initialized before the state store initialized, + // if rawAspectInfo is empty, we just go with init v0 store + aspectInfo, err := parseAspectInfo(rawAspectInfo) + if err != nil { + ctx.Logger().Error("parse aspect info failed", "aspectId", ctx.AspectID.Hex()) + return nil, err + } + + stateVersion := aspectInfo.StateVersion + + // load protocol state constructor + constructor, ok := aspectStateStoreRegistry[stateVersion] + if !ok { + ctx.Logger().Error("unsupported state version", "version", stateVersion) + return nil, ErrUnknownProtocolVersion + } + + return constructor(ctx), nil +} + +func latestStoreVersion[T any](registry map[ProtocolVersion]T) ProtocolVersion { + return ProtocolVersion(len(registry) - 1) +} diff --git a/x/aspect/store/v0/account.go b/x/aspect/store/v0/account.go new file mode 100644 index 0000000..48ede57 --- /dev/null +++ b/x/aspect/store/v0/account.go @@ -0,0 +1,278 @@ +package v0 + +import ( + "encoding/json" + "slices" + "sort" + + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + "github.com/artela-network/artela-rollkit/x/aspect/types" + evmtypes "github.com/artela-network/artela-rollkit/x/evm/artela/types" + artelasdkType "github.com/artela-network/aspect-core/types" +) + +var _ store.AccountStore = (*accountStore)(nil) + +// accountStore is the version 0 account Store, this is no longer maintained. +// Deprecated. +type accountStore struct { + BaseStore + + ctx *types.AccountStoreContext +} + +// NewAccountStore creates a new instance of account Store. +// Deprecated +func NewAccountStore(ctx *types.AccountStoreContext) store.AccountStore { + var meter GasMeter + if ctx.ChargeGas() { + meter = NewGasMeter(ctx) + } else { + meter = NewNoOpGasMeter(ctx) + } + + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &accountStore{ + BaseStore: NewBaseStore(meter, store), + ctx: ctx, + } +} + +func (s *accountStore) Used() (bool, error) { + // check all binding keys, if any of them is not empty, then the account Store is used + bindingKeys := []string{V0VerifierBindingKeyPrefix, V0ContractBindKeyPrefix} + account := s.ctx.Account + for _, bindingKey := range bindingKeys { + prefixStore := s.NewPrefixStore(bindingKey) + storeKey := AccountKey(account.Bytes()) + rawJSON, err := s.Load(prefixStore, storeKey) + if err != nil { + return false, err + } + if len(rawJSON) > 0 { + return true, nil + } + } + + return false, nil +} + +func (s *accountStore) MigrateFrom(old store.AccountStore) error { + panic("cannot migrate to v0 Store") +} + +func (s *accountStore) Init() error { + return nil +} + +func (s *accountStore) getBindingKeyAndLimit(joinPoint uint64, isCA bool) ([]struct { + key string + limit uint8 +}, error) { + joinPointI64 := int64(joinPoint) + isTxLevel := artelasdkType.CheckIsTransactionLevel(joinPointI64) + isVerifier := artelasdkType.CheckIsTxVerifier(joinPointI64) + + // for EoA account we can only bind verifier aspect + if !isCA && !isVerifier { + return nil, store.ErrInvalidBinding + } + + // only allow 1 verifier for each contract + verifierLimit := maxContractVerifierBoundLimit + if isCA { + verifierLimit = 1 + } + + bindingKeysAndLimit := make([]struct { + key string + limit uint8 + }, 0) + if isTxLevel { + bindingKeysAndLimit = append(bindingKeysAndLimit, struct { + key string + limit uint8 + }{key: V0ContractBindKeyPrefix, limit: maxAspectBoundLimit}) + } + if isVerifier { + bindingKeysAndLimit = append(bindingKeysAndLimit, struct { + key string + limit uint8 + }{key: V0VerifierBindingKeyPrefix, limit: verifierLimit}) + } + + return bindingKeysAndLimit, nil +} + +// StoreBinding stores the binding of the aspect with the given ID to the account. +func (s *accountStore) StoreBinding(aspectID common.Address, version uint64, joinPoint uint64, priority int8, isCA bool) error { + bindingKeysAndLimit, err := s.getBindingKeyAndLimit(joinPoint, isCA) + if err != nil { + return err + } + + account := s.ctx.Account + for _, bindingKeyAndLimit := range bindingKeysAndLimit { + prefixStore := s.NewPrefixStore(bindingKeyAndLimit.key) + storeKey := AccountKey(account.Bytes()) + rawJSON, err := s.Load(prefixStore, storeKey) + if err != nil { + return err + } + + bindings := make([]*evmtypes.AspectMeta, 0) + if len(rawJSON) > 0 { + if err := json.Unmarshal(rawJSON, &bindings); err != nil { + return store.ErrStorageCorrupted + } + } + + if len(bindings) >= int(bindingKeyAndLimit.limit) { + return store.ErrBindingLimitExceeded + } + + // check duplicates + for _, binding := range bindings { + if binding.Id == aspectID { + return store.ErrAlreadyBound + } + } + + newAspect := &evmtypes.AspectMeta{ + Id: aspectID, + Version: uint256.NewInt(version), + Priority: int64(priority), + } + + bindings = append(bindings, newAspect) + + // re-sort aspects by priority + if len(bindings) > 1 { + sort.Slice(bindings, evmtypes.NewBindingPriorityComparator(bindings)) + } + + bindingJSON, err := json.Marshal(bindings) + if err != nil { + return err + } + + if err := s.Store(prefixStore, storeKey, bindingJSON); err != nil { + return err + } + + s.ctx.Logger().Debug("aspect binding added", + "aspect", aspectID.Hex(), + "account", account.Hex(), + "storekey", bindingKeyAndLimit.key) + } + + return nil +} + +// RemoveBinding removes the binding of the aspect with the given ID from the account. +func (s *accountStore) RemoveBinding(aspectID common.Address, joinPoint uint64, isCA bool) error { + bindingKeysAndLimit, err := s.getBindingKeyAndLimit(joinPoint, isCA) + if err != nil { + return err + } + + account := s.ctx.Account + for _, bindingKeyAndLimit := range bindingKeysAndLimit { + prefixStore := s.NewPrefixStore(bindingKeyAndLimit.key) + storeKey := AccountKey(account.Bytes()) + rawJSON, err := s.Load(prefixStore, storeKey) + if err != nil { + return err + } + + bindings := make([]*evmtypes.AspectMeta, 0) + if len(rawJSON) > 0 { + if err := json.Unmarshal(rawJSON, &bindings); err != nil { + return store.ErrStorageCorrupted + } + } + + toDelete := slices.IndexFunc(bindings, func(meta *evmtypes.AspectMeta) bool { + return meta.Id == aspectID + }) + + if toDelete < 0 { + // not found + return nil + } + + bindings = slices.Delete(bindings, toDelete, toDelete+1) + bindingJSON, err := json.Marshal(bindings) + if err != nil { + return err + } + + if err := s.Store(prefixStore, storeKey, bindingJSON); err != nil { + return err + } + + s.ctx.Logger().Debug("aspect binding removed", + "aspect", aspectID.Hex(), + "account", account.Hex(), + "storekey", bindingKeyAndLimit.key) + } + + return nil +} + +// LoadAccountBoundAspects loads all aspects bound to the given account. +func (s *accountStore) LoadAccountBoundAspects(filter types.BindingFilter) ([]types.Binding, error) { + bindingKeys := make([]string, 0, 1) + if filter.JoinPoint != nil { + joinPoint := *filter.JoinPoint + if string(joinPoint) == artelasdkType.JoinPointRunType_VerifyTx.String() { + bindingKeys = append(bindingKeys, V0VerifierBindingKeyPrefix) + } else { + bindingKeys = append(bindingKeys, V0ContractBindKeyPrefix) + } + } else if filter.VerifierOnly { + bindingKeys = append(bindingKeys, V0VerifierBindingKeyPrefix) + } else if filter.TxLevelOnly { + bindingKeys = append(bindingKeys, V0ContractBindKeyPrefix) + } else { + bindingKeys = append(bindingKeys, V0VerifierBindingKeyPrefix, V0ContractBindKeyPrefix) + } + + account := s.ctx.Account + bindingSet := make(map[common.Address]struct{}) + bindings := make([]types.Binding, 0) + for _, bindingKey := range bindingKeys { + prefixStore := s.NewPrefixStore(bindingKey) + storeKey := AccountKey(account.Bytes()) + rawJSON, err := s.Load(prefixStore, storeKey) + if err != nil { + return nil, err + } + + aspectMetas := make([]*evmtypes.AspectMeta, 0) + if len(rawJSON) > 0 { + if err := json.Unmarshal(rawJSON, &aspectMetas); err != nil { + return nil, store.ErrStorageCorrupted + } + } + + for _, aspectMeta := range aspectMetas { + if _, ok := bindingSet[aspectMeta.Id]; ok { + continue + } + bindings = append(bindings, types.Binding{ + Account: aspectMeta.Id, + Version: aspectMeta.Version.Uint64(), + Priority: int8(aspectMeta.Priority), + }) + bindingSet[aspectMeta.Id] = struct{}{} + } + } + + return bindings, nil +} diff --git a/x/aspect/store/v0/base.go b/x/aspect/store/v0/base.go new file mode 100644 index 0000000..02c8c7c --- /dev/null +++ b/x/aspect/store/v0/base.go @@ -0,0 +1,90 @@ +package v0 + +import ( + "math" + + "cosmossdk.io/store/prefix" + storetypes "cosmossdk.io/store/types" + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" +) + +var emptyAddress common.Address + +const ( + maxAspectBoundLimit = math.MaxUint8 + maxContractVerifierBoundLimit = uint8(1) + protocolVersion = store.ProtocolVersion(0) +) + +// BaseStore defines a shared base store which can be implemented by all other stores +type BaseStore interface { + NewPrefixStore(prefixKey string) prefix.Store + Load(prefixStore prefix.Store, key []byte) ([]byte, error) + Store(prefixStore prefix.Store, key, value []byte) error + Version() store.ProtocolVersion + + store.GasMeteredStore +} + +type baseStore struct { + gasMeter GasMeter + kvStore storetypes.KVStore +} + +func NewBaseStore(gasMeter GasMeter, kvStore storetypes.KVStore) BaseStore { + return &baseStore{ + gasMeter: gasMeter, + kvStore: kvStore, + } +} + +// Version returns the protocol version of the Store. +func (s *baseStore) Version() store.ProtocolVersion { + return protocolVersion +} + +// NewPrefixStore creates an instance of prefix Store, +func (s *baseStore) NewPrefixStore(prefixKey string) prefix.Store { + return prefix.NewStore(s.kvStore, evmtypes.KeyPrefix(prefixKey)) +} + +// Load loads the value from the given Store and do gas metering for the given operation +func (s *baseStore) Load(prefixStore prefix.Store, key []byte) ([]byte, error) { + if key == nil { + return nil, store.ErrInvalidStorageKey + } + + value := prefixStore.Get(key) + + // gas metering after Load, since we are not like EVM, the data length is not known before Load + if err := s.gasMeter.MeasureStorageLoad(len(key) + len(value)); err != nil { + return nil, err + } + + return value, nil +} + +// Store stores the value to the given store and do gas metering for the given operation +func (s *baseStore) Store(prefixStore prefix.Store, key, value []byte) error { + if key == nil { + return store.ErrInvalidStorageKey + } + + if err := s.gasMeter.MeasureStorageStore(len(key) + len(value)); err != nil { + return err + } + + prefixStore.Set(key, value) + return nil +} + +func (s *baseStore) TransferGasFrom(store store.GasMeteredStore) { + s.gasMeter.UpdateGas(store.Gas()) +} + +func (s *baseStore) Gas() uint64 { + return s.gasMeter.RemainingGas() +} diff --git a/x/aspect/store/v0/gas.go b/x/aspect/store/v0/gas.go new file mode 100644 index 0000000..524b3c9 --- /dev/null +++ b/x/aspect/store/v0/gas.go @@ -0,0 +1,100 @@ +package v0 + +import ( + "github.com/artela-network/artela-rollkit/x/aspect/types" +) + +const ( + storageLoadCost = 10 + storageStoreCost = 1000 + storageSaveCodeCost = 1000 + storageUpdateCost = 1000 +) + +type GasMeter interface { + MeasureStorageUpdate(dataLen int) error + MeasureStorageCodeSave(dataLen int) error + MeasureStorageStore(dataLen int) error + MeasureStorageLoad(dataLen int) error + RemainingGas() uint64 + UpdateGas(newGas uint64) + Consume(dataLen int, gasCostPer32Bytes uint64) error +} + +type noopGasMeter struct { + ctx types.StoreContext +} + +func NewNoOpGasMeter(ctx types.StoreContext) GasMeter { + return &noopGasMeter{ + ctx: ctx, + } +} + +func (n *noopGasMeter) UpdateGas(_ uint64) { + return +} + +func (n *noopGasMeter) MeasureStorageUpdate(_ int) error { + return nil +} + +func (n *noopGasMeter) MeasureStorageCodeSave(_ int) error { + return nil +} + +func (n *noopGasMeter) MeasureStorageStore(_ int) error { + return nil +} + +func (n *noopGasMeter) MeasureStorageLoad(_ int) error { + return nil +} + +func (n *noopGasMeter) RemainingGas() uint64 { + return n.ctx.Gas() +} + +func (n *noopGasMeter) Consume(_ int, _ uint64) error { + return nil +} + +// gasMeter is a simple gas metering implementation for aspect storage v0. +type gasMeter struct { + ctx types.StoreContext +} + +func NewGasMeter(ctx types.StoreContext) GasMeter { + return &gasMeter{ + ctx: ctx, + } +} + +func (m *gasMeter) MeasureStorageUpdate(dataLen int) error { + return m.Consume(dataLen, storageUpdateCost) +} + +func (m *gasMeter) MeasureStorageCodeSave(dataLen int) error { + return m.Consume(dataLen, storageSaveCodeCost) +} + +func (m *gasMeter) MeasureStorageStore(dataLen int) error { + return m.Consume(dataLen, storageStoreCost) +} + +func (m *gasMeter) MeasureStorageLoad(dataLen int) error { + return m.Consume(dataLen, storageLoadCost) +} + +func (m *gasMeter) RemainingGas() uint64 { + return m.ctx.Gas() +} + +func (m *gasMeter) Consume(dataLen int, gasCostPer32Bytes uint64) error { + gas := ((uint64(dataLen) + 32) >> 5) * gasCostPer32Bytes + return m.ctx.ConsumeGas(gas) +} + +func (m *gasMeter) UpdateGas(gas uint64) { + m.ctx.UpdateGas(gas) +} diff --git a/x/aspect/store/v0/init.go b/x/aspect/store/v0/init.go new file mode 100644 index 0000000..ea93a8f --- /dev/null +++ b/x/aspect/store/v0/init.go @@ -0,0 +1,9 @@ +package v0 + +import "github.com/artela-network/artela-rollkit/x/aspect/store" + +func init() { + store.RegisterAccountStore(0, NewAccountStore) + store.RegisterAspectMetaStore(0, NewAspectMetaStore) + store.RegisterAspectStateStore(0, NewStateStore) +} diff --git a/x/aspect/store/v0/keys.go b/x/aspect/store/v0/keys.go new file mode 100644 index 0000000..69d9c6e --- /dev/null +++ b/x/aspect/store/v0/keys.go @@ -0,0 +1,94 @@ +package v0 + +// v0 keys +const ( + // AspectCodeKeyPrefix is the prefix to retrieve all AspectCodeStore + V0AspectCodeKeyPrefix = "AspectStore/Code/" + V0AspectCodeVersionKeyPrefix = "AspectStore/Version/" + V0AspectPropertyKeyPrefix = "AspectStore/Property/" + V0ContractBindKeyPrefix = "AspectStore/ContractBind/" + V0VerifierBindingKeyPrefix = "AspectStore/VerifierBind/" + V0AspectRefKeyPrefix = "AspectStore/AspectRef/" + V0AspectStateKeyPrefix = "AspectStore/State/" + + V0AspectJoinPointRunKeyPrefix = "AspectStore/JoinPointRun/" + + V0AspectIDMapKey = "aspectId" + V0VersionMapKey = "version" + V0PriorityMapKey = "priority" + + V0AspectAccountKey = "Aspect_@Acount@_" + V0AspectProofKey = "Aspect_@Proof@_" + V0AspectRunJoinPointKey = "Aspect_@Run@JoinPoint@_" + V0AspectPropertyAllKeyPrefix = "Aspect_@Property@AllKey@_" + V0AspectPropertyAllKeySplit = "^^^" +) + +var ( + PathSeparator = []byte("/") + PathSeparatorLen = len(PathSeparator) +) + +func AspectArrayKey(keys ...[]byte) []byte { + var key []byte + for _, b := range keys { + key = append(key, b...) + key = append(key, PathSeparator...) + } + return key +} + +// AspectCodeStoreKey returns the Store key to retrieve a AspectCodeStore from the index fields +func AspectPropertyKey( + aspectID []byte, + propertyKey []byte, +) []byte { + key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(propertyKey)) + + key = append(key, aspectID...) + key = append(key, PathSeparator...) + key = append(key, propertyKey...) + key = append(key, PathSeparator...) + + return key +} + +func AspectVersionKey( + aspectID []byte, + version []byte, +) []byte { + key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(version)) + + key = append(key, aspectID...) + key = append(key, PathSeparator...) + key = append(key, version...) + key = append(key, PathSeparator...) + + return key +} + +func AspectIDKey( + aspectID []byte, +) []byte { + key := make([]byte, 0, len(aspectID)+PathSeparatorLen) + key = append(key, aspectID...) + key = append(key, PathSeparator...) + + return key +} + +func AspectBlockKey() []byte { + var key []byte + key = append(key, []byte("AspectBlock")...) + key = append(key, PathSeparator...) + return key +} + +func AccountKey( + account []byte, +) []byte { + key := make([]byte, 0, len(account)+PathSeparatorLen) + key = append(key, account...) + key = append(key, PathSeparator...) + return key +} diff --git a/x/aspect/store/v0/meta.go b/x/aspect/store/v0/meta.go new file mode 100644 index 0000000..dd6054a --- /dev/null +++ b/x/aspect/store/v0/meta.go @@ -0,0 +1,417 @@ +package v0 + +import ( + "math/big" + "strings" + + "cosmossdk.io/store/prefix" + artelasdkType "github.com/artela-network/aspect-core/types" + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/emirpasic/gods/sets/treeset" + "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" + + aspectutils "github.com/artela-network/artela-rollkit/x/aspect/common" + "github.com/artela-network/artela-rollkit/x/aspect/store" + "github.com/artela-network/artela-rollkit/x/aspect/types" +) + +var _ store.AspectMetaStore = (*metaStore)(nil) + +var reservedPropertyKeys = map[string]struct{}{ + V0AspectAccountKey: {}, + V0AspectProofKey: {}, + V0AspectPropertyAllKeyPrefix: {}, +} + +// metaStore is the version 0 aspect meta, this is no longer maintained. +// Just keeping for backward compatibility. +// Deprecated. +type metaStore struct { + BaseStore + + latestVersionCache uint64 + ctx *types.AspectStoreContext +} + +// NewAspectMetaStore creates a new instance of aspect meta Store. +// Deprecated +func NewAspectMetaStore(ctx *types.AspectStoreContext, _ []byte) store.AspectMetaStore { + var meter GasMeter + if ctx.ChargeGas() { + meter = NewGasMeter(ctx) + } else { + meter = NewNoOpGasMeter(ctx) + } + + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &metaStore{ + BaseStore: NewBaseStore(meter, store), + ctx: ctx, + } +} + +func (s *metaStore) StoreMeta(meta *types.AspectMeta) error { + // v0 Store saves paymaster and proof as aspect properties + paymaster := types.Property{ + Key: V0AspectAccountKey, + Value: meta.PayMaster.Bytes(), + } + proof := types.Property{ + Key: V0AspectProofKey, + Value: meta.Proof, + } + return s.storeProperties([]types.Property{paymaster, proof}) +} + +func (s *metaStore) GetMeta() (*types.AspectMeta, error) { + paymaster, err := s.GetProperty(0, V0AspectAccountKey) + if err != nil { + return nil, err + } + proof, err := s.GetProperty(0, V0AspectProofKey) + if err != nil { + return nil, err + } + + return &types.AspectMeta{ + PayMaster: common.BytesToAddress(paymaster), + Proof: proof, + }, nil +} + +// StoreBinding stores the binding of the aspect with the given ID to the account. +func (s *metaStore) StoreBinding(account common.Address, _ uint64, _ uint64, _ int8) error { + return s.saveAspectRef(s.NewPrefixStore(V0AspectRefKeyPrefix), s.ctx.AspectID, account) +} + +// RemoveBinding removes the binding of the aspect with the given ID from the account. +func (s *metaStore) RemoveBinding(account common.Address) error { + return s.removeAspectRef(s.NewPrefixStore(V0AspectRefKeyPrefix), account) +} + +func (s *metaStore) MigrateFrom(_ store.AspectMetaStore) error { + panic("cannot migrate to Store v0") +} + +func (s *metaStore) Used() (bool, error) { + v, err := s.GetLatestVersion() + if err != nil { + return false, err + } + return v > 0, err +} + +func (s *metaStore) Init() error { + // for v0 Store, we do not need to init anything + return nil +} + +// GetCode returns the code of the aspect with the given ID and version. +// If version is 0 or aspectID is empty, it returns * Store.ErrCodeNotFound. +func (s *metaStore) GetCode(version uint64) ([]byte, error) { + aspectID := s.ctx.AspectID + if version == 0 || aspectID == emptyAddress { + return nil, store.ErrCodeNotFound + } + prefixStore := s.NewPrefixStore(V0AspectCodeKeyPrefix) + storeKey := AspectVersionKey(aspectID.Bytes(), uint256.NewInt(version).Bytes()) + + // we do not charge gas for code loading + code := prefixStore.Get(storeKey) + + // stored code is already validated, so we can ignore the error here + return aspectutils.ParseByteCode(code) +} + +// GetVersionMeta returns the meta of the aspect with the given ID and version. +func (s *metaStore) GetVersionMeta(version uint64) (*types.VersionMeta, error) { + return s.getMeta(s.ctx.AspectID, version) +} + +func (s *metaStore) getMeta(aspectID common.Address, version uint64) (*types.VersionMeta, error) { + u256Version := uint256.NewInt(version) + prefixStore := s.NewPrefixStore(V0AspectJoinPointRunKeyPrefix) + storeKey := AspectArrayKey( + aspectID.Bytes(), + u256Version.Bytes(), + []byte(V0AspectRunJoinPointKey), + ) + + joinPoint, err := s.Load(prefixStore, storeKey) + if err != nil { + return nil, err + } + + // for v0 pay master / Store / code hash is not stored + return &types.VersionMeta{ + JoinPoint: big.NewInt(0).SetBytes(joinPoint).Uint64(), + }, nil +} + +func (s *metaStore) GetLatestVersion() (uint64, error) { + return s.getLatestVersion(s.ctx.AspectID) +} + +// GetLatestVersion returns the latest version of the aspect with the given ID. +func (s *metaStore) getLatestVersion(aspectID common.Address) (uint64, error) { + if s.latestVersionCache > 0 { + return s.latestVersionCache, nil + } + + prefixStore := s.NewPrefixStore(V0AspectCodeVersionKeyPrefix) + storeKey := AspectIDKey(aspectID.Bytes()) + + // v0 aspect Store uses uint256 to Store version + version := uint256.NewInt(0) + versionBytes, err := s.Load(prefixStore, storeKey) + if err != nil { + return 0, err + } + if versionBytes != nil || len(versionBytes) > 0 { + version.SetBytes(versionBytes) + } + + s.latestVersionCache = version.Uint64() + return s.latestVersionCache, nil +} + +// GetProperty returns the property of the aspect with the given ID and key. +func (s *metaStore) GetProperty(_ uint64, key string) ([]byte, error) { + aspectID := s.ctx.AspectID + codeStore := s.NewPrefixStore(V0AspectPropertyKeyPrefix) + if _, ok := reservedPropertyKeys[key]; ok { + // for reserved key, we return empty value + return nil, nil + } + + aspectPropertyKey := AspectPropertyKey( + aspectID.Bytes(), + []byte(key), + ) + + return s.Load(codeStore, aspectPropertyKey) +} + +// BumpVersion bumps the version of the aspect with the given ID. +func (s *metaStore) BumpVersion() (v uint64, err error) { + aspectID := s.ctx.AspectID + version, err := s.GetLatestVersion() + if err != nil { + s.ctx.Logger().Error("failed to get latest version", "aspect", aspectID.Hex(), "err", err) + return 0, err + } + + newVersionU64 := version + 1 + newVersion := uint256.NewInt(newVersionU64) + prefixStore := s.NewPrefixStore(V0AspectCodeVersionKeyPrefix) + storeKey := AspectIDKey(aspectID.Bytes()) + + defer func() { + if err == nil { + s.latestVersionCache = newVersionU64 + } + }() + + return newVersionU64, s.Store(prefixStore, storeKey, newVersion.Bytes()) +} + +// StoreVersionMeta stores the meta of the aspect with the given ID and version. +func (s *metaStore) StoreVersionMeta(version uint64, meta *types.VersionMeta) error { + aspectID := s.ctx.AspectID + // Store join point + if meta.JoinPoint > 0 { + u256Version := uint256.NewInt(version) + joinPointBig := big.NewInt(0).SetUint64(meta.JoinPoint) + if _, ok := artelasdkType.CheckIsJoinPoint(joinPointBig); !ok { + joinPointBig.SetUint64(0) + } + + prefixStore := s.NewPrefixStore(V0AspectJoinPointRunKeyPrefix) + storeKey := AspectArrayKey(aspectID.Bytes(), u256Version.Bytes(), []byte(V0AspectRunJoinPointKey)) + if err := s.Store(prefixStore, storeKey, joinPointBig.Bytes()); err != nil { + return err + } + } + + // for v0 pay master / proof is stored with property + // code hash is not stored + return nil +} + +// StoreCode stores the code of the aspect with the given ID and version. +func (s *metaStore) StoreCode(version uint64, code []byte) error { + aspectID := s.ctx.AspectID + prefixStore := s.NewPrefixStore(V0AspectCodeKeyPrefix) + storeKey := AspectVersionKey(aspectID.Bytes(), uint256.NewInt(version).Bytes()) + return s.Store(prefixStore, storeKey, code) +} + +// StoreProperties stores the properties of the aspect with the given ID. +func (s *metaStore) StoreProperties(_ uint64, properties []types.Property) error { + if len(properties) == 0 { + return nil + } + + // check reserved keys + for _, prop := range properties { + if _, ok := reservedPropertyKeys[prop.Key]; ok { + return store.ErrPropertyReserved + } + } + + return s.storeProperties(properties) +} + +func (s *metaStore) storeProperties(properties []types.Property) error { + aspectID := s.ctx.AspectID + prefixStore := s.NewPrefixStore(V0AspectPropertyKeyPrefix) + propertyKeysKey := AspectPropertyKey(aspectID.Bytes(), []byte(V0AspectPropertyAllKeyPrefix)) + + propertyAllKey, err := s.Load(prefixStore, propertyKeysKey) + if err != nil { + return err + } + + keySet := treeset.NewWithStringComparator() + // add propertyAllKey to keySet + if len(propertyAllKey) > 0 { + splitData := strings.Split(string(propertyAllKey), V0AspectPropertyAllKeySplit) + for _, datum := range splitData { + keySet.Add(datum) + } + } + + for i := range properties { + // add key and deduplicate + keySet.Add(properties[i].Key) + } + + // check key limit + if keySet.Size() > types.AspectPropertyLimit { + return store.ErrTooManyProperties + } + + // Store property key + for i := range properties { + key := properties[i].Key + value := properties[i].Value + + // Store + aspectPropertyKey := AspectPropertyKey( + aspectID.Bytes(), + []byte(key), + ) + + if err := s.Store(prefixStore, aspectPropertyKey, value); err != nil { + s.ctx.Logger().Error("failed to Store aspect property", "aspect", aspectID.Hex(), "key", key, "err", err) + return err + } + + s.ctx.Logger().Debug("aspect property updated", "aspect", aspectID.Hex(), "key", key) + } + + // Store AspectPropertyAllKey + keyAry := make([]string, keySet.Size()) + for i, key := range keySet.Values() { + keyAry[i] = key.(string) + } + allKeys := strings.Join(keyAry, V0AspectPropertyAllKeySplit) + allKeysKey := AspectPropertyKey( + aspectID.Bytes(), + []byte(V0AspectPropertyAllKeyPrefix), + ) + if err := s.Store(prefixStore, allKeysKey, []byte(allKeys)); err != nil { + return err + } + + return nil +} + +// LoadAspectBoundAccounts loads all accounts bound to the given aspect. +func (s *metaStore) LoadAspectBoundAccounts() ([]types.Binding, error) { + prefixStore := s.NewPrefixStore(V0AspectRefKeyPrefix) + set, err := s.loadAspectRef(prefixStore) + if err != nil { + return nil, err + } + + bindings := make([]types.Binding, 0) + if set != nil { + for _, data := range set.Values() { + contractAddr := common.HexToAddress(data.(string)) + bindings = append(bindings, types.Binding{ + Account: contractAddr, + }) + } + } + + return bindings, nil +} + +func (s *metaStore) saveAspectRef(prefixStore prefix.Store, aspectID common.Address, account common.Address) error { + storeKey := AspectIDKey(aspectID.Bytes()) + set, err := s.loadAspectRef(prefixStore) + if err != nil { + return err + } + + accountHex := account.Hex() + if set.Contains(accountHex) { + // already exist + return store.ErrAlreadyBound + } + + set.Add(accountHex) + rawJSON, err := set.MarshalJSON() + if err != nil { + return err + } + + return s.Store(prefixStore, storeKey, rawJSON) +} + +func (s *metaStore) removeAspectRef(prefixStore prefix.Store, account common.Address) error { + aspectID := s.ctx.AspectID + storeKey := AspectIDKey(aspectID.Bytes()) + set, err := s.loadAspectRef(prefixStore) + if err != nil { + return err + } + + accountHex := account.Hex() + if !set.Contains(accountHex) { + // not exist + return nil + } + + set.Remove(accountHex) + rawJSON, err := set.MarshalJSON() + if err != nil { + return err + } + + return s.Store(prefixStore, storeKey, rawJSON) +} + +func (s *metaStore) loadAspectRef(prefixStore prefix.Store) (*treeset.Set, error) { + aspectID := s.ctx.AspectID + storeKey := AspectIDKey(aspectID.Bytes()) + + rawTree, err := s.Load(prefixStore, storeKey) + if err != nil { + return nil, err + } + + if rawTree == nil { + return treeset.NewWithStringComparator(), nil + } + + set := treeset.NewWithStringComparator() + if err := set.UnmarshalJSON(rawTree); err != nil { + return nil, err + } + + return set, nil +} diff --git a/x/aspect/store/v0/state.go b/x/aspect/store/v0/state.go new file mode 100644 index 0000000..6aefc50 --- /dev/null +++ b/x/aspect/store/v0/state.go @@ -0,0 +1,50 @@ +package v0 + +import ( + "github.com/cosmos/cosmos-sdk/runtime" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + "github.com/artela-network/artela-rollkit/x/aspect/types" +) + +var _ store.AspectStateStore = (*stateStore)(nil) + +// stateStore is the version 0 state Store, this is no longer maintained. +// Deprecated. +type stateStore struct { + BaseStore + + ctx *types.AspectStoreContext +} + +// NewStateStore creates a new instance of account state. +// Deprecated +func NewStateStore(ctx *types.AspectStoreContext) store.AspectStateStore { + // for state Store, we have already charged gas in host api, + // so no need to charge it again in the Store + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &stateStore{ + BaseStore: NewBaseStore(NewNoOpGasMeter(ctx), store), + ctx: ctx, + } +} + +// SetState sets the state of the aspect with the given ID and key. +func (s *stateStore) SetState(key []byte, value []byte) { + aspectID := s.ctx.AspectID + prefixStore := s.NewPrefixStore(V0AspectStateKeyPrefix) + storeKey := AspectArrayKey(aspectID.Bytes(), key) + if len(value) == 0 { + prefixStore.Delete(storeKey) + } + prefixStore.Set(storeKey, value) +} + +// GetState returns the state of the aspect with the given ID and key. +func (s *stateStore) GetState(key []byte) []byte { + aspectID := s.ctx.AspectID + prefixStore := s.NewPrefixStore(V0AspectStateKeyPrefix) + storeKey := AspectArrayKey(aspectID.Bytes(), key) + return prefixStore.Get(storeKey) +} diff --git a/x/aspect/store/v1/account.go b/x/aspect/store/v1/account.go new file mode 100644 index 0000000..daff2ad --- /dev/null +++ b/x/aspect/store/v1/account.go @@ -0,0 +1,198 @@ +package v1 + +import ( + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + v0 "github.com/artela-network/artela-rollkit/x/aspect/store/v0" + "github.com/artela-network/artela-rollkit/x/aspect/types" + aspect "github.com/artela-network/aspect-core/types" +) + +var _ store.AccountStore = (*accountStore)(nil) + +type accountStore struct { + BaseStore + + ctx *types.AccountStoreContext +} + +// NewAccountStore creates a new instance of account store. +func NewAccountStore(ctx *types.AccountStoreContext) store.AccountStore { + var meter v0.GasMeter + if ctx.ChargeGas() { + meter = v0.NewGasMeter(ctx) + } else { + meter = v0.NewNoOpGasMeter(ctx) + } + + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &accountStore{ + BaseStore: NewBaseStore(ctx.CosmosContext().Logger(), meter, store), + ctx: ctx, + } +} + +func (a *accountStore) LoadAccountBoundAspects(filter types.BindingFilter) ([]types.Binding, error) { + allBindings, err := a.getAllBindings() + if err != nil { + return nil, err + } + + var result []types.Binding + for _, binding := range allBindings { + if filter.JoinPoint != nil { + jp, ok := aspect.JoinPointRunType_value[string(*filter.JoinPoint)] + if !ok { + return nil, store.ErrInvalidJoinPoint + } + if (binding.JoinPoint | uint16(jp)) == 0 { + continue + } + + result = append(result, types.Binding(binding)) + } else if filter.VerifierOnly && aspect.CheckIsTxVerifier(int64(binding.JoinPoint)) { + result = append(result, types.Binding(binding)) + } else if filter.TxLevelOnly && aspect.CheckIsTransactionLevel(int64(binding.JoinPoint)) { + result = append(result, types.Binding(binding)) + } else { + result = append(result, types.Binding(binding)) + } + } + + return result, nil +} + +func (a *accountStore) StoreBinding(aspectID common.Address, version uint64, joinPoint uint64, priority int8, isCA bool) (err error) { + allBindings, err := a.getAllBindings() + if err != nil { + return err + } + + i64JP := int64(joinPoint) + isTxVerifier := aspect.CheckIsTxVerifier(i64JP) + isTxLevel := aspect.CheckIsTransactionLevel(i64JP) + + if !isTxLevel && !isTxVerifier { + return store.ErrNoJoinPoint + } + + if !isCA && !isTxVerifier { + return store.ErrBoundNonVerifierWithEOA + } + + if len(allBindings) >= maxAspectBoundLimit { + return store.ErrBindingLimitExceeded + } + + for _, binding := range allBindings { + if binding.Account == aspectID { + return store.ErrAlreadyBound + } + if isTxVerifier && isCA && aspect.CheckIsTxVerifier(int64(binding.JoinPoint)) { + // contract only allowed to bind 1 verifier + return store.ErrBindingLimitExceeded + } + } + + newBinding := Binding{ + Account: aspectID, + Version: version, + Priority: priority, + JoinPoint: uint16(joinPoint), + } + allBindings = append(allBindings, newBinding) + + key := store.NewKeyBuilder(V1AccountBindingKeyPrefix).AppendBytes(a.ctx.Account.Bytes()).Build() + bindingsBytes, err := Bindings(allBindings).MarshalText() + if err != nil { + return err + } + + return a.Store(key, bindingsBytes) +} + +func (a *accountStore) getAllBindings() ([]Binding, error) { + key := store.NewKeyBuilder(V1AccountBindingKeyPrefix).AppendBytes(a.ctx.Account.Bytes()).Build() + bindings, err := a.Load(key) + if err != nil { + return nil, err + } + + result := make([]Binding, 0, len(bindings)/32) + for i := 0; i < len(bindings); i += 32 { + data := bindings[i : i+32] + if common.Hash(data) == emptyHash { + // EOF + return result, nil + } + + var binding Binding + if err := binding.UnmarshalText(data); err != nil { + return nil, err + } + result = append(result, binding) + } + + return result, nil +} + +func (a *accountStore) RemoveBinding(aspectID common.Address, _ uint64, _ bool) error { + key := store.NewKeyBuilder(V1AccountBindingKeyPrefix).AppendBytes(a.ctx.Account.Bytes()).Build() + allBindings, err := a.getAllBindings() + if err != nil { + return err + } + + toDelete := -1 + for i, binding := range allBindings { + if binding.Account == aspectID { + toDelete = i + break + } + } + + if toDelete < 0 { + // if not bind, return nil + return nil + } + + allBindings = append(allBindings[:toDelete], allBindings[toDelete+1:]...) + bindingsBytes, err := Bindings(allBindings).MarshalText() + if err != nil { + return err + } + return a.Store(key, bindingsBytes) +} + +func (a *accountStore) Used() (bool, error) { + key := store.NewKeyBuilder(store.AspectProtocolInfoKeyPrefix).AppendBytes(a.ctx.Account.Bytes()).Build() + protocol, err := a.Load(key) + if err != nil { + return false, err + } + + var protocolVersion store.ProtocolVersion + if err := protocolVersion.UnmarshalText(protocol); err != nil { + return false, err + } + + return protocolVersion == store.ProtocolVersion(1), nil +} + +func (a *accountStore) MigrateFrom(old store.AccountStore) error { + //TODO implement me + panic("implement me") +} + +func (a *accountStore) Init() error { + versionBytes, err := protocolVersion.MarshalText() + if err != nil { + return err + } + + key := store.NewKeyBuilder(store.AspectProtocolInfoKeyPrefix).AppendBytes(a.ctx.Account.Bytes()).Build() + return a.Store(key, versionBytes) +} diff --git a/x/aspect/store/v1/base.go b/x/aspect/store/v1/base.go new file mode 100644 index 0000000..7f685b9 --- /dev/null +++ b/x/aspect/store/v1/base.go @@ -0,0 +1,102 @@ +package v1 + +import ( + "encoding/hex" + "math" + + "cosmossdk.io/log" + storetypes "cosmossdk.io/store/types" + + "github.com/artela-network/artela-rollkit/x/aspect/store" + v0 "github.com/artela-network/artela-rollkit/x/aspect/store/v0" +) + +const ( + maxAspectBoundLimit = math.MaxUint8 + protocolVersion = store.ProtocolVersion(1) +) + +// BaseStore defines a shared base store which can be implemented by all other stores +type BaseStore interface { + Load(key []byte) ([]byte, error) + Store(key, value []byte) error + Version() store.ProtocolVersion + + store.GasMeteredStore +} + +type baseStore struct { + gasMeter v0.GasMeter + kvStore storetypes.KVStore + logger log.Logger +} + +func NewBaseStore(logger log.Logger, gasMeter v0.GasMeter, kvStore storetypes.KVStore) BaseStore { + return &baseStore{ + gasMeter: gasMeter, + kvStore: kvStore, + logger: logger, + } +} + +// Version returns the protocol version of the Store. +func (s *baseStore) Version() store.ProtocolVersion { + return protocolVersion +} + +// Load loads the value from the given Store and do gas metering for the given operation +func (s *baseStore) Load(key []byte) ([]byte, error) { + if key == nil { + return nil, store.ErrInvalidStorageKey + } + + value := s.kvStore.Get(key) + + s.logger.Debug("load from aspect store", "key", abbreviateHex(key), "data", abbreviateHex(value)) + // gas metering after Load, since we are not like EVM, the data length is not known before Load + if err := s.gasMeter.MeasureStorageLoad(len(key) + len(value)); err != nil { + return nil, err + } + + // copy values to avoid unexpected modification + result := make([]byte, len(value)) + copy(result, value) + + return result, nil +} + +// Store stores the value to the given store and do gas metering for the given operation +func (s *baseStore) Store(key, value []byte) error { + if key == nil { + return store.ErrInvalidStorageKey + } + + if len(value) == 0 { + // if value is nil, we just delete the key, this will not charge gas + s.logger.Debug("deleting from aspect store", "key", abbreviateHex(key)) + s.kvStore.Delete(key) + } else { + if err := s.gasMeter.MeasureStorageStore(len(key) + len(value)); err != nil { + return err + } + + s.logger.Debug("saving to aspect store", "key", abbreviateHex(key), "data", abbreviateHex(value)) + s.kvStore.Set(key, value) + } + return nil +} + +func (s *baseStore) TransferGasFrom(store store.GasMeteredStore) { + s.gasMeter.UpdateGas(store.Gas()) +} + +func (s *baseStore) Gas() uint64 { + return s.gasMeter.RemainingGas() +} + +func abbreviateHex(data []byte) string { + if len(data) > 100 { + return hex.EncodeToString(data[:100]) + "..." + } + return hex.EncodeToString(data) +} diff --git a/x/aspect/store/v1/init.go b/x/aspect/store/v1/init.go new file mode 100644 index 0000000..1cab37c --- /dev/null +++ b/x/aspect/store/v1/init.go @@ -0,0 +1,9 @@ +package v1 + +import "github.com/artela-network/artela-rollkit/x/aspect/store" + +func init() { + store.RegisterAccountStore(1, NewAccountStore) + store.RegisterAspectMetaStore(1, NewAspectMetaStore) + store.RegisterAspectStateStore(1, NewStateStore) +} diff --git a/x/aspect/store/v1/keys.go b/x/aspect/store/v1/keys.go new file mode 100644 index 0000000..39088a0 --- /dev/null +++ b/x/aspect/store/v1/keys.go @@ -0,0 +1,21 @@ +package v1 + +import ( + "github.com/artela-network/artela-rollkit/x/aspect/store" +) + +// v1 keys, first 1 byte for scope, second 2 bytes for version, next 2 bytes for type +var ( + V1AspectMetaKeyPrefix = []byte{store.AspectScope, 0x00, 0x01, 0x00, 0x01} + V1AspectBindingKeyPrefix = []byte{store.AspectScope, 0x00, 0x01, 0x00, 0x02} + V1AspectCodeKeyPrefix = []byte{store.AspectScope, 0x00, 0x01, 0x00, 0x03} + V1AspectPropertiesKeyPrefix = []byte{store.AspectScope, 0x00, 0x01, 0x00, 0x04} + V1AspectStateKeyPrefix = []byte{store.AspectScope, 0x00, 0x01, 0x00, 0xff} + + V1AccountBindingKeyPrefix = []byte{store.AccountScope, 0x00, 0x01, 0x00, 0x01} +) + +var ( + V1AspectBindingFilterKeyPrefix = byte(0x01) + V1AspectBindingDataKeyPrefix = byte(0x02) +) diff --git a/x/aspect/store/v1/meta.go b/x/aspect/store/v1/meta.go new file mode 100644 index 0000000..a1ed606 --- /dev/null +++ b/x/aspect/store/v1/meta.go @@ -0,0 +1,850 @@ +package v1 + +import ( + "encoding/json" + "math" + "sort" + + "github.com/cosmos/cosmos-sdk/runtime" + "github.com/ethereum/go-ethereum/common" + + cuckoo "github.com/artela-network/artela-rollkit/x/aspect/cuckoofilter" + "github.com/artela-network/artela-rollkit/x/aspect/store" + v0 "github.com/artela-network/artela-rollkit/x/aspect/store/v0" + "github.com/artela-network/artela-rollkit/x/aspect/types" +) + +var _ store.AspectMetaStore = (*metaStore)(nil) + +const ( + bindingSlotSize = 120 + bindingInfoLength = 32 + bindingDataLength = 8 + filterMaxSize = 2047 + filterActualLimit = filterMaxSize * 9 / 10 // assume load factor of filter is 90% + filterManagedSlots = filterActualLimit / bindingSlotSize + maxBindingSize = filterManagedSlots * math.MaxUint8 * bindingSlotSize +) + +type metaStore struct { + BaseStore + + ext *Extension + ctx *types.AspectStoreContext + + propertiesCache map[uint64]map[string][]byte +} + +// NewAspectMetaStore creates a new instance of aspect meta Store. +func NewAspectMetaStore(ctx *types.AspectStoreContext, protocolExtension []byte) store.AspectMetaStore { + var meter v0.GasMeter + if ctx.ChargeGas() { + meter = v0.NewGasMeter(ctx) + } else { + meter = v0.NewNoOpGasMeter(ctx) + } + + ext := new(Extension) + if err := ext.UnmarshalText(protocolExtension); err != nil { + panic(err) + } + + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &metaStore{ + BaseStore: NewBaseStore(ctx.CosmosContext().Logger(), meter, store), + ctx: ctx, + ext: ext, + propertiesCache: make(map[uint64]map[string][]byte), + } +} + +func (m *metaStore) GetCode(version uint64) ([]byte, error) { + // key format {5B codePrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectCodeKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + return m.Load(key) +} + +func (m *metaStore) GetVersionMeta(version uint64) (*types.VersionMeta, error) { + // key format {5B metaPrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectMetaKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + raw, err := m.Load(key) + if err != nil { + return nil, err + } + + meta := new(VersionMeta) + if err := meta.UnmarshalText(raw); err != nil { + return nil, err + } + + return &types.VersionMeta{ + JoinPoint: meta.JoinPoint, + CodeHash: meta.CodeHash, + }, nil +} + +func (m *metaStore) GetMeta() (*types.AspectMeta, error) { + return &types.AspectMeta{ + PayMaster: m.ext.PayMaster, + Proof: m.ext.Proof, + }, nil +} + +func (m *metaStore) GetLatestVersion() (uint64, error) { + return m.ext.AspectVersion, nil +} + +func (m *metaStore) getProperties(version uint64) (properties map[string][]byte, err error) { + if _, ok := m.propertiesCache[version]; ok { + return m.propertiesCache[version], nil + } + + // key format {5B propertyPrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectPropertiesKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + allProps, err := m.Load(key) + if err != nil { + return nil, err + } + + defer func() { + if err == nil { + m.propertiesCache[version] = properties + } + }() + + if len(allProps) == 0 { + return make(map[string][]byte), nil + } + + propertiesArray := make([]types.Property, 0) + if err := json.Unmarshal(allProps, &propertiesArray); err != nil { + return nil, err + } + + properties = make(map[string][]byte, len(propertiesArray)) + for _, property := range propertiesArray { + properties[property.Key] = property.Value + } + + return properties, nil +} + +func (m *metaStore) GetProperty(version uint64, propKey string) ([]byte, error) { + if version == 0 { + // for non-exist version property, return nil + return nil, nil + } + + allProps, err := m.getProperties(version) + if err != nil { + return nil, err + } + + return allProps[propKey], nil +} + +func (m *metaStore) BumpVersion() (ver uint64, err error) { + key := store.NewKeyBuilder(store.AspectProtocolInfoKeyPrefix).AppendBytes(m.ctx.AspectID.Bytes()).Build() + raw, err := m.Load(key) + if err != nil { + return 0, err + } + + m.ext.AspectVersion += 1 + defer func() { + if err != nil { + // if failed, rollback the version + m.ext.AspectVersion -= 1 + } + }() + + marshaled, err := m.ext.MarshalText() + if err != nil { + return 0, err + } + + extensionOffset := store.ProtocolInfoLen + store.ProtocolVersionLen + result := make([]byte, 0, len(raw)) + result = append(result, raw[:extensionOffset]...) + result = append(result, marshaled...) + + return m.ext.AspectVersion, m.Store(key, result) +} + +func (m *metaStore) StoreVersionMeta(version uint64, meta *types.VersionMeta) error { + // key format {5B metaPrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectMetaKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + + marshaled, err := VersionMeta(*meta).MarshalText() + if err != nil { + return err + } + + return m.Store(key, marshaled) +} + +func (m *metaStore) StoreMeta(meta *types.AspectMeta) (err error) { + oldPayMaster := m.ext.PayMaster + oldProof := m.ext.Proof + + m.ext.PayMaster = meta.PayMaster + m.ext.Proof = meta.Proof + + defer func() { + // rollback if failed + if err != nil { + m.ext.PayMaster = oldPayMaster + m.ext.Proof = oldProof + } + }() + + marshaled, err := m.ext.MarshalText() + if err != nil { + return err + } + + key := store.NewKeyBuilder(store.AspectProtocolInfoKeyPrefix).AppendBytes(m.ctx.AspectID.Bytes()).Build() + raw, err := m.Load(key) + if err != nil { + return err + } + + extensionOffset := store.ProtocolInfoLen + store.ProtocolVersionLen + result := make([]byte, 0, len(raw)) + result = append(result, raw[:extensionOffset]...) + result = append(result, marshaled...) + + return m.Store(key, result) +} + +func (m *metaStore) StoreCode(version uint64, code []byte) error { + // key format {5B codePrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectCodeKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + return m.Store(key, code) +} + +func (m *metaStore) StoreProperties(version uint64, properties []types.Property) (err error) { + // for version > 1 (upgrade case), we need to load all previous properties and append the new ones + if version > 1 { + oldVersionProperties, err := m.getProperties(version - 1) + if err != nil { + return err + } + + keySet := make(map[string]int, len(properties)) + for i, prop := range properties { + keySet[prop.Key] = i + } + + for key, value := range oldVersionProperties { + if _, ok := keySet[key]; ok { + // for exiting one, ignore the old value + continue + } + + // for non-existing one, we need to append it + properties = append(properties, types.Property{ + Key: key, + Value: value, + }) + } + } + + // check limits + if len(properties) > types.AspectPropertyLimit { + return store.ErrTooManyProperties + } + + // sort the slice lexicographically + sort.Slice(properties, func(i, j int) bool { + return properties[i].Key < properties[j].Key + }) + + // key format {5B propertyPrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectPropertiesKeyPrefix). + AppendUint64(version). + AppendBytes(m.ctx.AspectID.Bytes()). + Build() + + bytes, err := json.Marshal(properties) + if err != nil { + return store.ErrSerdeFail + } + + defer func() { + if err == nil { + m.propertiesCache[version] = make(map[string][]byte, len(properties)) + for _, prop := range properties { + m.propertiesCache[version][prop.Key] = prop.Value + } + } + }() + + return m.Store(key, bytes) +} + +func (m *metaStore) StoreBinding(account common.Address, version uint64, joinPoint uint64, priority int8) (err error) { + // bindingKey format {5B codePrefix}{8B version}{20B aspectID} + bindingKey := store.NewKeyBuilder(V1AspectBindingKeyPrefix). + AppendBytes(m.ctx.AspectID.Bytes()) + + // load first slot + bindingSlotKey := bindingKey.AppendByte(V1AspectBindingDataKeyPrefix) + firstSlotKey := bindingSlotKey.AppendUint64(0).Build() + firstSlot, err := m.Load(firstSlotKey) + if err != nil { + return err + } + + // marshal binding info + newBinding := Binding{ + Account: account, + Version: version, + Priority: priority, + JoinPoint: uint16(joinPoint), + } + newBindingBytes, err := newBinding.MarshalText() + if err != nil { + return err + } + + var length DataLength + if err := length.UnmarshalText(firstSlot); err != nil { + return err + } + + // check max binding amount, an aspect can bind with at most 459000 accounts + if length >= maxBindingSize { + return store.ErrBindingLimitExceeded + } + + filterKey := bindingKey.AppendByte(V1AspectBindingFilterKeyPrefix) + if length == 0 { + // first time this aspect is bound + // use cuckoo filter instead of bloom, since cuckoo also support delete, + // we use a separate slot to store the filters, + // each filter will manage 28 slots, which should be enough for a long time. + + // first time this aspect is bound + filter := cuckoo.NewFilter(filterMaxSize) + // insert {aspectId}:{filterManagedSlotOffset 0-27} into cuckoo filter + // each filter will manage 28 binding slots + filter.Insert(store.NewKeyBuilder(account.Bytes()).AppendUint8(0).Build()) + filterData := filter.Encode() + // save filter + if err := m.Store(filterKey.AppendUint8(0).Build(), filterData); err != nil { + return err + } + // save binding data + length := DataLength(1) + lengthBytes, err := length.MarshalText() + if err != nil { + return err + } + + // store binding data + if err := m.Store(firstSlotKey, append(lengthBytes, newBindingBytes...)); err != nil { + return err + } + + return nil + } + + lastSlot := uint64(length / bindingSlotSize) + lastFilterSlot := uint8(lastSlot / filterManagedSlots) + + var lastFilter *cuckoo.Filter + // first use filter to check whether the account is already bound + for i := uint8(0); i <= lastFilterSlot; i++ { + key := filterKey.AppendUint8(i).Build() + filterData, err := m.Load(key) + if err != nil { + return err + } + if len(filterData) == 0 { + // reached the end of the filter + break + } + + filter, err := cuckoo.Decode(filterData) + if err != nil { + return err + } + + // cache the last filter + if i == lastFilterSlot { + lastFilter = filter + } + + accountKey := store.NewKeyBuilder(account.Bytes()) + + // if total slot is less than managed, just test all slots, otherwise test managed + slotsToTest := uint8(filterManagedSlots) + if filterManagedSlots > lastSlot { + slotsToTest = uint8(lastSlot + 1) + } + + // check aspect is already bound + for j := uint8(0); j < slotsToTest; j++ { + if !filter.Lookup(accountKey.AppendUint8(j).Build()) { + // filter test fail, continue searching + continue + } + + // filter test succeeded, double check with the actual data + var bindingDataInSlot []byte + if i == 0 && j == 0 { + // since we have already loaded the first slot, no need to load it again + bindingDataInSlot = firstSlot[bindingDataLength:] + } else { + slotIndex := uint64(i)*filterManagedSlots + uint64(j) + bindingDataInSlot, err = m.Load(bindingSlotKey.AppendUint64(slotIndex).Build()) + if err != nil { + return err + } + } + for k := 0; k < len(bindingDataInSlot); k += bindingInfoLength { + data := bindingDataInSlot[k : k+bindingInfoLength] + var binding Binding + if err := binding.UnmarshalText(data); err != nil { + return err + } + if binding.Account == account { + return store.ErrAlreadyBound + } + } + } + } + + // check if the last slot is full + if length%bindingSlotSize == 0 { + // last slot is full, check if we need create a new filter + if lastSlot%filterManagedSlots == 0 { + // create a new filter + filter := cuckoo.NewFilter(filterMaxSize) + // insert {aspectId}:{filterManagedSlotOffset 0-27} into cuckoo filter + // each filter will manage 28 binding slots + filter.Insert(store.NewKeyBuilder(account.Bytes()).AppendUint8(0).Build()) + filterData := filter.Encode() + // save filter + if err := m.Store(filterKey.AppendUint8(lastFilterSlot).Build(), filterData); err != nil { + return err + } + } else { + // update filter data + lastFilterKey := filterKey.AppendUint8(lastFilterSlot).Build() + if lastFilter == nil { + // if last filter is not loaded for some reason, load and decode + filterData, err := m.Load(lastFilterKey) + if err != nil { + return err + } + + lastFilter, err = cuckoo.Decode(filterData) + if err != nil { + return err + } + } + lastFilter.Insert(store.NewKeyBuilder(account.Bytes()).AppendUint8(uint8(lastSlot % filterManagedSlots)).Build()) + filterData := lastFilter.Encode() + if err := m.Store(lastFilterKey, filterData); err != nil { + return err + } + } + // create a new slot + newSlotKey := bindingSlotKey.AppendUint64(lastSlot).Build() + if err := m.Store(newSlotKey, newBindingBytes); err != nil { + return err + } + } else { + // slot is not full, update the slot and filter directly + // update filter data + lastFilterKey := filterKey.AppendUint8(lastFilterSlot).Build() + if lastFilter == nil { + // if last filter is not loaded for some reason, load and decode + filterData, err := m.Load(lastFilterKey) + if err != nil { + return err + } + + lastFilter, err = cuckoo.Decode(filterData) + if err != nil { + return err + } + } + lastFilter.Insert(store.NewKeyBuilder(account.Bytes()).AppendUint8(uint8(lastSlot % filterManagedSlots)).Build()) + filterData := lastFilter.Encode() + if err := m.Store(lastFilterKey, filterData); err != nil { + return err + } + + // update the slot data + if lastSlot == 0 { + // since we have already loaded the first slot, no need to load it again + // just update the first slot data + firstSlot = append(firstSlot, newBindingBytes...) + } else { + // otherwise we need to load the last slot data + lastSlotKey := bindingSlotKey.AppendUint64(lastSlot).Build() + lastSlotData, err := m.Load(lastSlotKey) + if err != nil { + return err + } + + // append the new binding to the last slot and save it + lastSlotData = append(lastSlotData, newBindingBytes...) + if err := m.Store(lastSlotKey, lastSlotData); err != nil { + return err + } + } + } + + // update length + length++ + lengthBytes, err := length.MarshalText() + if err != nil { + return err + } + + // overwrite the length in first slot + copy(firstSlot, lengthBytes) + // update first slot + return m.Store(firstSlotKey, firstSlot) +} + +func (m *metaStore) LoadAspectBoundAccounts() ([]types.Binding, error) { + // key format {5B codePrefix}{8B version}{20B aspectID} + key := store.NewKeyBuilder(V1AspectBindingKeyPrefix). + AppendBytes(m.ctx.AspectID.Bytes()).AppendByte(V1AspectBindingDataKeyPrefix) + + firstSlot, err := m.Load(key.AppendUint64(0).Build()) + if err != nil { + return nil, err + } + + var length DataLength + if err := length.UnmarshalText(firstSlot); err != nil { + return nil, err + } + + // binding format for first slot {8B Length}{256B Bloom}{32B Binding}{32B Binding}... + // each slot will save maximum 120 binding info, which is 3840 bytes + bindingData := firstSlot[bindingDataLength:] + bindings := make([]types.Binding, 0, length) + for i := uint64(0); i < uint64(length); i += bindingSlotSize { + for j := 0; j < len(bindingData); j += bindingInfoLength { + data := bindingData[j : j+bindingInfoLength] + var binding Binding + if err := binding.UnmarshalText(data); err != nil { + return nil, err + } + bindings = append(bindings, types.Binding(binding)) + if uint64(len(bindings)) == uint64(length) { + // EOF + return bindings, nil + } + } + + // load next slot + bindingData, err = m.Load(key.AppendUint64((i / bindingSlotSize) + 1).Build()) + if err != nil { + return nil, err + } + } + + return bindings, nil +} + +func (m *metaStore) RemoveBinding(account common.Address) (err error) { + // bindingKey format {5B codePrefix}{8B version}{20B aspectID} + bindingKey := store.NewKeyBuilder(V1AspectBindingKeyPrefix). + AppendBytes(m.ctx.AspectID.Bytes()) + + // load first slot + bindingSlotKey := bindingKey.AppendByte(V1AspectBindingDataKeyPrefix) + firstSlotKey := bindingSlotKey.AppendUint64(0).Build() + firstSlot, err := m.Load(firstSlotKey) + if err != nil { + return err + } + + var length DataLength + if err := length.UnmarshalText(firstSlot); err != nil { + return err + } + + if length == 0 { + // if not bound, just pass + return nil + } + + lastSlot := uint64(length / bindingSlotSize) + if length%bindingSlotSize == 0 { + lastSlot = lastSlot - 1 + } + lastFilterSlot := uint8(lastSlot / filterManagedSlots) + + var ( + lastFilter *cuckoo.Filter + bindingFilter *cuckoo.Filter + bindingSlot *uint64 + bindingSlotData []byte + bindingSlotOffset *int + ) + // first use filter to check whether the account is already bound + filterKey := bindingKey.AppendByte(V1AspectBindingFilterKeyPrefix) + for i := uint8(0); i <= lastFilterSlot; i++ { + key := filterKey.AppendUint8(i).Build() + filterData, err := m.Load(key) + if err != nil { + return err + } + if len(filterData) == 0 { + // reached last filter + break + } + + filter, err := cuckoo.Decode(filterData) + if err != nil { + return err + } + + // cache the last filter + if i == lastFilterSlot { + lastFilter = filter + } + + accountKey := store.NewKeyBuilder(account.Bytes()) + for j := uint8(0); j < filterManagedSlots; j++ { + if !filter.Lookup(accountKey.AppendUint8(j).Build()) { + // filter test fail, continue searching + continue + } + + // filter test succeeded, double check with the actual data + var bindingDataInSlot []byte + slotIndex := uint64(0) + if i == 0 && j == 0 { + // since we have already loaded the first slot, no need to load it again + bindingDataInSlot = firstSlot[bindingDataLength:] + } else { + slotIndex = uint64(i)*filterManagedSlots + uint64(j) + bindingDataInSlot, err = m.Load(bindingSlotKey.AppendUint64(slotIndex).Build()) + if err != nil { + return err + } + } + // search in the slot + for k := 0; k < len(bindingDataInSlot); k += bindingInfoLength { + data := bindingDataInSlot[k : k+bindingInfoLength] + var binding Binding + if err := binding.UnmarshalText(data); err != nil { + return err + } + if binding.Account == account { + // found binding, record position and break out the loops + bindingSlotData = bindingDataInSlot + bindingSlotOffset = &k + bindingSlot = &slotIndex + bindingFilter = filter + goto BindingFound + } + } + } + } + +BindingFound: + if bindingSlotData == nil || bindingSlot == nil || bindingFilter == nil || bindingSlotOffset == nil { + // if not bound, just pass + return nil + } + + // remove the binding from the slot + if *bindingSlot == lastSlot { + // only first slot used, or binding in last slot, we can just remove the binding from the slot + if len(bindingSlotData) > bindingInfoLength { + copy(bindingSlotData[*bindingSlotOffset:], bindingSlotData[*bindingSlotOffset+bindingInfoLength:]) + } + bindingSlotData = bindingSlotData[:len(bindingSlotData)-bindingInfoLength] + if *bindingSlot > 0 { + // if not the first slot we just save the data + if err := m.Store(bindingSlotKey.AppendUint64(*bindingSlot).Build(), bindingSlotData); err != nil { + return err + } + } else { + // for the first slot we just need update the first slot data + firstSlot = append(firstSlot[:bindingDataLength], bindingSlotData...) + } + + // remove the account from the filter, and update filter + filterSlot := uint8(*bindingSlot / filterManagedSlots) + bindingFilter.Delete(store.NewKeyBuilder(account.Bytes()).AppendUint8(filterSlot).Build()) + // if there is nothing in the filter, delete it + var updatedFilter []byte + if bindingFilter.Count() > 0 { + // otherwise we update it + updatedFilter = bindingFilter.Encode() + } + + if err := m.Store(filterKey.AppendUint8(filterSlot).Build(), updatedFilter); err != nil { + return err + } + } else if lastSlot > *bindingSlot { + // move the last binding to the removed position + lastSlotKey := bindingSlotKey.AppendUint64(lastSlot).Build() + lastSlotData, err := m.Load(lastSlotKey) + if err != nil { + return err + } + lastBindingBytes := lastSlotData[len(lastSlotData)-bindingInfoLength:] + + // replace delete binding with the last binding + copy(bindingSlotData[*bindingSlotOffset:], lastBindingBytes) + lastSlotData = lastSlotData[:len(lastSlotData)-bindingInfoLength] + + // update last slot + if err := m.Store(lastSlotKey, lastSlotData); err != nil { + return err + } + + // update the updated slot + if *bindingSlot == 0 { + // for the first slot we just need to copy over the data + copy(firstSlot[bindingDataLength:], bindingSlotData) + } else { + // for other slots we need to save it first + if err := m.Store(bindingSlotKey.AppendUint64(*bindingSlot).Build(), bindingSlotData); err != nil { + return err + } + } + + // load the filter if needed + if lastFilter == nil { + // if last filter is not loaded for some reason, load and decode + filterData, err := m.Load(filterKey.AppendUint8(lastFilterSlot).Build()) + if err != nil { + return err + } + lastFilter, err = cuckoo.Decode(filterData) + if err != nil { + return err + } + } + + lastBinding := new(Binding) + if err := lastBinding.UnmarshalText(lastBindingBytes); err != nil { + return err + } + + // remove the binding from the filters + if lastSlot/filterManagedSlots == *bindingSlot/filterManagedSlots { + bindingFilterOffsetKey := uint8(*bindingSlot % filterManagedSlots) + lastFilterOffsetKey := uint8(lastSlot % filterManagedSlots) + // need to remove both last binding and the unbound one from their old position + // and add last one to the new position + lastFilter.Delete(store.NewKeyBuilder(account.Bytes()).AppendUint8(bindingFilterOffsetKey).Build()) + lastFilter.Delete(store.NewKeyBuilder(lastBinding.Account.Bytes()).AppendUint8(lastFilterOffsetKey).Build()) + lastFilter.Insert(store.NewKeyBuilder(lastBinding.Account.Bytes()).AppendUint8(bindingFilterOffsetKey).Build()) + + // update last filter + if err := m.Store(filterKey.AppendUint8(lastFilterSlot).Build(), lastFilter.Encode()); err != nil { + return err + } + } else { + // if the last slot and the binding slot are in different filters, we need to update both filters + // remove the moved binding account from the last slot filter, and update filter + lastFilterOffsetKey := uint8(lastSlot % filterManagedSlots) + lastFilter.Delete(store.NewKeyBuilder(lastBinding.Account.Bytes()).AppendUint8(lastFilterOffsetKey).Build()) + var updatedFilter []byte + if lastFilter.Count() > 0 { + updatedFilter = lastFilter.Encode() + } + if err := m.Store(filterKey.AppendUint8(lastFilterSlot).Build(), updatedFilter); err != nil { + return err + } + + // remove the account from the binding slot filter, and update filter + bindingFilterOffset := uint8(*bindingSlot % filterManagedSlots) + bindingFilter.Delete(store.NewKeyBuilder(account.Bytes()).AppendUint8(bindingFilterOffset).Build()) + bindingFilter.Insert(store.NewKeyBuilder(lastBinding.Account.Bytes()).AppendUint8(bindingFilterOffset).Build()) + if err := m.Store(filterKey.AppendUint8(uint8(*bindingSlot/filterManagedSlots)).Build(), bindingFilter.Encode()); err != nil { + return err + } + } + } else { + // should not happen + return store.ErrStorageCorrupted + } + + // update length + length-- + lengthBytes, err := length.MarshalText() + if err != nil { + return err + } + + // overwrite the length in first slot + copy(firstSlot, lengthBytes) + // update first slot + return m.Store(firstSlotKey, firstSlot) +} + +func (m *metaStore) MigrateFrom(old store.AspectMetaStore) error { + //TODO implement me + panic("implement me") +} + +func (m *metaStore) Used() (bool, error) { + return m.ext.AspectVersion > 0, nil +} + +func (m *metaStore) Init() error { + versionBytes, err := protocolVersion.MarshalText() + if err != nil { + return err + } + + info := &store.AspectInfo{ + MetaVersion: protocolVersion, + StateVersion: protocolVersion, + } + + infoBytes, err := info.MarshalText() + if err != nil { + return err + } + + extension := &Extension{ + AspectVersion: 0, + PayMaster: common.Address{}, + Proof: nil, + } + extBytes, err := extension.MarshalText() + if err != nil { + return err + } + + key := store.NewKeyBuilder(store.AspectProtocolInfoKeyPrefix).AppendBytes(m.ctx.AspectID.Bytes()).Build() + result := make([]byte, 0, len(versionBytes)+len(infoBytes)+len(extBytes)) + result = append(result, versionBytes...) + result = append(result, infoBytes...) + result = append(result, extBytes...) + + return m.Store(key, result) +} diff --git a/x/aspect/store/v1/models.go b/x/aspect/store/v1/models.go new file mode 100644 index 0000000..e1d63cd --- /dev/null +++ b/x/aspect/store/v1/models.go @@ -0,0 +1,147 @@ +package v1 + +import ( + "encoding/binary" + + "github.com/ethereum/go-ethereum/common" + + "github.com/artela-network/artela-rollkit/x/aspect/store" +) + +var emptyHash = common.Hash{} + +type DataLength uint64 + +func (l *DataLength) UnmarshalText(text []byte) error { + if len(text) < 8 { + *l = 0 + } else { + *l = DataLength(binary.BigEndian.Uint64(text[:8])) + } + return nil +} + +func (l DataLength) MarshalText() (text []byte, err error) { + result := make([]byte, 8) + binary.BigEndian.PutUint64(result, uint64(l)) + return result, nil +} + +type Bindings []Binding + +func (b *Bindings) UnmarshalText(text []byte) error { + if len(text)%32 != 0 { + return store.ErrInvalidBinding + } + for i := 0; i < len(text); i += 32 { + data := text[i : i+32] + if common.Hash(data) == emptyHash { + // EOF + return nil + } + + var binding Binding + if err := binding.UnmarshalText(data); err != nil { + return err + } + *b = append(*b, binding) + } + return nil +} + +func (b Bindings) MarshalText() (text []byte, err error) { + result := make([]byte, 0, len(b)*32) + for _, binding := range b { + marshaled, err := binding.MarshalText() + if err != nil { + return nil, err + } + result = append(result, marshaled...) + } + return result, nil +} + +type Binding struct { + Account common.Address + Version uint64 + Priority int8 + JoinPoint uint16 +} + +func (b *Binding) UnmarshalText(text []byte) error { + if len(text) < 32 { + return store.ErrInvalidBinding + } + b.Account.SetBytes(text[:20]) + b.Version = binary.BigEndian.Uint64(text[20:28]) + b.Priority = int8(text[28]) + b.JoinPoint = binary.BigEndian.Uint16(text[29:31]) + // last byte is reserved for future use + return nil +} + +func (b Binding) MarshalText() (text []byte, err error) { + result := make([]byte, 32) + copy(result[:20], b.Account.Bytes()) + binary.BigEndian.PutUint64(result[20:28], b.Version) + result[28] = byte(b.Priority) + binary.BigEndian.PutUint16(result[29:31], b.JoinPoint) + // last byte is reserved for future use + return result, nil +} + +type Extension struct { + AspectVersion uint64 + PayMaster common.Address + Proof []byte +} + +func (e *Extension) UnmarshalText(text []byte) error { + if len(text) == 0 { + // not inited + return nil + } + if len(text) < 36 { + return store.ErrInvalidExtension + } + e.AspectVersion = binary.BigEndian.Uint64(text[:8]) + e.PayMaster.SetBytes(text[8:28]) + proofLen := binary.BigEndian.Uint64(text[28:36]) + if uint64(len(text)) != 36+proofLen { + return store.ErrInvalidExtension + } + e.Proof = make([]byte, proofLen) + copy(e.Proof, text[36:]) + return nil +} + +func (e Extension) MarshalText() (text []byte, err error) { + result := make([]byte, 8+20+8+len(e.Proof)) + binary.BigEndian.PutUint64(result[:8], e.AspectVersion) + copy(result[8:28], e.PayMaster.Bytes()) + binary.BigEndian.PutUint64(result[28:36], uint64(len(e.Proof))) + copy(result[36:], e.Proof) + return result, nil +} + +// VersionMeta is the data model for holding the metadata of a specific version of aspect +type VersionMeta struct { + JoinPoint uint64 + CodeHash common.Hash +} + +func (v *VersionMeta) UnmarshalText(text []byte) error { + if len(text) < 40 { + return store.ErrInvalidVersionMeta + } + v.JoinPoint = binary.BigEndian.Uint64(text[:8]) + v.CodeHash.SetBytes(text[8:40]) + return nil +} + +func (v VersionMeta) MarshalText() (text []byte, err error) { + result := make([]byte, 40) + binary.BigEndian.PutUint64(result[:8], v.JoinPoint) + copy(result[8:], v.CodeHash.Bytes()) + return result, nil +} diff --git a/x/aspect/store/v1/state.go b/x/aspect/store/v1/state.go new file mode 100644 index 0000000..d1a349a --- /dev/null +++ b/x/aspect/store/v1/state.go @@ -0,0 +1,49 @@ +package v1 + +import ( + "github.com/artela-network/artela-rollkit/x/aspect/store" + v0 "github.com/artela-network/artela-rollkit/x/aspect/store/v0" + "github.com/artela-network/artela-rollkit/x/aspect/types" + "github.com/cosmos/cosmos-sdk/runtime" +) + +var _ store.AspectStateStore = (*stateStore)(nil) + +// stateStore is the version 1 state Store +type stateStore struct { + BaseStore + + ctx *types.AspectStoreContext +} + +// NewStateStore creates a new instance of account state. +func NewStateStore(ctx *types.AspectStoreContext) store.AspectStateStore { + // for state Store, we have already charged gas in host api, + // so no need to charge it again in the Store + store := runtime.KVStoreAdapter(ctx.StoreService().OpenKVStore(ctx.CosmosContext())) + + return &stateStore{ + BaseStore: NewBaseStore(ctx.CosmosContext().Logger(), v0.NewNoOpGasMeter(ctx), store), + ctx: ctx, + } +} + +// SetState sets the state of the aspect with the given ID and key. +func (s *stateStore) SetState(key []byte, value []byte) { + aspectID := s.ctx.AspectID + stateKey := store.NewKeyBuilder(V1AspectStateKeyPrefix).AppendBytes(aspectID.Bytes()).AppendBytes(key).Build() + // no need to check error here, since we are using noop gas meter in state store + _ = s.Store(stateKey, value) + s.ctx.Logger().Debug("set aspect state", "key", string(key), "value", abbreviateHex(value)) + return +} + +// GetState returns the state of the aspect with the given ID and key. +func (s *stateStore) GetState(key []byte) []byte { + aspectID := s.ctx.AspectID + stateKey := store.NewKeyBuilder(V1AspectStateKeyPrefix).AppendBytes(aspectID.Bytes()).AppendBytes(key).Build() + // no need to check error here, since we are using noop gas meter in state store + data, _ := s.Load(stateKey) + s.ctx.Logger().Debug("get aspect state", "key", string(key), "value", abbreviateHex(data)) + return data +} diff --git a/x/aspect/types/constants.go b/x/aspect/types/constants.go new file mode 100644 index 0000000..2c5ae6b --- /dev/null +++ b/x/aspect/types/constants.go @@ -0,0 +1,16 @@ +package types + +import "math" + +const ( + // ModuleName string name of module + ModuleName = "aspect" + + // StoreKey key for aspect storage data + StoreKey = ModuleName +) + +const ( + // AspectPropertyLimit is the maximum number of properties that can be set on an aspect + AspectPropertyLimit = math.MaxUint8 +) diff --git a/x/aspect/types/context.go b/x/aspect/types/context.go new file mode 100644 index 0000000..40d6ca2 --- /dev/null +++ b/x/aspect/types/context.go @@ -0,0 +1,111 @@ +package types + +import ( + cstore "cosmossdk.io/core/store" + "cosmossdk.io/log" + "github.com/artela-network/artela-evm/vm" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/ethereum/go-ethereum/common" +) + +type storeContext struct { + cosmosCtx sdk.Context + storeService cstore.KVStoreService + gas uint64 + + chargeGas bool +} + +func (s *storeContext) clone() StoreContext { + return &storeContext{ + cosmosCtx: s.cosmosCtx, + storeService: s.storeService, + gas: s.gas, + } +} + +func (s *storeContext) Logger() log.Logger { + return s.cosmosCtx.Logger() +} + +func (s *storeContext) CosmosContext() sdk.Context { + return s.cosmosCtx +} + +func (s *storeContext) StoreService() cstore.KVStoreService { + return s.storeService +} + +func (s *storeContext) Gas() uint64 { + return s.gas +} + +func (s *storeContext) UpdateGas(gas uint64) { + s.gas = gas +} + +func (s *storeContext) ChargeGas() bool { + return s.chargeGas +} + +func (s *storeContext) ConsumeGas(gas uint64) error { + if s.gas < gas { + s.gas = 0 + return vm.ErrOutOfGas + } + s.gas -= gas + return nil +} + +type StoreContext interface { + CosmosContext() sdk.Context + StoreService() cstore.KVStoreService + Gas() uint64 + ConsumeGas(gas uint64) error + UpdateGas(gas uint64) + Logger() log.Logger + ChargeGas() bool + + clone() StoreContext +} + +func NewStoreContext(ctx sdk.Context, storeService cstore.KVStoreService, gas uint64) StoreContext { + return &storeContext{ + cosmosCtx: ctx, + storeService: storeService, + gas: gas, + chargeGas: true, + } +} + +func NewGasFreeStoreContext(ctx sdk.Context, storeService cstore.KVStoreService) StoreContext { + return &storeContext{ + cosmosCtx: ctx, + storeService: storeService, + chargeGas: false, + } +} + +type AccountStoreContext struct { + StoreContext + Account common.Address +} + +func (a *AccountStoreContext) Clone() AccountStoreContext { + return AccountStoreContext{ + StoreContext: a.StoreContext.clone(), + Account: a.Account, + } +} + +type AspectStoreContext struct { + StoreContext + AspectID common.Address +} + +func (a *AspectStoreContext) Clone() AspectStoreContext { + return AspectStoreContext{ + StoreContext: a.StoreContext.clone(), + AspectID: a.AspectID, + } +} diff --git a/x/aspect/types/models.go b/x/aspect/types/models.go new file mode 100644 index 0000000..4fd8abe --- /dev/null +++ b/x/aspect/types/models.go @@ -0,0 +1,58 @@ +package types + +import ( + "github.com/artela-network/aspect-core/types" + "github.com/ethereum/go-ethereum/common" +) + +// BindingFilter is the data model for holding the filter of querying aspect bindings +type BindingFilter struct { + // filter bindings with given join point + JoinPoint *types.PointCut + // only return bindings of verifier aspects + VerifierOnly bool + // only return bindings of tx level aspects + TxLevelOnly bool +} + +func NewDefaultFilter(isCA bool) BindingFilter { + if isCA { + return BindingFilter{} + } + + return BindingFilter{ + VerifierOnly: true, + } +} + +func NewJoinPointFilter(cut types.PointCut) BindingFilter { + return BindingFilter{ + JoinPoint: &cut, + } +} + +// Binding is the data model for holding the binding of an aspect to an account +type Binding struct { + Account common.Address + Version uint64 + Priority int8 + JoinPoint uint16 +} + +// VersionMeta is the data model for holding the metadata of a specific version of aspect +type VersionMeta struct { + JoinPoint uint64 + CodeHash common.Hash +} + +// AspectMeta is the data model for holding the metadata of an aspect +type AspectMeta struct { + PayMaster common.Address + Proof []byte +} + +// Property is the data model for holding the properties of an aspect +type Property struct { + Key string `json:"Key"` + Value []byte `json:"Value"` +} diff --git a/x/evm/artela/api/aspect_property_api.go b/x/evm/artela/api/aspect_property_api.go index f1e47d6..4f27643 100644 --- a/x/evm/artela/api/aspect_property_api.go +++ b/x/evm/artela/api/aspect_property_api.go @@ -4,10 +4,8 @@ import ( "context" "errors" - asptypes "github.com/artela-network/aspect-core/types" - - "github.com/artela-network/artela-rollkit/x/evm/artela/contract" "github.com/artela-network/artela-rollkit/x/evm/artela/types" + asptypes "github.com/artela-network/aspect-core/types" ) var _ asptypes.AspectPropertyHostAPI = (*aspectPropertyHostAPI)(nil) @@ -17,10 +15,7 @@ type aspectPropertyHostAPI struct { } func (a *aspectPropertyHostAPI) Get(ctx *asptypes.RunnerContext, key string) (ret []byte, err error) { - // TODO: this part looks weird, - // but due to the time issue, we just migrate the old logics for now - nativeContractStore := contract.NewAspectStore(a.aspectRuntimeContext.StoreService(), a.aspectRuntimeContext.Logger()) - ret, ctx.Gas, err = nativeContractStore.GetAspectPropertyValue(a.aspectRuntimeContext.CosmosContext(), ctx.AspectId, key, ctx.Gas) + ret = a.aspectRuntimeContext.GetAspectProperty(ctx, ctx.AspectVersion, key) return } diff --git a/x/evm/artela/api/aspect_runtime_ctx_api.go b/x/evm/artela/api/aspect_runtime_ctx_api.go index 353a05b..b88183a 100644 --- a/x/evm/artela/api/aspect_runtime_ctx_api.go +++ b/x/evm/artela/api/aspect_runtime_ctx_api.go @@ -92,7 +92,6 @@ func (a *aspectRuntimeContextHostAPI) Register() { blockCtx := datactx.NewBlockContext(a.aspectRuntimeContext) a.execMap[aspctx.BlockHeaderParentHash] = blockCtx.ValueLoader(aspctx.BlockHeaderParentHash) a.execMap[aspctx.BlockHeaderMiner] = blockCtx.ValueLoader(aspctx.BlockHeaderMiner) - a.execMap[aspctx.BlockHeaderTransactionsRoot] = blockCtx.ValueLoader(aspctx.BlockHeaderTransactionsRoot) a.execMap[aspctx.BlockHeaderNumber] = blockCtx.ValueLoader(aspctx.BlockHeaderNumber) a.execMap[aspctx.BlockHeaderTimestamp] = blockCtx.ValueLoader(aspctx.BlockHeaderTimestamp) diff --git a/x/evm/artela/api/datactx/block.go b/x/evm/artela/api/datactx/block.go index 76d3b6b..66176ff 100644 --- a/x/evm/artela/api/datactx/block.go +++ b/x/evm/artela/api/datactx/block.go @@ -35,9 +35,6 @@ func (c *BlockContext) registerLoaders() { loaders[context.BlockHeaderMiner] = func(blockCtx *types.EthBlockContext) proto.Message { return &artelatypes.BytesData{Data: blockCtx.BlockHeader().Coinbase.Bytes()} } - loaders[context.BlockHeaderTransactionsRoot] = func(blockCtx *types.EthBlockContext) proto.Message { - return &artelatypes.BytesData{Data: blockCtx.BlockHeader().TxHash.Bytes()} - } loaders[context.BlockHeaderNumber] = func(blockCtx *types.EthBlockContext) proto.Message { number := blockCtx.BlockHeader().Number.Uint64() return &artelatypes.UintData{Data: &number} diff --git a/x/evm/artela/api/datactx/tx.go b/x/evm/artela/api/datactx/tx.go index b6a0074..34b2c07 100644 --- a/x/evm/artela/api/datactx/tx.go +++ b/x/evm/artela/api/datactx/tx.go @@ -43,7 +43,7 @@ func (c *TxContext) registerLoaders() { return &artelatypes.UintData{Data: &txType} } loaders[aspctx.TxChainId] = func(_ *types.EthTxContext, tx *ethereum.Transaction) proto.Message { - if tx.ChainId() != nil { + if v, _, _ := tx.RawSignatureValues(); v.Cmp(big.NewInt(0)) != 0 && tx.ChainId() != nil { return &artelatypes.BytesData{Data: tx.ChainId().Bytes()} } return &artelatypes.BytesData{Data: []byte{}} diff --git a/x/evm/artela/api/evm_api.go b/x/evm/artela/api/evm_api.go index e34ab84..893febd 100644 --- a/x/evm/artela/api/evm_api.go +++ b/x/evm/artela/api/evm_api.go @@ -78,18 +78,23 @@ func (e *evmHostApi) StaticCall(ctx *asptypes.RunnerContext, request *asptypes.S request.Gas = &ctx.Gas } - ret, gas, err := evm.StaticCall(ctx.Ctx, vm.AccountRef(from), to, request.Data, *request.Gas) + ret, leftover, err := evm.StaticCall(ctx.Ctx, vm.AccountRef(from), to, request.Data, *request.Gas) // update gas - ctx.Gas = gas + usedGas := *request.Gas - leftover + ctx.Gas -= usedGas errStr := "" if err != nil { + // ignore revert error, error message will be set to vmError + if err.Error() != vm.ErrExecutionReverted.Error() { + return nil, err + } errStr = err.Error() } return &asptypes.StaticCallResult{ Ret: ret, - GasLeft: &gas, + GasLeft: &ctx.Gas, VmError: &errStr, }, nil } diff --git a/x/evm/artela/contract/contract.go b/x/evm/artela/contract/contract.go index 27d1ddb..ad032ce 100644 --- a/x/evm/artela/contract/contract.go +++ b/x/evm/artela/contract/contract.go @@ -7,39 +7,37 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/core" "github.com/artela-network/artela-evm/vm" - "github.com/artela-network/artela-rollkit/common" "github.com/artela-network/artela-rollkit/common/aspect" - "github.com/artela-network/artela-rollkit/x/evm/states" evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" ) type AspectNativeContract struct { - aspectService *AspectService - evmState *states.StateDB - evm *vm.EVM + evmState *states.StateDB + evm *vm.EVM logger log.Logger handlers map[string]Handler + + storeService store.KVStoreService } -func NewAspectNativeContract(storeService store.KVStoreService, +func NewAspectNativeContract( + storeService store.KVStoreService, evm *vm.EVM, - getBlockHeight func() int64, evmState *states.StateDB, logger log.Logger, ) *AspectNativeContract { return &AspectNativeContract{ - aspectService: NewAspectService(storeService, getBlockHeight, logger), - evm: evm, - evmState: evmState, - logger: logger, - handlers: make(map[string]Handler), + storeService: storeService, + evm: evm, + evmState: evmState, + logger: logger, + handlers: make(map[string]Handler), } } @@ -60,14 +58,7 @@ func (c *AspectNativeContract) register(handler Handler) { } func (c *AspectNativeContract) ApplyMessage(ctx sdk.Context, msg *core.Message, gas uint64, commit bool) (ret []byte, remainingGas uint64, err error) { - var writeCacheFunc func() - ctx, writeCacheFunc = ctx.CacheContext() - ret, remainingGas, err = c.applyMsg(ctx, msg, gas, commit) - if err == nil && commit { - writeCacheFunc() - } - - return ret, remainingGas, err + return c.applyMsg(ctx, msg, gas, commit) } func (c *AspectNativeContract) applyMsg(ctx sdk.Context, msg *core.Message, gas uint64, commit bool) (ret []byte, remainingGas uint64, err error) { @@ -86,11 +77,11 @@ func (c *AspectNativeContract) applyMsg(ctx sdk.Context, msg *core.Message, gas msg.From, parameters, commit, - c.aspectService, common.WrapLogger(c.logger.With("module", "aspect-system-contract")), c.evmState, c.evm, method, + c.storeService, msg.Data, msg.Nonce, msg.GasLimit, diff --git a/x/evm/artela/contract/handlers.go b/x/evm/artela/contract/handlers.go index 56ef322..a7859be 100644 --- a/x/evm/artela/contract/handlers.go +++ b/x/evm/artela/contract/handlers.go @@ -7,6 +7,11 @@ import ( "math/big" "time" + asptool "github.com/artela-network/artela-rollkit/x/aspect/common" + "github.com/artela-network/artela-rollkit/x/aspect/store" + aspectmoduletypes "github.com/artela-network/artela-rollkit/x/aspect/types" + + cstore "cosmossdk.io/core/store" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -20,7 +25,7 @@ import ( runtime "github.com/artela-network/aspect-runtime" runtimeTypes "github.com/artela-network/aspect-runtime/types" - artool "github.com/artela-network/artela-rollkit/common" + arttool "github.com/artela-network/artela-rollkit/common" "github.com/artela-network/artela-rollkit/x/evm/artela/types" "github.com/artela-network/artela-rollkit/x/evm/states" ) @@ -36,12 +41,13 @@ type HandlerContext struct { from common.Address parameters map[string]interface{} commit bool - service *AspectService logger runtimeTypes.Logger evmState *states.StateDB evm *vm.EVM abi *abi.Method + storeService cstore.KVStoreService + rawInput []byte nonce uint64 gasLimit uint64 @@ -58,40 +64,70 @@ type Handler interface { type DeployHandler struct{} func (h DeployHandler) Handle(ctx *HandlerContext, gas uint64) ([]byte, uint64, error) { - aspectId, code, initData, properties, joinPoint, err := h.decodeAndValidate(ctx) + aspectID, code, initData, properties, joinPoint, paymaster, proof, err := h.decodeAndValidate(ctx) if err != nil { ctx.logger.Error("deploy aspect failed", "error", err, "from", ctx.from, "gasLimit", ctx.gasLimit) return nil, 0, err } - store := ctx.service.aspectStore - newVersion, gas, err := store.BumpAspectVersion(ctx.cosmosCtx, aspectId, gas) + // we can ignore the new store here, since new deployed aspect should not have that + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, gas)) if err != nil { - ctx.logger.Error("bump aspect version failed", "error", err) - return nil, gas, err + return nil, 0, err + } + + // check duplicate deployment + var latestVersion uint64 + if latestVersion, err = metaStore.GetLatestVersion(); err != nil { + return nil, 0, err + } else if latestVersion > 0 { + return nil, 0, errors.New("aspect already deployed") + } + + if err := metaStore.Init(); err != nil { + ctx.logger.Error("init aspect meta failed", "error", err) + return nil, 0, err } - gas, err = store.StoreAspectCode(ctx.cosmosCtx, aspectId, code, newVersion, gas) + newVersion, err := metaStore.BumpVersion() if err != nil { + ctx.logger.Error("bump aspect version failed", "error", err) + return nil, 0, err + } + + if err = metaStore.StoreCode(newVersion, code); err != nil { ctx.logger.Error("store aspect code failed", "error", err) - return nil, gas, err + return nil, 0, err } // join point might be nil, since there are some operation only Aspects - if joinPoint != nil { - store.StoreAspectJP(ctx.cosmosCtx, aspectId, *newVersion, joinPoint) + if err = metaStore.StoreVersionMeta(newVersion, &aspectmoduletypes.VersionMeta{ + JoinPoint: joinPoint.Uint64(), + CodeHash: crypto.Keccak256Hash(code), + }); err != nil { + ctx.logger.Error("store aspect meta failed", "error", err) + return nil, 0, err } - if len(properties) > 0 { - gas, err = store.StoreAspectProperty(ctx.cosmosCtx, aspectId, properties, gas) - if err != nil { - ctx.logger.Error("store aspect property failed", "error", err) - } + if err = metaStore.StoreMeta(&aspectmoduletypes.AspectMeta{ + Proof: proof, + PayMaster: paymaster, + }); err != nil { + ctx.logger.Error("store aspect meta failed", "error", err) + return nil, 0, err } + if err = metaStore.StoreProperties(newVersion, properties); err != nil { + ctx.logger.Error("store aspect property failed", "error", err) + return nil, 0, err + } + + // get remaining gas after updating store + gas = metaStore.Gas() + // initialize aspect aspectCtx := mustGetAspectContext(ctx.cosmosCtx) - runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectId.String(), newVersion.Uint64(), code, ctx.commit) + runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectID.String(), newVersion, code, ctx.commit) if err != nil { ctx.logger.Error("failed to create aspect runner", "error", err) return nil, 0, err @@ -107,10 +143,10 @@ func (h DeployHandler) Handle(ctx *HandlerContext, gas uint64) ([]byte, uint64, height := ctx.cosmosCtx.BlockHeight() heightU64 := uint64(height) - return runner.JoinPoint(artelasdkType.INIT_METHOD, gas, height, aspectId, &artelasdkType.InitInput{ + return runner.JoinPoint(artelasdkType.INIT_METHOD, gas, height, aspectID, &artelasdkType.InitInput{ Tx: &artelasdkType.WithFromTxInput{ Hash: txHash, - To: aspectId.Bytes(), + To: aspectID.Bytes(), From: ctx.from.Bytes(), }, Block: &artelasdkType.BlockInput{Number: &heightU64}, @@ -122,7 +158,15 @@ func (h DeployHandler) Method() string { return "deploy" } -func (h DeployHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.Address, code, initData []byte, properties []types.Property, joinPoint *big.Int, err error) { +func (h DeployHandler) decodeAndValidate(ctx *HandlerContext) ( + aspectId common.Address, + code, + initData []byte, + properties []aspectmoduletypes.Property, + joinPoint *big.Int, + paymaster common.Address, + proof []byte, + err error) { // input validations code = ctx.parameters["code"].([]byte) if len(code) == 0 { @@ -139,51 +183,27 @@ func (h DeployHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.A for i := range propertiesArr { s := propertiesArr[i] - if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { - // Block query of account and Proof - err = errors.New("using reserved aspect property key") - return - } - - properties = append(properties, types.Property{ + properties = append(properties, aspectmoduletypes.Property{ Key: s.Key, Value: s.Value, }) } - account := ctx.parameters["account"].(common.Address) - if bytes.Equal(account.Bytes(), ctx.from.Bytes()) { - accountProperty := types.Property{ - Key: types.AspectAccountKey, - Value: account.Bytes(), - } - properties = append(properties, accountProperty) - } else { + paymaster = ctx.parameters["account"].(common.Address) + if !bytes.Equal(paymaster.Bytes(), ctx.from.Bytes()) { err = errors.New("account verification fail") return } - proof := ctx.parameters["proof"].([]byte) - proofProperty := types.Property{ - Key: types.AspectProofKey, - Value: proof, - } - properties = append(properties, proofProperty) + proof = ctx.parameters["proof"].([]byte) joinPoint = ctx.parameters["joinPoints"].(*big.Int) if joinPoint == nil { - err = errors.New("unable to decode join point") - return + joinPoint = big.NewInt(0) } aspectId = crypto.CreateAddress(ctx.from, ctx.nonce) - // check duplicate deployment - if isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { - err = errors.New("aspect already deployed") - return - } - // validate aspect code code, err = validateCode(ctx.cosmosCtx, code) return @@ -192,45 +212,87 @@ func (h DeployHandler) decodeAndValidate(ctx *HandlerContext) (aspectId common.A type UpgradeHandler struct{} func (h UpgradeHandler) Handle(ctx *HandlerContext, gas uint64) ([]byte, uint64, error) { - aspectId, code, properties, joinPoint, gas, err := h.decodeAndValidate(ctx, gas) + aspectID, code, properties, joinPoint, err := h.decodeAndValidate(ctx) if err != nil { - return nil, gas, err + return nil, 0, err } - store := ctx.service.aspectStore - newVersion, gas, err := store.BumpAspectVersion(ctx.cosmosCtx, aspectId, gas) + // check deployment + storeCtx := buildAspectStoreCtx(ctx, aspectID, gas) + currentStore, _, err := store.GetAspectMetaStore(storeCtx) + if err != nil { + return nil, 0, err + } + + // check deployment + var latestVersion uint64 + if latestVersion, err = currentStore.GetLatestVersion(); err != nil { + return nil, 0, err + } else if latestVersion == 0 { + return nil, 0, errors.New("aspect not deployed") + } + + // check aspect owner + var currentCode []byte + currentCode, err = currentStore.GetCode(latestVersion) + if err != nil { + return nil, 0, err + } + + var ok bool + ok, gas, err = checkAspectOwner(ctx.cosmosCtx, aspectID, ctx.from, storeCtx.Gas(), currentCode, latestVersion, ctx.commit) + if err != nil || !ok { + err = errors.New("aspect ownership validation failed") + return nil, 0, err + } + storeCtx.UpdateGas(gas) + + // bump version + newVersion, err := currentStore.BumpVersion() if err != nil { ctx.logger.Error("bump aspect version failed", "error", err) return nil, gas, err } - if gas, err = store.StoreAspectCode(ctx.cosmosCtx, aspectId, code, newVersion, gas); err != nil { + if err = currentStore.StoreCode(newVersion, code); err != nil { ctx.logger.Error("store aspect code failed", "error", err) - return nil, gas, err + return nil, 0, err } // join point might be nil, since there are some operation only Aspects + var jpU64 uint64 if joinPoint != nil { - store.StoreAspectJP(ctx.cosmosCtx, aspectId, *newVersion, joinPoint) + jpU64 = joinPoint.Uint64() + } + + if err = currentStore.StoreVersionMeta(newVersion, &aspectmoduletypes.VersionMeta{ + JoinPoint: jpU64, + CodeHash: common.BytesToHash(crypto.Keccak256(code)), + }); err != nil { + ctx.logger.Error("store aspect meta failed", "error", err) + return nil, 0, err } - if len(properties) > 0 { - gas, err = store.StoreAspectProperty(ctx.cosmosCtx, aspectId, properties, gas) + // save properties if any + if err = currentStore.StoreProperties(newVersion, properties); err != nil { + ctx.logger.Error("store aspect property failed", "error", err) + return nil, 0, err } - return nil, gas, err + return nil, storeCtx.Gas(), err } func (h UpgradeHandler) Method() string { return "upgrade" } -func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) (aspectId common.Address, +func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext) ( + aspectID common.Address, code []byte, - properties []types.Property, - joinPoint *big.Int, leftover uint64, err error) { - aspectId = ctx.parameters["aspectId"].(common.Address) - if bytes.Equal(emptyAddr.Bytes(), aspectId.Bytes()) { + properties []aspectmoduletypes.Property, + joinPoint *big.Int, err error) { + aspectID = ctx.parameters["aspectId"].(common.Address) + if bytes.Equal(emptyAddr.Bytes(), aspectID.Bytes()) { err = errors.New("aspectId not specified") return } @@ -247,17 +309,10 @@ func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) (aspe Value []byte `json:"value"` }) - for i := range propertiesArr { - s := propertiesArr[i] - if types.AspectProofKey == s.Key || types.AspectAccountKey == s.Key { - // Block query of account and Proof - err = errors.New("using reserved aspect property key") - return - } - - properties = append(properties, types.Property{ - Key: s.Key, - Value: s.Value, + for _, prop := range propertiesArr { + properties = append(properties, aspectmoduletypes.Property{ + Key: prop.Key, + Value: prop.Value, }) } @@ -266,23 +321,6 @@ func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) (aspe joinPoint = big.NewInt(0) } - // check deployment - store := ctx.service.aspectStore - if !isAspectDeployed(ctx.cosmosCtx, store, aspectId) { - err = errors.New("aspect not deployed") - return - } - - // check aspect owner - currentCode, version := store.GetAspectCode(ctx.cosmosCtx, aspectId, nil) - - var ok bool - ok, leftover, err = checkAspectOwner(ctx.cosmosCtx, aspectId, ctx.from, gas, currentCode, version, ctx.commit) - if err != nil || !ok { - err = errors.New("aspect ownership validation failed") - return - } - // validate aspect code code, err = validateCode(ctx.cosmosCtx, code) return @@ -291,20 +329,41 @@ func (h UpgradeHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) (aspe type BindHandler struct{} func (b BindHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, account, aspectVersion, priority, isContract, leftover, err := b.decodeAndValidate(ctx, gas) + aspectID, account, aspectVersion, priority, isContract, leftover, err := b.decodeAndValidate(ctx, gas) if err != nil { - return nil, leftover, err + return nil, 0, err } - // check aspect types - store := ctx.service.aspectStore - aspectJP, err := store.GetAspectJP(ctx.cosmosCtx, aspectId, aspectVersion) + // no need to get new version store, since we only do auto migration during aspect upgrade + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, leftover)) if err != nil { - return nil, leftover, err + return nil, 0, err + } + + // get latest version if aspect version is empty + latestVersion, err := metaStore.GetLatestVersion() + if err != nil { + return nil, 0, err + } + if latestVersion == 0 { + return nil, 0, errors.New("aspect not deployed") } - txAspect := artelasdkType.CheckIsTransactionLevel(aspectJP.Int64()) - txVerifier := artelasdkType.CheckIsTxVerifier(aspectJP.Int64()) + if aspectVersion == 0 { + // use latest if not specified + aspectVersion = latestVersion + } else if aspectVersion > latestVersion { + return nil, 0, errors.New("aspect version not deployed") + } + + meta, err := metaStore.GetVersionMeta(aspectVersion) + if err != nil { + return nil, 0, err + } + + i64JP := int64(meta.JoinPoint) + txAspect := artelasdkType.CheckIsTransactionLevel(i64JP) + txVerifier := artelasdkType.CheckIsTxVerifier(i64JP) if !txAspect && !txVerifier { return nil, 0, errors.New("aspect is either for tx or verifier") @@ -315,28 +374,34 @@ func (b BindHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remain return nil, 0, errors.New("only verifier aspect can be bound with eoa") } - // bind tx processing aspect if account is a contract - if txAspect && isContract { - if err := store.BindTxAspect(ctx.cosmosCtx, account, aspectId, aspectVersion, priority); err != nil { - ctx.logger.Error("bind tx aspect failed", "aspect", aspectId.Hex(), "version", aspectVersion.Uint64(), "contract", account.Hex(), "error", err) - return nil, 0, err - } + // save aspect -> contract bindings + if err := metaStore.StoreBinding(account, aspectVersion, meta.JoinPoint, priority); err != nil { + return nil, 0, err } - // bind tx verifier aspect - if txVerifier { - if err := store.BindVerificationAspect(ctx.cosmosCtx, account, aspectId, aspectVersion, priority, isContract); err != nil { - ctx.logger.Error("bind verifier aspect failed", "aspect", aspectId.Hex(), "version", aspectVersion.Uint64(), "account", account.Hex(), "error", err) + // init account store + accountStore, _, err := store.GetAccountStore(buildAccountStoreCtx(ctx, account, metaStore.Gas())) + if err != nil { + return nil, 0, err + } + + // check if used + if used, err := accountStore.Used(); err != nil { + return nil, 0, err + } else if !used { + // init if not used + if err := accountStore.Init(); err != nil { return nil, 0, err } } - // save reverse index - if err := store.StoreAspectRefValue(ctx.cosmosCtx, account, aspectId); err != nil { + // save account -> contract bindings + if err := accountStore.StoreBinding(aspectID, aspectVersion, meta.JoinPoint, priority, isContract); err != nil { + ctx.logger.Error("bind tx aspect failed", "aspect", aspectID.Hex(), "version", aspectVersion, "contract", account.Hex(), "error", err) return nil, 0, err } - return nil, leftover, nil + return nil, accountStore.Gas(), nil } func (b BindHandler) Method() string { @@ -346,7 +411,7 @@ func (b BindHandler) Method() string { func (b BindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( aspectId common.Address, account common.Address, - aspectVersion *uint256.Int, + aspectVersion uint64, priority int8, isContract bool, leftover uint64, @@ -361,6 +426,10 @@ func (b BindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( if version != nil && version.Sign() < 0 { err = errors.New("aspectVersion is negative") return + } else if version == nil { + aspectVersion = 0 + } else { + aspectVersion = version.Uint64() } account = ctx.parameters["contract"].(common.Address) @@ -371,12 +440,6 @@ func (b BindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( priority = ctx.parameters["priority"].(int8) - store := ctx.service.aspectStore - if !isAspectDeployed(ctx.cosmosCtx, store, aspectId) { - err = errors.New("aspect not deployed") - return - } - isContract = len(ctx.evmState.GetCode(account)) > 0 if isContract { var isOwner bool @@ -392,41 +455,65 @@ func (b BindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( leftover = gas } - aspectVersion, _ = uint256.FromBig(version) - - // overwrite aspect version, just in case if aspect version is 0 which means we will need to overwrite - // it to latest - if aspectVersion == nil || aspectVersion.Cmp(zero) <= 0 { - aspectVersion = ctx.service.aspectStore.GetAspectLastVersion(ctx.cosmosCtx, aspectId) - } - return } type UnbindHandler struct{} func (u UnbindHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, account, isContract, leftover, err := u.decodeAndValidate(ctx, gas) + aspectID, account, isContract, leftover, err := u.decodeAndValidate(ctx, gas) if err != nil { return nil, leftover, err } - store := ctx.service.aspectStore + // init account store + accountStore, _, err := store.GetAccountStore(buildAccountStoreCtx(ctx, account, leftover)) + if err != nil { + return nil, 0, err + } - if err := store.UnBindVerificationAspect(ctx.cosmosCtx, account, aspectId); err != nil { - return nil, leftover, err + bindings, err := accountStore.LoadAccountBoundAspects(aspectmoduletypes.NewDefaultFilter(isContract)) + if err != nil { + return nil, 0, err } - if isContract { - if err := store.UnBindContractAspects(ctx.cosmosCtx, account, aspectId); err != nil { - return nil, leftover, err + + // looking for binding info + version := uint64(0) + for _, binding := range bindings { + if binding.Account == aspectID { + version = binding.Version + break } } - if err := store.UnbindAspectRefValue(ctx.cosmosCtx, account, aspectId); err != nil { - return nil, leftover, err + if version == 0 { + // not bound + return nil, accountStore.Gas(), nil + } + + // init aspect meta store + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, accountStore.Gas())) + if err != nil { + return nil, 0, err } - return nil, leftover, nil + // remove account from aspect bound list + if err := metaStore.RemoveBinding(account); err != nil { + return nil, 0, err + } + // load aspect join point + meta, err := metaStore.GetVersionMeta(version) + if err != nil { + return nil, 0, err + } + + // remove aspect from account bound list + accountStore.TransferGasFrom(metaStore) + if err := accountStore.RemoveBinding(aspectID, meta.JoinPoint, isContract); err != nil { + return nil, 0, err + } + + return nil, accountStore.Gas(), nil } func (u UnbindHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) ( @@ -470,30 +557,94 @@ func (u UnbindHandler) Method() string { type ChangeVersionHandler struct{} func (c ChangeVersionHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, account, version, isContract, leftover, err := c.decodeAndValidate(ctx, gas) + aspectID, account, version, isContract, leftover, err := c.decodeAndValidate(ctx, gas) if err != nil { return nil, leftover, err } - aspectJP, err := ctx.service.aspectStore.GetAspectJP(ctx.cosmosCtx, aspectId, uint256.NewInt(version)) + // init account store + accountStore, _, err := store.GetAccountStore(buildAccountStoreCtx(ctx, account, leftover)) if err != nil { - return nil, leftover, err + return nil, 0, err } - txAspect := artelasdkType.CheckIsTransactionLevel(aspectJP.Int64()) - verifierAspect := artelasdkType.CheckIsTxVerifier(aspectJP.Int64()) + bindings, err := accountStore.LoadAccountBoundAspects(aspectmoduletypes.NewDefaultFilter(isContract)) + if err != nil { + return nil, 0, err + } + + // looking for binding info + var bindingInfo *aspectmoduletypes.Binding + for _, binding := range bindings { + if binding.Account == aspectID { + bindingInfo = &binding + break + } + } - if !txAspect && !verifierAspect { - return nil, leftover, errors.New("aspect is either for tx or verifier") + if bindingInfo == nil { + // not bound + return nil, 0, errors.New("aspect not bound") } - if !verifierAspect && !isContract { + // init aspect meta store + metaStoreCtx := buildAspectStoreCtx(ctx, aspectID, accountStore.Gas()) + metaStore, _, err := store.GetAspectMetaStore(metaStoreCtx) + if err != nil { + return nil, 0, err + } + + // load current bound version aspect meta + currentVersionMeta, err := metaStore.GetVersionMeta(bindingInfo.Version) + if err != nil { + return nil, 0, err + } + + latestVersion, err := metaStore.GetLatestVersion() + if latestVersion == 0 { + return nil, 0, errors.New("aspect not deployed") + } + + if version > latestVersion { + return nil, 0, errors.New("given version of aspect does not exist") + } + + if version == 0 { + // use latest if not specified + version = latestVersion + } + + // load new aspect meta + newVersionMeta, err := metaStore.GetVersionMeta(version) + if err != nil { + return nil, 0, err + } + + i64JP := int64(newVersionMeta.JoinPoint) + txAspect := artelasdkType.CheckIsTransactionLevel(i64JP) + txVerifier := artelasdkType.CheckIsTxVerifier(i64JP) + + if !txAspect && !txVerifier { + return nil, 0, errors.New("aspect is either for tx or verifier") + } + + // EoA can only bind with tx verifier + if !txVerifier && !isContract { return nil, 0, errors.New("only verifier aspect can be bound with eoa") } - err = ctx.service.aspectStore.ChangeBoundAspectVersion(ctx.cosmosCtx, account, aspectId, version, isContract, verifierAspect, txAspect) - remainingGas = leftover - return + // remove old version aspect from account bound list + accountStore.TransferGasFrom(metaStore) + if err := accountStore.RemoveBinding(aspectID, currentVersionMeta.JoinPoint, isContract); err != nil { + return nil, 0, err + } + + // update new binding in account store + if err := accountStore.StoreBinding(aspectID, version, newVersionMeta.JoinPoint, bindingInfo.Priority, isContract); err != nil { + return nil, 0, err + } + + return nil, accountStore.Gas(), nil } func (c ChangeVersionHandler) Method() string { @@ -520,19 +671,7 @@ func (c ChangeVersionHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) return } - // should check whether expected version is greater than - // the latest version we have, if so, the designated aspect - // does not exist yet version = ctx.parameters["version"].(uint64) - store := ctx.service.aspectStore - latestVersion := store.GetAspectLastVersion(ctx.cosmosCtx, aspectId) - if latestVersion == nil || latestVersion.Cmp(zero) == 0 || latestVersion.Uint64() < version { - err = errors.New("given version of aspect does not exist") - return - } - if version == 0 { - version = latestVersion.Uint64() - } if isContract = len(ctx.evmState.GetCode(account)) > 0; isContract { var isOwner bool @@ -551,19 +690,28 @@ func (c ChangeVersionHandler) decodeAndValidate(ctx *HandlerContext, gas uint64) type GetVersionHandler struct{} func (g GetVersionHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, err := g.decodeAndValidate(ctx) + aspectID, err := g.decodeAndValidate(ctx) + if err != nil { + return nil, 0, err + } + + // no need to get new version store, since we only do auto migration during aspect upgrade + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, gas)) if err != nil { return nil, 0, err } - version := ctx.service.aspectStore.GetAspectLastVersion(ctx.cosmosCtx, aspectId) + version, err := metaStore.GetLatestVersion() + if err != nil { + return nil, 0, err + } - ret, err = ctx.abi.Outputs.Pack(version.Uint64()) + ret, err = ctx.abi.Outputs.Pack(version) if err != nil { return nil, gas, err } - return ret, gas, nil + return ret, metaStore.Gas(), nil } func (g GetVersionHandler) Method() string { @@ -588,49 +736,29 @@ func (g GetBindingHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, return nil, 0, err } - aspectInfo := make([]types.AspectInfo, 0) - deduplicationMap := make(map[common.Address]struct{}) + // init account store + accountStore, _, err := store.GetAccountStore(buildAccountStoreCtx(ctx, account, gas)) + if err != nil { + return nil, 0, err + } - accountVerifiers, err := ctx.service.aspectStore.GetVerificationAspects(ctx.cosmosCtx, account) + bindings, err := accountStore.LoadAccountBoundAspects(aspectmoduletypes.NewDefaultFilter(isContract)) if err != nil { return nil, 0, err } - for _, aspect := range accountVerifiers { - if _, exist := deduplicationMap[aspect.Id]; exist { - continue - } - deduplicationMap[aspect.Id] = struct{}{} + aspectInfo := make([]types.AspectInfo, 0) + for _, binding := range bindings { info := types.AspectInfo{ - AspectId: aspect.Id, - Version: aspect.Version.Uint64(), - Priority: int8(aspect.Priority), + AspectId: binding.Account, + Version: binding.Version, + Priority: binding.Priority, } aspectInfo = append(aspectInfo, info) } - if isContract { - txLevelAspects, err := ctx.service.aspectStore.GetTxLevelAspects(ctx.cosmosCtx, account) - if err != nil { - return nil, 0, err - } - - for _, aspect := range txLevelAspects { - if _, exist := deduplicationMap[aspect.Id]; exist { - continue - } - deduplicationMap[aspect.Id] = struct{}{} - info := types.AspectInfo{ - AspectId: aspect.Id, - Version: aspect.Version.Uint64(), - Priority: int8(aspect.Priority), - } - aspectInfo = append(aspectInfo, info) - } - } - ret, err = ctx.abi.Outputs.Pack(aspectInfo) - return ret, gas, err + return ret, accountStore.Gas(), err } func (g GetBindingHandler) Method() string { @@ -651,21 +779,32 @@ func (g GetBindingHandler) decodeAndValidate(ctx *HandlerContext) (account commo type GetBoundAddressHandler struct{} func (g GetBoundAddressHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, err := g.decodeAndValidate(ctx) + aspectID, err := g.decodeAndValidate(ctx) if err != nil { return nil, 0, err } - value, err := ctx.service.GetAspectOf(ctx.cosmosCtx, aspectId) + // init account store + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, gas)) if err != nil { return nil, 0, err } + + // check deployment + if latestVersion, err := metaStore.GetLatestVersion(); err != nil { + return nil, 0, err + } else if latestVersion == 0 { + return nil, 0, errors.New("aspect not deployed") + } + + bindings, err := metaStore.LoadAspectBoundAccounts() + if err != nil { + return nil, 0, err + } + addressArr := make([]common.Address, 0) - if value != nil { - for _, data := range value.Values() { - contractAddr := common.HexToAddress(data.(string)) - addressArr = append(addressArr, contractAddr) - } + for _, binding := range bindings { + addressArr = append(addressArr, binding.Account) } ret, err = ctx.abi.Outputs.Pack(addressArr) @@ -683,26 +822,38 @@ func (g GetBoundAddressHandler) decodeAndValidate(ctx *HandlerContext) (aspectId return } - if !isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { - err = errors.New("aspect not deployed") - } - return } type OperationHandler struct{} func (o OperationHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, remainingGas uint64, err error) { - aspectId, args, err := o.decodeAndValidate(ctx) + aspectID, args, err := o.decodeAndValidate(ctx) if err != nil { return nil, 0, err } lastHeight := ctx.cosmosCtx.BlockHeight() - code, version := ctx.service.GetAspectCode(ctx.cosmosCtx, aspectId, nil) + metaStore, _, err := store.GetAspectMetaStore(buildAspectStoreCtx(ctx, aspectID, gas)) + if err != nil { + return nil, 0, err + } + + // check deployment + latestVersion, err := metaStore.GetLatestVersion() + if err != nil { + return nil, 0, err + } else if latestVersion == 0 { + return nil, 0, errors.New("aspect not deployed") + } + + code, err := metaStore.GetCode(latestVersion) + if err != nil { + return nil, 0, err + } aspectCtx := mustGetAspectContext(ctx.cosmosCtx) - runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectId.String(), version.Uint64(), code, ctx.commit) + runner, err := run.NewRunner(aspectCtx, ctx.logger, aspectID.String(), latestVersion, code, ctx.commit) if err != nil { ctx.logger.Error("failed to create aspect runner", "error", err) return nil, 0, err @@ -715,10 +866,10 @@ func (o OperationHandler) Handle(ctx *HandlerContext, gas uint64) (ret []byte, r txHash = ethTxCtx.TxContent().Hash().Bytes() } height := uint64(lastHeight) - ret, remainingGas, err = runner.JoinPoint(artelasdkType.OPERATION_METHOD, gas, lastHeight, aspectId, &artelasdkType.OperationInput{ + ret, remainingGas, err = runner.JoinPoint(artelasdkType.OPERATION_METHOD, gas, lastHeight, aspectID, &artelasdkType.OperationInput{ Tx: &artelasdkType.WithFromTxInput{ Hash: txHash, - To: aspectId.Bytes(), + To: aspectID.Bytes(), From: ctx.from.Bytes(), }, Block: &artelasdkType.BlockInput{Number: &height}, @@ -745,29 +896,20 @@ func (o OperationHandler) decodeAndValidate(ctx *HandlerContext) (aspectId commo return } - if !isAspectDeployed(ctx.cosmosCtx, ctx.service.aspectStore, aspectId) { - err = errors.New("aspect not deployed") - return - } - args = ctx.parameters["optArgs"].([]byte) return } -func isAspectDeployed(ctx sdk.Context, store *AspectStore, aspectId common.Address) bool { - return store.GetAspectLastVersion(ctx, aspectId).Cmp(zero) > 0 -} - func validateCode(ctx sdk.Context, aspectCode []byte) ([]byte, error) { startTime := time.Now() - validator, err := runtime.NewValidator(ctx, artool.WrapLogger(ctx.Logger()), runtime.WASM) + validator, err := runtime.NewValidator(ctx, arttool.WrapLogger(ctx.Logger()), runtime.WASM) if err != nil { return nil, err } ctx.Logger().Info("validated aspect bytecode", "duration", time.Since(startTime).String()) startTime = time.Now() - parsed, err := ParseByteCode(aspectCode) + parsed, err := asptool.ParseByteCode(aspectCode) if err != nil { return nil, err } @@ -814,9 +956,9 @@ func checkContractOwner(ctx *HandlerContext, contractAddr common.Address, gas ui return result, leftover } -func checkAspectOwner(ctx sdk.Context, aspectId common.Address, sender common.Address, gas uint64, code []byte, version *uint256.Int, commit bool) (bool, uint64, error) { +func checkAspectOwner(ctx sdk.Context, aspectId common.Address, sender common.Address, gas uint64, code []byte, version uint64, commit bool) (bool, uint64, error) { aspectCtx := mustGetAspectContext(ctx) - runner, err := run.NewRunner(aspectCtx, artool.WrapLogger(ctx.Logger()), aspectId.String(), version.Uint64(), code, commit) + runner, err := run.NewRunner(aspectCtx, arttool.WrapLogger(ctx.Logger()), aspectId.String(), version, code, commit) if err != nil { panic(fmt.Sprintf("failed to create runner: %v", err)) } @@ -834,3 +976,17 @@ func mustGetAspectContext(ctx sdk.Context) *types.AspectRuntimeContext { return aspectCtx } + +func buildAspectStoreCtx(ctx *HandlerContext, aspectID common.Address, gas uint64) *aspectmoduletypes.AspectStoreContext { + return &aspectmoduletypes.AspectStoreContext{ + StoreContext: aspectmoduletypes.NewStoreContext(ctx.cosmosCtx, ctx.storeService, gas), + AspectID: aspectID, + } +} + +func buildAccountStoreCtx(ctx *HandlerContext, account common.Address, gas uint64) *aspectmoduletypes.AccountStoreContext { + return &aspectmoduletypes.AccountStoreContext{ + StoreContext: aspectmoduletypes.NewStoreContext(ctx.cosmosCtx, ctx.storeService, gas), + Account: account, + } +} diff --git a/x/evm/artela/contract/service.go b/x/evm/artela/contract/service.go deleted file mode 100644 index 66394e3..0000000 --- a/x/evm/artela/contract/service.go +++ /dev/null @@ -1,146 +0,0 @@ -package contract - -import ( - "math/big" - - "cosmossdk.io/core/store" - "cosmossdk.io/log" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/emirpasic/gods/sets/treeset" - "github.com/ethereum/go-ethereum/common" - "github.com/holiman/uint256" - "github.com/pkg/errors" - - artela "github.com/artela-network/aspect-core/types" - - evmtypes "github.com/artela-network/artela-rollkit/x/evm/artela/types" -) - -type AspectService struct { - aspectStore *AspectStore - getHeight evmtypes.GetLastBlockHeight -} - -func NewAspectService(storeService store.KVStoreService, - getHeight evmtypes.GetLastBlockHeight, logger log.Logger) *AspectService { - return &AspectService{ - aspectStore: NewAspectStore(storeService, logger), - getHeight: getHeight, - } -} - -func (service *AspectService) GetAspectOf(ctx sdk.Context, aspectId common.Address) (*treeset.Set, error) { - aspects, err := service.aspectStore.GetAspectRefValue(ctx, aspectId) - if err != nil { - return nil, errors.Wrap(err, "load aspect ref failed") - } - return aspects, nil -} - -func (service *AspectService) GetAspectCode(ctx sdk.Context, aspectId common.Address, version *uint256.Int) ([]byte, *uint256.Int) { - if version == nil || version.Cmp(zero) <= 0 { - version = service.aspectStore.GetAspectLastVersion(ctx, aspectId) - } - return service.aspectStore.GetAspectCode(ctx, aspectId, version) -} - -func (service *AspectService) GetBoundAspectForAddr(sdkCtx sdk.Context, to common.Address) ([]*artela.AspectCode, error) { - aspects, err := service.aspectStore.GetTxLevelAspects(sdkCtx, to) - if err != nil { - return nil, errors.Wrap(err, "load contract aspect binding failed") - } - aspectCodes := make([]*artela.AspectCode, 0, len(aspects)) - if aspects == nil { - return aspectCodes, nil - } - for _, aspect := range aspects { - codeBytes, ver := service.aspectStore.GetAspectCode(sdkCtx, aspect.Id, nil) - aspectCode := &artela.AspectCode{ - AspectId: aspect.Id.String(), - Priority: uint32(aspect.Priority), - Version: ver.Uint64(), - Code: codeBytes, - } - aspectCodes = append(aspectCodes, aspectCode) - } - return aspectCodes, nil -} - -// GetAspectsForJoinPoint BoundAspects get bound Aspects on previous block -func (service *AspectService) GetAspectsForJoinPoint(ctx sdk.Context, to common.Address, cut artela.PointCut) ([]*artela.AspectCode, error) { - aspects, err := service.aspectStore.GetTxLevelAspects(ctx, to) - - if err != nil { - return nil, errors.Wrap(err, "load contract aspect binding failed") - } - - aspectCodes := make([]*artela.AspectCode, 0, len(aspects)) - if aspects == nil { - return aspectCodes, nil - } - for _, aspect := range aspects { - // check if the Join point has run permissions - jp, err := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) - if err != nil { - return nil, err - } - - if !artela.CanExecPoint(jp.Int64(), cut) { - continue - } - codeBytes, ver := service.aspectStore.GetAspectCode(ctx, aspect.Id, nil) - aspectCode := &artela.AspectCode{ - AspectId: aspect.Id.String(), - Priority: uint32(aspect.Priority), - Version: ver.Uint64(), - Code: codeBytes, - } - aspectCodes = append(aspectCodes, aspectCode) - } - - return aspectCodes, nil -} - -// GetAccountVerifiers gets the bound Aspect verifier for the account -func (service *AspectService) GetAccountVerifiers(ctx sdk.Context, to common.Address) ([]*artela.AspectCode, error) { - aspects, err := service.aspectStore.GetVerificationAspects(ctx, to) - if err != nil { - return nil, errors.Wrap(err, "load contract aspect binding failed") - } - aspectCodes := make([]*artela.AspectCode, 0, len(aspects)) - if aspects == nil { - return aspectCodes, nil - } - for _, aspect := range aspects { - // check if the verify point has run permissions - jp, err := service.aspectStore.GetAspectJP(ctx, aspect.Id, nil) - if err != nil { - return nil, err - } - - if !artela.CanExecPoint(jp.Int64(), artela.VERIFY_TX) { - continue - } - codeBytes, ver := service.aspectStore.GetAspectCode(ctx, aspect.Id, nil) - aspectCode := &artela.AspectCode{ - AspectId: aspect.Id.String(), - Priority: uint32(aspect.Priority), - Version: ver.Uint64(), - Code: codeBytes, - } - aspectCodes = append(aspectCodes, aspectCode) - } - return aspectCodes, nil -} - -func (service *AspectService) GetBlockHeight() int64 { - return service.getHeight() -} - -func (service *AspectService) GetAspectJoinPoint(ctx sdk.Context, aspectId common.Address, version *uint256.Int) (*big.Int, error) { - - if version == nil { - version = service.aspectStore.GetAspectLastVersion(ctx, aspectId) - } - return service.aspectStore.GetAspectJP(ctx, aspectId, version) -} diff --git a/x/evm/artela/contract/store.go b/x/evm/artela/contract/store.go deleted file mode 100644 index 79c8761..0000000 --- a/x/evm/artela/contract/store.go +++ /dev/null @@ -1,663 +0,0 @@ -package contract - -import ( - "bytes" - "encoding/json" - "errors" - "math" - "math/big" - "sort" - "strings" - - "cosmossdk.io/core/store" - "cosmossdk.io/log" - "cosmossdk.io/store/prefix" - "github.com/cosmos/cosmos-sdk/runtime" - "github.com/emirpasic/gods/sets/treeset" - "github.com/holiman/uint256" - "golang.org/x/exp/slices" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" - - artelasdkType "github.com/artela-network/aspect-core/types" - runtimeTypes "github.com/artela-network/aspect-runtime/types" - - "github.com/artela-network/artela-rollkit/x/evm/artela/types" - evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" -) - -const ( - storageLoadCost = 50 - storageStoreCost = 20000 - storageSaveCodeCost = 1000 - storageUpdateCost = 5000 -) - -type gasMeter struct { - gas uint64 -} - -func newGasMeter(gas uint64) *gasMeter { - return &gasMeter{ - gas: gas, - } -} - -func (m *gasMeter) measureStorageUpdate(dataLen int) error { - return m.consume(dataLen, storageUpdateCost) -} - -func (m *gasMeter) measureStorageCodeSave(dataLen int) error { - return m.consume(dataLen, storageSaveCodeCost) -} - -func (m *gasMeter) measureStorageStore(dataLen int) error { - return m.consume(dataLen, storageStoreCost) -} - -func (m *gasMeter) measureStorageLoad(dataLen int) error { - return m.consume(dataLen, storageLoadCost) -} - -func (m *gasMeter) remainingGas() uint64 { - return m.gas -} - -func (m *gasMeter) consume(dataLen int, gasCostPer32Bytes uint64) error { - gas := ((uint64(dataLen) + 32) >> 5) * gasCostPer32Bytes - if m.gas < gas { - m.gas = 0 - return runtimeTypes.OutOfGasError - } - m.gas -= gas - return nil -} - -type AspectStore struct { - storeService store.KVStoreService - logger log.Logger -} - -type bindingQueryFunc func(sdk.Context, common.Address) ([]*types.AspectMeta, error) - -func NewAspectStore(storeService store.KVStoreService, logger log.Logger) *AspectStore { - return &AspectStore{ - storeService: storeService, - logger: logger, - } -} - -func (k *AspectStore) newPrefixStore(ctx sdk.Context, fixKey string) prefix.Store { - return prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), evmtypes.KeyPrefix(fixKey)) -} - -func (k *AspectStore) BumpAspectVersion(ctx sdk.Context, aspectID common.Address, gas uint64) (*uint256.Int, uint64, error) { - meter := newGasMeter(gas) - version := k.getAspectLastVersion(ctx, aspectID) - - newVersion := version.Add(version, uint256.NewInt(1)) - if err := k.storeAspectVersion(ctx, aspectID, newVersion, meter); err != nil { - return nil, meter.remainingGas(), err - } - - return newVersion, meter.remainingGas(), nil -} - -// StoreAspectCode aspect code -func (k *AspectStore) StoreAspectCode(ctx sdk.Context, aspectID common.Address, code []byte, version *uint256.Int, gas uint64) (uint64, error) { - meter := newGasMeter(gas) - if err := meter.measureStorageCodeSave(len(code)); err != nil { - return meter.remainingGas(), err - } - - // store code - codeStore := k.newPrefixStore(ctx, types.AspectCodeKeyPrefix) - versionKey := types.AspectVersionKey( - aspectID.Bytes(), - version.Bytes(), - ) - codeStore.Set(versionKey, code) - - k.logger.Info("saved aspect code", "id", aspectID.Hex(), "version", version.String()) - return meter.remainingGas(), nil -} - -func (k *AspectStore) GetAspectCode(ctx sdk.Context, aspectId common.Address, version *uint256.Int) ([]byte, *uint256.Int) { - codeStore := k.newPrefixStore(ctx, types.AspectCodeKeyPrefix) - if version == nil { - version = k.getAspectLastVersion(ctx, aspectId) - } - - if version.Cmp(zero) == 0 { - return nil, zero - } - - versionKey := types.AspectVersionKey( - aspectId.Bytes(), - version.Bytes(), - ) - code := codeStore.Get(versionKey) - - // stored code is already validated, so we can ignore the error here - parsed, _ := ParseByteCode(code) - - return parsed, version -} - -// storeAspectVersion version -func (k *AspectStore) storeAspectVersion(ctx sdk.Context, aspectId common.Address, version *uint256.Int, meter *gasMeter) error { - var err error - if version.Cmp(one) == 0 { - err = meter.measureStorageStore(32) - } else { - err = meter.measureStorageUpdate(32) - } - if err != nil { - return err - } - - versionStore := k.newPrefixStore(ctx, types.AspectCodeVersionKeyPrefix) - versionKey := types.AspectIDKey(aspectId.Bytes()) - versionStore.Set(versionKey, version.Bytes()) - - k.logger.Info("saved aspect version info", "id", aspectId.Hex(), "version", version.String()) - return nil -} - -func (k *AspectStore) GetAspectLastVersion(ctx sdk.Context, aspectId common.Address) *uint256.Int { - return k.getAspectLastVersion(ctx, aspectId) -} - -func (k *AspectStore) getAspectLastVersion(ctx sdk.Context, aspectId common.Address) *uint256.Int { - aspectVersionStore := k.newPrefixStore(ctx, types.AspectCodeVersionKeyPrefix) - versionKey := types.AspectIDKey(aspectId.Bytes()) - version := uint256.NewInt(0) - if data := aspectVersionStore.Get(versionKey); data != nil || len(data) > 0 { - version.SetBytes(data) - } - - return version -} - -// StoreAspectProperty -// -// @Description: property storage format -// 1. {aspectid,key}=>{prperty value} -// 2. {aspectid,"AspectPropertyAllKeyPrefix"}=>"key1,key2,key3..." -// @receiver k -// @param ctx -// @param aspectId -// @param prop -// @return error -func (k *AspectStore) StoreAspectProperty(ctx sdk.Context, aspectId common.Address, prop []types.Property, gas uint64) (uint64, error) { - meter := newGasMeter(gas) - if len(prop) == 0 { - return gas, nil - } - - // get treemap value - aspectConfigStore := k.newPrefixStore(ctx, types.AspectPropertyKeyPrefix) - // get all property key - propertyAllKey, err := k.getAspectPropertyValue(ctx, aspectId, types.AspectPropertyAllKeyPrefix, meter) - if err != nil { - return meter.remainingGas(), err - } - - keySet := treeset.NewWithStringComparator() - // add propertyAllKey to keySet - if len(propertyAllKey) > 0 { - splitData := strings.Split(string(propertyAllKey), types.AspectPropertyAllKeySplit) - for _, datum := range splitData { - keySet.Add(datum) - } - } - for i := range prop { - key := prop[i].Key - // add key and deduplicate - keySet.Add(key) - } - // check key limit - if keySet.Size() > types.AspectPropertyLimit { - return meter.remainingGas(), errors.New("aspect property limit exceeds") - } - - // store property key - for i := range prop { - key := prop[i].Key - value := prop[i].Value - - if err := meter.measureStorageCodeSave(len(key) + len(value)); err != nil { - k.logger.Error("unable to save property", "err", err, "key", key, "value", value) - return meter.remainingGas(), err - } - - // store - aspectPropertyKey := types.AspectPropertyKey( - aspectId.Bytes(), - []byte(key), - ) - - aspectConfigStore.Set(aspectPropertyKey, value) - - k.logger.Info("aspect property updated", "aspect", aspectId.Hex(), "key", key, "value", value) - } - - // store AspectPropertyAllKey - keyAry := make([]string, keySet.Size()) - for i, key := range keySet.Values() { - keyAry[i] = key.(string) - } - join := strings.Join(keyAry, types.AspectPropertyAllKeySplit) - allPropertyKeys := types.AspectPropertyKey( - aspectId.Bytes(), - []byte(types.AspectPropertyAllKeyPrefix), - ) - aspectConfigStore.Set(allPropertyKeys, []byte(join)) - - return meter.remainingGas(), nil -} - -func (k *AspectStore) GetAspectPropertyValue(ctx sdk.Context, aspectId common.Address, propertyKey string, gas uint64) ([]byte, uint64, error) { - meter := newGasMeter(gas) - value, err := k.getAspectPropertyValue(ctx, aspectId, propertyKey, meter) - return value, meter.remainingGas(), err -} - -func (k *AspectStore) getAspectPropertyValue(ctx sdk.Context, aspectId common.Address, propertyKey string, meter *gasMeter) ([]byte, error) { - codeStore := k.newPrefixStore(ctx, types.AspectPropertyKeyPrefix) - aspectPropertyKey := types.AspectPropertyKey( - aspectId.Bytes(), - []byte(propertyKey), - ) - - value := codeStore.Get(aspectPropertyKey) - return value, meter.measureStorageLoad(len(propertyKey) + len(value)) -} - -func (k *AspectStore) BindTxAspect(ctx sdk.Context, account common.Address, aspectId common.Address, aspectVersion *uint256.Int, priority int8) error { - return k.saveBindingInfo(ctx, account, aspectId, aspectVersion, priority, - k.GetTxLevelAspects, types.ContractBindKeyPrefix, math.MaxUint8) -} - -func (k *AspectStore) BindVerificationAspect(ctx sdk.Context, account common.Address, aspectId common.Address, aspectVersion *uint256.Int, priority int8, isContractAccount bool) error { - // EoA can have multiple verifiers - limit := math.MaxUint8 - if isContractAccount { - // contract can have only 1 verifier - limit = 1 - } - - return k.saveBindingInfo(ctx, account, aspectId, aspectVersion, priority, - k.GetVerificationAspects, types.VerifierBindingKeyPrefix, limit) -} - -func (k *AspectStore) saveBindingInfo(ctx sdk.Context, account common.Address, aspectId common.Address, - aspectVersion *uint256.Int, priority int8, queryBinding bindingQueryFunc, bindingNameSpace string, limit int, -) error { - // check aspect existence - code, version := k.GetAspectCode(ctx, aspectId, aspectVersion) - if code == nil || version == nil { - return errors.New("aspect not found") - } - - // get transaction level aspect binding relationships - bindings, err := queryBinding(ctx, account) - if err != nil { - return err - } - - if len(bindings) >= limit { - return errors.New("binding limit exceeded") - } - - // check duplicates - for _, binding := range bindings { - if bytes.Equal(binding.Id.Bytes(), aspectId.Bytes()) { - return errors.New("aspect already bound") - } - } - - newAspect := &types.AspectMeta{ - Id: aspectId, - Version: version, - Priority: int64(priority), - } - - bindings = append(bindings, newAspect) - - // re-sort aspects by priority - if limit != 1 { - sort.Slice(bindings, types.NewBindingPriorityComparator(bindings)) - } - - jsonBytes, err := json.Marshal(bindings) - if err != nil { - return err - } - - // save bindings - aspectBindingStore := k.newPrefixStore(ctx, bindingNameSpace) - aspectPropertyKey := types.AccountKey( - account.Bytes(), - ) - aspectBindingStore.Set(aspectPropertyKey, jsonBytes) - - k.logger.Info("binding info saved", - "aspect", aspectId.Hex(), - "contract", account.Hex(), - "bindings", string(jsonBytes), - ) - - return nil -} - -func (k *AspectStore) UnBindContractAspects(ctx sdk.Context, contract common.Address, aspectId common.Address) error { - txAspectBindings, err := k.GetTxLevelAspects(ctx, contract) - if err != nil { - return err - } - toDelete := slices.IndexFunc(txAspectBindings, func(meta *types.AspectMeta) bool { - return bytes.Equal(meta.Id.Bytes(), aspectId.Bytes()) - }) - if toDelete < 0 { - // not found - return nil - } - txAspectBindings = slices.Delete(txAspectBindings, toDelete, toDelete+1) - jsonBytes, err := json.Marshal(txAspectBindings) - if err != nil { - return err - } - // store - contractBindingStore := k.newPrefixStore(ctx, types.ContractBindKeyPrefix) - - aspectPropertyKey := types.AccountKey( - contract.Bytes(), - ) - contractBindingStore.Set(aspectPropertyKey, jsonBytes) - - k.logger.Info("tx aspect unbound", "aspect", aspectId.Hex(), "contract", contract.String()) - return nil -} - -func (k *AspectStore) GetTxLevelAspects(ctx sdk.Context, contract common.Address) ([]*types.AspectMeta, error) { - return k.getAccountBondAspects(ctx, contract, types.ContractBindKeyPrefix) -} - -func (k *AspectStore) GetVerificationAspects(ctx sdk.Context, account common.Address) ([]*types.AspectMeta, error) { - return k.getAccountBondAspects(ctx, account, types.VerifierBindingKeyPrefix) -} - -func (k *AspectStore) getAccountBondAspects(ctx sdk.Context, account common.Address, bindingPrefix string) ([]*types.AspectMeta, error) { - // retrieve raw binding store - aspectBindingStore := k.newPrefixStore(ctx, bindingPrefix) - accountKey := types.AccountKey( - account.Bytes(), - ) - rawJSON := aspectBindingStore.Get(accountKey) - - var bindings []*types.AspectMeta - if len(rawJSON) == 0 { - return bindings, nil - } - if err := json.Unmarshal(rawJSON, &bindings); err != nil { - return nil, errors.New("failed to unmarshal aspect bindings") - } - return bindings, nil -} - -func (k *AspectStore) ChangeBoundAspectVersion(ctx sdk.Context, account common.Address, aspectId common.Address, version uint64, isContract, verifierAspect, txAspect bool) error { - bindingStoreKeys := make([]string, 0, 2) - bindingStoreKeys = append(bindingStoreKeys, types.VerifierBindingKeyPrefix) - if isContract { - bindingStoreKeys = append(bindingStoreKeys, types.ContractBindKeyPrefix) - } - - bindings := make(map[string][]*types.AspectMeta, len(bindingStoreKeys)) - bindingIndex := make(map[string]int, len(bindingStoreKeys)) - - bound := false - var priority int8 - for _, bindingStoreKey := range bindingStoreKeys { - binding, err := k.getAccountBondAspects(ctx, account, bindingStoreKey) - if err != nil { - return err - } - bindings[bindingStoreKey] = binding - - for i, aspect := range binding { - if bytes.Equal(aspect.Id.Bytes(), aspectId.Bytes()) { - bindingIndex[bindingStoreKey] = i - bound = true - priority = int8(aspect.Priority) - break - } - } - } - - if !bound { - return errors.New("aspect not bound") - } - - newBindingTypes := make(map[string]bool, 2) - newBindingTypes[types.VerifierBindingKeyPrefix] = verifierAspect - newBindingTypes[types.ContractBindKeyPrefix] = txAspect - u256Version := uint256.NewInt(version) - - for bindingStoreKey, binding := range bindings { - updateIdx, ok := bindingIndex[bindingStoreKey] - if !ok { - // join-point in the new version aspect has been changed, we need to add the new binding type - if newBindingTypes[bindingStoreKey] { - var err error - if bindingStoreKey == types.ContractBindKeyPrefix { - err = k.BindTxAspect(ctx, account, aspectId, u256Version, priority) - } else { - err = k.BindVerificationAspect(ctx, account, aspectId, u256Version, priority, isContract) - } - if err != nil { - k.logger.Error("failed to add new aspect binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) - return err - } - k.logger.Info("added new binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) - } - continue - } - - // join-point in the new version aspect has been changed, we need to remove the non-exist binding type - if !newBindingTypes[bindingStoreKey] { - var unbind func(ctx sdk.Context, contract common.Address, aspectId common.Address) error - if bindingStoreKey == types.ContractBindKeyPrefix { - unbind = k.UnBindContractAspects - } else { - unbind = k.UnBindVerificationAspect - } - - if err := unbind(ctx, account, aspectId); err != nil { - k.logger.Error("failed to remove aspect binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) - return err - } - - k.logger.Info("removed binding type", "store", bindingStoreKey, "aspect", aspectId.Hex(), "version", version, "account", account.String()) - continue - } - - // join-point in the new version aspect not changed, we can just update the old one - oldVer := binding[updateIdx].Version.Uint64() - binding[updateIdx].Version = u256Version - - jsonBytes, err := json.Marshal(binding) - if err != nil { - return err - } - - bindingStore := k.newPrefixStore(ctx, bindingStoreKey) - bindingKey := types.AccountKey( - account.Bytes(), - ) - bindingStore.Set(bindingKey, jsonBytes) - - k.logger.Info("aspect bound version changed", "aspect", aspectId.Hex(), "account", account.String(), "old", oldVer, "new", version) - } - - return nil -} - -func (k *AspectStore) GetAspectRefValue(ctx sdk.Context, aspectId common.Address) (*treeset.Set, error) { - aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - aspectPropertyKey := types.AspectIDKey( - aspectId.Bytes(), - ) - - rawTree := aspectRefStore.Get(aspectPropertyKey) - if rawTree == nil { - return nil, nil - } - - set := treeset.NewWithStringComparator() - if err := set.UnmarshalJSON(rawTree); err != nil { - return nil, err - } - return set, nil -} - -func (k *AspectStore) StoreAspectRefValue(ctx sdk.Context, account common.Address, aspectId common.Address) error { - dataSet, err := k.GetAspectRefValue(ctx, aspectId) - if err != nil { - return err - } - if dataSet == nil { - dataSet = treeset.NewWithStringComparator() - } - dataSet.Add(account.String()) - jsonBytes, err := dataSet.MarshalJSON() - if err != nil { - return err - } - // store - aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - - aspectIdKey := types.AspectIDKey( - aspectId.Bytes(), - ) - aspectRefStore.Set(aspectIdKey, jsonBytes) - - k.logger.Info("aspect bound", "aspect", aspectId.Hex(), "account", account.Hex()) - return nil -} - -func (k *AspectStore) UnbindAspectRefValue(ctx sdk.Context, account common.Address, aspectId common.Address) error { - dataSet, err := k.GetAspectRefValue(ctx, aspectId) - if err != nil { - return err - } - if dataSet == nil { - return nil - } - // remove account - dataSet.Remove(account.String()) - // marshal set and put treemap with new blockHeight - jsonBytes, err := dataSet.MarshalJSON() - if err != nil { - return err - } - // store - aspectRefStore := k.newPrefixStore(ctx, types.AspectRefKeyPrefix) - aspectPropertyKey := types.AspectIDKey( - aspectId.Bytes(), - ) - aspectRefStore.Set(aspectPropertyKey, jsonBytes) - - k.logger.Info("aspect unbound", "aspect", aspectId.Hex(), "account", account.Hex()) - return nil -} - -func (k *AspectStore) UnBindVerificationAspect(ctx sdk.Context, account common.Address, aspectId common.Address) error { - bindings, err := k.GetVerificationAspects(ctx, account) - if err != nil { - return err - } - - toDelete := slices.IndexFunc(bindings, func(meta *types.AspectMeta) bool { - return bytes.Equal(meta.Id.Bytes(), aspectId.Bytes()) - }) - - if toDelete < 0 { - // not found - return nil - } - // delete existing - bindings = slices.Delete(bindings, toDelete, toDelete+1) - - sort.Slice(bindings, types.NewBindingPriorityComparator(bindings)) - jsonBytes, err := json.Marshal(bindings) - if err != nil { - return err - } - - // save bindings - aspectBindingStore := k.newPrefixStore(ctx, types.VerifierBindingKeyPrefix) - aspectPropertyKey := types.AccountKey( - account.Bytes(), - ) - aspectBindingStore.Set(aspectPropertyKey, jsonBytes) - - k.logger.Info("aspect unbound", "aspect", aspectId.Hex(), "account", account.String()) - return nil -} - -// StoreAspectJP -// -// @Description: Stores the execute conditions of the Aspect Join point. {aspectId,version,'AspectRunJoinPointKey'}==>{value} -// @receiver k -// @param ctx -// @param aspectId -// @param version: aspect version ,optional,Default Aspect last version -// @param point JoinPointRunType value, @see join_point_type.go -// @return bool Execute Result -func (k *AspectStore) StoreAspectJP(ctx sdk.Context, aspectId common.Address, version uint256.Int, point *big.Int) { - // check point - if _, ok := artelasdkType.CheckIsJoinPoint(point); !ok { - // Default store 0 - point = big.NewInt(0) - } - - aspectPropertyStore := k.newPrefixStore(ctx, types.AspectJoinPointRunKeyPrefix) - aspectPropertyKey := types.AspectArrayKey( - aspectId.Bytes(), - version.Bytes(), - []byte(types.AspectRunJoinPointKey), - ) - aspectPropertyStore.Set(aspectPropertyKey, point.Bytes()) -} - -// GetAspectJP -// -// @Description: get Aspect Join point run -// @receiver k -// @param ctx -// @param aspectId -// @param version -// @return *big.Int -func (k *AspectStore) GetAspectJP(ctx sdk.Context, aspectId common.Address, version *uint256.Int) (*big.Int, error) { - // Default last Aspect version - latestVersion := k.GetAspectLastVersion(ctx, aspectId) - if version == nil { - version = latestVersion - } else if version.Cmp(zero) < 0 || version.Cmp(latestVersion) > 0 { - return nil, errors.New("invalid aspect version") - } - - store := k.newPrefixStore(ctx, types.AspectJoinPointRunKeyPrefix) - aspectPropertyKey := types.AspectArrayKey( - aspectId.Bytes(), - version.Bytes(), - []byte(types.AspectRunJoinPointKey), - ) - jp := store.Get(aspectPropertyKey) - if len(jp) == 0 { - return new(big.Int), nil - } - return new(big.Int).SetBytes(jp), nil -} diff --git a/x/evm/artela/provider/artela.go b/x/evm/artela/provider/artela.go deleted file mode 100644 index 19f5959..0000000 --- a/x/evm/artela/provider/artela.go +++ /dev/null @@ -1,57 +0,0 @@ -package provider - -import ( - "context" - "errors" - - "cosmossdk.io/core/store" - "cosmossdk.io/log" - "github.com/ethereum/go-ethereum/common" - - asptypes "github.com/artela-network/aspect-core/types" - - "github.com/artela-network/artela-rollkit/x/evm/artela/contract" - "github.com/artela-network/artela-rollkit/x/evm/artela/types" -) - -var _ asptypes.AspectProvider = (*ArtelaProvider)(nil) - -type ArtelaProvider struct { - service *contract.AspectService - storeService store.KVStoreService -} - -func NewArtelaProvider(storeService store.KVStoreService, - getBlockHeight types.GetLastBlockHeight, - logger log.Logger, -) *ArtelaProvider { - service := contract.NewAspectService(storeService, getBlockHeight, logger) - - return &ArtelaProvider{service, storeService} -} - -func (j *ArtelaProvider) GetTxBondAspects(ctx context.Context, address common.Address, point asptypes.PointCut) ([]*asptypes.AspectCode, error) { - if ctx == nil { - return nil, errors.New("invalid Context") - } - aspectCtx, ok := ctx.(*types.AspectRuntimeContext) - if !ok { - return nil, errors.New("failed to unwrap AspectRuntimeContext from context.Context") - } - return j.service.GetAspectsForJoinPoint(aspectCtx.CosmosContext(), address, point) -} - -func (j *ArtelaProvider) GetAccountVerifiers(ctx context.Context, address common.Address) ([]*asptypes.AspectCode, error) { - if ctx == nil { - return nil, errors.New("invalid Context") - } - aspectCtx, ok := ctx.(*types.AspectRuntimeContext) - if !ok { - return nil, errors.New("failed to unwrap AspectRuntimeContext from context.Context") - } - return j.service.GetAccountVerifiers(aspectCtx.CosmosContext(), address) -} - -func (j *ArtelaProvider) GetLatestBlock() int64 { - return j.service.GetBlockHeight() -} diff --git a/x/evm/artela/types/aspect_store_key.go b/x/evm/artela/types/aspect_store_key.go deleted file mode 100644 index 7602462..0000000 --- a/x/evm/artela/types/aspect_store_key.go +++ /dev/null @@ -1,157 +0,0 @@ -package types - -import ( - "bytes" - "encoding/binary" - "math" - "strings" - - "github.com/emirpasic/gods/utils" - "github.com/holiman/uint256" - - "github.com/ethereum/go-ethereum/common" - - artela "github.com/artela-network/aspect-core/types" -) - -var _ binary.ByteOrder - -const ( - // AspectCodeKeyPrefix is the prefix to retrieve all AspectCodeStore - AspectCodeKeyPrefix = "AspectStore/Code/" - AspectCodeVersionKeyPrefix = "AspectStore/Version/" - AspectPropertyKeyPrefix = "AspectStore/Property/" - ContractBindKeyPrefix = "AspectStore/ContractBind/" - VerifierBindingKeyPrefix = "AspectStore/VerifierBind/" - AspectRefKeyPrefix = "AspectStore/AspectRef/" - AspectStateKeyPrefix = "AspectStore/State/" - - AspectJoinPointRunKeyPrefix = "AspectStore/JoinPointRun/" - - AspectIDMapKey = "aspectId" - VersionMapKey = "version" - PriorityMapKey = "priority" - - AspectAccountKey = "Aspect_@Acount@_" - AspectProofKey = "Aspect_@Proof@_" - AspectRunJoinPointKey = "Aspect_@Run@JoinPoint@_" - AspectPropertyAllKeyPrefix = "Aspect_@Property@AllKey@_" - AspectPropertyAllKeySplit = "^^^" - AspectPropertyLimit = math.MaxUint8 -) - -var ( - PathSeparator = []byte("/") - PathSeparatorLen = len(PathSeparator) -) - -func AspectArrayKey(keys ...[]byte) []byte { - var key []byte - for _, b := range keys { - key = append(key, b...) - key = append(key, PathSeparator...) - } - return key -} - -// AspectCodeStoreKey returns the store key to retrieve a AspectCodeStore from the index fields -func AspectPropertyKey( - aspectID []byte, - propertyKey []byte, -) []byte { - key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(propertyKey)) - - key = append(key, aspectID...) - key = append(key, PathSeparator...) - key = append(key, propertyKey...) - key = append(key, PathSeparator...) - - return key -} - -func AspectVersionKey( - aspectID []byte, - version []byte, -) []byte { - key := make([]byte, 0, len(aspectID)+PathSeparatorLen*2+len(version)) - - key = append(key, aspectID...) - key = append(key, PathSeparator...) - key = append(key, version...) - key = append(key, PathSeparator...) - - return key -} - -func AspectIDKey( - aspectID []byte, -) []byte { - key := make([]byte, 0, len(aspectID)+PathSeparatorLen) - key = append(key, aspectID...) - key = append(key, PathSeparator...) - - return key -} - -func AspectBlockKey() []byte { - var key []byte - key = append(key, []byte("AspectBlock")...) - key = append(key, PathSeparator...) - return key -} - -func AccountKey( - account []byte, -) []byte { - key := make([]byte, 0, len(account)+PathSeparatorLen) - key = append(key, account...) - key = append(key, PathSeparator...) - return key -} - -type AspectInfo struct { - AspectId common.Address `json:"AspectId"` - Version uint64 `json:"Version"` - Priority int8 `json:"Priority"` -} - -type AspectMeta struct { - Id common.Address `json:"id"` - Version *uint256.Int `json:"version"` - Priority int64 `json:"priority"` -} -type Property struct { - Key string `json:"Key"` - Value []byte `json:"Value"` -} - -type BoundAspectCode struct { - AspectId common.Address `json:"aspectId"` - Version *uint256.Int `json:"version"` - Priority int64 `json:"priority"` - Code []byte `json:"code"` -} - -func ByMapKeyPriority(a, b interface{}) int { - priorityA, ok := a.(map[string]interface{})[PriorityMapKey] - if !ok { - priorityA = 0 - } - priorityB, okb := b.(map[string]interface{})[PriorityMapKey] - if !okb { - priorityB = 1 - } - return utils.IntComparator(priorityA, priorityB) // "-" descending order -} - -func NewBindingPriorityComparator(x []*AspectMeta) func(i, j int) bool { - return func(i, j int) bool { - return x[i].Priority < x[j].Priority && (bytes.Compare(x[i].Id.Bytes(), x[j].Id.Bytes()) < 0) - } -} - -func NewBindingAspectPriorityComparator(x []*artela.AspectCode) func(i, j int) bool { - return func(i, j int) bool { - return (x[i].Priority < x[j].Priority) && (strings.Compare(x[i].AspectId, x[j].AspectId) < 0) - } -} diff --git a/x/evm/artela/types/context.go b/x/evm/artela/types/context.go index 3c04c49..f989ff3 100644 --- a/x/evm/artela/types/context.go +++ b/x/evm/artela/types/context.go @@ -2,27 +2,26 @@ package types import ( "context" + "encoding/hex" "fmt" "math/big" "sync" "time" - "cosmossdk.io/core/store" + cstore "cosmossdk.io/core/store" "cosmossdk.io/log" - "cosmossdk.io/store/prefix" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/runtime" cosmos "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" ethtypes "github.com/ethereum/go-ethereum/core/types" "github.com/artela-network/artela-evm/vm" + "github.com/artela-network/artela-rollkit/x/aspect/store" + "github.com/artela-network/artela-rollkit/x/aspect/types" + statedb "github.com/artela-network/artela-rollkit/x/evm/states" inherent "github.com/artela-network/aspect-core/chaincoreext/jit_inherent" artelatypes "github.com/artela-network/aspect-core/types" - - statedb "github.com/artela-network/artela-rollkit/x/evm/states" - evmtypes "github.com/artela-network/artela-rollkit/x/evm/types" ) const ( @@ -31,7 +30,7 @@ const ( AspectModuleName = "aspect" ) -var cachedStoreService store.KVStoreService +var cachedStoreService cstore.KVStoreService type GetLastBlockHeight func() int64 @@ -62,7 +61,7 @@ type AspectRuntimeContext struct { ethBlockContext *EthBlockContext aspectState *AspectState cosmosCtx *cosmos.Context - storeService store.KVStoreService + storeService cstore.KVStoreService logger log.Logger jitManager *inherent.Manager @@ -76,7 +75,7 @@ func NewAspectRuntimeContext() *AspectRuntimeContext { } } -func (c *AspectRuntimeContext) Init(storeService store.KVStoreService) { +func (c *AspectRuntimeContext) Init(storeService cstore.KVStoreService) { cachedStoreService = storeService c.storeService = storeService } @@ -104,7 +103,7 @@ func (c *AspectRuntimeContext) CosmosContext() cosmos.Context { return *c.cosmosCtx } -func (c *AspectRuntimeContext) StoreService() store.KVStoreService { +func (c *AspectRuntimeContext) StoreService() cstore.KVStoreService { return c.storeService } @@ -152,24 +151,31 @@ func (c *AspectRuntimeContext) ClearBlockContext() { } func (c *AspectRuntimeContext) CreateStateObject() { - c.aspectState = NewAspectState(*c.cosmosCtx, c.storeService, AspectStateKeyPrefix, c.logger) + c.aspectState = NewAspectState(*c.cosmosCtx, c.logger) +} + +func (c *AspectRuntimeContext) GetAspectProperty(ctx *artelatypes.RunnerContext, version uint64, key string) []byte { + metaStore, _, err := store.GetAspectMetaStore(&types.AspectStoreContext{ + StoreContext: types.NewGasFreeStoreContext(*c.cosmosCtx, cachedStoreService), + AspectID: ctx.AspectId, + }) + if err != nil { + panic(err) + } + + data, err := metaStore.GetProperty(version, key) + if err != nil { + panic(err) + } + return data } func (c *AspectRuntimeContext) GetAspectState(ctx *artelatypes.RunnerContext, key string) []byte { - stateKey := AspectArrayKey( - ctx.AspectId.Bytes(), - []byte(key), - ) - return c.aspectState.Get(stateKey) + return c.aspectState.Get(ctx.AspectId, key) } func (c *AspectRuntimeContext) SetAspectState(ctx *artelatypes.RunnerContext, key string, value []byte) { - stateKey := AspectArrayKey( - ctx.AspectId.Bytes(), - []byte(key), - ) - - c.aspectState.Set(stateKey, value) + c.aspectState.Set(ctx.AspectId, key, value) } func (c *AspectRuntimeContext) Destroy() { @@ -400,44 +406,65 @@ func (c *AspectContext) Clear() { } type AspectState struct { - state prefix.Store - storeService store.KVStoreService - logger log.Logger + + ctx cosmos.Context + storeCache map[common.Address]store.AspectStateStore } -func NewAspectState(ctx cosmos.Context, storeService store.KVStoreService, fixKey string, logger log.Logger) *AspectState { - cacheStore := prefix.NewStore(runtime.KVStoreAdapter(storeService.OpenKVStore(ctx)), evmtypes.KeyPrefix(fixKey)) +func NewAspectState(ctx cosmos.Context, logger log.Logger) *AspectState { stateObj := &AspectState{ - state: cacheStore, - storeService: storeService, - logger: logger, + ctx: ctx, + logger: logger, + + storeCache: make(map[common.Address]store.AspectStateStore), } return stateObj } -func (k *AspectState) Set(key, value []byte) { +func (k *AspectState) Set(aspectID common.Address, key string, value []byte) { + s := k.newStoreFromCache(aspectID) + action := "updated" if len(value) == 0 { - k.state.Delete(key) action = "deleted" - } else { - k.state.Set(key, value) } + s.SetState([]byte(key), value) + if value == nil { - k.logger.Debug("setState:", "action", action, "key", string(key), "value", "nil") + k.logger.Debug("setState:", "action", action, "key", key, "value", "nil") } else { - k.logger.Debug("setState:", "action", action, "key", string(key), "value", string(value)) + k.logger.Debug("setState:", "action", action, "key", key, "value", hex.EncodeToString(value)) } } -func (k *AspectState) Get(key []byte) []byte { - val := k.state.Get(key) +func (k *AspectState) Get(aspectID common.Address, key string) []byte { + s := k.newStoreFromCache(aspectID) + val := s.GetState([]byte(key)) + if val == nil { - k.logger.Debug("getState:", "key", string(key), "value", "nil") + k.logger.Debug("getState:", "key", key, "value", "nil") } else { - k.logger.Debug("getState:", "key", string(key), "value", string(val)) + k.logger.Debug("getState:", "key", key, "value", string(val)) } return val } + +func (k *AspectState) newStoreFromCache(aspectID common.Address) store.AspectStateStore { + s, ok := k.storeCache[aspectID] + if !ok { + var err error + s, err = store.GetAspectStateStore(&types.AspectStoreContext{ + StoreContext: types.NewGasFreeStoreContext(k.ctx, cachedStoreService), + AspectID: aspectID, + }) + if err != nil { + k.logger.Error("failed to get aspect state store", "err", err) + panic(err) + } + k.storeCache[aspectID] = s + } + + return s +} diff --git a/x/evm/artela/types/models.go b/x/evm/artela/types/models.go new file mode 100644 index 0000000..4cfc18d --- /dev/null +++ b/x/evm/artela/types/models.go @@ -0,0 +1,36 @@ +package types + +import ( + "bytes" + "github.com/ethereum/go-ethereum/common" + "github.com/holiman/uint256" +) + +type AspectInfo struct { + AspectId common.Address `json:"AspectId"` + Version uint64 `json:"Version"` + Priority int8 `json:"Priority"` +} + +type AspectMeta struct { + Id common.Address `json:"id"` + Version *uint256.Int `json:"version"` + Priority int64 `json:"priority"` +} +type Property struct { + Key string `json:"Key"` + Value []byte `json:"Value"` +} + +type BoundAspectCode struct { + AspectId common.Address `json:"aspectId"` + Version *uint256.Int `json:"version"` + Priority int64 `json:"priority"` + Code []byte `json:"code"` +} + +func NewBindingPriorityComparator(x []*AspectMeta) func(i, j int) bool { + return func(i, j int) bool { + return x[i].Priority < x[j].Priority && (bytes.Compare(x[i].Id.Bytes(), x[j].Id.Bytes()) < 0) + } +} diff --git a/x/evm/artela/types/treemap_test.go b/x/evm/artela/types/treemap_test.go deleted file mode 100644 index ce51eec..0000000 --- a/x/evm/artela/types/treemap_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package types - -import ( - "encoding/json" - "fmt" - "strings" - "testing" - - "github.com/emirpasic/gods/maps/hashmap" - "github.com/emirpasic/gods/maps/treemap" - pq "github.com/emirpasic/gods/queues/priorityqueue" -) - -func TestPriorityQueue(t *testing.T) { - /* a := BondAspect{AspectId: "1111", priority: 1} - b := BondAspect{AspectId: "22222", priority: -10} - c := BondAspect{AspectId: "3333", priority: 3} - */ - ma := make(map[string]interface{}, 2) - ma[AspectIDMapKey] = "1111" - ma[PriorityMapKey] = 1 - mb := make(map[string]interface{}, 2) - mb[AspectIDMapKey] = "2222" - mb[PriorityMapKey] = -10 - mc := make(map[string]interface{}, 2) - mc[AspectIDMapKey] = "3333" - mc[PriorityMapKey] = 3 - - queue := pq.NewWith(ByMapKeyPriority) // empty - queue.Enqueue(ma) // {a 1} - queue.Enqueue(mb) // {c 3}, {a 1} - queue.Enqueue(mc) // {c 3}, {b 2}, {a 1} - - values := queue.Values() - fmt.Println(values) - toJSON, _ := queue.MarshalJSON() - - queue2 := pq.NewWith(ByMapKeyPriority) - err := queue2.UnmarshalJSON(toJSON) - if err != nil { - fmt.Println(err) - } - v2 := queue2.Values() - fmt.Println(v2) - newQueue := pq.NewWith(ByMapKeyPriority) - - value, ok := queue.Dequeue() - for ok { - s, toStrOk := value.(map[string]interface{})["AspectId"].(string) - if toStrOk && strings.EqualFold("3333", s) { - break - } - newQueue.Enqueue(value) - value, ok = queue.Dequeue() - } - fmt.Println(newQueue.Values()) -} - -func TestTreemap(_ *testing.T) { - m := hashmap.New() - m.Put("a", "1") - m.Put("b", "2") - m.Put("c", "3") - - bytes, err := json.Marshal(m) // Same as "m.ToJSON(m)" - if err != nil { - fmt.Println(err) - } - fmt.Println(string(bytes)) - - hm := hashmap.New() - - err2 := json.Unmarshal(bytes, &hm) // Same as "hm.FromJSON(bytes)" - if err2 != nil { - fmt.Println(err2) - } - - fmt.Println(hm) // HashMap map[b:2 a:1] - - treem := treemap.NewWithIntComparator() // empty (keys are of type int) - treem.Put(1000, "v1.0") // 1->x - treem.Put(2000, "v2.0") // 1->x, 2->b (in order) - treem.Put(90000000, "a") - foundKey, foundValue := treem.Floor(4) - foundKey2, foundValue2 := treem.Floor(5) - foundKey3, foundValue3 := treem.Floor(6) - foundKey4, foundValue4 := treem.Floor(90000000) - foundKey5, foundValue5 := treem.Floor(90000001) - - bytes, err = json.Marshal(treem) // Same as "m.ToJSON(m)" - if err != nil { - fmt.Println(err) - } - fmt.Println(string(bytes)) - - comparator := treemap.NewWithIntComparator() - err = json.Unmarshal(bytes, &comparator) - if err != nil { - return - } - foundKey7, foundValue7 := comparator.Floor("90") - fmt.Print("%w, %w \n", foundKey, foundValue) - fmt.Print("%w, %w \n", foundKey2, foundValue2) - fmt.Print("%w, %w \n", foundKey3, foundValue3) - fmt.Print("%w, %w \n", foundKey4, foundValue4) - fmt.Print("%w, %w \n", foundKey5, foundValue5) - fmt.Print("%w, %w \n", foundKey7, foundValue7) - /* - m := treemap.NewWithIntComparator() // empty (keys are of type int) - m.Put(1, "x") // 1->x - m.Put(4, "b") // 1->x, 2->b (in order) - m.Put(90000000, "a") - - key, value := m.Floor(3) - key1, value1 := m.Floor(50) - fmt.Print("%w, %w \n", key, value) - fmt.Print("%w, %w \n", key1, value1) - bytes, err := json.Marshal(m) - if err == nil { - tree := treemap.NewWithIntComparator() - _ = json.Unmarshal(bytes, tree) - foundKey, foundValue := tree.Floor(90) - fmt.Print("%w, %w \n", foundKey, foundValue) - } - */ -} diff --git a/x/evm/keeper/aspect.go b/x/evm/keeper/aspect.go index 13ab50c..dc7a3d8 100644 --- a/x/evm/keeper/aspect.go +++ b/x/evm/keeper/aspect.go @@ -9,10 +9,6 @@ import ( artvmtype "github.com/artela-network/artela-rollkit/x/evm/artela/types" ) -func (k Keeper) GetAspectRuntimeContext() *artvmtype.AspectRuntimeContext { - return k.aspectRuntimeContext -} - func (k Keeper) JITSenderAspectByContext(ctx context.Context, userOpHash common.Hash) (common.Address, error) { return mustGetAspectCtx(ctx).JITManager().SenderAspect(userOpHash), nil } diff --git a/x/evm/keeper/evm.go b/x/evm/keeper/evm.go index 89fe74f..999d09c 100644 --- a/x/evm/keeper/evm.go +++ b/x/evm/keeper/evm.go @@ -385,7 +385,7 @@ func (k *Keeper) ApplyMessageWithConfig(ctx cosmos.Context, // if transaction is Aspect operational, short the circuit and skip the processes if isAspectOpTx := asptypes.IsAspectContractAddr(msg.To); isAspectOpTx { nativeContract := contract.NewAspectNativeContract(k.storeService, evm, - ctx.BlockHeight, stateDB, k.logger) + stateDB, k.logger) nativeContract.Init() ret, leftoverGas, vmErr = nativeContract.ApplyMessage(ctx, msg, leftoverGas, commit) } else if contractCreation { diff --git a/x/evm/keeper/keeper.go b/x/evm/keeper/keeper.go index 818d5f1..4b302b3 100644 --- a/x/evm/keeper/keeper.go +++ b/x/evm/keeper/keeper.go @@ -28,8 +28,8 @@ import ( "github.com/artela-network/artela-rollkit/common" artela "github.com/artela-network/artela-rollkit/ethereum/types" + "github.com/artela-network/artela-rollkit/x/aspect/provider" "github.com/artela-network/artela-rollkit/x/evm/artela/api" - "github.com/artela-network/artela-rollkit/x/evm/artela/provider" artvmtype "github.com/artela-network/artela-rollkit/x/evm/artela/types" "github.com/artela-network/artela-rollkit/x/evm/states" "github.com/artela-network/artela-rollkit/x/evm/txs" @@ -88,7 +88,6 @@ func NewKeeper( chainIDGetter types.ChainIDGetter, logger log.Logger, authority string, - ) Keeper { if _, err := sdk.AccAddressFromBech32(authority); err != nil { panic(fmt.Sprintf("invalid authority address: %s", authority)) @@ -100,7 +99,7 @@ func NewKeeper( } // init aspect - aspect := provider.NewArtelaProvider(storeService, artvmtype.GetLastBlockHeight(blockGetter), logger) + aspect := provider.NewArtelaProvider(storeService, artvmtype.GetLastBlockHeight(blockGetter)) // new Aspect Runtime Context aspectRuntimeContext := artvmtype.NewAspectRuntimeContext() aspectRuntimeContext.Init(storeService) @@ -198,7 +197,7 @@ func (k Keeper) EmitBlockBloomEvent(ctx sdk.Context, bloom ethereum.Bloom) { encodedBloom := base64.StdEncoding.EncodeToString(bloom.Bytes()) sprintf := fmt.Sprintf("emit block event %d bloom %s header %d, ", len(bloom.Bytes()), encodedBloom, ctx.BlockHeight()) - k.Logger().Info(sprintf) + k.Logger().Debug(sprintf) ctx.EventManager().EmitEvent( sdk.NewEvent( diff --git a/x/evm/keeper/msg_server_test.go b/x/evm/keeper/msg_server_test.go index 5d5f9cc..9a3c44e 100644 --- a/x/evm/keeper/msg_server_test.go +++ b/x/evm/keeper/msg_server_test.go @@ -13,7 +13,7 @@ import ( func setupMsgServer(t testing.TB) (keeper.Keeper, types.MsgServer, context.Context) { k, ctx := keepertest.EvmKeeper(t) - return k, keeper.NewMsgServerImpl(k), ctx + return k, keeper.NewMsgServerImpl(&k), ctx } func TestMsgServer(t *testing.T) { diff --git a/x/evm/module/genesis_test.go b/x/evm/module/genesis_test.go index 19ccc5b..01d917a 100644 --- a/x/evm/module/genesis_test.go +++ b/x/evm/module/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/artela-network/artela-rollkit/testutil/nullify" evm "github.com/artela-network/artela-rollkit/x/evm/module" "github.com/artela-network/artela-rollkit/x/evm/types" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/stretchr/testify/require" ) @@ -19,8 +20,9 @@ func TestGenesis(t *testing.T) { } k, ctx := keepertest.EvmKeeper(t) - evm.InitGenesis(ctx, k, genesisState) - got := evm.ExportGenesis(ctx, k) + ak := authkeeper.AccountKeeper{} + evm.InitGenesis(ctx, k, ak, genesisState) + got := evm.ExportGenesis(ctx, k, ak) require.NotNil(t, got) nullify.Fill(&genesisState) diff --git a/x/evm/module/module.go b/x/evm/module/module.go index 504b81c..174a3e4 100644 --- a/x/evm/module/module.go +++ b/x/evm/module/module.go @@ -17,6 +17,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/grpc-ecosystem/grpc-gateway/runtime" + // this line is used by starport scaffolding # 1 modulev1 "github.com/artela-network/artela-rollkit/api/artela/evm/module" @@ -205,6 +206,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs { if in.Config.Authority != "" { authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority) } + k := keeper.NewKeeper( in.Cdc, in.StoreService, diff --git a/x/fee/keeper/msg_update_params_test.go b/x/fee/keeper/msg_update_params_test.go index c5d2c47..a5dac79 100644 --- a/x/fee/keeper/msg_update_params_test.go +++ b/x/fee/keeper/msg_update_params_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + cosmos "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -12,7 +13,8 @@ import ( func TestMsgUpdateParams(t *testing.T) { k, ms, ctx := setupMsgServer(t) params := types.DefaultParams() - require.NoError(t, k.SetParams(ctx, params)) + sdkCtx := cosmos.UnwrapSDKContext(ctx) + require.NoError(t, k.SetParams(sdkCtx, params)) wctx := sdk.UnwrapSDKContext(ctx) // default params diff --git a/x/fee/types/genesis_test.go b/x/fee/types/genesis_test.go index 8be7553..01ff614 100644 --- a/x/fee/types/genesis_test.go +++ b/x/fee/types/genesis_test.go @@ -3,9 +3,9 @@ package types_test import ( "testing" - "artela/x/fee/types" - "github.com/stretchr/testify/require" + + "github.com/artela-network/artela-rollkit/x/fee/types" ) func TestGenesisState_Validate(t *testing.T) {