Skip to content

Commit

Permalink
Merge pull request #125 from bnb-chain/develop
Browse files Browse the repository at this point in the history
release: draft the release v0.0.8
  • Loading branch information
unclezoro authored Mar 10, 2023
2 parents c65fdc3 + f9aaacc commit ce964e4
Show file tree
Hide file tree
Showing 37 changed files with 462 additions and 244 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ replace (

github.com/jhump/protoreflect => github.com/jhump/protoreflect v1.9.0

github.com/tendermint/tendermint => github.com/bnb-chain/gnfd-tendermint v0.0.2
github.com/tendermint/tendermint => github.com/bnb-chain/greenfield-tendermint v0.0.2
)

retract v0.46.2
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/bnb-chain/gnfd-tendermint v0.0.2 h1:2Oy7B5A7W/55teZNhlrFR9SamYNjCXAQNjwsbt534jM=
github.com/bnb-chain/gnfd-tendermint v0.0.2/go.mod h1:/v9z9F6cq0+f7EGG92lYSLBcPYQDILoK91X8YM28hWo=
github.com/bnb-chain/greenfield-tendermint v0.0.2 h1:SNb3C9QhYklaLgY6onimLHR42IlB6NQJvQqwmj/1ybM=
github.com/bnb-chain/greenfield-tendermint v0.0.2/go.mod h1:/v9z9F6cq0+f7EGG92lYSLBcPYQDILoK91X8YM28hWo=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/bradfitz/gomemcache v0.0.0-20170208213004-1952afaa557d/go.mod h1:PmM6Mmwb0LSuEubjR8N7PtNe1KxZLtOUHtbeikc5h60=
Expand Down
12 changes: 12 additions & 0 deletions math/uint.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ func (u *Uint) Unmarshal(data []byte) error {
return UintOverflow(u.i)
}

// Bytes returns the value of x as a big-endian byte slice.
func (u Uint) Bytes() []byte {
return u.i.Bytes()
}

// SetBytes interprets buf as the bytes of a big-endian unsigned
// integer, sets z to that value, and returns z.
func (u Uint) SetBytes(buf []byte) Uint {
u.i = u.i.SetBytes(buf)
return u
}

// Size implements the gogo proto custom type interface.
func (u *Uint) Size() int {
bz, _ := u.Marshal()
Expand Down
10 changes: 10 additions & 0 deletions math/uint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,13 @@ func TestWeakUnmarshalOverflow(t *testing.T) {
t.Fatalf("out of range value not reported, got instead %q", errStr)
}
}

func (s *uintTestSuite) TestUintBigEndian() {
u1 := sdkmath.NewUint(256)
u1b := u1.Bytes()

u2 := sdkmath.NewUint(0)
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
2 changes: 2 additions & 0 deletions proto/cosmos/crosschain/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ message EventCrossChain {
string relayer_fee = 8;
// Relayer fee for the ACK or FAIL_ACK package of this cross chain package
string ack_relayer_fee = 9;
// Callback gas price the ACK or FAIL_ACK package
string callback_gas_price = 10;
}
2 changes: 1 addition & 1 deletion proto/cosmos/crosschain/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ message QueryParamsResponse {
// QueryCrossChainPackageRequest is the request type for the Query/CrossChainPackage RPC method.
message QueryCrossChainPackageRequest {
uint32 channel_id = 1;
uint64 sequence = 2;
uint64 sequence = 2;
}

// QueryCrossChainPackageResponse is the response type for the Query/CrossChainPackage RPC method.
Expand Down
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
3 changes: 2 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 All @@ -27,4 +26,6 @@ message EventPackageClaim {
string relayer_fee = 9;
// Relayer fee paid for the ACK or FAIL_ACK package
string ack_relayer_fee = 10;
// Callback gas price the ACK or FAIL_ACK package
string callback_gas_price = 11;
}
16 changes: 8 additions & 8 deletions proto/cosmos/oracle/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ 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;
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;
}

// 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
25 changes: 10 additions & 15 deletions types/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"
"strings"
"sync"

"github.com/hashicorp/golang-lru/simplelru"
Expand Down Expand Up @@ -155,22 +153,22 @@ func MustAccAddressFromHex(address string) AccAddress {
// Note, this function is considered unsafe as it may produce an AccAddress from
// otherwise invalid input, such as a transaction hash.
func AccAddressFromHexUnsafe(address string) (AccAddress, error) {
addr := strings.ToLower(address)
if len(addr) >= 2 && addr[:2] == "0x" {
addr = addr[2:]
}
if len(strings.TrimSpace(addr)) == 0 {
if len(address) == 0 {
return AccAddress{}, ErrEmptyHexAddress
}
if length := len(addr); length != 2*EthAddressLength {
return AccAddress{}, fmt.Errorf("invalid address hex length: %v != %v", length, 2*EthAddressLength)

if len(address) >= 2 && address[0] == '0' && (address[1] == 'x' || address[1] == 'X') {
address = address[2:]
}
if len(address) != 2*EthAddressLength {
return AccAddress{}, fmt.Errorf("invalid address hex length: %v != %v", len(address), 2*EthAddressLength)
}

bz, err := hex.DecodeString(addr)
bz, err := hex.DecodeString(address)
if err != nil {
return AccAddress{}, err
}
return AccAddress(bz), nil
return bz, nil
}

// VerifyAddressFormat verifies that the provided bytes form a valid address
Expand Down Expand Up @@ -219,10 +217,7 @@ func (aa AccAddress) Equals(aa2 Address) bool {

// Returns boolean for whether an AccAddress is empty
func (aa AccAddress) Empty() bool {
addrValue := big.NewInt(0)
addrValue.SetBytes(aa[:])

return addrValue.Cmp(big.NewInt(0)) == 0
return len(aa) == 0
}

// Marshal returns the raw address bytes. It is needed for protobuf
Expand Down
10 changes: 10 additions & 0 deletions types/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,13 @@ func (s *addressTestSuite) TestGetFromBech32() {
s.Require().Error(err)
s.Require().Equal("invalid Bech32 prefix; expected x, got cosmos", err.Error())
}

func (s *addressTestSuite) TestAddressCases() {
addrStr1 := "0x17d749d3e2ac204a07e19d8096d9a05c423ea3af"
addr1, _ := types.AccAddressFromHexUnsafe(addrStr1)
s.Require().False(addr1.Empty())

addrStr2 := "0x17D749D3E2ac204a07e19D8096d9a05c423ea3af"
addr2, _ := types.AccAddressFromHexUnsafe(addrStr2)
s.Require().True(addr1.Equals(addr2))
}
Loading

0 comments on commit ce964e4

Please sign in to comment.