Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f5b0584
simulators/eth2: Create common library
marioevz Dec 30, 2022
1e30d98
simulators/eth2/common: Add main file to pass compilation
marioevz Dec 30, 2022
6f65855
simulators/eth2/common: All withdrawals changes
marioevz Jan 19, 2023
d32d665
simulators/eth2/engine: changes due to new geth version
marioevz Jan 19, 2023
9a04741
simulators/eth2/withdrawals: Test Spec
marioevz Dec 26, 2022
575ba24
RESET: Withdrawals progress
marioevz Dec 19, 2022
9d05e33
simulators/eth2/withdrawals: More cases, library refactor
marioevz Dec 21, 2022
bf5c3d4
simulators/eth2/withdrawals: go.work changes
marioevz Dec 23, 2022
f2c584a
simulator/eth2/withdrawals: Dockerfile changes
marioevz Dec 23, 2022
2dbbc89
simulators/eth2/common: implement WaitSlots
marioevz Dec 22, 2022
fc75d02
simulators/eth2/withdrawals: update tests
marioevz Dec 23, 2022
b8f1623
simulators/eth2/withdrawals: Allow BLS to exec rpc error
marioevz Dec 23, 2022
9a0a316
simulators/eth2/withdrawals: remove unused methods
marioevz Dec 23, 2022
962fa9b
simulators/eth2/withdrawals: minor refactor
marioevz Dec 26, 2022
cb47908
simulators/eth2/common: Refactor validator operations
marioevz Dec 26, 2022
aa4f263
simulators/eth2/withdrawals: Full withdrawals test (not working)
marioevz Dec 27, 2022
0a299f6
simulators/eth2: Update zrnt and remove from workspace
marioevz Jan 5, 2023
8d35608
simulators/eth2/withdrawals: remove zrnt
marioevz Jan 5, 2023
0dea3b7
simulators/eth2/withdrawals: fixes and new tests
marioevz Jan 12, 2023
821eda9
simulators/eth2/withdrawals: rework tests to use a single general fun…
marioevz Jan 13, 2023
fa246c0
simulators/eth2/withdrawals: update bls to exec signature
marioevz Jan 17, 2023
e7b2b7b
simulators/eth2/common: go mod replace eth2api
marioevz Jan 17, 2023
f388553
simulators/eth2/withdrawals: readme update
marioevz Jan 18, 2023
d3ee03a
simulators/eth2/withdrawals: nit
marioevz Jan 18, 2023
e6160c8
simulators/eth2/withdrawals: allow getting state from other clients
marioevz Jan 19, 2023
ee19a85
simulators/eth2/withdrawals: reduce timeout for withdrawals
marioevz Jan 19, 2023
b74e218
simulators/eth2/common: fix rebase issue
marioevz Jan 19, 2023
6e696ea
simulators/eth2/withdrawals: go.mod
marioevz Jan 19, 2023
74bcbf4
simulators/eth2: add common Go workspace for CL simulators
fjl Jan 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions simulators/eth2/common/chain_generators/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package chaingenerators

import (
"github.com/ethereum/go-ethereum/core/types"
el "github.com/ethereum/hive/simulators/eth2/common/config/execution"
)

type ChainGenerator interface {
Generate(*el.ExecutionGenesis) ([]*types.Block, error)
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package main
package pow

import (
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"

"github.com/ethereum/hive/simulators/eth2/engine/setup"
execution_config "github.com/ethereum/hive/simulators/eth2/common/config/execution"
)

type ChainGenerator interface {
Generate(*setup.Eth1Genesis) ([]*types.Block, error)
}

var PoWChainGeneratorDefaults = ethash.Config{
var Defaults = ethash.Config{
PowMode: ethash.ModeNormal,
CachesInMem: 2,
DatasetsOnDisk: 2,
DatasetDir: "/ethash",
}

type PoWChainGenerator struct {
type ChainGenerator struct {
BlockCount int
ethash.Config
GenFunction func(int, *core.BlockGen)
Expand All @@ -35,8 +29,24 @@ type instaSeal struct{ consensus.Engine }

// FinalizeAndAssemble implements consensus.Engine, accumulating the block and uncle rewards,
// setting the final state and assembling the block.
func (e instaSeal) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error) {
block, err := e.Engine.FinalizeAndAssemble(chain, header, state, txs, uncles, receipts)
func (e instaSeal) FinalizeAndAssemble(
chain consensus.ChainHeaderReader,
header *types.Header,
state *state.StateDB,
txs []*types.Transaction,
uncles []*types.Header,
receipts []*types.Receipt,
withdrawals []*types.Withdrawal,
) (*types.Block, error) {
block, err := e.Engine.FinalizeAndAssemble(
chain,
header,
state,
txs,
uncles,
receipts,
withdrawals,
)
if err != nil {
return nil, err
}
Expand All @@ -47,26 +57,31 @@ func (e instaSeal) FinalizeAndAssemble(chain consensus.ChainHeaderReader, header
return <-sealedBlock, nil
}

func (p *PoWChainGenerator) Generate(genesis *setup.Eth1Genesis) ([]*types.Block, error) {
func (p *ChainGenerator) Generate(
genesis *execution_config.ExecutionGenesis,
) ([]*types.Block, error) {
// We generate a new chain only if the generator had not generated one already.
// This is done because the chain generators can be reused on different clients to ensure
// they start with the same chain.
if p.blocks != nil {
return p.blocks, nil
}
db := rawdb.NewMemoryDatabase()
engine := ethash.New(p.Config, nil, false)
insta := instaSeal{engine}
genesisBlock := genesis.Genesis.ToBlock()
p.blocks, _ = core.GenerateChain(genesis.Genesis.Config, genesisBlock, insta, db, p.BlockCount, p.GenFunction)
_, p.blocks, _ = core.GenerateChainWithGenesis(
genesis.Genesis,
insta,
p.BlockCount,
p.GenFunction,
)
return p.blocks, nil
}

func (p *PoWChainGenerator) Blocks() []*types.Block {
func (p *ChainGenerator) Blocks() []*types.Block {
return p.blocks
}

func (p *PoWChainGenerator) Head() *types.Block {
func (p *ChainGenerator) Head() *types.Block {
if p.blocks == nil || len(p.blocks) == 0 {
return nil
}
Expand Down
Loading