forked from cerc-io/plugeth
ForkIDs() added to test plugin
This commit is contained in:
parent
e35d5eb3fe
commit
39b5250f63
@ -1447,7 +1447,6 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
|
|||||||
setGraphQL(ctx, cfg)
|
setGraphQL(ctx, cfg)
|
||||||
setWS(ctx, cfg)
|
setWS(ctx, cfg)
|
||||||
setNodeUserIdent(ctx, cfg)
|
setNodeUserIdent(ctx, cfg)
|
||||||
log.Error("calling set data dir", "cfg.datadir", cfg.DataDir)
|
|
||||||
SetDataDir(ctx, cfg)
|
SetDataDir(ctx, cfg)
|
||||||
setSmartCard(ctx, cfg)
|
setSmartCard(ctx, cfg)
|
||||||
|
|
||||||
@ -1512,7 +1511,6 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetDataDir(ctx *cli.Context, cfg *node.Config) {
|
func SetDataDir(ctx *cli.Context, cfg *node.Config) {
|
||||||
log.Error("Inside of setDataDir", "default", node.DefaultDataDir())
|
|
||||||
// begin PluGeth injection
|
// begin PluGeth injection
|
||||||
pluginPath := pluginDefaultDataDir(node.DefaultDataDir())
|
pluginPath := pluginDefaultDataDir(node.DefaultDataDir())
|
||||||
switch {
|
switch {
|
||||||
|
@ -240,11 +240,6 @@ func checksumToBytes(hash uint32) [4]byte {
|
|||||||
// gatherForks gathers all the known forks and creates two sorted lists out of
|
// gatherForks gathers all the known forks and creates two sorted lists out of
|
||||||
// them, one for the block number based forks and the second for the timestamps.
|
// them, one for the block number based forks and the second for the timestamps.
|
||||||
func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64) {
|
func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64) {
|
||||||
// begin PluGeth injection
|
|
||||||
if byBlock, byTime, ok := pluginForkIDs(); ok {
|
|
||||||
return byBlock, byTime
|
|
||||||
}
|
|
||||||
// end PluGeth injection
|
|
||||||
|
|
||||||
// Gather all the fork block numbers via reflection
|
// Gather all the fork block numbers via reflection
|
||||||
kind := reflect.TypeOf(params.ChainConfig{})
|
kind := reflect.TypeOf(params.ChainConfig{})
|
||||||
@ -299,5 +294,10 @@ func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64
|
|||||||
for len(forksByTime) > 0 && forksByTime[0] <= genesis {
|
for len(forksByTime) > 0 && forksByTime[0] <= genesis {
|
||||||
forksByTime = forksByTime[1:]
|
forksByTime = forksByTime[1:]
|
||||||
}
|
}
|
||||||
|
// begin PluGeth injection
|
||||||
|
if byBlock, byTime, ok := pluginForkIDs(forksByBlock, forksByTime); ok {
|
||||||
|
return byBlock, byTime
|
||||||
|
}
|
||||||
|
// end PluGeth injection
|
||||||
return forksByBlock, forksByTime
|
return forksByBlock, forksByTime
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,37 @@
|
|||||||
package forkid
|
package forkid
|
||||||
|
|
||||||
import (
|
import (
|
||||||
// "encoding/json"
|
|
||||||
// "math/big"
|
|
||||||
// "reflect"
|
|
||||||
// "time"
|
|
||||||
// "sync"
|
|
||||||
|
|
||||||
// "github.com/ethereum/go-ethereum/common"
|
|
||||||
// "github.com/ethereum/go-ethereum/core/state"
|
|
||||||
// "github.com/ethereum/go-ethereum/core/types"
|
|
||||||
// "github.com/ethereum/go-ethereum/core/vm"
|
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/plugins"
|
"github.com/ethereum/go-ethereum/plugins"
|
||||||
// "github.com/ethereum/go-ethereum/plugins/wrappers"
|
|
||||||
// "github.com/ethereum/go-ethereum/rlp"
|
|
||||||
// "github.com/openrelayxyz/plugeth-utils/core"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func PluginForkIDs(pl *plugins.PluginLoader) ([]uint64, []uint64, bool) {
|
func PluginForkIDs(pl *plugins.PluginLoader, byBlock, byTime []uint64) ([]uint64, []uint64, bool) {
|
||||||
f, ok := plugins.LookupOne[func() ([]uint64, []uint64)](pl, "ForkIDs")
|
f, ok := plugins.LookupOne[func([]uint64, []uint64) ([]uint64, []uint64)](pl, "ForkIDs")
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, false
|
return nil, nil, false
|
||||||
}
|
}
|
||||||
byBlock, byTime := f()
|
pluginByBlock, pluginByTime := f(byBlock, byTime)
|
||||||
|
|
||||||
return byBlock, byTime, ok
|
return pluginByBlock, pluginByTime, ok
|
||||||
|
|
||||||
|
// fnList := pl.Lookup("ForkIDs", func(item interface{}) bool {
|
||||||
|
// _, ok := item.(func([]uint64, []uint64) ([]uint64, []uint64))
|
||||||
|
// return ok
|
||||||
|
// })
|
||||||
|
// for _, fni := range fnList {
|
||||||
|
// if fn, ok := fni.(func([]uint64, []uint64) ([]uint64, []uint64)); ok {
|
||||||
|
// pluginByBlock, pluginByTime := fn(byBlock, byTime)
|
||||||
|
// return pluginByBlock, pluginByTime, true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return nil, nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func pluginForkIDs() ([]uint64, []uint64, bool) {
|
func pluginForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64, bool) {
|
||||||
if plugins.DefaultPluginLoader == nil {
|
if plugins.DefaultPluginLoader == nil {
|
||||||
log.Warn("Attempting PluginForkIDs, but default PluginLoader has not been initialized")
|
log.Warn("Attempting PluginForkIDs, but default PluginLoader has not been initialized")
|
||||||
return nil, nil, false
|
return nil, nil, false
|
||||||
}
|
}
|
||||||
return PluginForkIDs(plugins.DefaultPluginLoader)
|
return PluginForkIDs(plugins.DefaultPluginLoader, byBlock, byTime)
|
||||||
}
|
}
|
||||||
|
@ -141,6 +141,23 @@ func SetTrieFlushIntervalClone(duration time.Duration) time.Duration {
|
|||||||
return duration
|
return duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// core/forkid/
|
||||||
|
|
||||||
|
var onceZero sync.Once
|
||||||
|
|
||||||
|
func ForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64) {
|
||||||
|
go func() {
|
||||||
|
onceZero.Do(func() {
|
||||||
|
m := map[string]struct{}{
|
||||||
|
"ForkIDs":struct{}{},
|
||||||
|
}
|
||||||
|
hookChan <- m
|
||||||
|
})
|
||||||
|
}()
|
||||||
|
|
||||||
|
return byBlock, byTime
|
||||||
|
}
|
||||||
|
|
||||||
// core/rawdb/
|
// core/rawdb/
|
||||||
|
|
||||||
func ModifyAncients(index uint64, freezerUpdate map[string]struct{}) {
|
func ModifyAncients(index uint64, freezerUpdate map[string]struct{}) {
|
||||||
@ -154,7 +171,6 @@ func AppendAncient(number uint64, hash, header, body, receipts, td []byte) {
|
|||||||
// core/state/
|
// core/state/
|
||||||
|
|
||||||
func StateUpdate(blockRoot core.Hash, parentRoot core.Hash, coreDestructs map[core.Hash]struct{}, coreAccounts map[core.Hash][]byte, coreStorage map[core.Hash]map[core.Hash][]byte, coreCode map[core.Hash][]byte) {
|
func StateUpdate(blockRoot core.Hash, parentRoot core.Hash, coreDestructs map[core.Hash]struct{}, coreAccounts map[core.Hash][]byte, coreStorage map[core.Hash]map[core.Hash][]byte, coreCode map[core.Hash][]byte) {
|
||||||
// log.Warn("StatueUpdate", "blockRoot", blockRoot, "parentRoot", parentRoot, "coreDestructs", coreDestructs, "coreAccounts", coreAccounts, "coreStorage", coreStorage, "coreCode", coreCode)
|
|
||||||
m := map[string]struct{}{
|
m := map[string]struct{}{
|
||||||
"StateUpdate":struct{}{},
|
"StateUpdate":struct{}{},
|
||||||
}
|
}
|
||||||
@ -171,11 +187,11 @@ func GetRPCCalls(method string, id string, params string) {
|
|||||||
hookChan <- m
|
hookChan <- m
|
||||||
}
|
}
|
||||||
|
|
||||||
var once sync.Once
|
var onceOne sync.Once
|
||||||
|
|
||||||
func RPCSubscriptionTest() {
|
func RPCSubscriptionTest() {
|
||||||
go func() {
|
go func() {
|
||||||
once.Do(func() {
|
onceOne.Do(func() {
|
||||||
m := map[string]struct{}{
|
m := map[string]struct{}{
|
||||||
"RPCSubscriptionTest":struct{}{},
|
"RPCSubscriptionTest":struct{}{},
|
||||||
}
|
}
|
||||||
@ -230,5 +246,6 @@ var plugins map[string]struct{} = map[string]struct{}{
|
|||||||
"SetNetworkId":struct{}{},
|
"SetNetworkId":struct{}{},
|
||||||
"SetETHDiscoveryURLs": struct{}{},
|
"SetETHDiscoveryURLs": struct{}{},
|
||||||
"SetSnapDiscoveryURLs": struct{}{},
|
"SetSnapDiscoveryURLs": struct{}{},
|
||||||
|
"ForkIDs": struct{}{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,6 +126,8 @@ func BlockChain() {
|
|||||||
delete(plugins, "SetETHDiscoveryURLs")
|
delete(plugins, "SetETHDiscoveryURLs")
|
||||||
case f("SetSnapDiscoveryURLs"):
|
case f("SetSnapDiscoveryURLs"):
|
||||||
delete(plugins, "SetSnapDiscoveryURLs")
|
delete(plugins, "SetSnapDiscoveryURLs")
|
||||||
|
case f("ForkIDs"):
|
||||||
|
delete(plugins, "ForkIDs")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user