forked from cerc-io/laconicd-deprecated
lint: fix many broken lint issues (#49)
* lint: fix many broken lint issues * more lint issues resolved * more lint issues resolved * all actions issues fixed * pin variables for websocket * Update .github/workflows/lint.yml * more fixes * fix lint issues in pubsub, rpc, types * fix lint issues in statedb, journal, pubsub, cli * fix comment Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
co-authored by
Federico Kunze
parent
fcb7c114d0
commit
e3270aee5d
@@ -45,20 +45,3 @@ func formatKeyToHash(key string) string {
|
||||
|
||||
return ethkey.Hex()
|
||||
}
|
||||
|
||||
// nolint: deadcode
|
||||
func cosmosAddressFromArg(addr string) (sdk.AccAddress, error) {
|
||||
if strings.HasPrefix(addr, sdk.GetConfig().GetBech32AccountAddrPrefix()) {
|
||||
// Check to see if address is Cosmos bech32 formatted
|
||||
toAddr, err := sdk.AccAddressFromBech32(addr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "invalid bech32 formatted address")
|
||||
}
|
||||
return toAddr, nil
|
||||
}
|
||||
|
||||
// Strip 0x prefix if exists
|
||||
addr = strings.TrimPrefix(addr, "0x")
|
||||
|
||||
return sdk.AccAddressFromHex(addr)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@@ -10,6 +12,22 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
func cosmosAddressFromArg(addr string) (sdk.AccAddress, error) {
|
||||
if strings.HasPrefix(addr, sdk.GetConfig().GetBech32AccountAddrPrefix()) {
|
||||
// Check to see if address is Cosmos bech32 formatted
|
||||
toAddr, err := sdk.AccAddressFromBech32(addr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "invalid bech32 formatted address")
|
||||
}
|
||||
return toAddr, nil
|
||||
}
|
||||
|
||||
// Strip 0x prefix if exists
|
||||
addr = strings.TrimPrefix(addr, "0x")
|
||||
|
||||
return sdk.AccAddressFromHex(addr)
|
||||
}
|
||||
|
||||
func TestAddressFormats(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
@@ -340,7 +340,7 @@ func (k *Keeper) GetCommittedState(addr common.Address, hash common.Hash) common
|
||||
return common.BytesToHash(value)
|
||||
}
|
||||
|
||||
// GetState returns the commited state for the given key hash, as all changes are commited directly
|
||||
// GetState returns the committed state for the given key hash, as all changes are committed directly
|
||||
// to the KVStore.
|
||||
func (k *Keeper) GetState(addr common.Address, hash common.Hash) common.Hash {
|
||||
return k.GetCommittedState(addr, hash)
|
||||
|
||||
@@ -16,7 +16,7 @@ func NewAccessList(ethAccessList *ethtypes.AccessList) AccessList {
|
||||
return nil
|
||||
}
|
||||
|
||||
var AccessListMappings AccessList
|
||||
al := AccessList{}
|
||||
for _, tuple := range *ethAccessList {
|
||||
storageKeys := make([]string, len(tuple.StorageKeys))
|
||||
|
||||
@@ -24,19 +24,19 @@ func NewAccessList(ethAccessList *ethtypes.AccessList) AccessList {
|
||||
storageKeys[i] = tuple.StorageKeys[i].String()
|
||||
}
|
||||
|
||||
AccessListMappings = append(AccessListMappings, AccessTuple{
|
||||
al = append(al, AccessTuple{
|
||||
Address: tuple.Address.String(),
|
||||
StorageKeys: storageKeys,
|
||||
})
|
||||
}
|
||||
|
||||
return AccessListMappings
|
||||
return al
|
||||
}
|
||||
|
||||
// ToEthAccessList is an utility function to convert the protobuf compatible
|
||||
// AccessList to eth core AccessList from go-ethereum
|
||||
func (al AccessList) ToEthAccessList() *ethtypes.AccessList {
|
||||
var AccessListMappings ethtypes.AccessList
|
||||
var ethAccessList ethtypes.AccessList
|
||||
|
||||
for _, tuple := range al {
|
||||
storageKeys := make([]ethcmn.Hash, len(tuple.StorageKeys))
|
||||
@@ -45,11 +45,11 @@ func (al AccessList) ToEthAccessList() *ethtypes.AccessList {
|
||||
storageKeys[i] = ethcmn.HexToHash(tuple.StorageKeys[i])
|
||||
}
|
||||
|
||||
AccessListMappings = append(AccessListMappings, ethtypes.AccessTuple{
|
||||
ethAccessList = append(ethAccessList, ethtypes.AccessTuple{
|
||||
Address: ethcmn.HexToAddress(tuple.Address),
|
||||
StorageKeys: storageKeys,
|
||||
})
|
||||
}
|
||||
|
||||
return &AccessListMappings
|
||||
return ðAccessList
|
||||
}
|
||||
|
||||
@@ -191,13 +191,6 @@ type (
|
||||
// prev bool
|
||||
// prevDirty bool
|
||||
}
|
||||
accessListAddAccountChange struct {
|
||||
address *ethcmn.Address
|
||||
}
|
||||
accessListAddSlotChange struct {
|
||||
address *ethcmn.Address
|
||||
slot *ethcmn.Hash
|
||||
}
|
||||
)
|
||||
|
||||
func (ch createObjectChange) revert(s *CommitStateDB) {
|
||||
@@ -353,28 +346,3 @@ func (ch addPreimageChange) revert(s *CommitStateDB) {
|
||||
func (ch addPreimageChange) dirtied() *ethcmn.Address {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch accessListAddAccountChange) revert(s *CommitStateDB) {
|
||||
/*
|
||||
One important invariant here, is that whenever a (addr, slot) is added, if the
|
||||
addr is not already present, the add causes two journal entries:
|
||||
- one for the address,
|
||||
- one for the (address,slot)
|
||||
Therefore, when unrolling the change, we can always blindly delete the
|
||||
(addr) at this point, since no storage adds can remain when come upon
|
||||
a single (addr) change.
|
||||
*/
|
||||
// s.accessList.DeleteAddress(*ch.address)
|
||||
}
|
||||
|
||||
func (ch accessListAddAccountChange) dirtied() *ethcmn.Address {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ch accessListAddSlotChange) revert(s *CommitStateDB) {
|
||||
// s.accessList.DeleteSlot(*ch.address, *ch.slot)
|
||||
}
|
||||
|
||||
func (ch accessListAddSlotChange) dirtied() *ethcmn.Address {
|
||||
return nil
|
||||
}
|
||||
|
||||
+6
-18
@@ -127,49 +127,37 @@ func (csdb *CommitStateDB) SetParams(params Params) {
|
||||
// SetBalance sets the balance of an account.
|
||||
func (csdb *CommitStateDB) SetBalance(addr ethcmn.Address, amount *big.Int) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.SetBalance(amount)
|
||||
}
|
||||
so.SetBalance(amount)
|
||||
}
|
||||
|
||||
// AddBalance adds amount to the account associated with addr.
|
||||
func (csdb *CommitStateDB) AddBalance(addr ethcmn.Address, amount *big.Int) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.AddBalance(amount)
|
||||
}
|
||||
so.AddBalance(amount)
|
||||
}
|
||||
|
||||
// SubBalance subtracts amount from the account associated with addr.
|
||||
func (csdb *CommitStateDB) SubBalance(addr ethcmn.Address, amount *big.Int) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.SubBalance(amount)
|
||||
}
|
||||
so.SubBalance(amount)
|
||||
}
|
||||
|
||||
// SetNonce sets the nonce (sequence number) of an account.
|
||||
func (csdb *CommitStateDB) SetNonce(addr ethcmn.Address, nonce uint64) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.SetNonce(nonce)
|
||||
}
|
||||
so.SetNonce(nonce)
|
||||
}
|
||||
|
||||
// SetState sets the storage state with a key, value pair for an account.
|
||||
func (csdb *CommitStateDB) SetState(addr ethcmn.Address, key, value ethcmn.Hash) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.SetState(nil, key, value)
|
||||
}
|
||||
so.SetState(nil, key, value)
|
||||
}
|
||||
|
||||
// SetCode sets the code for a given account.
|
||||
func (csdb *CommitStateDB) SetCode(addr ethcmn.Address, code []byte) {
|
||||
so := csdb.GetOrNewStateObject(addr)
|
||||
if so != nil {
|
||||
so.SetCode(ethcrypto.Keccak256Hash(code), code)
|
||||
}
|
||||
so.SetCode(ethcrypto.Keccak256Hash(code), code)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user