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
25d67c04
Commit
25d67c04
authored
Sep 26, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix uncle support
parent
add9a4ee
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
74 additions
and
28 deletions
+74
-28
test_pc.yml
.github/workflows/test_pc.yml
+6
-4
state_processor.go
minigeth/core/state_processor.go
+1
-9
main.go
minigeth/main.go
+3
-1
prefetch.go
minigeth/oracle/prefetch.go
+57
-13
run.sh
run.sh
+7
-1
No files found.
.github/workflows/test_pc.yml
View file @
25d67c04
...
...
@@ -17,9 +17,11 @@ jobs:
run
:
|
(cd minigeth/ && go build)
mkdir -p /tmp/eth
-
name
:
Test block
13284491
-
name
:
Test block 13284491
(0 tx)
run
:
minigeth/go-ethereum
13284491
-
name
:
Test block
13284469
-
name
:
Test block 13284469
(few tx)
run
:
minigeth/go-ethereum
13284469
-
name
:
Test block
13284053
run
:
minigeth/go-ethereum 13284053
\ No newline at end of file
-
name
:
Test block 13284053 (deletion)
run
:
minigeth/go-ethereum
13284053
-
name
:
Test block 13303075 (uncles)
run
:
minigeth/go-ethereum 13303075
\ No newline at end of file
minigeth/core/state_processor.go
View file @
25d67c04
...
...
@@ -27,15 +27,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
/*"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/misc"
"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/params"*/
)
)
// StateProcessor is a basic Processor, which takes care of transitioning
// state from one point to another.
...
...
minigeth/main.go
View file @
25d67c04
...
...
@@ -96,6 +96,8 @@ func main() {
// TODO: OMG the transaction ordering isn't fixed
var
uncles
[]
*
types
.
Header
check
(
rlp
.
DecodeBytes
(
oracle
.
Preimage
(
newheader
.
UncleHash
),
&
uncles
))
var
receipts
[]
*
types
.
Receipt
block
:=
types
.
NewBlock
(
&
newheader
,
txs
,
uncles
,
receipts
,
trie
.
NewStackTrie
(
nil
))
fmt
.
Println
(
"made block, parent:"
,
newheader
.
ParentHash
)
...
...
@@ -106,7 +108,7 @@ func main() {
panic
(
"wrong transactions for block"
)
}
if
newheader
.
UncleHash
!=
block
.
Header
()
.
UncleHash
{
panic
(
"wrong uncles for block
"
)
panic
(
"wrong uncles for block
"
+
newheader
.
UncleHash
.
String
()
+
" "
+
block
.
Header
()
.
UncleHash
.
String
()
)
}
_
,
_
,
_
,
err
:=
processor
.
Process
(
block
,
statedb
,
vmconfig
)
...
...
minigeth/oracle/prefetch.go
View file @
25d67c04
...
...
@@ -41,6 +41,12 @@ type jsonresps struct {
Result
string
`json:"result"`
}
type
jsonrespi
struct
{
Jsonrpc
string
`json:"jsonrpc"`
Id
uint64
`json:"id"`
Result
hexutil
.
Uint64
`json:"result"`
}
type
jsonrespt
struct
{
Jsonrpc
string
`json:"jsonrpc"`
Id
uint64
`json:"id"`
...
...
@@ -196,6 +202,53 @@ func Output(output common.Hash) {
}
}
func
check
(
err
error
)
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
func
prefetchUncles
(
blockHash
common
.
Hash
,
uncleHash
common
.
Hash
,
hasher
types
.
TrieHasher
)
{
jr
:=
jsonrespi
{}
{
r
:=
jsonreq
{
Jsonrpc
:
"2.0"
,
Method
:
"eth_getUncleCountByBlockHash"
,
Id
:
1
}
r
.
Params
=
make
([]
interface
{},
1
)
r
.
Params
[
0
]
=
blockHash
.
Hex
()
jsonData
,
_
:=
json
.
Marshal
(
r
)
check
(
json
.
NewDecoder
(
getAPI
(
jsonData
))
.
Decode
(
&
jr
))
}
var
uncles
[]
*
types
.
Header
for
u
:=
0
;
u
<
int
(
jr
.
Result
);
u
++
{
jr2
:=
jsonrespt
{}
{
r
:=
jsonreq
{
Jsonrpc
:
"2.0"
,
Method
:
"eth_getUncleByBlockHashAndIndex"
,
Id
:
1
}
r
.
Params
=
make
([]
interface
{},
2
)
r
.
Params
[
0
]
=
blockHash
.
Hex
()
r
.
Params
[
1
]
=
fmt
.
Sprintf
(
"0x%x"
,
u
)
jsonData
,
_
:=
json
.
Marshal
(
r
)
/*a, _ := ioutil.ReadAll(getAPI(jsonData))
fmt.Println(string(a))*/
check
(
json
.
NewDecoder
(
getAPI
(
jsonData
))
.
Decode
(
&
jr2
))
}
uncleHeader
:=
jr2
.
Result
.
ToHeader
()
uncles
=
append
(
uncles
,
&
uncleHeader
)
//fmt.Println(uncleHeader)
//fmt.Println(jr2.Result)
}
unclesRlp
,
_
:=
rlp
.
EncodeToBytes
(
uncles
)
hash
:=
crypto
.
Keccak256Hash
(
unclesRlp
)
if
hash
!=
uncleHash
{
panic
(
"wrong uncle hash"
)
}
preimages
[
hash
]
=
unclesRlp
}
func
PrefetchBlock
(
blockNumber
*
big
.
Int
,
startBlock
bool
,
hasher
types
.
TrieHasher
)
{
r
:=
jsonreq
{
Jsonrpc
:
"2.0"
,
Method
:
"eth_getBlockByNumber"
,
Id
:
1
}
r
.
Params
=
make
([]
interface
{},
2
)
...
...
@@ -207,10 +260,7 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
fmt.Println(string(dat))*/
jr
:=
jsonrespt
{}
err
:=
json
.
NewDecoder
(
getAPI
(
jsonData
))
.
Decode
(
&
jr
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
check
(
json
.
NewDecoder
(
getAPI
(
jsonData
))
.
Decode
(
&
jr
))
//fmt.Println(jr.Result)
blockHeader
:=
jr
.
Result
.
ToHeader
()
...
...
@@ -245,10 +295,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
key
:=
fmt
.
Sprintf
(
"/tmp/eth/%d"
,
blockNumber
.
Uint64
()
-
1
)
ioutil
.
WriteFile
(
key
,
saveinput
,
0644
)
// save the txs
txs
:=
make
([]
*
types
.
Transaction
,
len
(
jr
.
Result
.
Transactions
))
for
i
:=
0
;
i
<
len
(
jr
.
Result
.
Transactions
);
i
++
{
txs
[
i
]
=
jr
.
Result
.
Transactions
[
i
]
.
ToTransaction
()
//fmt.Println("tx", i, "hash", txs[i].Hash())
}
testTxHash
:=
types
.
DeriveSha
(
types
.
Transactions
(
txs
),
hasher
)
if
testTxHash
!=
blockHeader
.
TxHash
{
...
...
@@ -256,14 +306,8 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
panic
(
"tx hash derived wrong"
)
}
// put in transaction trie
//return blockHeader, txs
/*var uncles []*types.Header
var receipts []*types.Receipt
block := types.NewBlock(&blockHeader, txs, uncles, receipts, trie.NewStackTrie(nil))*/
// save the uncles
prefetchUncles
(
blockHeader
.
Hash
(),
blockHeader
.
UncleHash
,
hasher
)
}
func
getProofAccount
(
blockNumber
*
big
.
Int
,
addr
common
.
Address
,
skey
common
.
Hash
,
storage
bool
)
[]
string
{
...
...
run.sh
View file @
25d67c04
...
...
@@ -5,5 +5,11 @@ mkdir -p /tmp/eth
# 0 tx: 13284491
# low tx: 13284469
# delete issue: 13284053
minigeth/go-ethereum 13284469
if
[
$#
-eq
0
]
;
then
BLOCK
=
13284469
else
BLOCK
=
$1
fi
minigeth/go-ethereum
$BLOCK
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