Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: e2ee module not up to date #1610

Merged
merged 17 commits into from
Sep 27, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [#1592](https://github.com/crypto-org-chain/cronos/pull/1592) Change the default parallelism of the block-stm to minimum between GOMAXPROCS and NumCPU
* [#1600](https://github.com/crypto-org-chain/cronos/pull/1600) Update ethermint to avoid unnecessary block result in header related api call.
* [#1606](https://github.com/crypto-org-chain/cronos/pull/1606) Fix pebbledb support.
* [#1610](https://github.com/crypto-org-chain/cronos/pull/1610) Sync e2ee module with v1.3.x branch.

### Bug Fixes

Expand Down
217 changes: 217 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,216 @@ info:
description: A REST interface for state queries
version: 1.0.0
paths:
/cronos/v1/blocklist:
get:
summary: BlockList
operationId: BlockList
responses:
'200':
description: A successful response.
schema:
type: object
properties:
blob:
type: string
format: byte
title: QueryBlockListResponse
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
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.


Schemes other than `http`, `https` (or the empty scheme)
might be

used with implementation specific semantics.
value:
type: string
format: byte
description: >-
Must be a valid serialized protocol buffer of the above
specified type.
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": <string>,
"lastName": <string>
}

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
/cronos/v1/contract_by_denom:
get:
summary: >-
Expand Down Expand Up @@ -44682,6 +44892,13 @@ definitions:
type: string
format: uint64
description: Params defines the parameters for the cronos module.
cronos.QueryBlockListResponse:
type: object
properties:
blob:
type: string
format: byte
title: QueryBlockListResponse
cronos.QueryParamsResponse:
type: object
properties:
Expand Down
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/test-go/testify v1.1.4
golang.org/x/crypto v0.27.0
google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094
google.golang.org/grpc v1.66.1
Expand Down
3 changes: 0 additions & 3 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,6 @@ schema = 3
[mod."github.com/tendermint/go-amino"]
version = "v0.16.0"
hash = "sha256-JW4zO/0vMzf1dXLePOqaMtiLUZgNbuIseh9GV+jQlf0="
[mod."github.com/test-go/testify"]
version = "v1.1.4"
hash = "sha256-8xygO1Rd4eTrmRe/g7zaifpNkeb6EmjNfUvTWbjDtPg="
[mod."github.com/tidwall/btree"]
version = "v0.0.0-20240406140148-2687063b042c"
hash = "sha256-8eDLGHhw4qXG6MEa7w5Q9KLwOobXr8Vn5qqyQhuipQw="
Expand Down
66 changes: 60 additions & 6 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ def tx_search_rpc(self, criteria: str, order=None):
assert "error" not in rsp, rsp["error"]
return rsp["result"]["txs"]

def query_account(self, addr, **kwargs):
return json.loads(
self.raw(
"query",
"auth",
"account",
addr,
home=self.data_dir,
**kwargs,
)
)

yihuang marked this conversation as resolved.
Show resolved Hide resolved
def distribution_commission(self, addr):
coin = json.loads(
self.raw(
Expand Down Expand Up @@ -353,7 +365,16 @@ def staking_pool(self, bonded=True):
res = res.get("pool") or res
return int(res["bonded_tokens" if bonded else "not_bonded_tokens"])

def transfer(self, from_, to, coins, generate_only=False, fees=None, **kwargs):
def transfer(
self,
from_,
to,
coins,
generate_only=False,
event_query_tx=True,
fees=None,
**kwargs,
):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
rsp = json.loads(
self.raw(
Expand All @@ -370,7 +391,7 @@ def transfer(self, from_, to, coins, generate_only=False, fees=None, **kwargs):
**kwargs,
)
)
if rsp["code"] == 0:
if rsp["code"] == 0 and event_query_tx:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

Expand Down Expand Up @@ -1699,6 +1720,24 @@ def update_permissions(self, address, permissions, **kwargs):
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def store_blocklist(self, data, **kwargs):
kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE)
kwargs.setdefault("gas", DEFAULT_GAS)
rsp = json.loads(
self.raw(
"tx",
"cronos",
"store-block-list",
data,
"-y",
home=self.data_dir,
**kwargs,
)
)
if rsp["code"] == 0:
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def rollback(self):
self.raw("rollback", home=self.data_dir)

Expand Down Expand Up @@ -1807,7 +1846,6 @@ def event_query_tx_for(self, hash):
"event-query-tx-for",
hash,
home=self.data_dir,
stderr=subprocess.DEVNULL,
)
)

Expand Down Expand Up @@ -1865,10 +1903,13 @@ def register_e2ee_key(self, key, **kwargs):
rsp = self.event_query_tx_for(rsp["txhash"])
return rsp

def keygen(self, **kwargs):
def e2ee_keygen(self, **kwargs):
return self.raw("e2ee", "keygen", home=self.data_dir, **kwargs).strip().decode()

def encrypt(self, input, *recipients, **kwargs):
def e2ee_pubkey(self, **kwargs):
return self.raw("e2ee", "pubkey", home=self.data_dir, **kwargs).strip().decode()

def e2ee_encrypt(self, input, *recipients, **kwargs):
return (
self.raw(
"e2ee",
Expand All @@ -1882,7 +1923,7 @@ def encrypt(self, input, *recipients, **kwargs):
.decode()
)

def decrypt(self, input, identity="e2ee-identity", **kwargs):
def e2ee_decrypt(self, input, identity="e2ee-identity", **kwargs):
return (
self.raw(
"e2ee",
Expand All @@ -1895,3 +1936,16 @@ def decrypt(self, input, identity="e2ee-identity", **kwargs):
.strip()
.decode()
)

def e2ee_encrypt_to_validators(self, input, **kwargs):
return (
self.raw(
"e2ee",
"encrypt-to-validators",
input,
home=self.data_dir,
**kwargs,
)
.strip()
.decode()
)
Loading
Loading