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
0e6ad3bb
Commit
0e6ad3bb
authored
Sep 25, 2021
by
han0110
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: get absense proof and brute-forcely enumerate all possible short node preimage pairs
parent
c2f67a9c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
1 deletion
+46
-1
state_object.go
minigeth/core/state/state_object.go
+2
-1
preimage.go
minigeth/oracle/preimage.go
+5
-0
database.go
minigeth/trie/database.go
+37
-0
trie.go
minigeth/trie/trie.go
+2
-0
No files found.
minigeth/core/state/state_object.go
View file @
0e6ad3bb
...
...
@@ -355,7 +355,8 @@ func (s *stateObject) updateTrie(db Database) Trie {
var
v
[]
byte
oracle
.
PrefetchStorage
(
db
.
BlockNumber
,
s
.
address
,
key
)
//oracle.PrefetchStorage(big.NewInt(db.BlockNumber.Int64()+1), s.address, key)
// Get absense proof of current key in case the deletion make the extension node to short node.
oracle
.
PrefetchStorage
(
big
.
NewInt
(
db
.
BlockNumber
.
Int64
()
+
1
),
s
.
address
,
key
)
if
(
value
==
common
.
Hash
{})
{
//fmt.Println("delete", s.address, key)
s
.
setError
(
tr
.
TryDelete
(
key
[
:
]))
...
...
minigeth/oracle/preimage.go
View file @
0e6ad3bb
...
...
@@ -22,3 +22,8 @@ func Preimage(hash common.Hash) []byte {
}
return
val
}
// TODO: Maybe we will want to have a seperate preimages for next block's preimages?
func
Preimages
()
map
[
common
.
Hash
][]
byte
{
return
preimages
}
minigeth/trie/database.go
View file @
0e6ad3bb
package
trie
import
(
"bytes"
"fmt"
"io"
"math/big"
...
...
@@ -8,7 +9,9 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/oracle"
"github.com/ethereum/go-ethereum/rlp"
)
// rawNode is a simple binary blob used to differentiate between collapsed trie
...
...
@@ -61,3 +64,37 @@ func (db *Database) insert(hash common.Hash, size int, node node) {
// can put things in the oracle here if we care
//fmt.Println("insert", hash, size)
}
// TODO: Create pairs only when seeing pos
func
genPossibleShortNodePreimage
(
pos
int
)
{
preimages
:=
oracle
.
Preimages
()
newPreimages
:=
make
(
map
[
common
.
Hash
][]
byte
)
for
_
,
val
:=
range
preimages
{
node
,
err
:=
decodeNode
(
nil
,
val
)
if
err
!=
nil
{
continue
}
if
node
,
ok
:=
node
.
(
*
shortNode
);
ok
{
for
i
:=
1
;
i
<
len
(
node
.
Key
);
i
+=
1
{
n
:=
shortNode
{
Key
:
hexToCompact
(
node
.
Key
[
len
(
node
.
Key
)
-
i
:
]),
Val
:
node
.
Val
,
}
buf
:=
new
(
bytes
.
Buffer
)
if
err
:=
rlp
.
Encode
(
buf
,
n
);
err
!=
nil
{
panic
(
"encode error: "
+
err
.
Error
())
}
preimage
:=
buf
.
Bytes
()
if
len
(
preimage
)
<
32
{
continue
}
newPreimages
[
crypto
.
Keccak256Hash
(
preimage
)]
=
preimage
}
}
}
for
hash
,
val
:=
range
newPreimages
{
preimages
[
hash
]
=
val
}
}
minigeth/trie/trie.go
View file @
0e6ad3bb
...
...
@@ -443,6 +443,8 @@ func (t *Trie) delete(n node, prefix, key []byte) (bool, node, error) {
// might not be loaded yet, resolve it just for this
// check.
// TODO: Try to cache short nodes already generated
genPossibleShortNodePreimage
(
pos
)
// remove this optimisticly? if it's not a shortNode, it doesn't do anything
cnode
,
err
:=
t
.
resolve
(
n
.
Children
[
pos
],
prefix
)
if
err
!=
nil
{
...
...
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