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
e7e3af9f
Commit
e7e3af9f
authored
Sep 27, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix 13284494
parent
d04bfcc2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
fake_blockchain.go
minigeth/core/fake_blockchain.go
+25
-3
main.go
minigeth/main.go
+1
-1
prefetch.go
minigeth/oracle/prefetch.go
+4
-1
No files found.
minigeth/core/fake_blockchain.go
View file @
e7e3af9f
package
core
package
core
import
(
import
(
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/oracle"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
)
)
type
BlockChain
struct
{
type
BlockChain
struct
{
// TODO: write stub BlockChain
// TODO: write stub BlockChain
chainConfig
*
params
.
ChainConfig
// Chain & network configuration
chainConfig
*
params
.
ChainConfig
// Chain & network configuration
engine
consensus
.
Engine
engine
consensus
.
Engine
lastBlock
*
types
.
Header
}
}
func
NewBlockChain
()
*
BlockChain
{
func
NewBlockChain
(
parent
*
types
.
Header
)
*
BlockChain
{
return
&
BlockChain
{
return
&
BlockChain
{
chainConfig
:
params
.
MainnetChainConfig
,
chainConfig
:
params
.
MainnetChainConfig
,
engine
:
&
ethash
.
Ethash
{},
engine
:
&
ethash
.
Ethash
{},
lastBlock
:
parent
,
}
}
}
}
...
@@ -30,21 +37,36 @@ func (bc *BlockChain) Engine() consensus.Engine { return bc.engine }
...
@@ -30,21 +37,36 @@ func (bc *BlockChain) Engine() consensus.Engine { return bc.engine }
// GetHeader retrieves a block header from the database by hash and number,
// GetHeader retrieves a block header from the database by hash and number,
// caching it if found.
// caching it if found.
func
(
bc
*
BlockChain
)
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
{
func
(
bc
*
BlockChain
)
GetHeader
(
hash
common
.
Hash
,
number
uint64
)
*
types
.
Header
{
return
nil
if
hash
==
bc
.
lastBlock
.
Hash
()
{
return
bc
.
lastBlock
}
oracle
.
PrefetchBlock
(
big
.
NewInt
(
int64
(
number
)),
true
,
nil
)
var
ret
types
.
Header
err
:=
rlp
.
DecodeBytes
(
oracle
.
Preimage
(
hash
),
&
ret
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
return
&
ret
}
}
func
(
bc
*
BlockChain
)
CurrentHeader
()
*
types
.
Header
{
func
(
bc
*
BlockChain
)
CurrentHeader
()
*
types
.
Header
{
return
nil
log
.
Fatal
(
"CurrentHeader"
)
// this right?
return
bc
.
lastBlock
}
}
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
// GetHeaderByHash retrieves a block header from the database by hash, caching it if
// found.
// found.
func
(
bc
*
BlockChain
)
GetHeaderByHash
(
hash
common
.
Hash
)
*
types
.
Header
{
func
(
bc
*
BlockChain
)
GetHeaderByHash
(
hash
common
.
Hash
)
*
types
.
Header
{
log
.
Fatal
(
"GetHeaderByHash"
,
hash
)
return
nil
return
nil
}
}
// GetHeaderByNumber retrieves a block header from the database by number,
// GetHeaderByNumber retrieves a block header from the database by number,
// caching it (associated with its hash) if found.
// caching it (associated with its hash) if found.
func
(
bc
*
BlockChain
)
GetHeaderByNumber
(
number
uint64
)
*
types
.
Header
{
func
(
bc
*
BlockChain
)
GetHeaderByNumber
(
number
uint64
)
*
types
.
Header
{
log
.
Fatal
(
"GetHeaderByNumber"
,
number
)
return
nil
return
nil
}
}
minigeth/main.go
View file @
e7e3af9f
...
@@ -61,7 +61,7 @@ func main() {
...
@@ -61,7 +61,7 @@ func main() {
newheader
.
GasLimit
=
oracle
.
Input
(
4
)
.
Big
()
.
Uint64
()
newheader
.
GasLimit
=
oracle
.
Input
(
4
)
.
Big
()
.
Uint64
()
newheader
.
Time
=
oracle
.
Input
(
5
)
.
Big
()
.
Uint64
()
newheader
.
Time
=
oracle
.
Input
(
5
)
.
Big
()
.
Uint64
()
bc
:=
core
.
NewBlockChain
()
bc
:=
core
.
NewBlockChain
(
&
parent
)
database
:=
state
.
NewDatabase
(
parent
)
database
:=
state
.
NewDatabase
(
parent
)
statedb
,
_
:=
state
.
New
(
parent
.
Root
,
database
,
nil
)
statedb
,
_
:=
state
.
New
(
parent
.
Root
,
database
,
nil
)
vmconfig
:=
vm
.
Config
{}
vmconfig
:=
vm
.
Config
{}
...
...
minigeth/oracle/prefetch.go
View file @
e7e3af9f
...
@@ -269,7 +269,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
...
@@ -269,7 +269,10 @@ func PrefetchBlock(blockNumber *big.Int, startBlock bool, hasher types.TrieHashe
blockHeaderRlp
,
_
:=
rlp
.
EncodeToBytes
(
blockHeader
)
blockHeaderRlp
,
_
:=
rlp
.
EncodeToBytes
(
blockHeader
)
hash
:=
crypto
.
Keccak256Hash
(
blockHeaderRlp
)
hash
:=
crypto
.
Keccak256Hash
(
blockHeaderRlp
)
preimages
[
hash
]
=
blockHeaderRlp
preimages
[
hash
]
=
blockHeaderRlp
emptyHash
:=
common
.
Hash
{}
if
inputs
[
0
]
==
emptyHash
{
inputs
[
0
]
=
hash
inputs
[
0
]
=
hash
}
return
return
}
}
...
...
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