Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge V0.2.12 candidate from maticnetwork:v0.2.12-candidate #7

Merged
merged 128 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
3258211
core/vm: rework jumpdest analysis benchmarks (#23499)
chfast Aug 30, 2021
f85cf72
docs: add links to more audits in SECURITY.md (#23482)
fredriksvantes Aug 31, 2021
31be5d4
core: fix typo in iterator.go (#23502)
eltociear Aug 31, 2021
d019e90
common: fixes format verb (#23495)
AlexanderYastrebov Aug 31, 2021
067084f
core: fix race conditions in txpool (#23474)
MariusVanDerWijden Aug 31, 2021
4d88974
cmd/evm: add tests for evm t8n (#23507)
holiman Sep 2, 2021
de2c44a
trie: add missing copyright header (#23530)
aaronbuchwald Sep 7, 2021
7957530
docs: add post-mortem (#23518)
holiman Sep 7, 2021
ca5bc67
internal/debug: remove deprecated flags (#23368)
n1charlie Sep 7, 2021
9a0df80
cmd/geth, cmd/utils: remove legacy rpc flags (#23358)
n1charlie Sep 7, 2021
794c613
core/rawdb: freezer batch write (#23462)
holiman Sep 7, 2021
6ef3a16
p2p/enode: use unix timestamp as base ENR sequence number (#19903)
karalabe Sep 7, 2021
51ed39c
core: make txPricedList.stales the first field for 64bit alignment (#…
fjl Sep 7, 2021
5c1fc3b
core: 64bit alignment of testBlockChain.gasLimit (#23543)
fjl Sep 7, 2021
90987db
appveyor.yml: add linux/amd64 build job (#23548)
fjl Sep 8, 2021
9e17648
les: duplicate downloader and fetcher to allow progressive refactoring
karalabe Sep 10, 2021
9ada4a2
Merge pull request #23561 from karalabe/temp-split-leseh
karalabe Sep 10, 2021
578bc81
README: add londonBlock to example genesis config (#23565)
verheesj Sep 13, 2021
babe9b9
cmd/evm: transaction validation tool (#23494)
holiman Sep 13, 2021
b8d7c66
core, rpc: disable memory output by default in traces (#23558)
MariusVanDerWijden Sep 13, 2021
84ff152
cmd/devp2p/internal/ethtest: only use eth66 if eth66 is negotiated (#…
MariusVanDerWijden Sep 15, 2021
7ada89d
eth/tracers: abort evm execution when trace is aborted (#23580)
holiman Sep 16, 2021
4013549
core,eth: call frame tracing (#23087)
s1na Sep 17, 2021
1b34283
ethclient, accounts/keystore: fix flaky tests (#23599)
holiman Sep 20, 2021
62e3b83
docs: fix spelling on 2021-08-22 postmortem (#23595)
peteyburgers Sep 20, 2021
e28f713
internal: support optional filter expression for debug.stacks (#23605)
karalabe Sep 20, 2021
9bf495b
internal/debug: make gosimple linter happy
karalabe Sep 20, 2021
86f3625
Merge pull request #23609 from karalabe/regex-fix
karalabe Sep 20, 2021
5b246af
go.mod: fix module file to prevent go from updating it during build
karalabe Sep 20, 2021
b1a5e4a
Merge pull request #23610 from karalabe/gomod-tify
karalabe Sep 20, 2021
d8211c7
console: add note about typing exit to exit (#23602)
thadguidry Sep 21, 2021
b61ef24
consensus/clique: prevent 0 len extradata from panicing (#23538)
MariusVanDerWijden Sep 21, 2021
ca9bce9
rpc: set scheme for ws and ipc conns to the server (#23615)
s1na Sep 21, 2021
57a3fab
accounts/abi: fix resolving single struct argument (#23573)
rjl493456442 Sep 22, 2021
51ececb
rpc: set pong read deadline (#23556)
jmank88 Sep 27, 2021
12674d4
cmd/puppeth: remove shh from Dockerfile (#23634)
n1charlie Sep 27, 2021
ac7baea
eth/tracers: re-write of 4byte tracer using enter/exit (#23622)
s1na Sep 27, 2021
443afc9
core/state: move state account to core/types + abstracted "write acco…
gballet Sep 28, 2021
ab2caae
eth/tracers: implement debug.intermediateRoots (#23594)
holiman Sep 28, 2021
783e97e
core/rawdb: avoid unnecessary receipt processing for log filtering (#…
s1na Sep 28, 2021
92c5d10
accounts/abi/bind: check event signature before parsing (#23230)
yihau Sep 28, 2021
3531ca2
eth/tracers: avoid unsyncronized mutations on trie database (#23632)
holiman Sep 28, 2021
a541fbe
eth/protocols/eth: simplify peer known block/txs caches (#23649)
ferranbt Sep 28, 2021
42bc194
graphql: add storage slots to access list (#23650)
holiman Sep 28, 2021
3a6fe69
eth/protocols/snap, trie: better error-handling (#23657)
holiman Sep 29, 2021
eae3b19
params: release go-ethereum v1.10.9 stable
fjl Sep 29, 2021
06082fe
params: begin v1.10.10 release cycle
fjl Sep 29, 2021
f2491c5
core: fix typo in comment (#23658)
eltociear Sep 29, 2021
07a5bc1
internal/ethapi: support retrieving header RLPs too
karalabe Oct 1, 2021
a47b8cf
Merge pull request #23670 from karalabe/get-header-rlp
karalabe Oct 1, 2021
b522f5e
eth/tracers: fix callTracer fault handling (#23667)
s1na Oct 1, 2021
5240725
internal/ethapi: make header/block rlp retrieval canonical
karalabe Oct 3, 2021
01fdca5
Merge pull request #23677 from karalabe/canon-rlp-fetcher
karalabe Oct 3, 2021
12f971f
core/state: fix typo in comment (#23665)
hsyodyssey Oct 4, 2021
5a0e1d8
eth/filters: fix TestPendingLogsSubscription (#23619)
mirokuratczyk Oct 4, 2021
0dbb3b1
eth/protocols/eth: replace array with counter in txn broadcaster (#23…
ferranbt Oct 4, 2021
307156c
eth/api: add rpc method to obtain which states are accessible (#23646)
holiman Oct 5, 2021
57ff2de
go.mod: upgrade github.com/karalable/usb (#23684)
fjl Oct 5, 2021
4e599ee
core/types: copy tx recipient address (#23376)
aaronbuchwald Oct 6, 2021
edb1937
core: improve shutdown synchronization in BlockChain (#22853)
holiman Oct 7, 2021
48496e0
internal/ethapi: use correct signer when serving old blocks (#23683)
s1na Oct 7, 2021
ec2b43c
cmd/geth: fix typo in error message (#23697)
darcys22 Oct 8, 2021
2fe0c65
build: upgrade -dlgo version to 1.17.2 (#23698)
fjl Oct 8, 2021
28d30b5
eth: close miner on exit (instead of just stopping) (#21992)
holiman Oct 8, 2021
ee120ef
miner: fix data race during shutdown (#23435)
MariusVanDerWijden Oct 8, 2021
1bea4b0
miner/stress: initialize account backends explicitly (#23699)
fjl Oct 9, 2021
a6a0609
internal/jsre: handle null and undefined to prevent crash (#23701)
aditya520 Oct 10, 2021
84bccd0
core/state: fix typos in comments (#23702)
hsyodyssey Oct 10, 2021
bcbd700
eth/gasprice: avoid modifying TestChainConfig (#23204)
aaronbuchwald Oct 10, 2021
8a430fb
cmd/puppeth: add txpool to explorer Dockerfile (#23652)
n1charlie Oct 11, 2021
64da037
cmd/evm: stricter transaction validation (#23694)
holiman Oct 11, 2021
8b6e018
build: increase C thread stack size on linux (#23676)
gballet Oct 11, 2021
53b1420
params: changed CatalystBlock to TerminalTotalDifficulty (#23700)
MariusVanDerWijden Oct 11, 2021
088bc34
les/vflux/server: fix metrics (#22946)
rjl493456442 Oct 11, 2021
cf8a6d6
core: tests for forked blocks retrievable by hash (#23695)
mirokuratczyk Oct 11, 2021
da3da7c
ci: enable race tests as cron job on travis (#23480)
MariusVanDerWijden Oct 11, 2021
6289137
consensus/clique, core: API cleanup (#23100)
holiman Oct 11, 2021
3d11a22
fixed broken web3 methods link in README.md (#23703)
z89 Oct 12, 2021
633e7ef
eth,rpc: allow for flag configured timeouts for eth_call (#23645)
noam-alchemy Oct 12, 2021
f9d683b
go.mod: upgrade goja (#23721)
fjl Oct 13, 2021
e4f570f
core/types: add MarshalBinary, UnmarshalBinary for Receipt (#22806)
i-norden Oct 13, 2021
778ff94
all: fix some go-critic linter warnings (#23709)
quasilyte Oct 13, 2021
79b727b
accounts/abi/bind: refactor transact method (#23719)
MariusVanDerWijden Oct 13, 2021
011fe3e
core: remove unused error from TxPool.Pending (#23720)
jwasinger Oct 13, 2021
08e782c
accounts/abi: add basic support for error types (#23161)
MariusVanDerWijden Oct 14, 2021
f915f68
core/state/snapshot: fix data race in layer flattening (#23628)
rjl493456442 Oct 15, 2021
bb74230
params: release go-ethereum v1.10.10 stable
fjl Oct 15, 2021
0aa8fee
Apply best practices to Dockerfile
Nov 5, 2021
1cd6c84
Vendor protobuf and go extension issue PR (#223)
rajatlko13 Nov 9, 2021
57898e4
Final touches to Dockerfiles
Nov 10, 2021
e58bdfa
Build the new CLI
Nov 10, 2021
8ce3032
Bump Go
Nov 10, 2021
ba25f84
Revert "Build the new CLI"
Nov 10, 2021
2191490
Add chain set head command (#226)
ferranbt Nov 11, 2021
5d0f0b7
Merge pull request #227 from maticnetwork/victor/pos-48-refactor-bor-…
vcastellm Nov 11, 2021
fc58176
Added Prometheus flag on bor-cli
0xsharma Nov 11, 2021
7b6bab4
Release multi-platform with goreleaser
Nov 9, 2021
f3a43f9
Added Prometheus to New CLI: fixes
0xsharma Nov 12, 2021
c23cd5e
minor Clean
0xsharma Nov 12, 2021
a5bcab1
Minor Clean-up
0xsharma Nov 12, 2021
cd6a163
minor cleanup
0xsharma Nov 12, 2021
9ab4781
Merge pull request #228 from maticnetwork/victor/pos-47-improve-bor-b…
vcastellm Nov 12, 2021
358e683
Added Prometheus Flag and Default
0xsharma Nov 12, 2021
3b264e9
Merge branch 'master' into main
0xsharma Nov 12, 2021
baed325
Merge pull request #231 from Shivam691999/main
0xsharma Nov 13, 2021
322e964
added opentelemetry config, flags, and setup (#235)
manav2401 Nov 17, 2021
78ba316
Adapt Dockerfile for development (#237)
vcastellm Nov 17, 2021
87f9b91
added service name in config and flags (#238)
manav2401 Nov 17, 2021
983e32b
merged geth v1.10.10
ssandeep Nov 22, 2021
c55094a
fix: bor receipt #1
jdkanani Nov 22, 2021
9513fbd
Write bor receipts in ancient
ferranbt Nov 22, 2021
ded22da
fix: bor receipt rlp
jdkanani Nov 22, 2021
908cbbf
fix: testcases
jdkanani Nov 22, 2021
5431702
merge conflicts
temaniarpit27 Nov 23, 2021
6f59153
Arpit/reorg fix 2 (#210)
temaniarpit27 Nov 25, 2021
fb79b8d
Merge pull request #242 from maticnetwork/geth-v1.10.10
ssandeep Nov 26, 2021
b1fb79a
Small tweeks to Dockerfiles (#247)
vcastellm Nov 30, 2021
149f47e
Fix ancient receipts
ferranbt Dec 1, 2021
d3010f4
Fix ancestor bor receipts (#249)
ferranbt Dec 1, 2021
08db8bc
bumped version to 0.2.11
ssandeep Dec 1, 2021
cf900a9
Changed syncmode from fast to full
0xsharma Dec 2, 2021
b633382
Merge pull request #250 from maticnetwork/shivam/newCLI-syncmode
0xsharma Dec 3, 2021
a7d97ce
Genesis change fix (#252)
temaniarpit27 Dec 3, 2021
e51394b
add block alloc
temaniarpit27 Dec 3, 2021
753301c
change block alloc
temaniarpit27 Dec 3, 2021
64ba7d6
remove byte array
temaniarpit27 Dec 3, 2021
488ea2b
mainnet upgrade
jdkanani Dec 4, 2021
a276c23
Merge branch 'master' of github.com:maticnetwork/bor into v0.2.12-can…
temaniarpit27 Dec 7, 2021
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
Prev Previous commit
Next Next commit
core/state: move state account to core/types + abstracted "write acco…
…unt to trie" (#23567)

* core/state: abstracted "write account to trie" method

* fix appveyor build

* Apply suggestions from code review

Co-authored-by: Martin Holst Swende <martin@swende.se>

* review feedback

* core/state/accounts: move Account to core/types

* core/types: rename Account -> StateAccount

* core/state: restore EncodeRLP for stateObject

* core/types: add the missing file

* more review feedback

* more review feedback

Co-authored-by: Martin Holst Swende <martin@swende.se>
Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
3 people authored Sep 28, 2021
commit 443afc975c7a4016bf9ed1b057b8cc186cb089e1
5 changes: 3 additions & 2 deletions cmd/geth/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/pruner"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -287,7 +288,7 @@ func traverseState(ctx *cli.Context) error {
accIter := trie.NewIterator(t.NodeIterator(nil))
for accIter.Next() {
accounts += 1
var acc state.Account
var acc types.StateAccount
if err := rlp.DecodeBytes(accIter.Value, &acc); err != nil {
log.Error("Invalid account encountered during traversal", "err", err)
return err
Expand Down Expand Up @@ -393,7 +394,7 @@ func traverseRawState(ctx *cli.Context) error {
// dig into the storage trie further.
if accIter.Leaf() {
accounts += 1
var acc state.Account
var acc types.StateAccount
if err := rlp.DecodeBytes(accIter.LeafBlob(), &acc); err != nil {
log.Error("Invalid account encountered during traversal", "err", err)
return errors.New("invalid account")
Expand Down
4 changes: 4 additions & 0 deletions core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/VictoriaMetrics/fastcache"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
lru "github.com/hashicorp/golang-lru"
Expand Down Expand Up @@ -70,6 +71,9 @@ type Trie interface {
// trie.MissingNodeError is returned.
TryGet(key []byte) ([]byte, error)

// TryUpdateAccount abstract an account write in the trie.
TryUpdateAccount(key []byte, account *types.StateAccount) error

// TryUpdate associates key with value in the trie. If value has length zero, any
// existing value is deleted from the trie. The value bytes must not be modified
// by the caller while they are stored in the trie. If a node was not found in the
Expand Down
3 changes: 2 additions & 1 deletion core/state/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
Expand Down Expand Up @@ -140,7 +141,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []

it := trie.NewIterator(s.trie.NodeIterator(conf.Start))
for it.Next() {
var data Account
var data types.StateAccount
if err := rlp.DecodeBytes(it.Value, &data); err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion core/state/iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
)
Expand Down Expand Up @@ -104,7 +105,7 @@ func (it *NodeIterator) step() error {
return nil
}
// Otherwise we've reached an account node, initiate data iteration
var account Account
var account types.StateAccount
if err := rlp.Decode(bytes.NewReader(it.stateIt.LeafBlob()), &account); err != nil {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions core/state/pruner/pruner.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
Expand Down Expand Up @@ -426,7 +425,7 @@ func extractGenesis(db ethdb.Database, stateBloom *stateBloom) error {
// If it's a leaf node, yes we are touching an account,
// dig into the storage trie further.
if accIter.Leaf() {
var acc state.Account
var acc types.StateAccount
if err := rlp.DecodeBytes(accIter.LeafBlob(), &acc); err != nil {
return err
}
Expand Down
16 changes: 4 additions & 12 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/rlp"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (s Storage) Copy() Storage {
type stateObject struct {
address common.Address
addrHash common.Hash // hash of ethereum address of the account
data Account
data types.StateAccount
db *StateDB

// DB error.
Expand Down Expand Up @@ -97,17 +98,8 @@ func (s *stateObject) empty() bool {
return s.data.Nonce == 0 && s.data.Balance.Sign() == 0 && bytes.Equal(s.data.CodeHash, emptyCodeHash)
}

// Account is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type Account struct {
Nonce uint64
Balance *big.Int
Root common.Hash // merkle root of the storage trie
CodeHash []byte
}

// newObject creates a state object.
func newObject(db *StateDB, address common.Address, data Account) *stateObject {
func newObject(db *StateDB, address common.Address, data types.StateAccount) *stateObject {
if data.Balance == nil {
data.Balance = new(big.Int)
}
Expand All @@ -130,7 +122,7 @@ func newObject(db *StateDB, address common.Address, data Account) *stateObject {

// EncodeRLP implements rlp.Encoder.
func (s *stateObject) EncodeRLP(w io.Writer) error {
return rlp.Encode(w, s.data)
return rlp.Encode(w, &s.data)
}

// setError remembers the first non-nil error it is called with.
Expand Down
17 changes: 6 additions & 11 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,7 @@ func (s *StateDB) updateStateObject(obj *stateObject) {
}
// Encode the account and update the account trie
addr := obj.Address()

data, err := rlp.EncodeToBytes(obj)
if err != nil {
panic(fmt.Errorf("can't encode object at %x: %v", addr[:], err))
}
if err = s.trie.TryUpdate(addr[:], data); err != nil {
if err := s.trie.TryUpdateAccount(addr[:], &obj.data); err != nil {
s.setError(fmt.Errorf("updateStateObject (%x) error: %v", addr[:], err))
}

Expand Down Expand Up @@ -512,7 +507,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
}
// If no live objects are available, attempt to use snapshots
var (
data *Account
data *types.StateAccount
err error
)
if s.snap != nil {
Expand All @@ -524,7 +519,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
if acc == nil {
return nil
}
data = &Account{
data = &types.StateAccount{
Nonce: acc.Nonce,
Balance: acc.Balance,
CodeHash: acc.CodeHash,
Expand All @@ -551,7 +546,7 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
if len(enc) == 0 {
return nil
}
data = new(Account)
data = new(types.StateAccount)
if err := rlp.DecodeBytes(enc, data); err != nil {
log.Error("Failed to decode state object", "addr", addr, "err", err)
return nil
Expand Down Expand Up @@ -588,7 +583,7 @@ func (s *StateDB) createObject(addr common.Address) (newobj, prev *stateObject)
s.snapDestructs[prev.addrHash] = struct{}{}
}
}
newobj = newObject(s, addr, Account{})
newobj = newObject(s, addr, types.StateAccount{})
if prev == nil {
s.journal.append(createObjectChange{account: &addr})
} else {
Expand Down Expand Up @@ -942,7 +937,7 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
}
// The onleaf func is called _serially_, so we can reuse the same account
// for unmarshalling every time.
var account Account
var account types.StateAccount
root, accountCommitted, err := s.trie.Commit(func(_ [][]byte, _ []byte, leaf []byte, parent common.Hash) error {
if err := rlp.DecodeBytes(leaf, &account); err != nil {
return nil
Expand Down
3 changes: 2 additions & 1 deletion core/state/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bytes"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/trie"
Expand All @@ -43,7 +44,7 @@ func NewStateSync(root common.Hash, database ethdb.KeyValueReader, bloom *trie.S
return err
}
}
var obj Account
var obj types.StateAccount
if err := rlp.Decode(bytes.NewReader(leaf), &obj); err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion core/state/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb/memorydb"
Expand Down Expand Up @@ -203,7 +204,7 @@ func testIterativeStateSync(t *testing.T, count int, commit bool, bypath bool) {
}
results[len(hashQueue)+i] = trie.SyncResult{Hash: crypto.Keccak256Hash(data), Data: data}
} else {
var acc Account
var acc types.StateAccount
if err := rlp.DecodeBytes(srcTrie.Get(path[0]), &acc); err != nil {
t.Fatalf("failed to decode account on path %x: %v", path, err)
}
Expand Down
32 changes: 32 additions & 0 deletions core/types/state_account.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2021 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

package types

import (
"math/big"

"github.com/ethereum/go-ethereum/common"
)

// StateAccount is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type StateAccount struct {
Nonce uint64
Balance *big.Int
Root common.Hash // merkle root of the storage trie
CodeHash []byte
}
4 changes: 2 additions & 2 deletions eth/protocols/snap/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
Expand Down Expand Up @@ -319,7 +319,7 @@ func handleMessage(backend Backend, peer *Peer) error {
if err != nil {
return p2p.Send(peer.rw, StorageRangesMsg, &StorageRangesPacket{ID: req.ID})
}
var acc state.Account
var acc types.StateAccount
if err := rlp.DecodeBytes(accTrie.Get(account[:]), &acc); err != nil {
return p2p.Send(peer.rw, StorageRangesMsg, &StorageRangesPacket{ID: req.ID})
}
Expand Down
11 changes: 6 additions & 5 deletions eth/protocols/snap/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
Expand Down Expand Up @@ -125,8 +126,8 @@ type accountRequest struct {
type accountResponse struct {
task *accountTask // Task which this request is filling

hashes []common.Hash // Account hashes in the returned range
accounts []*state.Account // Expanded accounts in the returned range
hashes []common.Hash // Account hashes in the returned range
accounts []*types.StateAccount // Expanded accounts in the returned range

cont bool // Whether the account range has a continuation
}
Expand Down Expand Up @@ -2274,9 +2275,9 @@ func (s *Syncer) OnAccounts(peer SyncPeer, id uint64, hashes []common.Hash, acco
s.scheduleRevertAccountRequest(req)
return err
}
accs := make([]*state.Account, len(accounts))
accs := make([]*types.StateAccount, len(accounts))
for i, account := range accounts {
acc := new(state.Account)
acc := new(types.StateAccount)
if err := rlp.DecodeBytes(account, acc); err != nil {
panic(err) // We created these blobs, we must be able to decode them
}
Expand Down Expand Up @@ -2740,7 +2741,7 @@ func (s *Syncer) onHealByteCodes(peer SyncPeer, id uint64, bytecodes [][]byte) e
// Note it's not concurrent safe, please handle the concurrent issue outside.
func (s *Syncer) onHealState(paths [][]byte, value []byte) error {
if len(paths) == 1 {
var account state.Account
var account types.StateAccount
if err := rlp.DecodeBytes(value, &account); err != nil {
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions eth/protocols/snap/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/light"
Expand Down Expand Up @@ -1349,7 +1349,7 @@ func makeAccountTrieNoStorage(n int) (*trie.Trie, entrySlice) {
accTrie, _ := trie.New(common.Hash{}, db)
var entries entrySlice
for i := uint64(1); i <= uint64(n); i++ {
value, _ := rlp.EncodeToBytes(state.Account{
value, _ := rlp.EncodeToBytes(types.StateAccount{
Nonce: i,
Balance: big.NewInt(int64(i)),
Root: emptyRoot,
Expand Down Expand Up @@ -1394,7 +1394,7 @@ func makeBoundaryAccountTrie(n int) (*trie.Trie, entrySlice) {
}
// Fill boundary accounts
for i := 0; i < len(boundaries); i++ {
value, _ := rlp.EncodeToBytes(state.Account{
value, _ := rlp.EncodeToBytes(types.StateAccount{
Nonce: uint64(0),
Balance: big.NewInt(int64(i)),
Root: emptyRoot,
Expand All @@ -1406,7 +1406,7 @@ func makeBoundaryAccountTrie(n int) (*trie.Trie, entrySlice) {
}
// Fill other accounts if required
for i := uint64(1); i <= uint64(n); i++ {
value, _ := rlp.EncodeToBytes(state.Account{
value, _ := rlp.EncodeToBytes(types.StateAccount{
Nonce: i,
Balance: big.NewInt(int64(i)),
Root: emptyRoot,
Expand Down Expand Up @@ -1442,7 +1442,7 @@ func makeAccountTrieWithStorageWithUniqueStorage(accounts, slots int, code bool)
stTrie, stEntries := makeStorageTrieWithSeed(uint64(slots), i, db)
stRoot := stTrie.Hash()
stTrie.Commit(nil)
value, _ := rlp.EncodeToBytes(state.Account{
value, _ := rlp.EncodeToBytes(types.StateAccount{
Nonce: i,
Balance: big.NewInt(int64(i)),
Root: stRoot,
Expand Down Expand Up @@ -1489,7 +1489,7 @@ func makeAccountTrieWithStorage(accounts, slots int, code, boundary bool) (*trie
if code {
codehash = getCodeHash(i)
}
value, _ := rlp.EncodeToBytes(state.Account{
value, _ := rlp.EncodeToBytes(types.StateAccount{
Nonce: i,
Balance: big.NewInt(int64(i)),
Root: stRoot,
Expand Down
Loading