feat: use sdk.Int for TxData (#208)

* feat: use sdk.Int for TxData

* c++

* fix

* fix test

* fix rpc

* lint
This commit is contained in:
Federico Kunze Küllmer
2021-06-30 15:28:38 +00:00
committed by GitHub
parent 0113b4d2c0
commit 86e30e8fa3
24 changed files with 359 additions and 1085 deletions
+2 -9
View File
@@ -36,7 +36,7 @@ func (k Keeper) Account(c context.Context, req *types.QueryAccountRequest) (*typ
k.WithContext(ctx)
return &types.QueryAccountResponse{
Balance: k.GetBalance(addr).String(),
Balance: k.GetBalance(addr).Int64(),
CodeHash: k.GetCodeHash(addr).Hex(),
Nonce: k.GetNonce(addr),
}, nil
@@ -125,16 +125,9 @@ func (k Keeper) Balance(c context.Context, req *types.QueryBalanceRequest) (*typ
k.WithContext(ctx)
balanceInt := k.GetBalance(ethcmn.HexToAddress(req.Address))
balance, err := ethermint.MarshalBigInt(balanceInt)
if err != nil {
return nil, status.Error(
codes.Internal,
"failed to marshal big.Int to string",
)
}
return &types.QueryBalanceResponse{
Balance: balance,
Balance: balanceInt.Int64(),
}, nil
}
+17 -10
View File
@@ -32,10 +32,11 @@ func (suite *KeeperTestSuite) TestQueryAccount() {
malleate func()
expPass bool
}{
{"invalid address",
{
"invalid address",
func() {
expAccount = &types.QueryAccountResponse{
Balance: "0",
Balance: 0,
CodeHash: common.BytesToHash(ethcrypto.Keccak256(nil)).Hex(),
Nonce: 0,
}
@@ -49,10 +50,13 @@ func (suite *KeeperTestSuite) TestQueryAccount() {
"success",
func() {
amt := sdk.Coins{ethermint.NewPhotonCoinInt64(100)}
suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt)
err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
suite.Require().NoError(err)
err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt)
suite.Require().NoError(err)
expAccount = &types.QueryAccountResponse{
Balance: "100",
Balance: 100,
CodeHash: common.BytesToHash(ethcrypto.Keccak256(nil)).Hex(),
Nonce: 0,
}
@@ -164,7 +168,7 @@ func (suite *KeeperTestSuite) TestQueryCosmosAccount() {
func (suite *KeeperTestSuite) TestQueryBalance() {
var (
req *types.QueryBalanceRequest
expBalance string
expBalance int64
)
testCases := []struct {
@@ -174,7 +178,7 @@ func (suite *KeeperTestSuite) TestQueryBalance() {
}{
{"invalid address",
func() {
expBalance = "0"
expBalance = 0
req = &types.QueryBalanceRequest{
Address: invalidAddress,
}
@@ -185,9 +189,12 @@ func (suite *KeeperTestSuite) TestQueryBalance() {
"success",
func() {
amt := sdk.Coins{ethermint.NewPhotonCoinInt64(100)}
suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt)
expBalance = "100"
err := suite.app.BankKeeper.MintCoins(suite.ctx, types.ModuleName, amt)
suite.Require().NoError(err)
err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, suite.address.Bytes(), amt)
suite.Require().NoError(err)
expBalance = 100
req = &types.QueryBalanceRequest{
Address: suite.address.String(),
}
+151 -741
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -66,10 +66,10 @@ func (msg *MsgEthereumTx) FromEthereumTx(tx *ethtypes.Transaction) {
msg.Data.To = tx.To().Hex()
}
if tx.Value() != nil {
msg.Data.Amount = tx.Value().Bytes()
msg.Data.Amount = sdk.NewIntFromBigInt(tx.Value())
}
if tx.GasPrice() != nil {
msg.Data.GasPrice = tx.GasPrice().Bytes()
msg.Data.GasPrice = sdk.NewIntFromBigInt(tx.GasPrice())
}
if tx.AccessList() != nil {
al := tx.AccessList()
+20 -20
View File
@@ -66,24 +66,24 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_ValidateBasic() {
testCases := []struct {
msg string
to string
amount *big.Int
gasPrice *big.Int
amount sdk.Int
gasPrice sdk.Int
from string
accessList *ethtypes.AccessList
chainID *big.Int
chainID sdk.Int
expectPass bool
}{
{msg: "pass with recipient - Legacy Tx", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true},
{msg: "pass with recipient - AccessList Tx", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(0), accessList: &ethtypes.AccessList{}, chainID: big.NewInt(1), expectPass: true},
{msg: "pass contract - Legacy Tx", to: "", amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true},
{msg: "invalid recipient", to: invalidFromAddress, amount: big.NewInt(-1), gasPrice: big.NewInt(1000), expectPass: false},
{msg: "nil amount", to: suite.to.Hex(), amount: nil, gasPrice: big.NewInt(1000), expectPass: true},
{msg: "negative amount", to: suite.to.Hex(), amount: big.NewInt(-1), gasPrice: big.NewInt(1000), expectPass: true},
{msg: "nil gas price", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: nil, expectPass: false},
{msg: "negative gas price", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(-1), expectPass: true},
{msg: "zero gas price", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(0), expectPass: true},
{msg: "invalid from address", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(0), from: invalidFromAddress, expectPass: false},
{msg: "chain ID not set on AccessListTx", to: suite.to.Hex(), amount: big.NewInt(100), gasPrice: big.NewInt(0), accessList: &ethtypes.AccessList{}, chainID: nil, expectPass: false},
{msg: "pass with recipient - Legacy Tx", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.NewInt(100000), expectPass: true},
{msg: "pass with recipient - AccessList Tx", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.ZeroInt(), accessList: &ethtypes.AccessList{}, chainID: sdk.OneInt(), expectPass: true},
{msg: "pass contract - Legacy Tx", to: "", amount: sdk.NewInt(100), gasPrice: sdk.NewInt(100000), expectPass: true},
{msg: "invalid recipient", to: invalidFromAddress, amount: sdk.NewInt(-1), gasPrice: sdk.NewInt(1000), expectPass: false},
{msg: "nil amount", to: suite.to.Hex(), amount: sdk.Int{}, gasPrice: sdk.NewInt(1000), expectPass: true},
{msg: "negative amount", to: suite.to.Hex(), amount: sdk.NewInt(-1), gasPrice: sdk.NewInt(1000), expectPass: false},
{msg: "nil gas price", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.Int{}, expectPass: false},
{msg: "negative gas price", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.NewInt(-1), expectPass: false},
{msg: "zero gas price", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.ZeroInt(), expectPass: true},
{msg: "invalid from address", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.ZeroInt(), from: invalidFromAddress, expectPass: false},
{msg: "chain ID not set on AccessListTx", to: suite.to.Hex(), amount: sdk.NewInt(100), gasPrice: sdk.ZeroInt(), accessList: &ethtypes.AccessList{}, chainID: sdk.Int{}, expectPass: false},
}
for i, tc := range testCases {
@@ -96,17 +96,17 @@ func (suite *MsgsTestSuite) TestMsgEthereumTx_ValidateBasic() {
if tc.accessList != nil {
txData.Accesses = NewAccessList(tc.accessList)
if tc.chainID != nil {
txData.ChainID = tc.chainID.Bytes()
if !tc.chainID.IsNil() {
txData.ChainID = tc.chainID
}
}
if tc.amount != nil {
txData.Amount = tc.amount.Bytes()
if !tc.amount.IsNil() {
txData.Amount = tc.amount
}
if tc.gasPrice != nil {
txData.GasPrice = tc.gasPrice.Bytes()
if !tc.gasPrice.IsNil() {
txData.GasPrice = tc.gasPrice
}
msg := MsgEthereumTx{
+89 -121
View File
@@ -72,7 +72,7 @@ var xxx_messageInfo_QueryAccountRequest proto.InternalMessageInfo
// QueryAccountResponse is the response type for the Query/Account RPC method.
type QueryAccountResponse struct {
// balance is the balance of the EVM denomination.
Balance string `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"`
Balance int64 `protobuf:"varint,1,opt,name=balance,proto3" json:"balance,omitempty"`
// code hash is the hex-formatted code bytes from the EOA.
CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty"`
// nonce is the account's sequence number.
@@ -112,11 +112,11 @@ func (m *QueryAccountResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryAccountResponse proto.InternalMessageInfo
func (m *QueryAccountResponse) GetBalance() string {
func (m *QueryAccountResponse) GetBalance() int64 {
if m != nil {
return m.Balance
}
return ""
return 0
}
func (m *QueryAccountResponse) GetCodeHash() string {
@@ -381,7 +381,7 @@ var xxx_messageInfo_QueryBalanceRequest proto.InternalMessageInfo
// QueryBalanceResponse is the response type for the Query/Balance RPC method.
type QueryBalanceResponse struct {
// balance is the balance of the EVM denomination.
Balance string `protobuf:"bytes,1,opt,name=balance,proto3" json:"balance,omitempty"`
Balance int64 `protobuf:"varint,1,opt,name=balance,proto3" json:"balance,omitempty"`
}
func (m *QueryBalanceResponse) Reset() { *m = QueryBalanceResponse{} }
@@ -417,11 +417,11 @@ func (m *QueryBalanceResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_QueryBalanceResponse proto.InternalMessageInfo
func (m *QueryBalanceResponse) GetBalance() string {
func (m *QueryBalanceResponse) GetBalance() int64 {
if m != nil {
return m.Balance
}
return ""
return 0
}
// QueryStorageRequest is the request type for the Query/Storage RPC method.
@@ -1077,77 +1077,77 @@ func init() {
}
var fileDescriptor_8bbc79ec2b6c5cb2 = []byte{
// 1117 bytes of a gzipped FileDescriptorProto
// 1119 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x97, 0x4d, 0x6f, 0x1b, 0x45,
0x18, 0xc7, 0xbd, 0x8d, 0x13, 0x27, 0x4f, 0x12, 0x08, 0x83, 0x29, 0x61, 0x5b, 0x9c, 0xb0, 0xa8,
0xb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, 0xef, 0xa0, 0xdb, 0x49, 0xec, 0xfd, 0xd0, 0x73, 0x88, 0x1f, 0xd5, 0xb8, 0x33,
0xf4, 0x83, 0x06, 0x39, 0xf5, 0xf4, 0xa7, 0x0c, 0x44, 0x5c, 0x5b, 0x52, 0x06, 0x62, 0x44, 0x4d,
0x8c, 0x8a, 0x00, 0xdd, 0x43, 0x3b, 0x49, 0xa0, 0x4a, 0x5c, 0x58, 0xa4, 0xbd, 0x3f, 0x69, 0x90,
0x53, 0xb2, 0x90, 0x82, 0x16, 0x57, 0xa2, 0x14, 0xb4, 0x11, 0xa5, 0x31, 0xde, 0x11, 0x68, 0x65,
0x64, 0x25, 0xa1, 0x31, 0xe9, 0x30, 0x24, 0xb3, 0x4e, 0x8f, 0xc8, 0xc9, 0x19, 0xfa, 0x5a, 0x83,
0x2c, 0x17, 0x14, 0x54, 0x4a, 0x99, 0xba, 0x81, 0x56, 0xe9, 0xdb, 0x33, 0x58, 0x2a, 0x2c, 0x4b,
0x60, 0x6d, 0xa3, 0x62, 0xf2, 0x58, 0x36, 0x63, 0xed, 0xfa, 0x56, 0x83, 0x05, 0x29, 0x41, 0x68,
0x67, 0x6a, 0x9a, 0x98, 0xb6, 0xe9, 0xbb, 0x33, 0xd9, 0x2a, 0x28, 0x53, 0x40, 0x95, 0xd0, 0x56,
0x12, 0x94, 0x92, 0x09, 0xeb, 0x94, 0x8b, 0x94, 0xb8, 0xc2, 0xa5, 0x81, 0x9c, 0xa0, 0x9b, 0xd3,
0x47, 0x66, 0x44, 0xf6, 0x74, 0x73, 0x56, 0xf3, 0x59, 0x1f, 0x9d, 0x06, 0x77, 0x89, 0xf1, 0xfd,
0xa8, 0x01, 0x0c, 0x95, 0x02, 0xcd, 0x90, 0x31, 0x2a, 0x36, 0xba, 0x35, 0xb3, 0xbd, 0x42, 0xdc,
0x15, 0x88, 0x37, 0xd0, 0xeb, 0xd3, 0x11, 0x85, 0x32, 0xa1, 0x2f, 0x35, 0x58, 0x90, 0x3a, 0x92,
0x72, 0xa1, 0x31, 0xe9, 0x4a, 0xb9, 0xd0, 0xb8, 0xa0, 0x19, 0x5b, 0x02, 0x68, 0x13, 0x15, 0x92,
0x80, 0xa4, 0x74, 0x89, 0x46, 0x0d, 0xc5, 0x26, 0xa5, 0x51, 0x63, 0xfa, 0x96, 0xd2, 0xa8, 0x71,
0x15, 0x4b, 0x6f, 0x14, 0x13, 0x3e, 0x75, 0x1b, 0xbb, 0x6e, 0xb5, 0xfa, 0xf4, 0xbc, 0xa0, 0x3d,
0x3b, 0x2f, 0x68, 0x7f, 0x9d, 0x17, 0xb4, 0x6f, 0x2e, 0x0a, 0x99, 0x67, 0x17, 0x85, 0xcc, 0xef,
0x17, 0x85, 0xcc, 0xa7, 0x25, 0xa7, 0x1d, 0xb4, 0x7a, 0x0d, 0xd3, 0xa6, 0x1d, 0x2b, 0x68, 0x61,
0x9f, 0xb5, 0x59, 0x24, 0xe0, 0xb1, 0x08, 0x19, 0x9c, 0x74, 0x09, 0x6b, 0x2c, 0x88, 0x7f, 0x63,
0x6f, 0xfc, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x62, 0xa4, 0x45, 0x4d, 0x0e, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@@ -1676,12 +1676,10 @@ func (m *QueryAccountResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i--
dAtA[i] = 0x12
}
if len(m.Balance) > 0 {
i -= len(m.Balance)
copy(dAtA[i:], m.Balance)
i = encodeVarintQuery(dAtA, i, uint64(len(m.Balance)))
if m.Balance != 0 {
i = encodeVarintQuery(dAtA, i, uint64(m.Balance))
i--
dAtA[i] = 0xa
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
@@ -1876,12 +1874,10 @@ func (m *QueryBalanceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if len(m.Balance) > 0 {
i -= len(m.Balance)
copy(dAtA[i:], m.Balance)
i = encodeVarintQuery(dAtA, i, uint64(len(m.Balance)))
if m.Balance != 0 {
i = encodeVarintQuery(dAtA, i, uint64(m.Balance))
i--
dAtA[i] = 0xa
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
@@ -2377,9 +2373,8 @@ func (m *QueryAccountResponse) Size() (n int) {
}
var l int
_ = l
l = len(m.Balance)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
if m.Balance != 0 {
n += 1 + sovQuery(uint64(m.Balance))
}
l = len(m.CodeHash)
if l > 0 {
@@ -2474,9 +2469,8 @@ func (m *QueryBalanceResponse) Size() (n int) {
}
var l int
_ = l
l = len(m.Balance)
if l > 0 {
n += 1 + l + sovQuery(uint64(l))
if m.Balance != 0 {
n += 1 + sovQuery(uint64(m.Balance))
}
return n
}
@@ -2794,10 +2788,10 @@ func (m *QueryAccountResponse) Unmarshal(dAtA []byte) error {
}
switch fieldNum {
case 1:
if wireType != 2 {
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType)
}
var stringLen uint64
m.Balance = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
@@ -2807,24 +2801,11 @@ func (m *QueryAccountResponse) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
m.Balance |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Balance = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CodeHash", wireType)
@@ -3431,10 +3412,10 @@ func (m *QueryBalanceResponse) Unmarshal(dAtA []byte) error {
}
switch fieldNum {
case 1:
if wireType != 2 {
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType)
}
var stringLen uint64
m.Balance = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowQuery
@@ -3444,24 +3425,11 @@ func (m *QueryBalanceResponse) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
m.Balance |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthQuery
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthQuery
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Balance = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipQuery(dAtA[iNdEx:])
+16 -18
View File
@@ -3,9 +3,12 @@ package types
import (
"math/big"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/ethereum/go-ethereum/common"
ethtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/tharsis/ethermint/types"
)
@@ -31,20 +34,25 @@ func newTxData(
// NOTE: we don't populate chain id on LegacyTx type
if chainID != nil {
txData.ChainID = chainID.Bytes()
txData.ChainID = sdk.NewIntFromBigInt(chainID)
}
}
if amount != nil {
txData.Amount = amount.Bytes()
txData.Amount = sdk.NewIntFromBigInt(amount)
}
if gasPrice != nil {
txData.GasPrice = gasPrice.Bytes()
txData.GasPrice = sdk.NewIntFromBigInt(gasPrice)
}
return txData
}
func (data *TxData) txType() byte {
// Type returns the tx type
func (data TxData) Type() uint8 {
return data.txType()
}
func (data *TxData) txType() uint8 {
if data.Accesses == nil {
return ethtypes.LegacyTxType
}
@@ -57,11 +65,7 @@ func (data *TxData) chainID() *big.Int {
return DeriveChainID(v)
}
if data.ChainID == nil {
return nil
}
return new(big.Int).SetBytes(data.ChainID)
return data.ChainID.BigInt()
}
func (data *TxData) accessList() ethtypes.AccessList {
@@ -80,17 +84,11 @@ func (data *TxData) gas() uint64 {
}
func (data *TxData) gasPrice() *big.Int {
if data.GasPrice == nil {
return nil
}
return new(big.Int).SetBytes(data.GasPrice)
return data.GasPrice.BigInt()
}
func (data *TxData) amount() *big.Int {
if data.Amount == nil {
return nil
}
return new(big.Int).SetBytes(data.Amount)
return data.Amount.BigInt()
}
func (data *TxData) nonce() uint64 { return data.Nonce }
@@ -162,7 +160,7 @@ func (data *TxData) setSignatureValues(chainID, v, r, s *big.Int) {
data.S = s.Bytes()
}
if data.txType() == ethtypes.AccessListTxType && chainID != nil {
data.ChainID = chainID.Bytes()
data.ChainID = sdk.NewIntFromBigInt(chainID)
}
}
+5 -2
View File
@@ -4,8 +4,11 @@ import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common"
"github.com/tharsis/ethermint/tests"
)
@@ -16,7 +19,7 @@ func TestTxData_chainID(t *testing.T) {
expChainID *big.Int
}{
{
"access list tx", TxData{Accesses: AccessList{}, ChainID: big.NewInt(1).Bytes()}, big.NewInt(1),
"access list tx", TxData{Accesses: AccessList{}, ChainID: sdk.NewInt(1)}, big.NewInt(1),
},
{
"access list tx, nil chain ID", TxData{Accesses: AccessList{}}, nil,