good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
bbe79545
Commit
bbe79545
authored
Mar 24, 2015
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Secure trie shakey / key matching
parent
d6da5333
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/state/dump.go
+4
-4
4 additions, 4 deletions
core/state/dump.go
trie/secure_trie.go
+10
-1
10 additions, 1 deletion
trie/secure_trie.go
with
14 additions
and
5 deletions
core/state/dump.go
+
4
−
4
View file @
bbe79545
...
...
@@ -28,17 +28,17 @@ func (self *StateDB) RawDump() World {
it
:=
self
.
trie
.
Iterator
()
for
it
.
Next
()
{
stateObject
:=
NewStateObjectFromBytes
(
common
.
BytesToAddress
(
it
.
Key
),
it
.
Value
,
self
.
db
)
addr
:=
self
.
trie
.
GetKey
(
it
.
Key
)
stateObject
:=
NewStateObjectFromBytes
(
common
.
BytesToAddress
(
addr
),
it
.
Value
,
self
.
db
)
account
:=
Account
{
Balance
:
stateObject
.
balance
.
String
(),
Nonce
:
stateObject
.
nonce
,
Root
:
common
.
Bytes2Hex
(
stateObject
.
Root
()),
CodeHash
:
common
.
Bytes2Hex
(
stateObject
.
codeHash
)}
account
.
Storage
=
make
(
map
[
string
]
string
)
storageIt
:=
stateObject
.
State
.
trie
.
Iterator
()
for
storageIt
.
Next
()
{
fmt
.
Println
(
"value"
,
storageIt
.
Value
)
account
.
Storage
[
common
.
Bytes2Hex
(
storageIt
.
Key
)]
=
common
.
Bytes2Hex
(
storageIt
.
Value
)
account
.
Storage
[
common
.
Bytes2Hex
(
self
.
trie
.
GetKey
(
storageIt
.
Key
))]
=
common
.
Bytes2Hex
(
storageIt
.
Value
)
}
world
.
Accounts
[
common
.
Bytes2Hex
(
it
.
Key
)]
=
account
world
.
Accounts
[
common
.
Bytes2Hex
(
addr
)]
=
account
}
return
world
}
...
...
This diff is collapsed.
Click to expand it.
trie/secure_trie.go
+
10
−
1
View file @
bbe79545
...
...
@@ -2,6 +2,8 @@ package trie
import
"github.com/ethereum/go-ethereum/crypto"
var
keyPrefix
=
[]
byte
(
"secure-key-"
)
type
SecureTrie
struct
{
*
Trie
}
...
...
@@ -11,7 +13,10 @@ func NewSecure(root []byte, backend Backend) *SecureTrie {
}
func
(
self
*
SecureTrie
)
Update
(
key
,
value
[]
byte
)
Node
{
return
self
.
Trie
.
Update
(
crypto
.
Sha3
(
key
),
value
)
shaKey
:=
crypto
.
Sha3
(
key
)
self
.
Trie
.
cache
.
Put
(
append
(
keyPrefix
,
shaKey
...
),
key
)
return
self
.
Trie
.
Update
(
shaKey
,
value
)
}
func
(
self
*
SecureTrie
)
UpdateString
(
key
,
value
string
)
Node
{
return
self
.
Update
([]
byte
(
key
),
[]
byte
(
value
))
...
...
@@ -34,3 +39,7 @@ func (self *SecureTrie) DeleteString(key string) Node {
func
(
self
*
SecureTrie
)
Copy
()
*
SecureTrie
{
return
&
SecureTrie
{
self
.
Trie
.
Copy
()}
}
func
(
self
*
SecureTrie
)
GetKey
(
shaKey
[]
byte
)
[]
byte
{
return
self
.
Trie
.
cache
.
Get
(
append
(
keyPrefix
,
shaKey
...
))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment