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

release: draft release v0.0.11 #139

Merged
merged 5 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Changelog
## v0.0.11
This is a maintenance release.

* [\#135](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/135) fix: data race issue
* [\#134](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/134) feat: add gas params for new messages in storage module
* [\#133](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/133) feat: a relayer can relay cross chain tx in batch
* [\#136](https://github.com/bnb-chain/greenfield-cosmos-sdk/pull/136) fix: refine the code of crosschain and oracle module


## v0.0.10
This release reverts the unneeded changes.
Expand Down
1 change: 0 additions & 1 deletion math/uint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,4 @@ func (s *uintTestSuite) TestUintBigEndian() {
u2 = u2.SetBytes(u1b)

s.Require().Equal(u1, u2)

}
16 changes: 8 additions & 8 deletions proto/cosmos/auth/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ service Query {
option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts/{name}";
}

// // Bech32Prefix queries bech32Prefix
// //
// // Since: cosmos-sdk 0.46
// rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) {
// option (google.api.http).get = "/cosmos/auth/v1beta1/bech32";
// }
// // Bech32Prefix queries bech32Prefix
// //
// // Since: cosmos-sdk 0.46
// rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) {
// option (google.api.http).get = "/cosmos/auth/v1beta1/bech32";
// }

// AddressBytesToString converts Account Address bytes to string
//
Expand Down Expand Up @@ -138,12 +138,12 @@ message QueryModuleAccountByNameResponse {
//// Bech32PrefixRequest is the request type for Bech32Prefix rpc method.
////
//// Since: cosmos-sdk 0.46
//message Bech32PrefixRequest {}
// message Bech32PrefixRequest {}

//// Bech32PrefixResponse is the response type for Bech32Prefix rpc method.
////
//// Since: cosmos-sdk 0.46
//message Bech32PrefixResponse {
// message Bech32PrefixResponse {
// string bech32_prefix = 1;
//}

Expand Down
1 change: 1 addition & 0 deletions proto/cosmos/crosschain/v1/crosschain.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/crosschain/types";

// Params holds parameters for the cross chain module.
message Params {
// initial balance to mint for crosschain module when the chain starts
string init_module_balance = 1;
}
9 changes: 8 additions & 1 deletion proto/cosmos/crosschain/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,38 @@ message QueryParamsResponse {

// QueryCrossChainPackageRequest is the request type for the Query/CrossChainPackage RPC method.
message QueryCrossChainPackageRequest {
// channel id of the cross chain package
uint32 channel_id = 1;
uint64 sequence = 2;
// sequence of the cross chain package
uint64 sequence = 2;
}

// QueryCrossChainPackageResponse is the response type for the Query/CrossChainPackage RPC method.
message QueryCrossChainPackageResponse {
// content of the cross chain package
bytes package = 1;
}

// QuerySendSequenceRequest is the request type for the Query/SendSequence RPC method.
message QuerySendSequenceRequest {
// channel id of the cross chain package
uint32 channel_id = 1;
}

// QuerySendSequenceResponse is the response type for the Query/SendSequence RPC method.
message QuerySendSequenceResponse {
// sequence of the cross chain package
uint64 sequence = 1;
}

// QuerySendSequenceRequest is the request type for the Query/ReceiveSequence RPC method.
message QueryReceiveSequenceRequest {
// channel id of the cross chain package
uint32 channel_id = 1;
}

// QuerySendSequenceResponse is the response type for the Query/ReceiveSequence RPC method.
message QueryReceiveSequenceResponse {
// sequence of the cross chain package
uint64 sequence = 1;
}
2 changes: 1 addition & 1 deletion proto/cosmos/crypto/eth/bls/keys.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/eth/bls";

// PubKey defines a bls public key
// Key is the compressed form of the pubkey.
// Key is the compressed form of the pubkey.
message PubKey {
option (gogoproto.goproto_stringer) = false;

Expand Down
8 changes: 4 additions & 4 deletions proto/cosmos/gashub/v1alpha1/gashub.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ message Params {

// MsgGasParams defines gas for a msg type
message MsgGasParams {
option (gogoproto.equal) = true;
option (gogoproto.equal) = true;

string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"];
string msg_type_url = 1 [(gogoproto.customname) = "MsgTypeUrl"];
// gas_params is the oneof that represents either fixed_gas_params or dynamic_gas_params
oneof gas_params {
// fixed_type specifies fixed type gas params.
Expand All @@ -34,14 +34,14 @@ message MsgGasParams {
}
// FixedGasParams defines the parameters for fixed gas type.
message FixedGasParams {
option (gogoproto.equal) = true;
option (gogoproto.equal) = true;

uint64 fixed_gas = 1 [(gogoproto.customname) = "FixedGas"];
}

// DynamicGasParams defines the parameters for dynamic gas type.
message DynamicGasParams {
option (gogoproto.equal) = true;
option (gogoproto.equal) = true;

uint64 fixed_gas = 1 [(gogoproto.customname) = "FixedGas"];
uint64 gas_per_item = 2 [(gogoproto.customname) = "GasPerItem"];
Expand Down
2 changes: 1 addition & 1 deletion proto/cosmos/gashub/v1alpha1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ message MsgUpdateMsgGasParams {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
repeated MsgGasParams new_params_set = 2;
}

Expand Down
1 change: 0 additions & 1 deletion proto/cosmos/oracle/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
syntax = "proto3";
package cosmos.oracle.v1;


option go_package = "github.com/cosmos/cosmos-sdk/x/oracle/types";

// EventPackageClaim is emitted when a cross chain package is processed
Expand Down
10 changes: 8 additions & 2 deletions proto/cosmos/oracle/v1/oracle.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/oracle/types";
message Params {
// Timeout for the in turn relayer
uint64 relayer_timeout = 1; // in s
// Backoff time for the other relayers
uint64 relayer_backoff_time = 2; // in s
// RelayInterval is for in-turn relayer
uint64 relayer_interval = 2; // in s
// Reward share for the relayer sends the claim message,
// the other relayers signed the bls message will share the reward evenly.
uint32 relayer_reward_share = 3; // in percentage
}

// RelayInterval holds start and end(exclusive) time of in-turn relayer, [start, end)
message RelayInterval {
uint64 start = 1;
uint64 end = 2;
}
14 changes: 14 additions & 0 deletions proto/cosmos/oracle/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ service Query {
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/cosmos/oracle/v1/params";
}

// InturnRelayer returns the inturn relayer bls pub key and its relay interval
rpc InturnRelayer(QueryInturnRelayerRequest) returns (QueryInturnRelayerResponse) {
option (google.api.http).get = "/cosmos/oracle/v1/inturn_relayer";
}
}

// QueryParamsRequest is the request type for the Query/Params RPC method.
Expand All @@ -22,4 +27,13 @@ message QueryParamsRequest {}
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}

// QueryInturnRelayerRequest is the request type for the Query In-turn relayer RPC method.
message QueryInturnRelayerRequest {}

// QueryInturnRelayerResponse is the response type for the Query In-turn relayer RPC method.
message QueryInturnRelayerResponse {
string bls_pub_key = 1;
RelayInterval relay_interval = 2;
}
24 changes: 16 additions & 8 deletions proto/cosmos/oracle/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,22 @@ message MsgClaim {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint32 src_chain_id = 2;
uint32 dest_chain_id = 3;
uint64 sequence = 4;
uint64 timestamp = 5;
bytes payload = 6;
repeated fixed64 vote_address_set = 7;
bytes agg_signature = 8;
// sender address of the msg
string from_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// source chain id
uint32 src_chain_id = 2;
// destination chain id
uint32 dest_chain_id = 3;
// sequence of the oracle channel
uint64 sequence = 4;
// timestamp of the claim
uint64 timestamp = 5;
// payload of the claim
bytes payload = 6;
// bit map of the voted validators
repeated fixed64 vote_address_set = 7;
// bls signature of the claim
bytes agg_signature = 8;
}

// MsgClaimResponse defines the Msg/Claim response type
Expand Down
4 changes: 2 additions & 2 deletions proto/cosmos/params/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ message ParameterChangeProposal {
string title = 1;
string description = 2;
repeated ParamChange changes = 3 [(gogoproto.nullable) = false];
bool cross_chain = 4; // flag for cross chain proposal
repeated string addresses = 5; // used with cross_chain field to specify destination smart contract address(es)
bool cross_chain = 4; // flag for cross chain proposal
repeated string addresses = 5; // used with cross_chain field to specify destination smart contract address(es)
}

// ParamChange defines an individual parameter change, for use in
Expand Down
4 changes: 2 additions & 2 deletions proto/cosmos/slashing/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ message MsgImpeach {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string from = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

// MsgImpeachResponse defines the Msg/Impeach response type.
Expand Down
6 changes: 3 additions & 3 deletions proto/cosmos/staking/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ message MsgCreateValidator {

string from = 8 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string relayer_address = 9 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string relayer_bls_key = 10;
string relayer_bls_key = 10;
}

// MsgCreateValidatorResponse defines the Msg/CreateValidator response type.
Expand All @@ -87,8 +87,8 @@ message MsgEditValidator {
string min_self_delegation = 4
[(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int"];

string relayer_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string relayer_bls_key = 6; // The BLS pubkey for the authorized relayer
string relayer_address = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string relayer_bls_key = 6; // The BLS pubkey for the authorized relayer
}

// MsgEditValidatorResponse defines the Msg/EditValidator response type.
Expand Down
12 changes: 6 additions & 6 deletions proto/cosmos/tx/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,30 @@ message SignDocEip712 {
// chain_id is the identifier of the chain this transaction targets.
// It prevents signed transactions from being used on another chain by an
// attacker.
uint64 chain_id = 1[(gogoproto.jsontag) = "chain_id"];
uint64 chain_id = 1 [(gogoproto.jsontag) = "chain_id"];

// account_number is the account number of the account in state.
uint64 account_number = 2[(gogoproto.jsontag) = "account_number"];
uint64 account_number = 2 [(gogoproto.jsontag) = "account_number"];

// sequence is the sequence number of the signing account.
uint64 sequence = 3[(gogoproto.jsontag) = "sequence"];
uint64 sequence = 3 [(gogoproto.jsontag) = "sequence"];

// Fee is the fee and gas limit for the transaction. The first signer is the
// primary signer and the one which pays the fee. The fee can be calculated
// based on the cost of evaluating the body and doing signature verification
// of the signers. This can be estimated via simulation.
Fee fee = 4[(gogoproto.nullable) = false];
Fee fee = 4 [(gogoproto.nullable) = false];

// msg is the msg in the EIP712 transaction.
google.protobuf.Any msg = 5;

// timeout_height is the transaction's timeout height (if set).
uint64 timeout_height = 6[(gogoproto.jsontag) = "timeout_height"];
uint64 timeout_height = 6 [(gogoproto.jsontag) = "timeout_height"];

// memo is any arbitrary note/comment to be added to the transaction.
// WARNING: in clients, any publicly exposed text should not be called memo,
// but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122).
string memo = 7[(gogoproto.jsontag) = "memo"];
string memo = 7 [(gogoproto.jsontag) = "memo"];

// Tip is the optional tip used for transactions fees paid in another denom.
// It should be left empty if the signer is not the tipper for this
Expand Down
19 changes: 10 additions & 9 deletions x/auth/tx/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ import (
"github.com/gogo/protobuf/jsonpb"
)

var MsgCodec = jsonpb.Marshaler{
EmitDefaults: true,
OrigName: true,
}

var domain = apitypes.TypedDataDomain{
var domain = &apitypes.TypedDataDomain{
Name: "Greenfield Tx",
Version: "1.0.0",
VerifyingContract: "greenfield",
Expand Down Expand Up @@ -164,8 +159,13 @@ func WrapTxToTypedData(
signDoc *types.SignDocEip712,
msgTypes apitypes.Types,
) (apitypes.TypedData, error) {
msgCodec := jsonpb.Marshaler{
EmitDefaults: true,
OrigName: true,
}
bz, err := msgCodec.MarshalToString(signDoc)

var txData map[string]interface{}
bz, err := MsgCodec.MarshalToString(signDoc)
if err != nil {
return apitypes.TypedData{}, errors.Wrap(err, "failed to JSON marshal data")
}
Expand All @@ -180,11 +180,12 @@ func WrapTxToTypedData(
// filling nil value
cleanTypesAndMsgValue(msgTypes, "Msg", txData["msg"].(map[string]interface{}))

domain.ChainId = math.NewHexOrDecimal256(int64(chainID))
domainTemp := *domain
domainTemp.ChainId = math.NewHexOrDecimal256(int64(chainID))
typedData := apitypes.TypedData{
Types: msgTypes,
PrimaryType: "Tx",
Domain: domain,
Domain: domainTemp,
Message: txData,
}

Expand Down
2 changes: 1 addition & 1 deletion x/auth/tx/eip712_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tx
import (
"fmt"
"testing"
"time"

"github.com/stretchr/testify/require"

Expand All @@ -19,7 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/group"
"time"
)

func TestEIP712Handler(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions x/crosschain/types/crosschain.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions x/crosschain/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const (
SequenceLength = 8

GovChannelId = sdk.ChannelID(9)

QueryParameters = "parameters"
)

var (
Expand Down
Loading