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
1495f490
Commit
1495f490
authored
Sep 25, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ugh, transactions are in the wrong order
parent
2d12be53
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
13 deletions
+65
-13
database.go
minigeth/core/state/database.go
+0
-2
main.go
minigeth/main.go
+26
-7
embedded_mips.go
minigeth/oracle/embedded_mips.go
+8
-2
prefetch.go
minigeth/oracle/prefetch.go
+1
-0
preimage.go
minigeth/oracle/preimage.go
+26
-0
stacktrie.go
minigeth/trie/stacktrie.go
+4
-2
No files found.
minigeth/core/state/database.go
View file @
1495f490
...
@@ -40,8 +40,6 @@ func (db *Database) ContractCodeSize(addrHash common.Hash, codeHash common.Hash)
...
@@ -40,8 +40,6 @@ func (db *Database) ContractCodeSize(addrHash common.Hash, codeHash common.Hash)
}
}
func
(
db
*
Database
)
CopyTrie
(
trie
Trie
)
Trie
{
func
(
db
*
Database
)
CopyTrie
(
trie
Trie
)
Trie
{
// TODO: this is wrong
//return trie
panic
(
"don't copy tries"
)
panic
(
"don't copy tries"
)
}
}
...
...
minigeth/main.go
View file @
1495f490
...
@@ -26,9 +26,14 @@ func main() {
...
@@ -26,9 +26,14 @@ func main() {
// non mips
// non mips
if
len
(
os
.
Args
)
>
1
{
if
len
(
os
.
Args
)
>
1
{
pkw
:=
oracle
.
PreimageKeyValueWriter
{}
pkwtrie
:=
trie
.
NewStackTrie
(
pkw
)
blockNumber
,
_
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
blockNumber
,
_
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)),
true
,
trie
.
NewStackTrie
(
nil
))
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)),
true
,
nil
)
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)
+
1
),
false
,
trie
.
NewStackTrie
(
nil
))
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
blockNumber
)
+
1
),
false
,
pkwtrie
)
hash
,
err
:=
pkwtrie
.
Commit
()
fmt
.
Println
(
"commited transactions"
,
hash
,
err
)
}
}
// read start block header
// read start block header
...
@@ -59,14 +64,28 @@ func main() {
...
@@ -59,14 +64,28 @@ func main() {
fmt
.
Println
(
"made state processor"
)
fmt
.
Println
(
"made state processor"
)
// read txs
// read txs
//traverseStackTrie(newheader.TxHash)
//fmt.Println(fn)
//fmt.Println(txTrieRoot)
var
txs
[]
*
types
.
Transaction
var
txs
[]
*
types
.
Transaction
{
f
,
_
:=
os
.
Open
(
fmt
.
Sprintf
(
"data/txs_%d"
,
newheader
.
Number
))
triedb
:=
trie
.
NewDatabase
(
parent
)
rlpheader
:=
rlp
.
NewStream
(
f
,
0
)
tt
,
_
:=
trie
.
New
(
newheader
.
TxHash
,
&
triedb
)
rlpheader
.
Decode
(
&
txs
)
tni
:=
tt
.
NodeIterator
([]
byte
{})
f
.
Close
()
for
tni
.
Next
(
true
)
{
fmt
.
Println
(
tni
.
Hash
(),
tni
.
Leaf
(),
tni
.
Path
(),
tni
.
Error
())
if
tni
.
Leaf
()
{
tx
:=
types
.
Transaction
{}
lerr
:=
tx
.
UnmarshalBinary
(
tni
.
LeafBlob
())
if
lerr
!=
nil
{
log
.
Fatal
(
lerr
)
}
txs
=
append
(
txs
,
&
tx
)
}
}
}
fmt
.
Println
(
"read"
,
len
(
txs
),
"transactions"
)
fmt
.
Println
(
"read"
,
len
(
txs
),
"transactions"
)
// TODO: OMG the transaction ordering isn't fixed
var
uncles
[]
*
types
.
Header
var
uncles
[]
*
types
.
Header
var
receipts
[]
*
types
.
Receipt
var
receipts
[]
*
types
.
Receipt
...
...
minigeth/oracle/embedded_mips.go
View file @
1495f490
...
@@ -80,5 +80,11 @@ func Preimage(hash common.Hash) []byte {
...
@@ -80,5 +80,11 @@ func Preimage(hash common.Hash) []byte {
// these are stubs in embedded world
// these are stubs in embedded world
func
PrefetchStorage
(
*
big
.
Int
,
common
.
Address
,
common
.
Hash
,
func
(
map
[
common
.
Hash
][]
byte
))
{}
func
PrefetchStorage
(
*
big
.
Int
,
common
.
Address
,
common
.
Hash
,
func
(
map
[
common
.
Hash
][]
byte
))
{}
func
PrefetchAccount
(
*
big
.
Int
,
common
.
Address
,
func
(
map
[
common
.
Hash
][]
byte
))
{}
func
PrefetchAccount
(
*
big
.
Int
,
common
.
Address
,
func
(
map
[
common
.
Hash
][]
byte
))
{}
func
PrefetchCode
(
blockNumber
*
big
.
Int
,
addrHash
common
.
Hash
)
{}
func
PrefetchCode
(
blockNumber
*
big
.
Int
,
addrHash
common
.
Hash
)
{}
func
PrefetchBlock
(
blockNumber
*
big
.
Int
,
startBlock
bool
,
hasher
types
.
TrieHasher
)
{}
func
PrefetchBlock
(
blockNumber
*
big
.
Int
,
startBlock
bool
,
hasher
types
.
TrieHasher
)
{}
// KeyValueWriter wraps the Put method of a backing data store.
type
PreimageKeyValueWriter
struct
{}
func
(
kw
PreimageKeyValueWriter
)
Put
(
key
[]
byte
,
value
[]
byte
)
error
{
return
nil
}
func
(
kw
PreimageKeyValueWriter
)
Delete
(
key
[]
byte
)
error
{
return
nil
}
minigeth/oracle/prefetch.go
View file @
1495f490
...
@@ -247,6 +247,7 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
...
@@ -247,6 +247,7 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
txs
:=
make
([]
*
types
.
Transaction
,
len
(
jr
.
Result
.
Transactions
))
txs
:=
make
([]
*
types
.
Transaction
,
len
(
jr
.
Result
.
Transactions
))
for
i
:=
0
;
i
<
len
(
jr
.
Result
.
Transactions
);
i
++
{
for
i
:=
0
;
i
<
len
(
jr
.
Result
.
Transactions
);
i
++
{
txs
[
i
]
=
jr
.
Result
.
Transactions
[
i
]
.
ToTransaction
()
txs
[
i
]
=
jr
.
Result
.
Transactions
[
i
]
.
ToTransaction
()
fmt
.
Println
(
"tx"
,
i
,
"hash"
,
txs
[
i
]
.
Hash
())
}
}
testTxHash
:=
types
.
DeriveSha
(
types
.
Transactions
(
txs
),
hasher
)
testTxHash
:=
types
.
DeriveSha
(
types
.
Transactions
(
txs
),
hasher
)
if
testTxHash
!=
blockHeader
.
TxHash
{
if
testTxHash
!=
blockHeader
.
TxHash
{
...
...
minigeth/oracle/preimage.go
View file @
1495f490
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"io/ioutil"
"io/ioutil"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
var
preimages
=
make
(
map
[
common
.
Hash
][]
byte
)
...
@@ -19,6 +20,10 @@ func Preimage(hash common.Hash) []byte {
...
@@ -19,6 +20,10 @@ func Preimage(hash common.Hash) []byte {
if
!
ok
{
if
!
ok
{
fmt
.
Println
(
"can't find preimage"
,
hash
)
fmt
.
Println
(
"can't find preimage"
,
hash
)
}
}
comphash
:=
crypto
.
Keccak256Hash
(
val
)
if
hash
!=
comphash
{
panic
(
"corruption in hash "
+
hash
.
String
())
}
return
val
return
val
}
}
...
@@ -26,3 +31,24 @@ func Preimage(hash common.Hash) []byte {
...
@@ -26,3 +31,24 @@ func Preimage(hash common.Hash) []byte {
func
Preimages
()
map
[
common
.
Hash
][]
byte
{
func
Preimages
()
map
[
common
.
Hash
][]
byte
{
return
preimages
return
preimages
}
}
// KeyValueWriter wraps the Put method of a backing data store.
type
PreimageKeyValueWriter
struct
{}
// Put inserts the given value into the key-value data store.
func
(
kw
PreimageKeyValueWriter
)
Put
(
key
[]
byte
,
value
[]
byte
)
error
{
hash
:=
crypto
.
Keccak256Hash
(
value
)
if
hash
!=
common
.
BytesToHash
(
key
)
{
panic
(
"bad preimage value write"
)
}
nval
:=
make
([]
byte
,
len
(
value
))
copy
(
nval
,
value
)
preimages
[
hash
]
=
nval
//fmt.Println("tx preimage", hash, common.Bytes2Hex(value))
return
nil
}
// Delete removes the key from the key-value data store.
func
(
kw
PreimageKeyValueWriter
)
Delete
(
key
[]
byte
)
error
{
return
nil
}
minigeth/trie/stacktrie.go
View file @
1495f490
...
@@ -21,11 +21,13 @@ import (
...
@@ -21,11 +21,13 @@ import (
"bytes"
"bytes"
"encoding/gob"
"encoding/gob"
"errors"
"errors"
"fmt"
"io"
"io"
"sync"
"sync"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/log"
//"github.com/ethereum/go-ethereum/log"
//"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
...
@@ -199,12 +201,12 @@ func (st *StackTrie) TryUpdate(key, value []byte) error {
...
@@ -199,12 +201,12 @@ func (st *StackTrie) TryUpdate(key, value []byte) error {
func
(
st
*
StackTrie
)
Update
(
key
,
value
[]
byte
)
{
func
(
st
*
StackTrie
)
Update
(
key
,
value
[]
byte
)
{
if
err
:=
st
.
TryUpdate
(
key
,
value
);
err
!=
nil
{
if
err
:=
st
.
TryUpdate
(
key
,
value
);
err
!=
nil
{
//
log.Error(fmt.Sprintf("Unhandled trie error: %v", err))
log
.
Error
(
fmt
.
Sprintf
(
"Unhandled trie error: %v"
,
err
))
}
}
}
}
func
(
st
*
StackTrie
)
Reset
()
{
func
(
st
*
StackTrie
)
Reset
()
{
st
.
db
=
nil
//
st.db = nil
st
.
key
=
st
.
key
[
:
0
]
st
.
key
=
st
.
key
[
:
0
]
st
.
val
=
nil
st
.
val
=
nil
for
i
:=
range
st
.
children
{
for
i
:=
range
st
.
children
{
...
...
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