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
e10286b5
Commit
e10286b5
authored
Sep 17, 2021
by
George Hotz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add fake ethash
parent
5be4ecb4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
7 deletions
+81
-7
fake_ethash.go
minigeth/consensus/ethash/fake_ethash.go
+58
-0
blockchain.go
minigeth/core/blockchain.go
+5
-0
evm.go
minigeth/core/evm.go
+1
-0
main.go
minigeth/main.go
+17
-7
No files found.
minigeth/consensus/ethash/fake_ethash.go
0 → 100644
View file @
e10286b5
package
ethash
import
(
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
)
type
Ethash
struct
{
/*Author
Finalize*/
}
func
(
ethash
*
Ethash
)
Author
(
header
*
types
.
Header
)
(
common
.
Address
,
error
)
{
return
header
.
Coinbase
,
nil
}
func
(
ethash
*
Ethash
)
CalcDifficulty
(
chain
consensus
.
ChainHeaderReader
,
time
uint64
,
parent
*
types
.
Header
)
*
big
.
Int
{
return
nil
}
func
(
ethash
*
Ethash
)
Close
()
error
{
return
nil
}
func
(
ethash
*
Ethash
)
Finalize
(
chain
consensus
.
ChainHeaderReader
,
header
*
types
.
Header
,
state
*
state
.
StateDB
,
txs
[]
*
types
.
Transaction
,
uncles
[]
*
types
.
Header
)
{
}
func
(
ethash
*
Ethash
)
FinalizeAndAssemble
(
chain
consensus
.
ChainHeaderReader
,
header
*
types
.
Header
,
state
*
state
.
StateDB
,
txs
[]
*
types
.
Transaction
,
uncles
[]
*
types
.
Header
,
receipts
[]
*
types
.
Receipt
)
(
*
types
.
Block
,
error
)
{
return
nil
,
nil
}
func
(
ethash
*
Ethash
)
Prepare
(
chain
consensus
.
ChainHeaderReader
,
header
*
types
.
Header
)
error
{
return
nil
}
func
(
ethash
*
Ethash
)
Seal
(
chain
consensus
.
ChainHeaderReader
,
block
*
types
.
Block
,
results
chan
<-
*
types
.
Block
,
stop
<-
chan
struct
{})
error
{
return
nil
}
func
(
ethash
*
Ethash
)
SealHash
(
header
*
types
.
Header
)
(
hash
common
.
Hash
)
{
return
common
.
Hash
{}
}
func
(
ethash
*
Ethash
)
VerifyHeader
(
chain
consensus
.
ChainHeaderReader
,
header
*
types
.
Header
,
seal
bool
)
error
{
return
nil
}
func
(
ethash
*
Ethash
)
VerifyHeaders
(
chain
consensus
.
ChainHeaderReader
,
headers
[]
*
types
.
Header
,
seals
[]
bool
)
(
chan
<-
struct
{},
<-
chan
error
)
{
return
nil
,
nil
}
func
(
ethash
*
Ethash
)
VerifyUncles
(
chain
consensus
.
ChainReader
,
block
*
types
.
Block
)
error
{
return
nil
}
minigeth/core/blockchain.go
View file @
e10286b5
...
...
@@ -3,6 +3,7 @@ package core
import
(
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
)
...
...
@@ -13,6 +14,10 @@ type BlockChain struct {
engine
consensus
.
Engine
}
func
NewBlockChain
()
*
BlockChain
{
return
&
BlockChain
{
engine
:
&
ethash
.
Ethash
{}}
}
// Config retrieves the chain's fork configuration.
func
(
bc
*
BlockChain
)
Config
()
*
params
.
ChainConfig
{
return
bc
.
chainConfig
}
...
...
minigeth/core/evm.go
View file @
e10286b5
...
...
@@ -48,6 +48,7 @@ func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common
}
else
{
beneficiary
=
*
author
}
if
header
.
BaseFee
!=
nil
{
baseFee
=
new
(
big
.
Int
)
.
Set
(
header
.
BaseFee
)
}
...
...
minigeth/main.go
View file @
e10286b5
...
...
@@ -4,6 +4,7 @@ import (
"fmt"
"os"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
...
...
@@ -12,20 +13,29 @@ import (
"github.com/ethereum/go-ethereum/rlp"
)
type
DumbEngine
struct
{
/*Author
Finalize*/
}
func
(
ethash
*
DumbEngine
)
Author
(
header
*
types
.
Header
)
(
common
.
Address
,
error
)
{
return
header
.
Coinbase
,
nil
}
func
main
()
{
bc
:=
&
core
.
BlockChain
{}
//engine := ethash.NewFullFaker()
bc
:=
core
.
NewBlockChain
()
statedb
:=
&
state
.
StateDB
{}
vmconfig
:=
vm
.
Config
{}
processor
:=
core
.
NewStateProcessor
(
params
.
MainnetChainConfig
,
bc
,
nil
)
fmt
.
Println
(
"made state processor"
)
f
,
_
:=
os
.
Open
(
"../data/block_
block_
13247502"
)
f
,
_
:=
os
.
Open
(
"../data/block_13247502"
)
defer
f
.
Close
()
block
:=
&
types
.
Block
{}
block
.
DecodeRLP
(
rlp
.
NewStream
(
f
,
0
))
fmt
.
Println
(
"read block RLP"
)
var
header
types
.
Header
rlpheader
:=
rlp
.
NewStream
(
f
,
0
)
rlpheader
.
Decode
(
&
header
)
block
:=
types
.
NewBlockWithHeader
(
&
header
)
fmt
.
Println
(
"made block, parent:"
,
header
.
ParentHash
)
processor
.
Process
(
block
,
statedb
,
vmconfig
)
}
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