Commit e10286b5 authored by George Hotz's avatar George Hotz

add fake ethash

parent 5be4ecb4
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
}
......@@ -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 }
......
......@@ -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)
}
......
......@@ -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)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment