Skip to content
Open
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
2 changes: 1 addition & 1 deletion .avalanche-golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ linters:
- predeclared
- revive
- spancheck
# - staticcheck
- staticcheck
- tagalign
# - testifylint
- unconvert
Expand Down
8 changes: 4 additions & 4 deletions accounts/abi/abi_extra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import (

// Note: This file contains tests in addition to those found in go-ethereum.

const TEST_ABI = `[{"type":"function","name":"receive","inputs":[{"name":"sender","type":"address"},{"name":"amount","type":"uint256"},{"name":"memo","type":"bytes"}],"outputs":[{"internalType":"bool","name":"isAllowed","type":"bool"}]}]`
const TestABI = `[{"type":"function","name":"receive","inputs":[{"name":"sender","type":"address"},{"name":"amount","type":"uint256"},{"name":"memo","type":"bytes"}],"outputs":[{"internalType":"bool","name":"isAllowed","type":"bool"}]}]`

func TestUnpackInputIntoInterface(t *testing.T) {
abi, err := JSON(strings.NewReader(TEST_ABI))
abi, err := JSON(strings.NewReader(TestABI))
require.NoError(t, err)

type inputType struct {
Expand All @@ -35,7 +35,7 @@ func TestUnpackInputIntoInterface(t *testing.T) {
rawData, err := abi.Pack("receive", input.Sender, input.Amount, input.Memo)
require.NoError(t, err)

abi, err = JSON(strings.NewReader(TEST_ABI))
abi, err = JSON(strings.NewReader(TestABI))
require.NoError(t, err)

for _, test := range []struct {
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestUnpackInputIntoInterface(t *testing.T) {
}

func TestPackOutput(t *testing.T) {
abi, err := JSON(strings.NewReader(TEST_ABI))
abi, err := JSON(strings.NewReader(TestABI))
require.NoError(t, err)

bytes, err := abi.PackOutput("receive", true)
Expand Down
2 changes: 0 additions & 2 deletions cmd/simulator/load/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,8 @@ func ExecuteLoader(ctx context.Context, config config.Config) error {
log.Info("Distributed funds successfully", "time", time.Since(fundStart))

pks := make([]*ecdsa.PrivateKey, 0, len(keys))
senders := make([]common.Address, 0, len(keys))
for _, key := range keys {
pks = append(pks, key.PrivKey)
senders = append(senders, key.Address)
}

bigGwei := big.NewInt(params.GWei)
Expand Down
2 changes: 1 addition & 1 deletion core/extstate/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func wrapIfFirewood(db state.Database) state.Database {
if !ok {
return db
}
return &firewoodAccessorDb{
return &firewoodAccessorDB{
Database: db,
fw: fw,
}
Expand Down
12 changes: 6 additions & 6 deletions core/extstate/firewood_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ import (
)

var (
_ state.Database = (*firewoodAccessorDb)(nil)
_ state.Database = (*firewoodAccessorDB)(nil)
_ state.Trie = (*firewood.AccountTrie)(nil)
_ state.Trie = (*firewood.StorageTrie)(nil)
)

type firewoodAccessorDb struct {
type firewoodAccessorDB struct {
state.Database
fw *firewood.Database
}

// OpenTrie opens the main account trie.
func (db *firewoodAccessorDb) OpenTrie(root common.Hash) (state.Trie, error) {
func (db *firewoodAccessorDB) OpenTrie(root common.Hash) (state.Trie, error) {
return firewood.NewAccountTrie(root, db.fw)
}

// OpenStorageTrie opens a wrapped version of the account trie.
//
//nolint:revive // removing names loses context.
func (*firewoodAccessorDb) OpenStorageTrie(stateRoot common.Hash, addr common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
func (*firewoodAccessorDB) OpenStorageTrie(stateRoot common.Hash, addr common.Address, accountRoot common.Hash, self state.Trie) (state.Trie, error) {
accountTrie, ok := self.(*firewood.AccountTrie)
if !ok {
return nil, fmt.Errorf("Invalid account trie type: %T", self)
return nil, fmt.Errorf("invalid account trie type: %T", self)
}
return firewood.NewStorageTrie(accountTrie)
}

// CopyTrie returns a deep copy of the given trie.
// It can be altered by the caller.
func (*firewoodAccessorDb) CopyTrie(t state.Trie) state.Trie {
func (*firewoodAccessorDB) CopyTrie(t state.Trie) state.Trie {
switch t := t.(type) {
case *firewood.AccountTrie:
return t.Copy()
Expand Down
6 changes: 3 additions & 3 deletions network/waiting_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ func (w *waitingResponseHandler) OnFailure() error {
return nil
}

func (waitingHandler *waitingResponseHandler) WaitForResult(ctx context.Context) ([]byte, error) {
func (w *waitingResponseHandler) WaitForResult(ctx context.Context) ([]byte, error) {
select {
case <-ctx.Done():
return nil, ctx.Err()
case response := <-waitingHandler.responseChan:
if waitingHandler.failed {
case response := <-w.responseChan:
if w.failed {
return nil, errRequestFailed
}
return response, nil
Expand Down
10 changes: 5 additions & 5 deletions params/extras/network_upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ func (n *NetworkUpgrades) SetDefaults(agoUpgrades upgrade.Config) {
func (n *NetworkUpgrades) verifyNetworkUpgrades(agoUpgrades upgrade.Config) error {
defaults := GetNetworkUpgrades(agoUpgrades)
if err := verifyWithDefault(n.SubnetEVMTimestamp, defaults.SubnetEVMTimestamp); err != nil {
return fmt.Errorf("SubnetEVM fork block timestamp is invalid: %w", err)
return fmt.Errorf("subnetEVM fork block timestamp is invalid: %w", err)
}
if err := verifyWithDefault(n.DurangoTimestamp, defaults.DurangoTimestamp); err != nil {
return fmt.Errorf("Durango fork block timestamp is invalid: %w", err)
return fmt.Errorf("durango fork block timestamp is invalid: %w", err)
}
if err := verifyWithDefault(n.EtnaTimestamp, defaults.EtnaTimestamp); err != nil {
return fmt.Errorf("Etna fork block timestamp is invalid: %w", err)
return fmt.Errorf("etna fork block timestamp is invalid: %w", err)
}
if err := verifyWithDefault(n.FortunaTimestamp, defaults.FortunaTimestamp); err != nil {
return fmt.Errorf("Fortuna fork block timestamp is invalid: %w", err)
return fmt.Errorf("fortuna fork block timestamp is invalid: %w", err)
}
if err := verifyWithDefault(n.GraniteTimestamp, defaults.GraniteTimestamp); err != nil {
return fmt.Errorf("Granite fork block timestamp is invalid: %w", err)
return fmt.Errorf("granite fork block timestamp is invalid: %w", err)
}
return nil
}
Expand Down
8 changes: 4 additions & 4 deletions plugin/evm/blockgascost/cost.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ func BlockGasCost(
}

var (
minBlockGasCost uint64 = feeConfig.MinBlockGasCost.Uint64()
maxBlockGasCost uint64 = feeConfig.MaxBlockGasCost.Uint64()
op = safemath.Add[uint64]
defaultCost uint64 = feeConfig.MaxBlockGasCost.Uint64()
minBlockGasCost = feeConfig.MinBlockGasCost.Uint64()
maxBlockGasCost = feeConfig.MaxBlockGasCost.Uint64()
op = safemath.Add[uint64]
defaultCost = feeConfig.MaxBlockGasCost.Uint64()
)
if timeElapsed > feeConfig.TargetBlockRate {
op = safemath.Sub
Expand Down
4 changes: 2 additions & 2 deletions plugin/evm/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ type client struct {

// NewClient returns a Client for interacting with EVM [chain]
func NewClient(uri, chain string) Client {
requestUri := fmt.Sprintf("%s/ext/bc/%s", uri, chain)
return NewClientWithURL(requestUri)
requestURI := fmt.Sprintf("%s/ext/bc/%s", uri, chain)
return NewClientWithURL(requestURI)
}

// NewClientWithURL returns a Client for interacting with EVM [chain]
Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ type Config struct {
WarpOffChainMessages []hexutil.Bytes `json:"warp-off-chain-messages"`

// RPC settings
HttpBodyLimit uint64 `json:"http-body-limit"`
HTTPBodyLimit uint64 `json:"http-body-limit"`
BatchRequestLimit uint64 `json:"batch-request-limit"`
BatchResponseMaxSize uint64 `json:"batch-response-max-size"`

Expand Down
2 changes: 1 addition & 1 deletion plugin/evm/customrawdb/database_ext.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func ParseStateSchemeExt(provided string, disk ethdb.Database) (string, error) {
if provided == FirewoodScheme {
if diskScheme := rawdb.ReadStateScheme(disk); diskScheme != "" {
// Valid scheme on disk mismatched
return "", fmt.Errorf("State scheme %s already set on disk, can't use Firewood", diskScheme)
return "", fmt.Errorf("state scheme %s already set on disk, can't use Firewood", diskScheme)
}
// If no conflicting scheme is found, is valid.
return FirewoodScheme, nil
Expand Down
18 changes: 9 additions & 9 deletions plugin/evm/database/wrapped_database.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ import (
)

var (
_ ethdb.KeyValueStore = (*ethDbWrapper)(nil)
_ ethdb.KeyValueStore = (*ethDBWrapper)(nil)

ErrSnapshotNotSupported = errors.New("snapshot is not supported")
)

// ethDbWrapper implements ethdb.Database
type ethDbWrapper struct{ database.Database }
type ethDBWrapper struct{ database.Database }

func WrapDatabase(db database.Database) ethdb.KeyValueStore { return ethDbWrapper{db} }
func WrapDatabase(db database.Database) ethdb.KeyValueStore { return ethDBWrapper{db} }

// Stat implements ethdb.Database
func (ethDbWrapper) Stat(string) (string, error) { return "", database.ErrNotFound }
func (ethDBWrapper) Stat(string) (string, error) { return "", database.ErrNotFound }

// NewBatch implements ethdb.Database
func (db ethDbWrapper) NewBatch() ethdb.Batch { return wrappedBatch{db.Database.NewBatch()} }
func (db ethDBWrapper) NewBatch() ethdb.Batch { return wrappedBatch{db.Database.NewBatch()} }

// NewBatchWithSize implements ethdb.Database
// TODO: propagate size through avalanchego Database interface
func (db ethDbWrapper) NewBatchWithSize(int) ethdb.Batch {
func (db ethDBWrapper) NewBatchWithSize(int) ethdb.Batch {
return wrappedBatch{db.Database.NewBatch()}
}

func (ethDbWrapper) NewSnapshot() (ethdb.Snapshot, error) {
func (ethDBWrapper) NewSnapshot() (ethdb.Snapshot, error) {
return nil, ErrSnapshotNotSupported
}

// NewIterator implements ethdb.Database
//
// Note: This method assumes that the prefix is NOT part of the start, so there's
// no need for the caller to prepend the prefix to the start.
func (db ethDbWrapper) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
func (db ethDBWrapper) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
// avalanchego's database implementation assumes that the prefix is part of the
// start, so it is added here (if it is provided).
if len(prefix) > 0 {
Expand All @@ -54,7 +54,7 @@ func (db ethDbWrapper) NewIterator(prefix []byte, start []byte) ethdb.Iterator {
}

// NewIteratorWithStart implements ethdb.Database
func (db ethDbWrapper) NewIteratorWithStart(start []byte) ethdb.Iterator {
func (db ethDBWrapper) NewIteratorWithStart(start []byte) ethdb.Iterator {
return db.Database.NewIteratorWithStart(start)
}

Expand Down
8 changes: 4 additions & 4 deletions plugin/evm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ var (

// legacyApiNames maps pre geth v1.10.20 api names to their updated counterparts.
// used in attachEthService for backward configuration compatibility.
var legacyApiNames = map[string]string{
var legacyAPINames = map[string]string{
"internal-public-eth": "internal-eth",
"internal-public-blockchain": "internal-blockchain",
"internal-public-transaction-pool": "internal-transaction",
Expand Down Expand Up @@ -1140,8 +1140,8 @@ func (vm *VM) CreateHandlers(context.Context) (map[string]http.Handler, error) {
if vm.config.BatchRequestLimit > 0 && vm.config.BatchResponseMaxSize > 0 {
handler.SetBatchLimits(int(vm.config.BatchRequestLimit), int(vm.config.BatchResponseMaxSize))
}
if vm.config.HttpBodyLimit > 0 {
handler.SetHTTPBodyLimit(int(vm.config.HttpBodyLimit))
if vm.config.HTTPBodyLimit > 0 {
handler.SetHTTPBodyLimit(int(vm.config.HTTPBodyLimit))
}

enabledAPIs := vm.config.EthAPIs()
Expand Down Expand Up @@ -1309,7 +1309,7 @@ func attachEthService(handler *rpc.Server, apis []rpc.API, names []string) error
for _, ns := range names {
// handle pre geth v1.10.20 api names as aliases for their updated values
// to allow configurations to be backwards compatible.
if newName, isLegacy := legacyApiNames[ns]; isLegacy {
if newName, isLegacy := legacyAPINames[ns]; isLegacy {
log.Info("deprecated api name referenced in configuration.", "deprecated", ns, "new", newName)
enabledServicesSet[newName] = struct{}{}
continue
Expand Down
15 changes: 3 additions & 12 deletions precompile/contracts/feemanager/unpack_pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ func FuzzPackGetFeeConfigOutputEqualTest(f *testing.F) {
MaxBlockGasCost: bigIntVal,
BlockGasCostStep: bigIntVal,
}
doCheckOutputs := true
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
doCheckOutputs := bigIntVal.Cmp(abi.MaxUint256) <= 0
testOldPackGetFeeConfigOutputEqual(t, feeConfig, doCheckOutputs)
})
}
Expand Down Expand Up @@ -173,13 +170,10 @@ func FuzzPackGetLastChangedAtOutput(f *testing.F) {
f.Add(math.MaxBig256.Add(math.MaxBig256, common.Big1).Bytes())
f.Fuzz(func(t *testing.T, bigIntBytes []byte) {
bigIntVal := new(big.Int).SetBytes(bigIntBytes)
doCheckOutputs := true
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
doCheckOutputs := bigIntVal.Cmp(abi.MaxUint256) <= 0
testOldPackGetLastChangedAtOutputEqual(t, bigIntVal, doCheckOutputs)
})
}
Expand All @@ -203,13 +197,10 @@ func FuzzPackSetFeeConfigEqualTest(f *testing.F) {
MaxBlockGasCost: bigIntVal,
BlockGasCostStep: bigIntVal,
}
doCheckOutputs := true
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
doCheckOutputs := bigIntVal.Cmp(abi.MaxUint256) <= 0
testOldPackSetFeeConfigInputEqual(t, feeConfig, doCheckOutputs)
})
}
Expand Down
5 changes: 1 addition & 4 deletions precompile/contracts/nativeminter/unpack_pack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ func FuzzPackMintNativeCoinEqualTest(f *testing.F) {
f.Add(constants.BlackholeAddr.Bytes(), common.Big2.Bytes())
f.Fuzz(func(t *testing.T, b []byte, bigIntBytes []byte) {
bigIntVal := new(big.Int).SetBytes(bigIntBytes)
doCheckOutputs := true
// we can only check if outputs are correct if the value is less than MaxUint256
// otherwise the value will be truncated when packed,
// and thus unpacked output will not be equal to the value
if bigIntVal.Cmp(abi.MaxUint256) > 0 {
doCheckOutputs = false
}
doCheckOutputs := bigIntVal.Cmp(abi.MaxUint256) <= 0
testOldPackMintNativeCoinEqual(t, common.BytesToAddress(b), bigIntVal, doCheckOutputs)
})
}
Expand Down
8 changes: 4 additions & 4 deletions precompile/modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ type Module struct {

type moduleArray []Module

func (u moduleArray) Len() int {
return len(u)
func (m moduleArray) Len() int {
return len(m)
}

func (u moduleArray) Swap(i, j int) {
u[i], u[j] = u[j], u[i]
func (m moduleArray) Swap(i, j int) {
m[i], m[j] = m[j], m[i]
}

func (m moduleArray) Less(i, j int) bool {
Expand Down
2 changes: 1 addition & 1 deletion sync/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func (c *client) get(ctx context.Context, request message.Request, parseFn parse
var (
response []byte
nodeID ids.NodeID
start time.Time = time.Now()
start = time.Now()
)
if len(c.stateSyncNodes) == 0 {
response, nodeID, err = c.networkClient.SendSyncedAppRequestAny(ctx, StateSyncVersion, requestBytes)
Expand Down
Loading
Loading