Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
exchain
nebula
Commits
536d424b
Commit
536d424b
authored
Sep 22, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aha, trie is used in two places. refactor this to be better
parent
5b27a12d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
database.go
minigeth/core/state/database.go
+16
-9
statedb.go
minigeth/core/state/statedb.go
+1
-1
proved.go
minigeth/oracle/proved.go
+1
-1
No files found.
minigeth/core/state/database.go
View file @
536d424b
...
...
@@ -43,7 +43,7 @@ func (db *Database) ContractCodeSize(addrHash common.Hash, codeHash common.Hash)
// OpenStorageTrie opens the storage trie of an account.
func
(
db
*
Database
)
OpenStorageTrie
(
addrHash
,
root
common
.
Hash
)
(
Trie
,
error
)
{
return
SimpleTrie
{
db
.
BlockNumber
,
db
.
StateRoot
},
nil
return
SimpleTrie
{
db
.
BlockNumber
,
root
,
true
,
unhash
(
addrHash
)
},
nil
}
type
LeafCallback
func
(
paths
[][]
byte
,
hexpath
[]
byte
,
leaf
[]
byte
,
parent
common
.
Hash
)
error
...
...
@@ -75,15 +75,17 @@ type Trie interface {
type
SimpleTrie
struct
{
BlockNumber
*
big
.
Int
StateRoot
common
.
Hash
Root
common
.
Hash
Storage
bool
Address
common
.
Address
}
func
(
trie
SimpleTrie
)
Commit
(
onleaf
LeafCallback
)
(
common
.
Hash
,
error
)
{
return
trie
.
State
Root
,
nil
return
trie
.
Root
,
nil
}
func
(
trie
SimpleTrie
)
Hash
()
common
.
Hash
{
return
trie
.
State
Root
return
trie
.
Root
}
func
(
trie
SimpleTrie
)
TryUpdate
(
key
,
value
[]
byte
)
error
{
...
...
@@ -95,11 +97,16 @@ func (trie SimpleTrie) TryDelete(key []byte) error {
}
func
(
trie
SimpleTrie
)
TryGet
(
key
[]
byte
)
([]
byte
,
error
)
{
address
:=
common
.
BytesToAddress
(
key
)
addrHash
:=
crypto
.
Keccak256Hash
(
address
[
:
])
unhashMap
[
addrHash
]
=
address
enc
:=
oracle
.
GetProvedAccountBytes
(
trie
.
BlockNumber
,
trie
.
StateRoot
,
address
)
return
enc
,
nil
if
trie
.
Storage
{
enc
:=
oracle
.
GetProvedStorage
(
trie
.
BlockNumber
,
trie
.
Address
,
trie
.
Root
,
common
.
BytesToHash
(
key
))
return
enc
.
Bytes
(),
nil
}
else
{
address
:=
common
.
BytesToAddress
(
key
)
addrHash
:=
crypto
.
Keccak256Hash
(
address
[
:
])
unhashMap
[
addrHash
]
=
address
enc
:=
oracle
.
GetProvedAccountBytes
(
trie
.
BlockNumber
,
trie
.
Root
,
address
)
return
enc
,
nil
}
}
// stubbed: we don't prefetch
...
...
minigeth/core/state/statedb.go
View file @
536d424b
...
...
@@ -86,7 +86,7 @@ func NewStateDB(header types.Header) *StateDB {
stateObjectsDirty
:
make
(
map
[
common
.
Address
]
struct
{}),
stateRoot
:
header
.
Root
,
db
:
Database
{
BlockNumber
:
header
.
Number
,
StateRoot
:
header
.
Root
},
trie
:
SimpleTrie
{
BlockNumber
:
header
.
Number
,
StateRoot
:
header
.
Root
},
trie
:
SimpleTrie
{
BlockNumber
:
header
.
Number
,
Root
:
header
.
Root
,
Storage
:
false
},
journal
:
newJournal
(),
accessList
:
newAccessList
(),
logs
:
make
(
map
[
common
.
Hash
][]
*
types
.
Log
),
...
...
minigeth/oracle/proved.go
View file @
536d424b
...
...
@@ -65,7 +65,7 @@ type Account struct {
var
nodeUrl
=
"https://mainnet.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
func
toFilename
(
key
string
)
string
{
return
fmt
.
Sprintf
(
"
data
/%s"
,
key
)
return
fmt
.
Sprintf
(
"
/tmp/eth
/%s"
,
key
)
}
func
cacheRead
(
key
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