Skip to content

Commit 7a96aa6

Browse files
committed
fix lint issues
1 parent 647ae76 commit 7a96aa6

File tree

10 files changed

+40
-35
lines changed

10 files changed

+40
-35
lines changed

cmd/evm/runner.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ func runCmd(ctx *cli.Context) error {
316316
input = append(code, input...)
317317
execFunc = func() ([]byte, uint64, error) {
318318
// don't mutate the state!
319-
runtimeConfig.State = prestate.Copy()
319+
runtimeConfig.State = prestate.Copy().(*state.StateDB)
320320
output, _, gasLeft, err := runtime.Create(input, &runtimeConfig)
321321
return output, gasLeft, err
322322
}
@@ -326,7 +326,7 @@ func runCmd(ctx *cli.Context) error {
326326
}
327327
execFunc = func() ([]byte, uint64, error) {
328328
// don't mutate the state!
329-
runtimeConfig.State = prestate.Copy()
329+
runtimeConfig.State = prestate.Copy().(*state.StateDB)
330330
output, gasLeft, err := runtime.Call(receiver, input, &runtimeConfig)
331331
return output, initialGas - gasLeft, err
332332
}

consensus/beacon/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package beacon
1919
import (
2020
"errors"
2121
"fmt"
22+
"math/big"
23+
2224
"github.com/ethereum/go-ethereum/core/state"
2325
"github.com/ethereum/go-ethereum/core/vm"
24-
"math/big"
2526

2627
"github.com/ethereum/go-ethereum/common"
2728
"github.com/ethereum/go-ethereum/consensus"

consensus/consensus.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
package consensus
1919

2020
import (
21+
"math/big"
22+
2123
"github.com/ethereum/go-ethereum/core/state"
2224
"github.com/ethereum/go-ethereum/core/vm"
23-
"math/big"
2425

2526
"github.com/ethereum/go-ethereum/common"
2627
"github.com/ethereum/go-ethereum/core/types"

core/block_validator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package core
1919
import (
2020
"errors"
2121
"fmt"
22+
2223
"github.com/ethereum/go-ethereum/consensus"
2324
"github.com/ethereum/go-ethereum/core/state"
2425
"github.com/ethereum/go-ethereum/core/types"

core/state/block_access_list_creation.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,16 @@ func (a *AccessListCreationDB) Database() Database {
203203
func (a *AccessListCreationDB) GetTrie() Trie {
204204
return a.inner.GetTrie()
205205
}
206-
func (s *AccessListCreationDB) SetTxContext(thash common.Hash, ti int) {
207-
s.inner.SetTxContext(thash, ti)
206+
func (a *AccessListCreationDB) SetTxContext(thash common.Hash, ti int) {
207+
a.inner.SetTxContext(thash, ti)
208208
}
209209

210-
func (s *AccessListCreationDB) Error() error {
211-
return s.inner.Error()
210+
func (a *AccessListCreationDB) Error() error {
211+
return a.inner.Error()
212212
}
213213

214-
func (s *AccessListCreationDB) Copy() BlockProcessingDB {
215-
return &AccessListCreationDB{s.idx, s.inner.Copy(), s.accessList.Copy()}
214+
func (a *AccessListCreationDB) Copy() BlockProcessingDB {
215+
return &AccessListCreationDB{a.idx, a.inner.Copy(), a.accessList.Copy()}
216216
}
217217

218218
var _ BlockProcessingDB = &AccessListCreationDB{}

core/state/statedb_hooked.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
package state
1818

1919
import (
20-
"github.com/ethereum/go-ethereum/core/types/bal"
2120
"math/big"
2221

22+
"github.com/ethereum/go-ethereum/core/types/bal"
23+
2324
"github.com/ethereum/go-ethereum/common"
2425
"github.com/ethereum/go-ethereum/core/stateless"
2526
"github.com/ethereum/go-ethereum/core/tracing"

core/state/statedb_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,10 @@ func TestCopy(t *testing.T) {
175175
orig.Finalise(false)
176176

177177
// Copy the state
178-
copy := orig.Copy()
178+
copy := orig.Copy().(*StateDB)
179179

180180
// Copy the copy state
181-
ccopy := copy.Copy()
181+
ccopy := copy.Copy().(*StateDB)
182182

183183
// modify all in memory
184184
for i := byte(0); i < 255; i++ {
@@ -278,7 +278,7 @@ func TestCopyObjectState(t *testing.T) {
278278
obj.data.Root = common.HexToHash("0xdeadbeef")
279279
}
280280
orig.Finalise(true)
281-
cpy := orig.Copy()
281+
cpy := orig.Copy().(*StateDB)
282282
for _, op := range cpy.mutations {
283283
if have, want := op.applied, false; have != want {
284284
t.Fatalf("Error in test itself, the 'done' flag should not be set before Commit, have %v want %v", have, want)
@@ -528,7 +528,7 @@ func (test *snapshotTest) run() bool {
528528
for i, action := range test.actions {
529529
if len(test.snapshots) > sindex && i == test.snapshots[sindex] {
530530
snapshotRevs[sindex] = state.Snapshot()
531-
checkstates[sindex] = state.Copy()
531+
checkstates[sindex] = state.Copy().(*StateDB)
532532
sindex++
533533
}
534534
action.fn(action, state)
@@ -747,7 +747,7 @@ func TestCopyCommitCopy(t *testing.T) {
747747
t.Fatalf("initial committed storage slot mismatch: have %x, want %x", val, common.Hash{})
748748
}
749749
// Copy the non-committed state database and check pre/post commit balance
750-
copyOne := state.Copy()
750+
copyOne := state.Copy().(*StateDB)
751751
if balance := copyOne.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
752752
t.Fatalf("first copy pre-commit balance mismatch: have %v, want %v", balance, 42)
753753
}
@@ -761,7 +761,7 @@ func TestCopyCommitCopy(t *testing.T) {
761761
t.Fatalf("first copy pre-commit committed storage slot mismatch: have %x, want %x", val, common.Hash{})
762762
}
763763
// Copy the copy and check the balance once more
764-
copyTwo := copyOne.Copy()
764+
copyTwo := copyOne.Copy().(*StateDB)
765765
if balance := copyTwo.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
766766
t.Fatalf("second copy balance mismatch: have %v, want %v", balance, 42)
767767
}
@@ -820,7 +820,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
820820
t.Fatalf("initial committed storage slot mismatch: have %x, want %x", val, common.Hash{})
821821
}
822822
// Copy the non-committed state database and check pre/post commit balance
823-
copyOne := state.Copy()
823+
copyOne := state.Copy().(*StateDB)
824824
if balance := copyOne.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
825825
t.Fatalf("first copy balance mismatch: have %v, want %v", balance, 42)
826826
}
@@ -834,7 +834,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
834834
t.Fatalf("first copy committed storage slot mismatch: have %x, want %x", val, common.Hash{})
835835
}
836836
// Copy the copy and check the balance once more
837-
copyTwo := copyOne.Copy()
837+
copyTwo := copyOne.Copy().(*StateDB)
838838
if balance := copyTwo.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
839839
t.Fatalf("second copy pre-commit balance mismatch: have %v, want %v", balance, 42)
840840
}
@@ -848,7 +848,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
848848
t.Fatalf("second copy pre-commit committed storage slot mismatch: have %x, want %x", val, common.Hash{})
849849
}
850850
// Copy the copy-copy and check the balance once more
851-
copyThree := copyTwo.Copy()
851+
copyThree := copyTwo.Copy().(*StateDB)
852852
if balance := copyThree.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
853853
t.Fatalf("third copy balance mismatch: have %v, want %v", balance, 42)
854854
}
@@ -896,7 +896,7 @@ func TestCommitCopy(t *testing.T) {
896896
state.Commit(1, true, false)
897897

898898
// Copy the committed state database, the copied one is not fully functional.
899-
copied := state.Copy()
899+
copied := state.Copy().(*StateDB)
900900
if balance := copied.GetBalance(addr); balance.Cmp(uint256.NewInt(42)) != 0 {
901901
t.Fatalf("unexpected balance: have %v", balance)
902902
}
@@ -1098,7 +1098,7 @@ func TestStateDBAccessList(t *testing.T) {
10981098
verifySlots("bb", "01", "02")
10991099

11001100
// Make a copy
1101-
stateCopy1 := state.Copy()
1101+
stateCopy1 := state.Copy().(*StateDB)
11021102
if exp, got := 4, state.journal.length(); exp != got {
11031103
t.Fatalf("journal length mismatch: have %d, want %d", got, exp)
11041104
}

core/types/bal/bal.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ package bal
1919
import (
2020
"bytes"
2121
"encoding/json"
22+
"maps"
23+
2224
"github.com/ethereum/go-ethereum/common"
2325
"github.com/holiman/uint256"
24-
"maps"
2526
)
2627

2728
// CodeChange contains the runtime bytecode deployed at an address and the
@@ -192,14 +193,14 @@ func (c *ConstructionBlockAccessList) ApplyDiff(i uint, diff *StateDiff) {
192193
if c.Accounts[addr].NonceChanges == nil {
193194
c.Accounts[addr].NonceChanges = make(map[uint16]uint64)
194195
}
195-
c.Accounts[addr].NonceChanges[uint16(idx)] = *acctDiff.Nonce
196+
c.Accounts[addr].NonceChanges[idx] = *acctDiff.Nonce
196197
}
197198
if acctDiff.Code != nil {
198199
if c.Accounts[addr].CodeChanges == nil {
199200
c.Accounts[addr].CodeChanges = make(map[uint16]CodeChange)
200201
}
201202
// TODO: make the CodeChanges value just be []byte
202-
c.Accounts[addr].CodeChanges[uint16(idx)] = CodeChange{idx, acctDiff.Code}
203+
c.Accounts[addr].CodeChanges[idx] = CodeChange{idx, acctDiff.Code}
203204
}
204205
if acctDiff.StorageWrites != nil {
205206
if c.Accounts[addr].StorageWrites == nil {
@@ -227,7 +228,6 @@ func (c *ConstructionBlockAccessList) ApplyAccesses(accesses StateAccesses) {
227228
c.Accounts[addr] = &ConstructionAccountAccess{}
228229
}
229230
if len(acctAccesses) > 0 {
230-
231231
if c.Accounts[addr].StorageReads == nil {
232232
c.Accounts[addr].StorageReads = make(map[common.Hash]struct{})
233233
}
@@ -383,7 +383,6 @@ func (s *StateDiff) Merge(next *StateDiff) {
383383
mut.StorageWrites[key] = val
384384
}
385385
}
386-
387386
}
388387
} else {
389388
s.Mutations[account] = diff.Copy()

core/types/bal/bal_encoding.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ import (
2222
"encoding/json"
2323
"errors"
2424
"fmt"
25+
"io"
26+
"maps"
27+
"slices"
28+
2529
"github.com/ethereum/go-ethereum/common"
2630
"github.com/ethereum/go-ethereum/crypto"
2731
"github.com/ethereum/go-ethereum/params"
2832
"github.com/ethereum/go-ethereum/rlp"
2933
"github.com/holiman/uint256"
30-
"io"
31-
"maps"
32-
"slices"
3334
)
3435

3536
//go:generate go run github.com/ethereum/go-ethereum/rlp/rlpgen -out bal_encoding_rlp_generated.go -type AccountAccess -decoder
@@ -40,17 +41,17 @@ import (
4041
// BlockAccessList is the encoding format of ConstructionBlockAccessList.
4142
type BlockAccessList []AccountAccess
4243

43-
func (obj BlockAccessList) EncodeRLP(_w io.Writer) error {
44+
func (e BlockAccessList) EncodeRLP(_w io.Writer) error {
4445
w := rlp.NewEncoderBuffer(_w)
4546
l := w.List()
46-
for _, access := range obj {
47+
for _, access := range e {
4748
access.EncodeRLP(w)
4849
}
4950
w.ListEnd(l)
5051
return w.Flush()
5152
}
5253

53-
func (obj *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
54+
func (e *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
5455
if _, err := dec.List(); err != nil {
5556
return err
5657
}
@@ -59,7 +60,7 @@ func (obj *BlockAccessList) DecodeRLP(dec *rlp.Stream) error {
5960
if err := access.DecodeRLP(dec); err != nil {
6061
return err
6162
}
62-
*obj = append(*obj, access)
63+
*e = append(*e, access)
6364
}
6465
return nil
6566
}

core/types/block.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ import (
2121
"crypto/sha256"
2222
"encoding/binary"
2323
"fmt"
24-
"github.com/ethereum/go-ethereum/core/types/bal"
2524
"io"
2625
"math/big"
2726
"reflect"
2827
"slices"
2928
"sync/atomic"
3029
"time"
3130

31+
"github.com/ethereum/go-ethereum/core/types/bal"
32+
3233
"github.com/ethereum/go-ethereum/common"
3334
"github.com/ethereum/go-ethereum/common/hexutil"
3435
"github.com/ethereum/go-ethereum/rlp"

0 commit comments

Comments
 (0)