Left comments on all PluGeth code injections
This commit is contained in:
parent
4211c5c401
commit
fd0aaa1d6b
@ -328,6 +328,7 @@ func prepare(ctx *cli.Context) {
|
|||||||
// It creates a default node based on the command line arguments and runs it in
|
// It creates a default node based on the command line arguments and runs it in
|
||||||
// blocking mode, waiting for it to be shut down.
|
// blocking mode, waiting for it to be shut down.
|
||||||
func geth(ctx *cli.Context) error {
|
func geth(ctx *cli.Context) error {
|
||||||
|
//begin PluGeth code injection
|
||||||
if err := plugins.Initialize(path.Join(ctx.GlobalString(utils.DataDirFlag.Name), "plugins"), ctx); err != nil {
|
if err := plugins.Initialize(path.Join(ctx.GlobalString(utils.DataDirFlag.Name), "plugins"), ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -346,7 +347,7 @@ func geth(ctx *cli.Context) error {
|
|||||||
}
|
}
|
||||||
defer stack.Close()
|
defer stack.Close()
|
||||||
stack.RegisterAPIs(pluginGetAPIs(stack, wrapperBackend))
|
stack.RegisterAPIs(pluginGetAPIs(stack, wrapperBackend))
|
||||||
|
//end PluGeth code injection
|
||||||
startNode(ctx, stack, backend, false)
|
startNode(ctx, stack, backend, false)
|
||||||
stack.Wait()
|
stack.Wait()
|
||||||
return nil
|
return nil
|
||||||
|
@ -1313,6 +1313,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
|
|||||||
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
externTd := new(big.Int).Add(block.Difficulty(), ptd)
|
||||||
|
|
||||||
if status == CanonStatTy {
|
if status == CanonStatTy {
|
||||||
|
//begin PluGeth code injection
|
||||||
pluginNewHead(block, block.Hash(), logs, externTd)
|
pluginNewHead(block, block.Hash(), logs, externTd)
|
||||||
bc.chainFeed.Send(ChainEvent{Block: block, Hash: block.Hash(), Logs: logs})
|
bc.chainFeed.Send(ChainEvent{Block: block, Hash: block.Hash(), Logs: logs})
|
||||||
if len(logs) > 0 {
|
if len(logs) > 0 {
|
||||||
@ -1329,7 +1330,7 @@ func (bc *BlockChain) writeBlockAndSetHead(block *types.Block, receipts []*types
|
|||||||
} else {
|
} else {
|
||||||
pluginNewSideBlock(block, block.Hash(), logs)
|
pluginNewSideBlock(block, block.Hash(), logs)
|
||||||
bc.chainSideFeed.Send(ChainSideEvent{Block: block})
|
bc.chainSideFeed.Send(ChainSideEvent{Block: block})
|
||||||
}
|
} // end PluGeth code injection
|
||||||
return status, nil
|
return status, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2016,7 +2017,9 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
|
|||||||
msg = "Large chain reorg detected"
|
msg = "Large chain reorg detected"
|
||||||
logFn = log.Warn
|
logFn = log.Warn
|
||||||
}
|
}
|
||||||
|
//begin PluGeth code injection
|
||||||
pluginReorg(commonBlock, oldChain, newChain)
|
pluginReorg(commonBlock, oldChain, newChain)
|
||||||
|
//begin Plugeth code injection
|
||||||
logFn(msg, "number", commonBlock.Number(), "hash", commonBlock.Hash(),
|
logFn(msg, "number", commonBlock.Number(), "hash", commonBlock.Hash(),
|
||||||
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
|
"drop", len(oldChain), "dropfrom", oldChain[0].Hash(), "add", len(newChain), "addfrom", newChain[0].Hash())
|
||||||
blockReorgAddMeter.Mark(int64(len(newChain)))
|
blockReorgAddMeter.Mark(int64(len(newChain)))
|
||||||
|
@ -284,7 +284,9 @@ func (f *freezer) ModifyAncients(fn func(ethdb.AncientWriteOp) error) (writeSize
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
//begin PluGeth code injection
|
||||||
pluginCommitUpdate(item)
|
pluginCommitUpdate(item)
|
||||||
|
//end PluGeth code injection
|
||||||
atomic.StoreUint64(&f.frozen, item)
|
atomic.StoreUint64(&f.frozen, item)
|
||||||
return writeSize, nil
|
return writeSize, nil
|
||||||
}
|
}
|
||||||
|
@ -151,6 +151,7 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
|
|||||||
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
|
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Start PluGeth section
|
||||||
if sdb.snap == nil {
|
if sdb.snap == nil {
|
||||||
log.Debug("Snapshots not availble. Using plugin snapshot.")
|
log.Debug("Snapshots not availble. Using plugin snapshot.")
|
||||||
sdb.snap = &pluginSnapshot{root}
|
sdb.snap = &pluginSnapshot{root}
|
||||||
@ -158,6 +159,7 @@ func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error)
|
|||||||
sdb.snapAccounts = make(map[common.Hash][]byte)
|
sdb.snapAccounts = make(map[common.Hash][]byte)
|
||||||
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
|
sdb.snapStorage = make(map[common.Hash]map[common.Hash][]byte)
|
||||||
}
|
}
|
||||||
|
// End PluGeth section
|
||||||
return sdb, nil
|
return sdb, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,6 +893,7 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
|||||||
func (s *StateDB) Prepare(thash common.Hash, ti int) {
|
func (s *StateDB) Prepare(thash common.Hash, ti int) {
|
||||||
s.thash = thash
|
s.thash = thash
|
||||||
s.txIndex = ti
|
s.txIndex = ti
|
||||||
|
s.accessList = newAccessList()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StateDB) clearJournalAndRefund() {
|
func (s *StateDB) clearJournalAndRefund() {
|
||||||
@ -976,8 +979,10 @@ func (s *StateDB) Commit(deleteEmptyObjects bool) (common.Hash, error) {
|
|||||||
}
|
}
|
||||||
// Only update if there's a state transition (skip empty Clique blocks)
|
// Only update if there's a state transition (skip empty Clique blocks)
|
||||||
if parent := s.snap.Root(); parent != root {
|
if parent := s.snap.Root(); parent != root {
|
||||||
|
//begin PluGeth code injection
|
||||||
pluginStateUpdate(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage, codeUpdates)
|
pluginStateUpdate(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage, codeUpdates)
|
||||||
if _, ok := s.snap.(*pluginSnapshot); !ok && s.snaps != nil {
|
if _, ok := s.snap.(*pluginSnapshot); !ok && s.snaps != nil { // This if statement (but not its content) was added by PluGeth
|
||||||
|
//end PluGeth injection
|
||||||
if err := s.snaps.Update(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage); err != nil {
|
if err := s.snaps.Update(root, parent, s.snapDestructs, s.snapAccounts, s.snapStorage); err != nil {
|
||||||
log.Warn("Failed to update snapshot tree", "from", parent, "to", root, "err", err)
|
log.Warn("Failed to update snapshot tree", "from", parent, "to", root, "err", err)
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||||||
misc.ApplyDAOHardFork(statedb)
|
misc.ApplyDAOHardFork(statedb)
|
||||||
}
|
}
|
||||||
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
||||||
|
//begin PluGeth code injection
|
||||||
blockTracer, ok := pluginGetBlockTracer(header.Hash(), statedb)
|
blockTracer, ok := pluginGetBlockTracer(header.Hash(), statedb)
|
||||||
if ok {
|
if ok {
|
||||||
cfg.Tracer = blockTracer
|
cfg.Tracer = blockTracer
|
||||||
@ -104,6 +105,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg
|
|||||||
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
// Finalize the block, applying any consensus engine specific extras (e.g. block rewards)
|
||||||
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles())
|
p.engine.Finalize(p.bc, header, statedb, block.Transactions(), block.Uncles())
|
||||||
pluginPostProcessBlock(block)
|
pluginPostProcessBlock(block)
|
||||||
|
//begin PluGeth code injection
|
||||||
blockTracer.PostProcessBlock(block)
|
blockTracer.PostProcessBlock(block)
|
||||||
return receipts, allLogs, *usedGas, nil
|
return receipts, allLogs, *usedGas, nil
|
||||||
}
|
}
|
||||||
|
@ -881,7 +881,9 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Get the tracer from the plugin loader
|
// Get the tracer from the plugin loader
|
||||||
|
//begin PluGeth code injection
|
||||||
if tr, ok := getPluginTracer(*config.Tracer); ok {
|
if tr, ok := getPluginTracer(*config.Tracer); ok {
|
||||||
|
//end PluGeth code injection
|
||||||
tracer = tr(statedb, vmctx)
|
tracer = tr(statedb, vmctx)
|
||||||
} else {
|
} else {
|
||||||
// Constuct the JavaScript tracer to execute with
|
// Constuct the JavaScript tracer to execute with
|
||||||
|
@ -334,7 +334,9 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage
|
|||||||
return msg.errorResponse(&invalidParamsError{err.Error()})
|
return msg.errorResponse(&invalidParamsError{err.Error()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//begin PluGeth code injection
|
||||||
pluginGetRPCCalls(string(msg.ID), string(msg.Method), string(msg.Params))
|
pluginGetRPCCalls(string(msg.ID), string(msg.Method), string(msg.Params))
|
||||||
|
//begin PluGeth code injection
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
answer := h.runMethod(cp.ctx, msg, callb, args)
|
answer := h.runMethod(cp.ctx, msg, callb, args)
|
||||||
|
|
||||||
|
@ -64,7 +64,9 @@ func (r *serviceRegistry) registerName(name string, rcvr interface{}) error {
|
|||||||
return fmt.Errorf("no service name for type %s", rcvrVal.Type().String())
|
return fmt.Errorf("no service name for type %s", rcvrVal.Type().String())
|
||||||
}
|
}
|
||||||
callbacks := suitableCallbacks(rcvrVal)
|
callbacks := suitableCallbacks(rcvrVal)
|
||||||
|
// begin PluGeth code injection
|
||||||
pluginExtendedCallbacks(callbacks, rcvrVal)
|
pluginExtendedCallbacks(callbacks, rcvrVal)
|
||||||
|
// begin PluGeth code injection
|
||||||
if len(callbacks) == 0 {
|
if len(callbacks) == 0 {
|
||||||
return fmt.Errorf("service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
|
return fmt.Errorf("service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user