forked from cerc-io/laconicd-deprecated
Tools configuration and linters (#215)
* tools config * lint * lint * codecov
This commit is contained in:
@@ -28,10 +28,10 @@ type (
|
||||
func ValidateGenesis(data GenesisState) error {
|
||||
for _, acct := range data.Accounts {
|
||||
if len(acct.Address.Bytes()) == 0 {
|
||||
return fmt.Errorf("Invalid GenesisAccount Error: Missing Address")
|
||||
return fmt.Errorf("invalid GenesisAccount Error: Missing Address")
|
||||
}
|
||||
if acct.Balance == nil {
|
||||
return fmt.Errorf("Invalid GenesisAccount Error: Missing Balance")
|
||||
return fmt.Errorf("invalid GenesisAccount Error: Missing Balance")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -340,6 +340,7 @@ func TxDecoder(cdc *codec.Codec) sdk.TxDecoder {
|
||||
// returns the sender or an error.
|
||||
//
|
||||
// Ref: Ethereum Yellow Paper (BYZANTIUM VERSION 69351d5) Appendix F
|
||||
// nolint: gocritic
|
||||
func recoverEthSig(R, S, Vb *big.Int, sigHash ethcmn.Hash) (ethcmn.Address, error) {
|
||||
if Vb.BitLen() > 8 {
|
||||
return ethcmn.Address{}, errors.New("invalid signature")
|
||||
|
||||
+15
-10
@@ -42,7 +42,7 @@ func marshalAmino(td EncodableTxData) (string, error) {
|
||||
return string(bz), err
|
||||
}
|
||||
|
||||
func unmarshalAmino(td *EncodableTxData, text string) (err error) {
|
||||
func unmarshalAmino(td *EncodableTxData, text string) error {
|
||||
return cdc.UnmarshalBinaryBare([]byte(text), td)
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ func (td TxData) MarshalAmino() (string, error) {
|
||||
}
|
||||
|
||||
// UnmarshalAmino defines custom decoding scheme for TxData
|
||||
func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
func (td *TxData) UnmarshalAmino(text string) error {
|
||||
e := new(EncodableTxData)
|
||||
err = unmarshalAmino(e, text)
|
||||
err := unmarshalAmino(e, text)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
td.AccountNonce = e.AccountNonce
|
||||
@@ -82,8 +82,9 @@ func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
|
||||
price, err := utils.UnmarshalBigInt(e.Price)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if td.Price != nil {
|
||||
td.Price.Set(price)
|
||||
} else {
|
||||
@@ -92,8 +93,9 @@ func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
|
||||
amt, err := utils.UnmarshalBigInt(e.Amount)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if td.Amount != nil {
|
||||
td.Amount.Set(amt)
|
||||
} else {
|
||||
@@ -102,8 +104,9 @@ func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
|
||||
v, err := utils.UnmarshalBigInt(e.V)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if td.V != nil {
|
||||
td.V.Set(v)
|
||||
} else {
|
||||
@@ -112,8 +115,9 @@ func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
|
||||
r, err := utils.UnmarshalBigInt(e.R)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if td.R != nil {
|
||||
td.R.Set(r)
|
||||
} else {
|
||||
@@ -122,15 +126,16 @@ func (td *TxData) UnmarshalAmino(text string) (err error) {
|
||||
|
||||
s, err := utils.UnmarshalBigInt(e.S)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if td.S != nil {
|
||||
td.S.Set(s)
|
||||
} else {
|
||||
td.S = s
|
||||
}
|
||||
|
||||
return
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO: Implement JSON marshaling/ unmarshaling for this type
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/ethermint/crypto"
|
||||
"github.com/cosmos/ethermint/utils"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
@@ -36,12 +35,12 @@ func TestMsgEthereumTx(t *testing.T) {
|
||||
|
||||
func TestMsgEthereumTxValidation(t *testing.T) {
|
||||
testCases := []struct {
|
||||
payload []byte
|
||||
amount *big.Int
|
||||
gasPrice *big.Int
|
||||
gasLimit uint64
|
||||
nonce uint64
|
||||
to ethcmn.Address
|
||||
amount *big.Int
|
||||
gasLimit uint64
|
||||
gasPrice *big.Int
|
||||
payload []byte
|
||||
expectPass bool
|
||||
}{
|
||||
{amount: big.NewInt(100), gasPrice: big.NewInt(100000), expectPass: true},
|
||||
@@ -183,13 +182,13 @@ func TestMarshalAndUnmarshalLogs(t *testing.T) {
|
||||
|
||||
logs := []*ethtypes.Log{
|
||||
{
|
||||
Address: common.BytesToAddress([]byte{0x11}),
|
||||
TxHash: common.HexToHash("0x01"),
|
||||
Address: ethcmn.BytesToAddress([]byte{0x11}),
|
||||
TxHash: ethcmn.HexToHash("0x01"),
|
||||
// May need to find workaround since Topics is required to unmarshal from JSON
|
||||
Topics: []common.Hash{},
|
||||
Topics: []ethcmn.Hash{},
|
||||
Removed: true,
|
||||
},
|
||||
{Address: common.BytesToAddress([]byte{0x01, 0x11}), Topics: []common.Hash{}},
|
||||
{Address: ethcmn.BytesToAddress([]byte{0x01, 0x11}), Topics: []ethcmn.Hash{}},
|
||||
}
|
||||
|
||||
raw, err := codec.MarshalJSONIndent(cdc, logs)
|
||||
|
||||
@@ -51,22 +51,18 @@ type (
|
||||
// Account values can be accessed and modified through the object.
|
||||
// Finally, call CommitTrie to write the modified storage trie into a database.
|
||||
stateObject struct {
|
||||
address ethcmn.Address
|
||||
stateDB *CommitStateDB
|
||||
account *types.Account
|
||||
|
||||
code types.Code // contract bytecode, which gets set when code is loaded
|
||||
// DB error.
|
||||
// State objects are used by the consensus core and VM which are
|
||||
// unable to deal with database-level errors. Any error that occurs
|
||||
// during a database read is memoized here and will eventually be returned
|
||||
// by StateDB.Commit.
|
||||
dbErr error
|
||||
|
||||
code types.Code // contract bytecode, which gets set when code is loaded
|
||||
|
||||
dbErr error
|
||||
stateDB *CommitStateDB
|
||||
account *types.Account
|
||||
originStorage types.Storage // Storage cache of original entries to dedup rewrites
|
||||
dirtyStorage types.Storage // Storage entries that need to be flushed to disk
|
||||
|
||||
address ethcmn.Address
|
||||
// cache flags
|
||||
//
|
||||
// When an object is marked suicided it will be delete from the trie during
|
||||
|
||||
@@ -14,16 +14,16 @@ import (
|
||||
|
||||
// StateTransition defines data to transitionDB in evm
|
||||
type StateTransition struct {
|
||||
Sender common.Address
|
||||
AccountNonce uint64
|
||||
Price *big.Int
|
||||
GasLimit uint64
|
||||
Recipient *common.Address
|
||||
Amount *big.Int
|
||||
Payload []byte
|
||||
Csdb *CommitStateDB
|
||||
Recipient *common.Address
|
||||
AccountNonce uint64
|
||||
GasLimit uint64
|
||||
Price *big.Int
|
||||
Amount *big.Int
|
||||
ChainID *big.Int
|
||||
Csdb *CommitStateDB
|
||||
THash *common.Hash
|
||||
Sender common.Address
|
||||
Simulate bool
|
||||
}
|
||||
|
||||
|
||||
@@ -294,6 +294,7 @@ func (csdb *CommitStateDB) GetLogs(hash ethcmn.Hash) []*ethtypes.Log {
|
||||
|
||||
// Logs returns all the current logs in the state.
|
||||
func (csdb *CommitStateDB) Logs() []*ethtypes.Log {
|
||||
// nolint: prealloc
|
||||
var logs []*ethtypes.Log
|
||||
for _, lgs := range csdb.logs {
|
||||
logs = append(logs, lgs...)
|
||||
@@ -337,7 +338,7 @@ func (csdb *CommitStateDB) StorageTrie(addr ethcmn.Address) ethstate.Trie {
|
||||
// in the cache, it will either be removed, or have it's code set and/or it's
|
||||
// state (storage) updated. In addition, the state object (account) itself will
|
||||
// be written. Finally, the root hash (version) will be returned.
|
||||
func (csdb *CommitStateDB) Commit(deleteEmptyObjects bool) (root ethcmn.Hash, err error) {
|
||||
func (csdb *CommitStateDB) Commit(deleteEmptyObjects bool) (ethcmn.Hash, error) {
|
||||
defer csdb.clearJournalAndRefund()
|
||||
|
||||
// remove dirty state object entries based on the journal
|
||||
@@ -372,7 +373,7 @@ func (csdb *CommitStateDB) Commit(deleteEmptyObjects bool) (root ethcmn.Hash, er
|
||||
// NOTE: Ethereum returns the trie merkle root here, but as commitment
|
||||
// actually happens in the BaseApp at EndBlocker, we do not know the root at
|
||||
// this time.
|
||||
return
|
||||
return ethcmn.Hash{}, nil
|
||||
}
|
||||
|
||||
// Finalise finalizes the state objects (accounts) state by setting their state,
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/params"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
ethcmn "github.com/ethereum/go-ethereum/common"
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
@@ -79,7 +78,7 @@ func TestBloomFilter(t *testing.T) {
|
||||
|
||||
// Prepare db for logs
|
||||
tHash := ethcmn.BytesToHash([]byte{0x1})
|
||||
stateDB.Prepare(tHash, common.Hash{}, 0)
|
||||
stateDB.Prepare(tHash, ethcmn.Hash{}, 0)
|
||||
|
||||
contractAddress := ethcmn.BigToAddress(big.NewInt(1))
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ func DecodeReturnData(bytes []byte) (addr ethcmn.Address, bloom ethtypes.Bloom,
|
||||
bloom = ethtypes.BytesToBloom(bytes[bloomIdx:returnIdx])
|
||||
ret = bytes[returnIdx:]
|
||||
} else {
|
||||
err = fmt.Errorf("Invalid format for encoded data, message must be an EVM state transition")
|
||||
err = fmt.Errorf("invalid format for encoded data, message must be an EVM state transition")
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user