plugeth/plugins/wrappers/wrappers.go

603 lines
17 KiB
Go
Raw Normal View History

2021-08-31 20:29:09 +00:00
package wrappers
import (
2021-09-03 22:20:49 +00:00
"context"
"encoding/json"
"math/big"
"sync"
"time"
2021-09-14 22:44:25 +00:00
"reflect"
"fmt"
2021-09-03 22:20:49 +00:00
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
gcore "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/state"
2021-09-03 22:20:49 +00:00
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/downloader"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/plugins/interfaces"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
"github.com/openrelayxyz/plugeth-utils/core"
"github.com/openrelayxyz/plugeth-utils/restricted"
2021-09-14 22:44:25 +00:00
"github.com/openrelayxyz/plugeth-utils/restricted/params"
2021-08-31 20:29:09 +00:00
)
type WrappedScopeContext struct {
2021-09-03 22:20:49 +00:00
s *vm.ScopeContext
}
func NewWrappedScopeContext(s *vm.ScopeContext) *WrappedScopeContext {
return &WrappedScopeContext{s}
}
func (w *WrappedScopeContext) Memory() core.Memory {
2021-09-03 22:20:49 +00:00
return w.s.Memory
}
func (w *WrappedScopeContext) Stack() core.Stack {
2021-09-03 22:20:49 +00:00
return w.s.Stack
}
func (w *WrappedScopeContext) Contract() core.Contract {
return &WrappedContract{w.s.Contract}
}
2021-09-03 22:20:49 +00:00
type WrappedContract struct {
c *vm.Contract
}
func (w *WrappedContract) AsDelegate() core.Contract {
return &WrappedContract{w.c.AsDelegate()}
2021-09-03 22:20:49 +00:00
}
func (w *WrappedContract) GetOp(n uint64) core.OpCode {
2021-09-03 22:20:49 +00:00
return core.OpCode(w.c.GetOp(n))
}
func (w *WrappedContract) GetByte(n uint64) byte {
2021-09-03 22:20:49 +00:00
return w.c.GetByte(n)
}
func (w *WrappedContract) Caller() core.Address {
2021-09-03 22:20:49 +00:00
return core.Address(w.c.Caller())
}
func (w *WrappedContract) Address() core.Address {
2021-09-03 22:20:49 +00:00
return core.Address(w.c.Address())
}
func (w *WrappedContract) Value() *big.Int {
2021-09-03 22:20:49 +00:00
return w.c.Value()
}
// added UseGas bc compiler compained without it. Should investigate if the false return with effect performance.
// take this out of core.interface
func (w *WrappedContract) UseGas(gas uint64) (ok bool) {
return false
}
type WrappedTracer struct {
r core.TracerResult
}
func NewWrappedTracer(r core.TracerResult) *WrappedTracer {
return &WrappedTracer{r}
}
func (w WrappedTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
w.r.CaptureStart(core.Address(from), core.Address(to), create, input, gas, value)
}
func (w WrappedTracer) CaptureState(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, rData []byte, depth int, err error) {
w.r.CaptureState(pc, core.OpCode(op), gas, cost, &WrappedScopeContext{scope}, rData, depth, err)
}
func (w WrappedTracer) CaptureFault(env *vm.EVM, pc uint64, op vm.OpCode, gas, cost uint64, scope *vm.ScopeContext, depth int, err error) {
w.r.CaptureFault(pc, core.OpCode(op), gas, cost, &WrappedScopeContext{scope}, depth, err)
}
func (w WrappedTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration, err error) {
w.r.CaptureEnd(output, gasUsed, t, err)
}
func (w WrappedTracer) GetResult() (interface{}, error) {
return w.r.Result()
}
type WrappedStateDB struct {
s *state.StateDB
}
func NewWrappedStateDB(d *state.StateDB) *WrappedStateDB {
return &WrappedStateDB{d}
}
// GetBalance(Address) *big.Int
func (w *WrappedStateDB) GetBalance(addr core.Address) *big.Int {
return w.s.GetBalance(common.Address(addr))
}
// GetNonce(Address) uint64
func (w *WrappedStateDB) GetNonce(addr core.Address) uint64 {
return w.s.GetNonce(common.Address(addr))
}
// GetCodeHash(Address) Hash
func (w *WrappedStateDB) GetCodeHash(addr core.Address) core.Hash {
return core.Hash(w.s.GetCodeHash(common.Address(addr)))
} // sort this out
// GetCode(Address) []byte
func (w *WrappedStateDB) GetCode(addr core.Address) []byte {
return w.s.GetCode(common.Address(addr))
}
// GetCodeSize(Address) int
func (w *WrappedStateDB) GetCodeSize(addr core.Address) int {
return w.s.GetCodeSize(common.Address(addr))
}
//GetRefund() uint64
func (w *WrappedStateDB) GetRefund() uint64 { //are we sure we want to include this? getting a refund seems like changing state
return w.s.GetRefund()
}
// GetCommittedState(Address, Hash) Hash
func (w *WrappedStateDB) GetCommittedState(addr core.Address, hsh core.Hash) core.Hash {
return core.Hash(w.s.GetCommittedState(common.Address(addr), common.Hash(hsh)))
}
// GetState(Address, Hash) Hash
func (w *WrappedStateDB) GetState(addr core.Address, hsh core.Hash) core.Hash {
return core.Hash(w.s.GetState(common.Address(addr), common.Hash(hsh)))
}
// HasSuicided(Address) bool
func (w *WrappedStateDB) HasSuicided(addr core.Address) bool { // I figured we'd skip some of the future labor and update the name now
return w.s.HasSuicided(common.Address(addr))
}
// // Exist reports whether the given account exists in state.
// // Notably this should also return true for suicided accounts.
// Exist(Address) bool
func (w *WrappedStateDB) Exist(addr core.Address) bool {
return w.s.Exist(common.Address(addr))
}
// // Empty returns whether the given account is empty. Empty
// // is defined according to EIP161 (balance = nonce = code = 0).
// Empty(Address) bool
func (w *WrappedStateDB) Empty(addr core.Address) bool {
return w.s.Empty(common.Address(addr))
}
// AddressInAccessList(addr Address) bool
func (w *WrappedStateDB) AddressInAccessList(addr core.Address) bool {
return w.s.AddressInAccessList(common.Address(addr))
}
// SlotInAccessList(addr Address, slot Hash) (addressOk bool, slotOk bool)
func (w *WrappedStateDB) SlotInAccessList(addr core.Address, slot core.Hash) (addressOK, slotOk bool) {
return w.s.SlotInAccessList(common.Address(addr), common.Hash(slot))
}
2021-08-31 20:29:09 +00:00
type Node struct {
2021-09-03 22:20:49 +00:00
n *node.Node
2021-08-31 20:29:09 +00:00
}
func NewNode(n *node.Node) *Node {
2021-09-03 22:20:49 +00:00
return &Node{n}
2021-08-31 20:29:09 +00:00
}
func (n *Node) Server() core.Server {
2021-09-15 20:09:43 +00:00
return n.n.Server()
2021-08-31 20:29:09 +00:00
}
func (n *Node) DataDir() string {
2021-09-03 22:20:49 +00:00
return n.n.DataDir()
2021-08-31 20:29:09 +00:00
}
func (n *Node) InstanceDir() string {
2021-09-03 22:20:49 +00:00
return n.n.InstanceDir()
2021-08-31 20:29:09 +00:00
}
func (n *Node) IPCEndpoint() string {
2021-09-03 22:20:49 +00:00
return n.n.IPCEndpoint()
2021-08-31 20:29:09 +00:00
}
func (n *Node) HTTPEndpoint() string {
2021-09-03 22:20:49 +00:00
return n.n.HTTPEndpoint()
2021-08-31 20:29:09 +00:00
}
func (n *Node) WSEndpoint() string {
2021-09-03 22:20:49 +00:00
return n.n.WSEndpoint()
2021-08-31 20:29:09 +00:00
}
func (n *Node) ResolvePath(x string) string {
2021-09-03 22:20:49 +00:00
return n.n.ResolvePath(x)
2021-08-31 20:29:09 +00:00
}
2021-09-03 22:20:49 +00:00
type Backend struct {
b interfaces.Backend
newTxsFeed event.Feed
newTxsOnce sync.Once
chainFeed event.Feed
chainOnce sync.Once
chainHeadFeed event.Feed
chainHeadOnce sync.Once
chainSideFeed event.Feed
chainSideOnce sync.Once
logsFeed event.Feed
logsOnce sync.Once
pendingLogsFeed event.Feed
pendingLogsOnce sync.Once
removedLogsFeed event.Feed
removedLogsOnce sync.Once
2021-09-14 22:44:25 +00:00
chainConfig *params.ChainConfig
2021-08-31 20:29:09 +00:00
}
func NewBackend(b interfaces.Backend) *Backend {
2021-09-03 22:20:49 +00:00
return &Backend{b: b}
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
2021-09-03 22:20:49 +00:00
return b.b.SuggestGasTipCap(ctx)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) ChainDb() restricted.Database {
2021-09-03 22:20:49 +00:00
return b.b.ChainDb()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) ExtRPCEnabled() bool {
2021-09-03 22:20:49 +00:00
return b.b.ExtRPCEnabled()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) RPCGasCap() uint64 {
2021-09-03 22:20:49 +00:00
return b.b.RPCGasCap()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) RPCTxFeeCap() float64 {
2021-09-03 22:20:49 +00:00
return b.b.RPCTxFeeCap()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) UnprotectedAllowed() bool {
2021-09-03 22:20:49 +00:00
return b.b.UnprotectedAllowed()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SetHead(number uint64) {
2021-09-03 22:20:49 +00:00
b.b.SetHead(number)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) HeaderByNumber(ctx context.Context, number int64) ([]byte, error) {
2021-09-03 22:20:49 +00:00
header, err := b.b.HeaderByNumber(ctx, rpc.BlockNumber(number))
if err != nil {
return nil, err
}
return rlp.EncodeToBytes(header)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) HeaderByHash(ctx context.Context, hash core.Hash) ([]byte, error) {
2021-09-03 22:20:49 +00:00
header, err := b.b.HeaderByHash(ctx, common.Hash(hash))
if err != nil {
return nil, err
}
return rlp.EncodeToBytes(header)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) CurrentHeader() []byte {
2021-09-03 22:20:49 +00:00
ret, _ := rlp.EncodeToBytes(b.b.CurrentHeader())
return ret
2021-08-31 20:29:09 +00:00
}
func (b *Backend) CurrentBlock() []byte {
2021-09-03 22:20:49 +00:00
ret, _ := rlp.EncodeToBytes(b.b.CurrentBlock())
return ret
2021-08-31 20:29:09 +00:00
}
2021-09-03 22:20:49 +00:00
func (b *Backend) BlockByNumber(ctx context.Context, number int64) ([]byte, error) {
block, err := b.b.BlockByNumber(ctx, rpc.BlockNumber(number))
if err != nil {
return nil, err
}
return rlp.EncodeToBytes(block)
2021-08-31 20:29:09 +00:00
}
2021-09-03 22:20:49 +00:00
func (b *Backend) BlockByHash(ctx context.Context, hash core.Hash) ([]byte, error) {
block, err := b.b.BlockByHash(ctx, common.Hash(hash))
if err != nil {
return nil, err
}
return rlp.EncodeToBytes(block)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetReceipts(ctx context.Context, hash core.Hash) ([]byte, error) {
2021-09-03 22:20:49 +00:00
receipts, err := b.b.GetReceipts(ctx, common.Hash(hash))
if err != nil {
return nil, err
}
return json.Marshal(receipts)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetTd(ctx context.Context, hash core.Hash) *big.Int {
2021-09-03 22:20:49 +00:00
return b.b.GetTd(ctx, common.Hash(hash))
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SendTx(ctx context.Context, signedTx []byte) error {
tx := new(types.Transaction)
if err := tx.UnmarshalBinary(signedTx); err != nil {
return err
}
2021-09-03 22:20:49 +00:00
return b.b.SendTx(ctx, tx)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetTransaction(ctx context.Context, txHash core.Hash) ([]byte, core.Hash, uint64, uint64, error) { // RLP Encoded transaction {
2021-09-03 22:20:49 +00:00
tx, blockHash, blockNumber, index, err := b.b.GetTransaction(ctx, common.Hash(txHash))
if err != nil {
return nil, core.Hash(blockHash), blockNumber, index, err
}
enc, err := tx.MarshalBinary()
return enc, core.Hash(blockHash), blockNumber, index, err
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetPoolTransactions() ([][]byte, error) {
2021-09-03 22:20:49 +00:00
txs, err := b.b.GetPoolTransactions()
if err != nil {
return nil, err
}
results := make([][]byte, len(txs))
for i, tx := range txs {
results[i], _ = rlp.EncodeToBytes(tx)
}
return results, nil
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetPoolTransaction(txHash core.Hash) []byte {
2021-09-03 22:20:49 +00:00
tx := b.b.GetPoolTransaction(common.Hash(txHash))
if tx == nil {
return []byte{}
}
enc, _ := rlp.EncodeToBytes(tx)
return enc
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetPoolNonce(ctx context.Context, addr core.Address) (uint64, error) {
2021-09-03 22:20:49 +00:00
return b.b.GetPoolNonce(ctx, common.Address(addr))
2021-08-31 20:29:09 +00:00
}
func (b *Backend) Stats() (pending int, queued int) {
2021-09-03 22:20:49 +00:00
return b.b.Stats()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) TxPoolContent() (map[core.Address][][]byte, map[core.Address][][]byte) {
2021-09-03 22:20:49 +00:00
pending, queued := b.b.TxPoolContent()
trpending, trqueued := make(map[core.Address][][]byte), make(map[core.Address][][]byte)
for k, v := range pending {
trpending[core.Address(k)] = make([][]byte, len(v))
for i, tx := range v {
trpending[core.Address(k)][i], _ = tx.MarshalBinary()
}
}
for k, v := range queued {
trqueued[core.Address(k)] = make([][]byte, len(v))
for i, tx := range v {
trpending[core.Address(k)][i], _ = tx.MarshalBinary()
}
}
return trpending, trqueued
2021-08-31 20:29:09 +00:00
} // RLP encoded transactions
func (b *Backend) BloomStatus() (uint64, uint64) {
2021-09-03 22:20:49 +00:00
return b.b.BloomStatus()
2021-08-31 20:29:09 +00:00
}
func (b *Backend) GetLogs(ctx context.Context, blockHash core.Hash) ([][]byte, error) {
2021-09-03 22:20:49 +00:00
logs, err := b.b.GetLogs(ctx, common.Hash(blockHash))
if err != nil {
return nil, err
}
encLogs := make([][]byte, len(logs))
for i, log := range logs {
encLogs[i], _ = rlp.EncodeToBytes(log)
}
return encLogs, nil
2021-08-31 20:29:09 +00:00
} // []RLP encoded logs
2021-09-03 22:20:49 +00:00
type dl struct {
dl *downloader.Downloader
2021-08-31 20:29:09 +00:00
}
2021-09-03 22:20:49 +00:00
type progress struct {
p ethereum.SyncProgress
2021-08-31 20:29:09 +00:00
}
func (p *progress) StartingBlock() uint64 {
2021-09-03 22:20:49 +00:00
return p.p.StartingBlock
2021-08-31 20:29:09 +00:00
}
func (p *progress) CurrentBlock() uint64 {
2021-09-03 22:20:49 +00:00
return p.p.CurrentBlock
2021-08-31 20:29:09 +00:00
}
func (p *progress) HighestBlock() uint64 {
2021-09-03 22:20:49 +00:00
return p.p.HighestBlock
2021-08-31 20:29:09 +00:00
}
func (p *progress) PulledStates() uint64 {
2021-09-03 22:20:49 +00:00
return p.p.PulledStates
2021-08-31 20:29:09 +00:00
}
func (p *progress) KnownStates() uint64 {
2021-09-03 22:20:49 +00:00
return p.p.KnownStates
2021-08-31 20:29:09 +00:00
}
func (d *dl) Progress() core.Progress {
2021-09-03 22:20:49 +00:00
return &progress{d.dl.Progress()}
2021-08-31 20:29:09 +00:00
}
func (b *Backend) Downloader() core.Downloader {
2021-09-03 22:20:49 +00:00
return &dl{b.b.Downloader()}
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.newTxsOnce.Do(func() {
bch := make(chan gcore.NewTxsEvent, 100)
sub = b.b.SubscribeNewTxsEvent(bch)
go func() {
for {
select {
case item := <-bch:
txe := core.NewTxsEvent{
Txs: make([][]byte, len(item.Txs)),
}
for i, tx := range item.Txs {
txe.Txs[i], _ = tx.MarshalBinary()
}
b.newTxsFeed.Send(txe)
case err := <-sub.Err():
log.Warn("Subscription error for NewTxs", "err", err)
return
}
}
}()
})
return b.newTxsFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SubscribeChainEvent(ch chan<- core.ChainEvent) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.chainOnce.Do(func() {
bch := make(chan gcore.ChainEvent, 100)
sub = b.b.SubscribeChainEvent(bch)
go func() {
for {
select {
case item := <-bch:
ce := core.ChainEvent{
Hash: core.Hash(item.Hash),
}
ce.Block, _ = rlp.EncodeToBytes(item.Block)
ce.Logs, _ = rlp.EncodeToBytes(item.Logs)
b.chainFeed.Send(ce)
case err := <-sub.Err():
log.Warn("Subscription error for Chain", "err", err)
return
}
}
}()
})
return b.chainFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.chainHeadOnce.Do(func() {
bch := make(chan gcore.ChainHeadEvent, 100)
sub = b.b.SubscribeChainHeadEvent(bch)
go func() {
for {
select {
case item := <-bch:
che := core.ChainHeadEvent{}
che.Block, _ = rlp.EncodeToBytes(item.Block)
b.chainHeadFeed.Send(che)
case err := <-sub.Err():
log.Warn("Subscription error for ChainHead", "err", err)
return
}
}
}()
})
return b.chainHeadFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.chainSideOnce.Do(func() {
bch := make(chan gcore.ChainSideEvent, 100)
sub = b.b.SubscribeChainSideEvent(bch)
go func() {
for {
select {
case item := <-bch:
cse := core.ChainSideEvent{}
cse.Block, _ = rlp.EncodeToBytes(item.Block)
b.chainSideFeed.Send(cse)
case err := <-sub.Err():
log.Warn("Subscription error for ChainSide", "err", err)
return
}
}
}()
})
return b.chainSideFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
}
func (b *Backend) SubscribeLogsEvent(ch chan<- [][]byte) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.logsOnce.Do(func() {
bch := make(chan []*types.Log, 100)
sub = b.b.SubscribeLogsEvent(bch)
go func() {
for {
select {
case item := <-bch:
logs := make([][]byte, len(item))
for i, log := range item {
logs[i], _ = rlp.EncodeToBytes(log)
}
b.logsFeed.Send(logs)
case err := <-sub.Err():
log.Warn("Subscription error for Logs", "err", err)
return
}
}
}()
})
return b.logsFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
} // []RLP encoded logs
func (b *Backend) SubscribePendingLogsEvent(ch chan<- [][]byte) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.pendingLogsOnce.Do(func() {
bch := make(chan []*types.Log, 100)
sub = b.b.SubscribePendingLogsEvent(bch)
go func() {
for {
select {
case item := <-bch:
logs := make([][]byte, len(item))
for i, log := range item {
logs[i], _ = rlp.EncodeToBytes(log)
}
b.pendingLogsFeed.Send(logs)
case err := <-sub.Err():
log.Warn("Subscription error for PendingLogs", "err", err)
return
}
}
}()
})
return b.pendingLogsFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
} // RLP Encoded logs
func (b *Backend) SubscribeRemovedLogsEvent(ch chan<- []byte) core.Subscription {
2021-09-03 22:20:49 +00:00
var sub event.Subscription
b.removedLogsOnce.Do(func() {
bch := make(chan gcore.RemovedLogsEvent, 100)
sub = b.b.SubscribeRemovedLogsEvent(bch)
go func() {
for {
select {
case item := <-bch:
logs := make([][]byte, len(item.Logs))
for i, log := range item.Logs {
logs[i], _ = rlp.EncodeToBytes(log)
}
b.removedLogsFeed.Send(item)
case err := <-sub.Err():
log.Warn("Subscription error for RemovedLogs", "err", err)
return
}
}
}()
})
return b.removedLogsFeed.Subscribe(ch)
2021-08-31 20:29:09 +00:00
} // RLP encoded logs
2021-09-14 22:44:25 +00:00
func convertAndSet(a, b reflect.Value) (err error) {
defer func() {
if recover() != nil {
fmt.Errorf("error converting: %v", err.Error())
}
}()
a.Set(b.Convert(a.Type()))
return nil
}
func (b *Backend) ChainConfig() *params.ChainConfig {
// We're using the reflect library to copy data from params.ChainConfig to
// pparams.ChainConfig, so this function shouldn't need to be touched for
// simple changes to ChainConfig (though pparams.ChainConfig may need to be
// updated). Note that this probably won't carry over consensus engine data.
if b.chainConfig != nil { return b.chainConfig }
b.chainConfig = &params.ChainConfig{}
nval := reflect.ValueOf(b.b.ChainConfig())
ntype := nval.Type()
lval := reflect.ValueOf(b.chainConfig)
for i := 0; i < nval.NumField(); i++ {
field := ntype.Field(i)
v := nval.FieldByName(field.Name)
lv := lval.FieldByName(field.Name)
if v.Type() == lv.Type() && lv.CanSet() {
lv.Set(v)
} else {
convertAndSet(lv, v)
}
}
return b.chainConfig
}