incremental commit, manual changes to support merge

This commit is contained in:
philip-morlier 2023-07-11 17:01:10 -07:00
parent e516d5842c
commit dc56f2a361
5 changed files with 30 additions and 53 deletions

View File

@ -82,7 +82,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
// cfg.Debug = true // cfg.Debug = true
} }
// end pluGeth code injection // end pluGeth code injection
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
// begin PluGeth code injection // begin PluGeth code injection
pluginPreProcessBlock(block) pluginPreProcessBlock(block)
blockTracer.PreProcessBlock(block) blockTracer.PreProcessBlock(block)

View File

@ -186,3 +186,20 @@ func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database) (conse
} }
return beacon.New(ethash.NewFaker()), nil return beacon.New(ethash.NewFaker()), nil
} }
// CreateConsensusEngine creates a consensus engine for the given chain config.
// Clique is allowed for now to live standalone, but ethash is forbidden and can
// only exist on already merged networks.
func CreateConsensusEngine(config *params.ChainConfig, db ethdb.Database) (consensus.Engine, error) {
// If proof-of-authority is requested, set it up
if config.Clique != nil {
return beacon.New(clique.New(config.Clique, db)), nil
}
// If defaulting to proof-of-work, enforce an already merged network since
// we cannot run PoW algorithms and more, so we cannot even follow a chain
// not coordinated by a beacon node.
if !config.TerminalTotalDifficultyPassed {
return nil, errors.New("ethash is only supported as a historical component of already merged networks")
}
return beacon.New(ethash.NewFaker()), nil
}

View File

@ -373,15 +373,17 @@ func (ew *engineWrapper) Author(header *types.Header) (common.Address, error) {
addr, err := ew.engine.Author(gethToUtilsHeader(header)) addr, err := ew.engine.Author(gethToUtilsHeader(header))
return common.Address(addr), err return common.Address(addr), err
} }
func (ew *engineWrapper) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header, seal bool) error { func (ew *engineWrapper) VerifyHeader(chain consensus.ChainHeaderReader, header *types.Header) error {
return ew.engine.VerifyHeader(&WrappedHeaderReader{chain, nil}, gethToUtilsHeader(header), seal) var dummySeal bool
return ew.engine.VerifyHeader(&WrappedHeaderReader{chain, nil}, gethToUtilsHeader(header), dummySeal)
} }
func (ew *engineWrapper) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header, seals []bool) (chan<- struct{}, <-chan error) { func (ew *engineWrapper) VerifyHeaders(chain consensus.ChainHeaderReader, headers []*types.Header) (chan<- struct{}, <-chan error) {
pheaders := make([]*ptypes.Header, len(headers)) pheaders := make([]*ptypes.Header, len(headers))
for i, header := range headers { for i, header := range headers {
pheaders[i] = gethToUtilsHeader(header) pheaders[i] = gethToUtilsHeader(header)
} }
return ew.engine.VerifyHeaders(&WrappedHeaderReader{chain, nil}, pheaders, seals) dummySeals := []bool{false, false}
return ew.engine.VerifyHeaders(&WrappedHeaderReader{chain, nil}, pheaders, dummySeals)
} }
func (ew *engineWrapper) VerifyUncles(chain consensus.ChainReader, block *types.Block) error { func (ew *engineWrapper) VerifyUncles(chain consensus.ChainReader, block *types.Block) error {
return ew.engine.VerifyUncles(&WrappedChainReader{chain, nil}, gethToUtilsBlock(block)) return ew.engine.VerifyUncles(&WrappedChainReader{chain, nil}, gethToUtilsBlock(block))

View File

@ -6,6 +6,13 @@ import (
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
) )
// Is t context.Context or *context.Context?
func isContextType(t reflect.Type) bool {
for t.Kind() == reflect.Ptr {
t = t.Elem()
}
return t == contextType
}
func isChanType(t reflect.Type) bool { func isChanType(t reflect.Type) bool {
// Pointers to channels are weird, but whatever // Pointers to channels are weird, but whatever

View File

@ -1,48 +0,0 @@
package trie
import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/plugins"
"github.com/ethereum/go-ethereum/common"
"github.com/openrelayxyz/plugeth-utils/core"
)
func PluginPreTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
fnList := pl.Lookup("PreTrieCommit", func(item interface{}) bool {
_, ok := item.(func(core.Hash))
return ok
})
for _, fni := range fnList {
if fn, ok := fni.(func(core.Hash)); ok {
fn(core.Hash(node))
}
}
}
func pluginPreTrieCommit(node common.Hash) {
if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting PreTrieCommit, but default PluginLoader has not been initialized")
return
}
PluginPreTrieCommit(plugins.DefaultPluginLoader, node)
}
func PluginPostTrieCommit(pl *plugins.PluginLoader, node common.Hash) {
fnList := pl.Lookup("PostTrieCommit", func(item interface{}) bool {
_, ok := item.(func(core.Hash))
return ok
})
for _, fni := range fnList {
if fn, ok := fni.(func(core.Hash)); ok {
fn(core.Hash(node))
}
}
}
func pluginPostTrieCommit(node common.Hash) {
if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting PostTrieCommit, but default PluginLoader has not been initialized")
return
}
PluginPostTrieCommit(plugins.DefaultPluginLoader, node)
}