Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a1430182
Unverified
Commit
a1430182
authored
May 11, 2023
by
rjl493456442
Committed by
GitHub
May 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all: new empty trie with types.EmptyRootHash instead of null (#27230)
parent
7577b9c2
Changes
25
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
121 additions
and
113 deletions
+121
-113
execution.go
cmd/evm/internal/t8ntool/execution.go
+1
-1
runner.go
cmd/evm/runner.go
+2
-1
genesis.go
core/genesis.go
+2
-2
generate_test.go
core/state/snapshot/generate_test.go
+41
-41
state_test.go
core/state/state_test.go
+4
-3
statedb_test.go
core/state/statedb_test.go
+14
-14
sync_test.go
core/state/sync_test.go
+1
-1
trie_prefetcher_test.go
core/state/trie_prefetcher_test.go
+2
-1
txpool2_test.go
core/txpool/txpool2_test.go
+4
-4
txpool_test.go
core/txpool/txpool_test.go
+19
-19
gas_table_test.go
core/vm/gas_table_test.go
+3
-2
instructions_test.go
core/vm/instructions_test.go
+2
-1
interpreter_test.go
core/vm/interpreter_test.go
+2
-1
runtime.go
core/vm/runtime/runtime.go
+3
-2
runtime_test.go
core/vm/runtime/runtime_test.go
+5
-5
api_test.go
eth/api_test.go
+4
-3
block_fetcher_test.go
eth/fetcher/block_fetcher_test.go
+1
-1
sync_test.go
eth/protocols/snap/sync_test.go
+2
-2
block_fetcher_test.go
les/fetcher/block_fetcher_test.go
+1
-1
postprocess.go
light/postprocess.go
+2
-2
miner_test.go
miner/miner_test.go
+1
-1
state_test_util.go
tests/state_test_util.go
+1
-1
iterator_test.go
trie/iterator_test.go
+1
-1
secure_trie_test.go
trie/secure_trie_test.go
+2
-2
sync_test.go
trie/sync_test.go
+1
-1
No files found.
cmd/evm/internal/t8ntool/execution.go
View file @
a1430182
...
@@ -293,7 +293,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
...
@@ -293,7 +293,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
)
*
state
.
StateDB
{
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
)
*
state
.
StateDB
{
sdb
:=
state
.
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
})
sdb
:=
state
.
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
})
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
sdb
,
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
sdb
,
nil
)
for
addr
,
a
:=
range
accounts
{
for
addr
,
a
:=
range
accounts
{
statedb
.
SetCode
(
addr
,
a
.
Code
)
statedb
.
SetCode
(
addr
,
a
.
Code
)
statedb
.
SetNonce
(
addr
,
a
.
Nonce
)
statedb
.
SetNonce
(
addr
,
a
.
Nonce
)
...
...
cmd/evm/runner.go
View file @
a1430182
...
@@ -34,6 +34,7 @@ import (
...
@@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm/runtime"
"github.com/ethereum/go-ethereum/core/vm/runtime"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
...
@@ -146,7 +147,7 @@ func runCmd(ctx *cli.Context) error {
...
@@ -146,7 +147,7 @@ func runCmd(ctx *cli.Context) error {
chainConfig
=
gen
.
Config
chainConfig
=
gen
.
Config
}
else
{
}
else
{
sdb
:=
state
.
NewDatabaseWithConfig
(
rawdb
.
NewMemoryDatabase
(),
&
trie
.
Config
{
Preimages
:
preimages
})
sdb
:=
state
.
NewDatabaseWithConfig
(
rawdb
.
NewMemoryDatabase
(),
&
trie
.
Config
{
Preimages
:
preimages
})
statedb
,
_
=
state
.
New
(
common
.
Hash
{}
,
sdb
,
nil
)
statedb
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
sdb
,
nil
)
genesisConfig
=
new
(
core
.
Genesis
)
genesisConfig
=
new
(
core
.
Genesis
)
}
}
if
ctx
.
String
(
SenderFlag
.
Name
)
!=
""
{
if
ctx
.
String
(
SenderFlag
.
Name
)
!=
""
{
...
...
core/genesis.go
View file @
a1430182
...
@@ -120,7 +120,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
...
@@ -120,7 +120,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
// Create an ephemeral in-memory database for computing hash,
// Create an ephemeral in-memory database for computing hash,
// all the derived states will be discarded to not pollute disk.
// all the derived states will be discarded to not pollute disk.
db
:=
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
db
:=
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
statedb
,
err
:=
state
.
New
(
common
.
Hash
{}
,
db
,
nil
)
statedb
,
err
:=
state
.
New
(
types
.
EmptyRootHash
,
db
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
common
.
Hash
{},
err
return
common
.
Hash
{},
err
}
}
...
@@ -139,7 +139,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
...
@@ -139,7 +139,7 @@ func (ga *GenesisAlloc) deriveHash() (common.Hash, error) {
// all the generated states will be persisted into the given database.
// all the generated states will be persisted into the given database.
// Also, the genesis state specification will be flushed as well.
// Also, the genesis state specification will be flushed as well.
func
(
ga
*
GenesisAlloc
)
flush
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
,
blockhash
common
.
Hash
)
error
{
func
(
ga
*
GenesisAlloc
)
flush
(
db
ethdb
.
Database
,
triedb
*
trie
.
Database
,
blockhash
common
.
Hash
)
error
{
statedb
,
err
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabaseWithNodeDB
(
db
,
triedb
),
nil
)
statedb
,
err
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabaseWithNodeDB
(
db
,
triedb
),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
core/state/snapshot/generate_test.go
View file @
a1430182
This diff is collapsed.
Click to expand it.
core/state/state_test.go
View file @
a1430182
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"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/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie"
...
@@ -35,13 +36,13 @@ type stateTest struct {
...
@@ -35,13 +36,13 @@ type stateTest struct {
func
newStateTest
()
*
stateTest
{
func
newStateTest
()
*
stateTest
{
db
:=
rawdb
.
NewMemoryDatabase
()
db
:=
rawdb
.
NewMemoryDatabase
()
sdb
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
db
),
nil
)
sdb
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
db
),
nil
)
return
&
stateTest
{
db
:
db
,
state
:
sdb
}
return
&
stateTest
{
db
:
db
,
state
:
sdb
}
}
}
func
TestDump
(
t
*
testing
.
T
)
{
func
TestDump
(
t
*
testing
.
T
)
{
db
:=
rawdb
.
NewMemoryDatabase
()
db
:=
rawdb
.
NewMemoryDatabase
()
sdb
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
}),
nil
)
sdb
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
}),
nil
)
s
:=
&
stateTest
{
db
:
db
,
state
:
sdb
}
s
:=
&
stateTest
{
db
:
db
,
state
:
sdb
}
// generate a few entries
// generate a few entries
...
@@ -150,7 +151,7 @@ func TestSnapshotEmpty(t *testing.T) {
...
@@ -150,7 +151,7 @@ func TestSnapshotEmpty(t *testing.T) {
}
}
func
TestSnapshot2
(
t
*
testing
.
T
)
{
func
TestSnapshot2
(
t
*
testing
.
T
)
{
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
stateobjaddr0
:=
common
.
BytesToAddress
([]
byte
(
"so0"
))
stateobjaddr0
:=
common
.
BytesToAddress
([]
byte
(
"so0"
))
stateobjaddr1
:=
common
.
BytesToAddress
([]
byte
(
"so1"
))
stateobjaddr1
:=
common
.
BytesToAddress
([]
byte
(
"so1"
))
...
...
core/state/statedb_test.go
View file @
a1430182
...
@@ -39,7 +39,7 @@ import (
...
@@ -39,7 +39,7 @@ import (
func
TestUpdateLeaks
(
t
*
testing
.
T
)
{
func
TestUpdateLeaks
(
t
*
testing
.
T
)
{
// Create an empty state database
// Create an empty state database
db
:=
rawdb
.
NewMemoryDatabase
()
db
:=
rawdb
.
NewMemoryDatabase
()
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
db
),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
db
),
nil
)
// Update it with some accounts
// Update it with some accounts
for
i
:=
byte
(
0
);
i
<
255
;
i
++
{
for
i
:=
byte
(
0
);
i
<
255
;
i
++
{
...
@@ -73,8 +73,8 @@ func TestIntermediateLeaks(t *testing.T) {
...
@@ -73,8 +73,8 @@ func TestIntermediateLeaks(t *testing.T) {
// Create two state databases, one transitioning to the final state, the other final from the beginning
// Create two state databases, one transitioning to the final state, the other final from the beginning
transDb
:=
rawdb
.
NewMemoryDatabase
()
transDb
:=
rawdb
.
NewMemoryDatabase
()
finalDb
:=
rawdb
.
NewMemoryDatabase
()
finalDb
:=
rawdb
.
NewMemoryDatabase
()
transState
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
transDb
),
nil
)
transState
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
transDb
),
nil
)
finalState
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
finalDb
),
nil
)
finalState
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
finalDb
),
nil
)
modify
:=
func
(
state
*
StateDB
,
addr
common
.
Address
,
i
,
tweak
byte
)
{
modify
:=
func
(
state
*
StateDB
,
addr
common
.
Address
,
i
,
tweak
byte
)
{
state
.
SetBalance
(
addr
,
big
.
NewInt
(
int64
(
11
*
i
)
+
int64
(
tweak
)))
state
.
SetBalance
(
addr
,
big
.
NewInt
(
int64
(
11
*
i
)
+
int64
(
tweak
)))
...
@@ -149,7 +149,7 @@ func TestIntermediateLeaks(t *testing.T) {
...
@@ -149,7 +149,7 @@ func TestIntermediateLeaks(t *testing.T) {
// https://github.com/ethereum/go-ethereum/pull/15549.
// https://github.com/ethereum/go-ethereum/pull/15549.
func
TestCopy
(
t
*
testing
.
T
)
{
func
TestCopy
(
t
*
testing
.
T
)
{
// Create a random state test to copy and modify "independently"
// Create a random state test to copy and modify "independently"
orig
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
orig
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
for
i
:=
byte
(
0
);
i
<
255
;
i
++
{
for
i
:=
byte
(
0
);
i
<
255
;
i
++
{
obj
:=
orig
.
GetOrNewStateObject
(
common
.
BytesToAddress
([]
byte
{
i
}))
obj
:=
orig
.
GetOrNewStateObject
(
common
.
BytesToAddress
([]
byte
{
i
}))
...
@@ -409,7 +409,7 @@ func (test *snapshotTest) String() string {
...
@@ -409,7 +409,7 @@ func (test *snapshotTest) String() string {
func
(
test
*
snapshotTest
)
run
()
bool
{
func
(
test
*
snapshotTest
)
run
()
bool
{
// Run all actions and create snapshots.
// Run all actions and create snapshots.
var
(
var
(
state
,
_
=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
snapshotRevs
=
make
([]
int
,
len
(
test
.
snapshots
))
snapshotRevs
=
make
([]
int
,
len
(
test
.
snapshots
))
sindex
=
0
sindex
=
0
)
)
...
@@ -423,7 +423,7 @@ func (test *snapshotTest) run() bool {
...
@@ -423,7 +423,7 @@ func (test *snapshotTest) run() bool {
// Revert all snapshots in reverse order. Each revert must yield a state
// Revert all snapshots in reverse order. Each revert must yield a state
// that is equivalent to fresh state with all actions up the snapshot applied.
// that is equivalent to fresh state with all actions up the snapshot applied.
for
sindex
--
;
sindex
>=
0
;
sindex
--
{
for
sindex
--
;
sindex
>=
0
;
sindex
--
{
checkstate
,
_
:=
New
(
common
.
Hash
{}
,
state
.
Database
(),
nil
)
checkstate
,
_
:=
New
(
types
.
EmptyRootHash
,
state
.
Database
(),
nil
)
for
_
,
action
:=
range
test
.
actions
[
:
test
.
snapshots
[
sindex
]]
{
for
_
,
action
:=
range
test
.
actions
[
:
test
.
snapshots
[
sindex
]]
{
action
.
fn
(
action
,
checkstate
)
action
.
fn
(
action
,
checkstate
)
}
}
...
@@ -501,7 +501,7 @@ func TestTouchDelete(t *testing.T) {
...
@@ -501,7 +501,7 @@ func TestTouchDelete(t *testing.T) {
// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
// TestCopyOfCopy tests that modified objects are carried over to the copy, and the copy of the copy.
// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
// See https://github.com/ethereum/go-ethereum/pull/15225#issuecomment-380191512
func
TestCopyOfCopy
(
t
*
testing
.
T
)
{
func
TestCopyOfCopy
(
t
*
testing
.
T
)
{
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
addr
:=
common
.
HexToAddress
(
"aaaa"
)
addr
:=
common
.
HexToAddress
(
"aaaa"
)
state
.
SetBalance
(
addr
,
big
.
NewInt
(
42
))
state
.
SetBalance
(
addr
,
big
.
NewInt
(
42
))
...
@@ -518,7 +518,7 @@ func TestCopyOfCopy(t *testing.T) {
...
@@ -518,7 +518,7 @@ func TestCopyOfCopy(t *testing.T) {
//
//
// See https://github.com/ethereum/go-ethereum/issues/20106.
// See https://github.com/ethereum/go-ethereum/issues/20106.
func
TestCopyCommitCopy
(
t
*
testing
.
T
)
{
func
TestCopyCommitCopy
(
t
*
testing
.
T
)
{
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
// Create an account and check if the retrieved balance is correct
// Create an account and check if the retrieved balance is correct
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
...
@@ -590,7 +590,7 @@ func TestCopyCommitCopy(t *testing.T) {
...
@@ -590,7 +590,7 @@ func TestCopyCommitCopy(t *testing.T) {
//
//
// See https://github.com/ethereum/go-ethereum/issues/20106.
// See https://github.com/ethereum/go-ethereum/issues/20106.
func
TestCopyCopyCommitCopy
(
t
*
testing
.
T
)
{
func
TestCopyCopyCommitCopy
(
t
*
testing
.
T
)
{
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
// Create an account and check if the retrieved balance is correct
// Create an account and check if the retrieved balance is correct
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
...
@@ -680,7 +680,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
...
@@ -680,7 +680,7 @@ func TestCopyCopyCommitCopy(t *testing.T) {
// first, but the journal wiped the entire state object on create-revert.
// first, but the journal wiped the entire state object on create-revert.
func
TestDeleteCreateRevert
(
t
*
testing
.
T
)
{
func
TestDeleteCreateRevert
(
t
*
testing
.
T
)
{
// Create an initial state with a single contract
// Create an initial state with a single contract
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
addr
:=
common
.
BytesToAddress
([]
byte
(
"so"
))
addr
:=
common
.
BytesToAddress
([]
byte
(
"so"
))
state
.
SetBalance
(
addr
,
big
.
NewInt
(
1
))
state
.
SetBalance
(
addr
,
big
.
NewInt
(
1
))
...
@@ -713,7 +713,7 @@ func TestMissingTrieNodes(t *testing.T) {
...
@@ -713,7 +713,7 @@ func TestMissingTrieNodes(t *testing.T) {
memDb
:=
rawdb
.
NewMemoryDatabase
()
memDb
:=
rawdb
.
NewMemoryDatabase
()
db
:=
NewDatabase
(
memDb
)
db
:=
NewDatabase
(
memDb
)
var
root
common
.
Hash
var
root
common
.
Hash
state
,
_
:=
New
(
common
.
Hash
{}
,
db
,
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
db
,
nil
)
addr
:=
common
.
BytesToAddress
([]
byte
(
"so"
))
addr
:=
common
.
BytesToAddress
([]
byte
(
"so"
))
{
{
state
.
SetBalance
(
addr
,
big
.
NewInt
(
1
))
state
.
SetBalance
(
addr
,
big
.
NewInt
(
1
))
...
@@ -762,7 +762,7 @@ func TestStateDBAccessList(t *testing.T) {
...
@@ -762,7 +762,7 @@ func TestStateDBAccessList(t *testing.T) {
memDb
:=
rawdb
.
NewMemoryDatabase
()
memDb
:=
rawdb
.
NewMemoryDatabase
()
db
:=
NewDatabase
(
memDb
)
db
:=
NewDatabase
(
memDb
)
state
,
_
:=
New
(
common
.
Hash
{}
,
db
,
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
db
,
nil
)
state
.
accessList
=
newAccessList
()
state
.
accessList
=
newAccessList
()
verifyAddrs
:=
func
(
astrings
...
string
)
{
verifyAddrs
:=
func
(
astrings
...
string
)
{
...
@@ -932,7 +932,7 @@ func TestFlushOrderDataLoss(t *testing.T) {
...
@@ -932,7 +932,7 @@ func TestFlushOrderDataLoss(t *testing.T) {
var
(
var
(
memdb
=
rawdb
.
NewMemoryDatabase
()
memdb
=
rawdb
.
NewMemoryDatabase
()
statedb
=
NewDatabase
(
memdb
)
statedb
=
NewDatabase
(
memdb
)
state
,
_
=
New
(
common
.
Hash
{}
,
statedb
,
nil
)
state
,
_
=
New
(
types
.
EmptyRootHash
,
statedb
,
nil
)
)
)
for
a
:=
byte
(
0
);
a
<
10
;
a
++
{
for
a
:=
byte
(
0
);
a
<
10
;
a
++
{
state
.
CreateAccount
(
common
.
Address
{
a
})
state
.
CreateAccount
(
common
.
Address
{
a
})
...
@@ -968,7 +968,7 @@ func TestFlushOrderDataLoss(t *testing.T) {
...
@@ -968,7 +968,7 @@ func TestFlushOrderDataLoss(t *testing.T) {
func
TestStateDBTransientStorage
(
t
*
testing
.
T
)
{
func
TestStateDBTransientStorage
(
t
*
testing
.
T
)
{
memDb
:=
rawdb
.
NewMemoryDatabase
()
memDb
:=
rawdb
.
NewMemoryDatabase
()
db
:=
NewDatabase
(
memDb
)
db
:=
NewDatabase
(
memDb
)
state
,
_
:=
New
(
common
.
Hash
{}
,
db
,
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
db
,
nil
)
key
:=
common
.
Hash
{
0x01
}
key
:=
common
.
Hash
{
0x01
}
value
:=
common
.
Hash
{
0x02
}
value
:=
common
.
Hash
{
0x02
}
...
...
core/state/sync_test.go
View file @
a1430182
...
@@ -43,7 +43,7 @@ func makeTestState() (ethdb.Database, Database, common.Hash, []*testAccount) {
...
@@ -43,7 +43,7 @@ func makeTestState() (ethdb.Database, Database, common.Hash, []*testAccount) {
// Create an empty state
// Create an empty state
db
:=
rawdb
.
NewMemoryDatabase
()
db
:=
rawdb
.
NewMemoryDatabase
()
sdb
:=
NewDatabase
(
db
)
sdb
:=
NewDatabase
(
db
)
state
,
_
:=
New
(
common
.
Hash
{}
,
sdb
,
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
sdb
,
nil
)
// Fill it with some arbitrary data
// Fill it with some arbitrary data
var
accounts
[]
*
testAccount
var
accounts
[]
*
testAccount
...
...
core/state/trie_prefetcher_test.go
View file @
a1430182
...
@@ -23,10 +23,11 @@ import (
...
@@ -23,10 +23,11 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
)
)
func
filledStateDB
()
*
StateDB
{
func
filledStateDB
()
*
StateDB
{
state
,
_
:=
New
(
common
.
Hash
{}
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
New
(
types
.
EmptyRootHash
,
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
// Create an account and check if the retrieved balance is correct
// Create an account and check if the retrieved balance is correct
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
addr
:=
common
.
HexToAddress
(
"0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe"
)
...
...
core/txpool/txpool2_test.go
View file @
a1430182
...
@@ -78,7 +78,7 @@ func TestTransactionFutureAttack(t *testing.T) {
...
@@ -78,7 +78,7 @@ func TestTransactionFutureAttack(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
config
.
GlobalQueue
=
100
config
.
GlobalQueue
=
100
...
@@ -114,7 +114,7 @@ func TestTransactionFutureAttack(t *testing.T) {
...
@@ -114,7 +114,7 @@ func TestTransactionFutureAttack(t *testing.T) {
func
TestTransactionFuture1559
(
t
*
testing
.
T
)
{
func
TestTransactionFuture1559
(
t
*
testing
.
T
)
{
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
defer
pool
.
Stop
()
defer
pool
.
Stop
()
...
@@ -146,7 +146,7 @@ func TestTransactionFuture1559(t *testing.T) {
...
@@ -146,7 +146,7 @@ func TestTransactionFuture1559(t *testing.T) {
func
TestTransactionZAttack
(
t
*
testing
.
T
)
{
func
TestTransactionZAttack
(
t
*
testing
.
T
)
{
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
defer
pool
.
Stop
()
defer
pool
.
Stop
()
...
@@ -213,7 +213,7 @@ func TestTransactionZAttack(t *testing.T) {
...
@@ -213,7 +213,7 @@ func TestTransactionZAttack(t *testing.T) {
func
BenchmarkFutureAttack
(
b
*
testing
.
B
)
{
func
BenchmarkFutureAttack
(
b
*
testing
.
B
)
{
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
config
.
GlobalQueue
=
100
config
.
GlobalQueue
=
100
...
...
core/txpool/txpool_test.go
View file @
a1430182
...
@@ -126,7 +126,7 @@ func setupPool() (*TxPool, *ecdsa.PrivateKey) {
...
@@ -126,7 +126,7 @@ func setupPool() (*TxPool, *ecdsa.PrivateKey) {
}
}
func
setupPoolWithConfig
(
config
*
params
.
ChainConfig
)
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
func
setupPoolWithConfig
(
config
*
params
.
ChainConfig
)
(
*
TxPool
,
*
ecdsa
.
PrivateKey
)
{
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
10000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
10000000
,
statedb
,
new
(
event
.
Feed
))
key
,
_
:=
crypto
.
GenerateKey
()
key
,
_
:=
crypto
.
GenerateKey
()
...
@@ -218,7 +218,7 @@ func (c *testChain) State() (*state.StateDB, error) {
...
@@ -218,7 +218,7 @@ func (c *testChain) State() (*state.StateDB, error) {
// a state change between those fetches.
// a state change between those fetches.
stdb
:=
c
.
statedb
stdb
:=
c
.
statedb
if
*
c
.
trigger
{
if
*
c
.
trigger
{
c
.
statedb
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
c
.
statedb
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
// simulate that the new head block included tx0 and tx1
// simulate that the new head block included tx0 and tx1
c
.
statedb
.
SetNonce
(
c
.
address
,
2
)
c
.
statedb
.
SetNonce
(
c
.
address
,
2
)
c
.
statedb
.
SetBalance
(
c
.
address
,
new
(
big
.
Int
)
.
SetUint64
(
params
.
Ether
))
c
.
statedb
.
SetBalance
(
c
.
address
,
new
(
big
.
Int
)
.
SetUint64
(
params
.
Ether
))
...
@@ -236,7 +236,7 @@ func TestStateChangeDuringReset(t *testing.T) {
...
@@ -236,7 +236,7 @@ func TestStateChangeDuringReset(t *testing.T) {
var
(
var
(
key
,
_
=
crypto
.
GenerateKey
()
key
,
_
=
crypto
.
GenerateKey
()
address
=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
address
=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
statedb
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
trigger
=
false
trigger
=
false
)
)
...
@@ -434,7 +434,7 @@ func TestChainFork(t *testing.T) {
...
@@ -434,7 +434,7 @@ func TestChainFork(t *testing.T) {
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
resetState
:=
func
()
{
resetState
:=
func
()
{
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
AddBalance
(
addr
,
big
.
NewInt
(
100000000000000
))
statedb
.
AddBalance
(
addr
,
big
.
NewInt
(
100000000000000
))
pool
.
chain
=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
.
chain
=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
...
@@ -463,7 +463,7 @@ func TestDoubleNonce(t *testing.T) {
...
@@ -463,7 +463,7 @@ func TestDoubleNonce(t *testing.T) {
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
addr
:=
crypto
.
PubkeyToAddress
(
key
.
PublicKey
)
resetState
:=
func
()
{
resetState
:=
func
()
{
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
AddBalance
(
addr
,
big
.
NewInt
(
100000000000000
))
statedb
.
AddBalance
(
addr
,
big
.
NewInt
(
100000000000000
))
pool
.
chain
=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
.
chain
=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
...
@@ -663,7 +663,7 @@ func TestPostponing(t *testing.T) {
...
@@ -663,7 +663,7 @@ func TestPostponing(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the postponing with
// Create the pool to test the postponing with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
...
@@ -875,7 +875,7 @@ func testQueueGlobalLimiting(t *testing.T, nolocals bool) {
...
@@ -875,7 +875,7 @@ func testQueueGlobalLimiting(t *testing.T, nolocals bool) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -967,7 +967,7 @@ func testQueueTimeLimiting(t *testing.T, nolocals bool) {
...
@@ -967,7 +967,7 @@ func testQueueTimeLimiting(t *testing.T, nolocals bool) {
evictionInterval
=
time
.
Millisecond
*
100
evictionInterval
=
time
.
Millisecond
*
100
// Create the pool to test the non-expiration enforcement
// Create the pool to test the non-expiration enforcement
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -1152,7 +1152,7 @@ func TestPendingGlobalLimiting(t *testing.T) {
...
@@ -1152,7 +1152,7 @@ func TestPendingGlobalLimiting(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -1254,7 +1254,7 @@ func TestCapClearsFromAll(t *testing.T) {
...
@@ -1254,7 +1254,7 @@ func TestCapClearsFromAll(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -1288,7 +1288,7 @@ func TestPendingMinimumAllowance(t *testing.T) {
...
@@ -1288,7 +1288,7 @@ func TestPendingMinimumAllowance(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the limit enforcement with
// Create the pool to test the limit enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -1336,7 +1336,7 @@ func TestRepricing(t *testing.T) {
...
@@ -1336,7 +1336,7 @@ func TestRepricing(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
...
@@ -1584,7 +1584,7 @@ func TestRepricingKeepsLocals(t *testing.T) {
...
@@ -1584,7 +1584,7 @@ func TestRepricingKeepsLocals(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
eip1559Config
,
blockchain
)
...
@@ -1657,7 +1657,7 @@ func TestUnderpricing(t *testing.T) {
...
@@ -1657,7 +1657,7 @@ func TestUnderpricing(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -1771,7 +1771,7 @@ func TestStableUnderpricing(t *testing.T) {
...
@@ -1771,7 +1771,7 @@ func TestStableUnderpricing(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -2003,7 +2003,7 @@ func TestDeduplication(t *testing.T) {
...
@@ -2003,7 +2003,7 @@ func TestDeduplication(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
...
@@ -2069,7 +2069,7 @@ func TestReplacement(t *testing.T) {
...
@@ -2069,7 +2069,7 @@ func TestReplacement(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the pricing enforcement with
// Create the pool to test the pricing enforcement with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
...
@@ -2274,7 +2274,7 @@ func testJournaling(t *testing.T, nolocals bool) {
...
@@ -2274,7 +2274,7 @@ func testJournaling(t *testing.T, nolocals bool) {
os
.
Remove
(
journal
)
os
.
Remove
(
journal
)
// Create the original pool to inject transaction into the journal
// Create the original pool to inject transaction into the journal
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
config
:=
testTxPoolConfig
config
:=
testTxPoolConfig
...
@@ -2372,7 +2372,7 @@ func TestStatusCheck(t *testing.T) {
...
@@ -2372,7 +2372,7 @@ func TestStatusCheck(t *testing.T) {
t
.
Parallel
()
t
.
Parallel
()
// Create the pool to test the status retrievals with
// Create the pool to test the status retrievals with
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
blockchain
:=
newTestBlockChain
(
1000000
,
statedb
,
new
(
event
.
Feed
))
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
pool
:=
NewTxPool
(
testTxPoolConfig
,
params
.
TestChainConfig
,
blockchain
)
...
...
core/vm/gas_table_test.go
View file @
a1430182
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -83,7 +84,7 @@ func TestEIP2200(t *testing.T) {
...
@@ -83,7 +84,7 @@ func TestEIP2200(t *testing.T) {
for
i
,
tt
:=
range
eip2200Tests
{
for
i
,
tt
:=
range
eip2200Tests
{
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
CreateAccount
(
address
)
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
input
))
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
input
))
statedb
.
SetState
(
address
,
common
.
Hash
{},
common
.
BytesToHash
([]
byte
{
tt
.
original
}))
statedb
.
SetState
(
address
,
common
.
Hash
{},
common
.
BytesToHash
([]
byte
{
tt
.
original
}))
...
@@ -135,7 +136,7 @@ func TestCreateGas(t *testing.T) {
...
@@ -135,7 +136,7 @@ func TestCreateGas(t *testing.T) {
var
gasUsed
=
uint64
(
0
)
var
gasUsed
=
uint64
(
0
)
doCheck
:=
func
(
testGas
int
)
bool
{
doCheck
:=
func
(
testGas
int
)
bool
{
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
address
:=
common
.
BytesToAddress
([]
byte
(
"contract"
))
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
CreateAccount
(
address
)
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
code
))
statedb
.
SetCode
(
address
,
hexutil
.
MustDecode
(
tt
.
code
))
statedb
.
Finalise
(
true
)
statedb
.
Finalise
(
true
)
...
...
core/vm/instructions_test.go
View file @
a1430182
...
@@ -27,6 +27,7 @@ import (
...
@@ -27,6 +27,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"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/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/holiman/uint256"
"github.com/holiman/uint256"
...
@@ -579,7 +580,7 @@ func BenchmarkOpMstore(bench *testing.B) {
...
@@ -579,7 +580,7 @@ func BenchmarkOpMstore(bench *testing.B) {
func
TestOpTstore
(
t
*
testing
.
T
)
{
func
TestOpTstore
(
t
*
testing
.
T
)
{
var
(
var
(
statedb
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
env
=
NewEVM
(
BlockContext
{},
TxContext
{},
statedb
,
params
.
TestChainConfig
,
Config
{})
env
=
NewEVM
(
BlockContext
{},
TxContext
{},
statedb
,
params
.
TestChainConfig
,
Config
{})
stack
=
newstack
()
stack
=
newstack
()
mem
=
NewMemory
()
mem
=
NewMemory
()
...
...
core/vm/interpreter_test.go
View file @
a1430182
...
@@ -25,6 +25,7 @@ import (
...
@@ -25,6 +25,7 @@ import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
)
)
...
@@ -42,7 +43,7 @@ func TestLoopInterrupt(t *testing.T) {
...
@@ -42,7 +43,7 @@ func TestLoopInterrupt(t *testing.T) {
}
}
for
i
,
tt
:=
range
loopInterruptTests
{
for
i
,
tt
:=
range
loopInterruptTests
{
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
CreateAccount
(
address
)
statedb
.
CreateAccount
(
address
)
statedb
.
SetCode
(
address
,
common
.
Hex2Bytes
(
tt
))
statedb
.
SetCode
(
address
,
common
.
Hex2Bytes
(
tt
))
statedb
.
Finalise
(
true
)
statedb
.
Finalise
(
true
)
...
...
core/vm/runtime/runtime.go
View file @
a1430182
...
@@ -23,6 +23,7 @@ import (
...
@@ -23,6 +23,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
...
@@ -106,7 +107,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
...
@@ -106,7 +107,7 @@ func Execute(code, input []byte, cfg *Config) ([]byte, *state.StateDB, error) {
setDefaults
(
cfg
)
setDefaults
(
cfg
)
if
cfg
.
State
==
nil
{
if
cfg
.
State
==
nil
{
cfg
.
State
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
cfg
.
State
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
}
}
var
(
var
(
address
=
common
.
BytesToAddress
([]
byte
(
"contract"
))
address
=
common
.
BytesToAddress
([]
byte
(
"contract"
))
...
@@ -140,7 +141,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
...
@@ -140,7 +141,7 @@ func Create(input []byte, cfg *Config) ([]byte, common.Address, uint64, error) {
setDefaults
(
cfg
)
setDefaults
(
cfg
)
if
cfg
.
State
==
nil
{
if
cfg
.
State
==
nil
{
cfg
.
State
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
cfg
.
State
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
}
}
var
(
var
(
vmenv
=
NewEnv
(
cfg
)
vmenv
=
NewEnv
(
cfg
)
...
...
core/vm/runtime/runtime_test.go
View file @
a1430182
...
@@ -103,7 +103,7 @@ func TestExecute(t *testing.T) {
...
@@ -103,7 +103,7 @@ func TestExecute(t *testing.T) {
}
}
func
TestCall
(
t
*
testing
.
T
)
{
func
TestCall
(
t
*
testing
.
T
)
{
state
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
address
:=
common
.
HexToAddress
(
"0x0a"
)
address
:=
common
.
HexToAddress
(
"0x0a"
)
state
.
SetCode
(
address
,
[]
byte
{
state
.
SetCode
(
address
,
[]
byte
{
byte
(
vm
.
PUSH1
),
10
,
byte
(
vm
.
PUSH1
),
10
,
...
@@ -159,7 +159,7 @@ func BenchmarkCall(b *testing.B) {
...
@@ -159,7 +159,7 @@ func BenchmarkCall(b *testing.B) {
}
}
func
benchmarkEVM_Create
(
bench
*
testing
.
B
,
code
string
)
{
func
benchmarkEVM_Create
(
bench
*
testing
.
B
,
code
string
)
{
var
(
var
(
statedb
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
sender
=
common
.
BytesToAddress
([]
byte
(
"sender"
))
sender
=
common
.
BytesToAddress
([]
byte
(
"sender"
))
receiver
=
common
.
BytesToAddress
([]
byte
(
"receiver"
))
receiver
=
common
.
BytesToAddress
([]
byte
(
"receiver"
))
)
)
...
@@ -327,7 +327,7 @@ func TestBlockhash(t *testing.T) {
...
@@ -327,7 +327,7 @@ func TestBlockhash(t *testing.T) {
func
benchmarkNonModifyingCode
(
gas
uint64
,
code
[]
byte
,
name
string
,
tracerCode
string
,
b
*
testing
.
B
)
{
func
benchmarkNonModifyingCode
(
gas
uint64
,
code
[]
byte
,
name
string
,
tracerCode
string
,
b
*
testing
.
B
)
{
cfg
:=
new
(
Config
)
cfg
:=
new
(
Config
)
setDefaults
(
cfg
)
setDefaults
(
cfg
)
cfg
.
State
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
cfg
.
State
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
cfg
.
GasLimit
=
gas
cfg
.
GasLimit
=
gas
if
len
(
tracerCode
)
>
0
{
if
len
(
tracerCode
)
>
0
{
tracer
,
err
:=
tracers
.
DefaultDirectory
.
New
(
tracerCode
,
new
(
tracers
.
Context
),
nil
)
tracer
,
err
:=
tracers
.
DefaultDirectory
.
New
(
tracerCode
,
new
(
tracers
.
Context
),
nil
)
...
@@ -818,7 +818,7 @@ func TestRuntimeJSTracer(t *testing.T) {
...
@@ -818,7 +818,7 @@ func TestRuntimeJSTracer(t *testing.T) {
main
:=
common
.
HexToAddress
(
"0xaa"
)
main
:=
common
.
HexToAddress
(
"0xaa"
)
for
i
,
jsTracer
:=
range
jsTracers
{
for
i
,
jsTracer
:=
range
jsTracers
{
for
j
,
tc
:=
range
tests
{
for
j
,
tc
:=
range
tests
{
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
.
SetCode
(
main
,
tc
.
code
)
statedb
.
SetCode
(
main
,
tc
.
code
)
statedb
.
SetCode
(
common
.
HexToAddress
(
"0xbb"
),
calleeCode
)
statedb
.
SetCode
(
common
.
HexToAddress
(
"0xbb"
),
calleeCode
)
statedb
.
SetCode
(
common
.
HexToAddress
(
"0xcc"
),
calleeCode
)
statedb
.
SetCode
(
common
.
HexToAddress
(
"0xcc"
),
calleeCode
)
...
@@ -860,7 +860,7 @@ func TestJSTracerCreateTx(t *testing.T) {
...
@@ -860,7 +860,7 @@ func TestJSTracerCreateTx(t *testing.T) {
exit: function(res) { this.exits++ }}`
exit: function(res) { this.exits++ }}`
code
:=
[]
byte
{
byte
(
vm
.
PUSH1
),
0
,
byte
(
vm
.
PUSH1
),
0
,
byte
(
vm
.
RETURN
)}
code
:=
[]
byte
{
byte
(
vm
.
PUSH1
),
0
,
byte
(
vm
.
PUSH1
),
0
,
byte
(
vm
.
RETURN
)}
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
tracer
,
err
:=
tracers
.
DefaultDirectory
.
New
(
jsTracer
,
new
(
tracers
.
Context
),
nil
)
tracer
,
err
:=
tracers
.
DefaultDirectory
.
New
(
jsTracer
,
new
(
tracers
.
Context
),
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
eth/api_test.go
View file @
a1430182
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"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/crypto"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie"
)
)
...
@@ -68,7 +69,7 @@ func TestAccountRange(t *testing.T) {
...
@@ -68,7 +69,7 @@ func TestAccountRange(t *testing.T) {
var
(
var
(
statedb
=
state
.
NewDatabaseWithConfig
(
rawdb
.
NewMemoryDatabase
(),
&
trie
.
Config
{
Preimages
:
true
})
statedb
=
state
.
NewDatabaseWithConfig
(
rawdb
.
NewMemoryDatabase
(),
&
trie
.
Config
{
Preimages
:
true
})
state
,
_
=
state
.
New
(
common
.
Hash
{}
,
statedb
,
nil
)
state
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
statedb
,
nil
)
addrs
=
[
AccountRangeMaxResults
*
2
]
common
.
Address
{}
addrs
=
[
AccountRangeMaxResults
*
2
]
common
.
Address
{}
m
=
map
[
common
.
Address
]
bool
{}
m
=
map
[
common
.
Address
]
bool
{}
)
)
...
@@ -139,7 +140,7 @@ func TestEmptyAccountRange(t *testing.T) {
...
@@ -139,7 +140,7 @@ func TestEmptyAccountRange(t *testing.T) {
var
(
var
(
statedb
=
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
statedb
=
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
st
,
_
=
state
.
New
(
common
.
Hash
{}
,
statedb
,
nil
)
st
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
statedb
,
nil
)
)
)
st
.
Commit
(
true
)
st
.
Commit
(
true
)
st
.
IntermediateRoot
(
true
)
st
.
IntermediateRoot
(
true
)
...
@@ -162,7 +163,7 @@ func TestStorageRangeAt(t *testing.T) {
...
@@ -162,7 +163,7 @@ func TestStorageRangeAt(t *testing.T) {
// Create a state where account 0x010000... has a few storage entries.
// Create a state where account 0x010000... has a few storage entries.
var
(
var
(
state
,
_
=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
state
,
_
=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
rawdb
.
NewMemoryDatabase
()),
nil
)
addr
=
common
.
Address
{
0x01
}
addr
=
common
.
Address
{
0x01
}
keys
=
[]
common
.
Hash
{
// hashes of Keys of storage
keys
=
[]
common
.
Hash
{
// hashes of Keys of storage
common
.
HexToHash
(
"340dd630ad21bf010b4e676dbfa9ba9a02175262d1fa356232cfde6cb5b47ef2"
),
common
.
HexToHash
(
"340dd630ad21bf010b4e676dbfa9ba9a02175262d1fa356232cfde6cb5b47ef2"
),
...
...
eth/fetcher/block_fetcher_test.go
View file @
a1430182
...
@@ -45,7 +45,7 @@ var (
...
@@ -45,7 +45,7 @@ var (
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
),
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
),
}
}
genesis
=
gspec
.
MustCommit
(
testdb
)
genesis
=
gspec
.
MustCommit
(
testdb
)
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
GasLimit
:
params
.
GenesisGasLimit
,
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
)},
nil
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
Root
:
types
.
EmptyRootHash
,
GasLimit
:
params
.
GenesisGasLimit
,
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
)},
nil
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
)
)
// makeChain creates a chain of n blocks starting at and including parent.
// makeChain creates a chain of n blocks starting at and including parent.
...
...
eth/protocols/snap/sync_test.go
View file @
a1430182
...
@@ -1589,7 +1589,7 @@ func makeAccountTrieWithStorage(accounts, slots int, code, boundary bool) (strin
...
@@ -1589,7 +1589,7 @@ func makeAccountTrieWithStorage(accounts, slots int, code, boundary bool) (strin
// not-yet-committed trie and the sorted entries. The seeds can be used to ensure
// not-yet-committed trie and the sorted entries. The seeds can be used to ensure
// that tries are unique.
// that tries are unique.
func
makeStorageTrieWithSeed
(
owner
common
.
Hash
,
n
,
seed
uint64
,
db
*
trie
.
Database
)
(
common
.
Hash
,
*
trienode
.
NodeSet
,
entrySlice
)
{
func
makeStorageTrieWithSeed
(
owner
common
.
Hash
,
n
,
seed
uint64
,
db
*
trie
.
Database
)
(
common
.
Hash
,
*
trienode
.
NodeSet
,
entrySlice
)
{
trie
,
_
:=
trie
.
New
(
trie
.
StorageTrieID
(
common
.
Hash
{},
owner
,
common
.
Hash
{}
),
db
)
trie
,
_
:=
trie
.
New
(
trie
.
StorageTrieID
(
types
.
EmptyRootHash
,
owner
,
types
.
EmptyRootHash
),
db
)
var
entries
entrySlice
var
entries
entrySlice
for
i
:=
uint64
(
1
);
i
<=
n
;
i
++
{
for
i
:=
uint64
(
1
);
i
<=
n
;
i
++
{
// store 'x' at slot 'x'
// store 'x' at slot 'x'
...
@@ -1615,7 +1615,7 @@ func makeBoundaryStorageTrie(owner common.Hash, n int, db *trie.Database) (commo
...
@@ -1615,7 +1615,7 @@ func makeBoundaryStorageTrie(owner common.Hash, n int, db *trie.Database) (commo
var
(
var
(
entries
entrySlice
entries
entrySlice
boundaries
[]
common
.
Hash
boundaries
[]
common
.
Hash
trie
,
_
=
trie
.
New
(
trie
.
StorageTrieID
(
common
.
Hash
{},
owner
,
common
.
Hash
{}
),
db
)
trie
,
_
=
trie
.
New
(
trie
.
StorageTrieID
(
types
.
EmptyRootHash
,
owner
,
types
.
EmptyRootHash
),
db
)
)
)
// Initialize boundaries
// Initialize boundaries
var
next
common
.
Hash
var
next
common
.
Hash
...
...
les/fetcher/block_fetcher_test.go
View file @
a1430182
...
@@ -44,7 +44,7 @@ var (
...
@@ -44,7 +44,7 @@ var (
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
),
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
),
}
}
genesis
=
gspec
.
MustCommit
(
testdb
)
genesis
=
gspec
.
MustCommit
(
testdb
)
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
GasLimit
:
params
.
GenesisGasLimit
,
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
)},
nil
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
unknownBlock
=
types
.
NewBlock
(
&
types
.
Header
{
Root
:
types
.
EmptyRootHash
,
GasLimit
:
params
.
GenesisGasLimit
,
BaseFee
:
big
.
NewInt
(
params
.
InitialBaseFee
)},
nil
,
nil
,
nil
,
trie
.
NewStackTrie
(
nil
))
)
)
// makeChain creates a chain of n blocks starting at and including parent.
// makeChain creates a chain of n blocks starting at and including parent.
...
...
light/postprocess.go
View file @
a1430182
...
@@ -179,7 +179,7 @@ func (c *ChtIndexerBackend) fetchMissingNodes(ctx context.Context, section uint6
...
@@ -179,7 +179,7 @@ func (c *ChtIndexerBackend) fetchMissingNodes(ctx context.Context, section uint6
// Reset implements core.ChainIndexerBackend
// Reset implements core.ChainIndexerBackend
func
(
c
*
ChtIndexerBackend
)
Reset
(
ctx
context
.
Context
,
section
uint64
,
lastSectionHead
common
.
Hash
)
error
{
func
(
c
*
ChtIndexerBackend
)
Reset
(
ctx
context
.
Context
,
section
uint64
,
lastSectionHead
common
.
Hash
)
error
{
var
root
common
.
Hash
root
:=
types
.
EmptyRoot
Hash
if
section
>
0
{
if
section
>
0
{
root
=
GetChtRoot
(
c
.
diskdb
,
section
-
1
,
lastSectionHead
)
root
=
GetChtRoot
(
c
.
diskdb
,
section
-
1
,
lastSectionHead
)
}
}
...
@@ -404,7 +404,7 @@ func (b *BloomTrieIndexerBackend) fetchMissingNodes(ctx context.Context, section
...
@@ -404,7 +404,7 @@ func (b *BloomTrieIndexerBackend) fetchMissingNodes(ctx context.Context, section
// Reset implements core.ChainIndexerBackend
// Reset implements core.ChainIndexerBackend
func
(
b
*
BloomTrieIndexerBackend
)
Reset
(
ctx
context
.
Context
,
section
uint64
,
lastSectionHead
common
.
Hash
)
error
{
func
(
b
*
BloomTrieIndexerBackend
)
Reset
(
ctx
context
.
Context
,
section
uint64
,
lastSectionHead
common
.
Hash
)
error
{
var
root
common
.
Hash
root
:=
types
.
EmptyRoot
Hash
if
section
>
0
{
if
section
>
0
{
root
=
GetBloomTrieRoot
(
b
.
diskdb
,
section
-
1
,
lastSectionHead
)
root
=
GetBloomTrieRoot
(
b
.
diskdb
,
section
-
1
,
lastSectionHead
)
}
}
...
...
miner/miner_test.go
View file @
a1430182
...
@@ -264,7 +264,7 @@ func createMiner(t *testing.T) (*Miner, *event.TypeMux, func(skipMiner bool)) {
...
@@ -264,7 +264,7 @@ func createMiner(t *testing.T) (*Miner, *event.TypeMux, func(skipMiner bool)) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatalf
(
"can't create new chain %v"
,
err
)
t
.
Fatalf
(
"can't create new chain %v"
,
err
)
}
}
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
state
.
NewDatabase
(
chainDB
),
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
state
.
NewDatabase
(
chainDB
),
nil
)
blockchain
:=
&
testBlockChain
{
statedb
,
10000000
,
new
(
event
.
Feed
)}
blockchain
:=
&
testBlockChain
{
statedb
,
10000000
,
new
(
event
.
Feed
)}
pool
:=
txpool
.
NewTxPool
(
testTxPoolConfig
,
chainConfig
,
blockchain
)
pool
:=
txpool
.
NewTxPool
(
testTxPoolConfig
,
chainConfig
,
blockchain
)
...
...
tests/state_test_util.go
View file @
a1430182
...
@@ -286,7 +286,7 @@ func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
...
@@ -286,7 +286,7 @@ func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
,
snapshotter
bool
)
(
*
snapshot
.
Tree
,
*
state
.
StateDB
)
{
func
MakePreState
(
db
ethdb
.
Database
,
accounts
core
.
GenesisAlloc
,
snapshotter
bool
)
(
*
snapshot
.
Tree
,
*
state
.
StateDB
)
{
sdb
:=
state
.
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
})
sdb
:=
state
.
NewDatabaseWithConfig
(
db
,
&
trie
.
Config
{
Preimages
:
true
})
statedb
,
_
:=
state
.
New
(
common
.
Hash
{}
,
sdb
,
nil
)
statedb
,
_
:=
state
.
New
(
types
.
EmptyRootHash
,
sdb
,
nil
)
for
addr
,
a
:=
range
accounts
{
for
addr
,
a
:=
range
accounts
{
statedb
.
SetCode
(
addr
,
a
.
Code
)
statedb
.
SetCode
(
addr
,
a
.
Code
)
statedb
.
SetNonce
(
addr
,
a
.
Nonce
)
statedb
.
SetNonce
(
addr
,
a
.
Nonce
)
...
...
trie/iterator_test.go
View file @
a1430182
...
@@ -584,7 +584,7 @@ func makeLargeTestTrie() (*Database, *StateTrie, *loggingDb) {
...
@@ -584,7 +584,7 @@ func makeLargeTestTrie() (*Database, *StateTrie, *loggingDb) {
// Create an empty trie
// Create an empty trie
logDb
:=
&
loggingDb
{
0
,
memorydb
.
New
()}
logDb
:=
&
loggingDb
{
0
,
memorydb
.
New
()}
triedb
:=
NewDatabase
(
rawdb
.
NewDatabase
(
logDb
))
triedb
:=
NewDatabase
(
rawdb
.
NewDatabase
(
logDb
))
trie
,
_
:=
NewStateTrie
(
TrieID
(
common
.
Hash
{}
),
triedb
)
trie
,
_
:=
NewStateTrie
(
TrieID
(
types
.
EmptyRootHash
),
triedb
)
// Fill it with some arbitrary data
// Fill it with some arbitrary data
for
i
:=
0
;
i
<
10000
;
i
++
{
for
i
:=
0
;
i
<
10000
;
i
++
{
...
...
trie/secure_trie_test.go
View file @
a1430182
...
@@ -31,7 +31,7 @@ import (
...
@@ -31,7 +31,7 @@ import (
)
)
func
newEmptySecure
()
*
StateTrie
{
func
newEmptySecure
()
*
StateTrie
{
trie
,
_
:=
NewStateTrie
(
TrieID
(
common
.
Hash
{}
),
NewDatabase
(
rawdb
.
NewMemoryDatabase
()))
trie
,
_
:=
NewStateTrie
(
TrieID
(
types
.
EmptyRootHash
),
NewDatabase
(
rawdb
.
NewMemoryDatabase
()))
return
trie
return
trie
}
}
...
@@ -39,7 +39,7 @@ func newEmptySecure() *StateTrie {
...
@@ -39,7 +39,7 @@ func newEmptySecure() *StateTrie {
func
makeTestStateTrie
()
(
*
Database
,
*
StateTrie
,
map
[
string
][]
byte
)
{
func
makeTestStateTrie
()
(
*
Database
,
*
StateTrie
,
map
[
string
][]
byte
)
{
// Create an empty trie
// Create an empty trie
triedb
:=
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
triedb
:=
NewDatabase
(
rawdb
.
NewMemoryDatabase
())
trie
,
_
:=
NewStateTrie
(
TrieID
(
common
.
Hash
{}
),
triedb
)
trie
,
_
:=
NewStateTrie
(
TrieID
(
types
.
EmptyRootHash
),
triedb
)
// Fill it with some arbitrary data
// Fill it with some arbitrary data
content
:=
make
(
map
[
string
][]
byte
)
content
:=
make
(
map
[
string
][]
byte
)
...
...
trie/sync_test.go
View file @
a1430182
...
@@ -35,7 +35,7 @@ func makeTestTrie(scheme string) (ethdb.Database, *Database, *StateTrie, map[str
...
@@ -35,7 +35,7 @@ func makeTestTrie(scheme string) (ethdb.Database, *Database, *StateTrie, map[str
// Create an empty trie
// Create an empty trie
db
:=
rawdb
.
NewMemoryDatabase
()
db
:=
rawdb
.
NewMemoryDatabase
()
triedb
:=
newTestDatabase
(
db
,
scheme
)
triedb
:=
newTestDatabase
(
db
,
scheme
)
trie
,
_
:=
NewStateTrie
(
TrieID
(
common
.
Hash
{}
),
triedb
)
trie
,
_
:=
NewStateTrie
(
TrieID
(
types
.
EmptyRootHash
),
triedb
)
// Fill it with some arbitrary data
// Fill it with some arbitrary data
content
:=
make
(
map
[
string
][]
byte
)
content
:=
make
(
map
[
string
][]
byte
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment