@@ -1594,7 +1594,7 @@ type BlockTraceResult struct {
1594
1594
1595
1595
// TraceBlock processes the given block's RLP but does not import the block in to
1596
1596
// the chain.
1597
- func (api * PrivateDebugAPI ) TraceBlock (blockRlp []byte , config vm.Config ) BlockTraceResult {
1597
+ func (api * PrivateDebugAPI ) TraceBlock (blockRlp []byte , config * vm.Config ) BlockTraceResult {
1598
1598
var block types.Block
1599
1599
err := rlp .Decode (bytes .NewReader (blockRlp ), & block )
1600
1600
if err != nil {
@@ -1611,7 +1611,7 @@ func (api *PrivateDebugAPI) TraceBlock(blockRlp []byte, config vm.Config) BlockT
1611
1611
1612
1612
// TraceBlockFromFile loads the block's RLP from the given file name and attempts to
1613
1613
// process it but does not import the block in to the chain.
1614
- func (api * PrivateDebugAPI ) TraceBlockFromFile (file string , config vm.Config ) BlockTraceResult {
1614
+ func (api * PrivateDebugAPI ) TraceBlockFromFile (file string , config * vm.Config ) BlockTraceResult {
1615
1615
blockRlp , err := ioutil .ReadFile (file )
1616
1616
if err != nil {
1617
1617
return BlockTraceResult {Error : fmt .Sprintf ("could not read file: %v" , err )}
@@ -1620,7 +1620,7 @@ func (api *PrivateDebugAPI) TraceBlockFromFile(file string, config vm.Config) Bl
1620
1620
}
1621
1621
1622
1622
// TraceProcessBlock processes the block by canonical block number.
1623
- func (api * PrivateDebugAPI ) TraceBlockByNumber (number uint64 , config vm.Config ) BlockTraceResult {
1623
+ func (api * PrivateDebugAPI ) TraceBlockByNumber (number uint64 , config * vm.Config ) BlockTraceResult {
1624
1624
// Fetch the block that we aim to reprocess
1625
1625
block := api .eth .BlockChain ().GetBlockByNumber (number )
1626
1626
if block == nil {
@@ -1636,7 +1636,7 @@ func (api *PrivateDebugAPI) TraceBlockByNumber(number uint64, config vm.Config)
1636
1636
}
1637
1637
1638
1638
// TraceBlockByHash processes the block by hash.
1639
- func (api * PrivateDebugAPI ) TraceBlockByHash (hash common.Hash , config vm.Config ) BlockTraceResult {
1639
+ func (api * PrivateDebugAPI ) TraceBlockByHash (hash common.Hash , config * vm.Config ) BlockTraceResult {
1640
1640
// Fetch the block that we aim to reprocess
1641
1641
block := api .eth .BlockChain ().GetBlock (hash )
1642
1642
if block == nil {
@@ -1664,14 +1664,17 @@ func (t *TraceCollector) AddStructLog(slog vm.StructLog) {
1664
1664
}
1665
1665
1666
1666
// traceBlock processes the given block but does not save the state.
1667
- func (api * PrivateDebugAPI ) traceBlock (block * types.Block , config vm.Config ) (bool , []vm.StructLog , error ) {
1667
+ func (api * PrivateDebugAPI ) traceBlock (block * types.Block , config * vm.Config ) (bool , []vm.StructLog , error ) {
1668
1668
// Validate and reprocess the block
1669
1669
var (
1670
1670
blockchain = api .eth .BlockChain ()
1671
1671
validator = blockchain .Validator ()
1672
1672
processor = blockchain .Processor ()
1673
1673
collector = & TraceCollector {}
1674
1674
)
1675
+ if config == nil {
1676
+ config = new (vm.Config )
1677
+ }
1675
1678
config .Debug = true // make sure debug is set.
1676
1679
config .Logger .Collector = collector
1677
1680
@@ -1683,7 +1686,7 @@ func (api *PrivateDebugAPI) traceBlock(block *types.Block, config vm.Config) (bo
1683
1686
return false , collector .traces , err
1684
1687
}
1685
1688
1686
- receipts , _ , usedGas , err := processor .Process (block , statedb , config )
1689
+ receipts , _ , usedGas , err := processor .Process (block , statedb , * config )
1687
1690
if err != nil {
1688
1691
return false , collector .traces , err
1689
1692
}
@@ -1771,7 +1774,10 @@ func formatError(err error) string {
1771
1774
1772
1775
// TraceTransaction returns the structured logs created during the execution of EVM
1773
1776
// and returns them as a JSON object.
1774
- func (s * PrivateDebugAPI ) TraceTransaction (txHash common.Hash , logger vm.LogConfig ) (* ExecutionResult , error ) {
1777
+ func (s * PrivateDebugAPI ) TraceTransaction (txHash common.Hash , logger * vm.LogConfig ) (* ExecutionResult , error ) {
1778
+ if logger == nil {
1779
+ logger = new (vm.LogConfig )
1780
+ }
1775
1781
// Retrieve the tx from the chain and the containing block
1776
1782
tx , blockHash , _ , txIndex := core .GetTransaction (s .eth .ChainDb (), txHash )
1777
1783
if tx == nil {
@@ -1815,7 +1821,7 @@ func (s *PrivateDebugAPI) TraceTransaction(txHash common.Hash, logger vm.LogConf
1815
1821
continue
1816
1822
}
1817
1823
// Otherwise trace the transaction and return
1818
- vmenv := core .NewEnv (stateDb , s .config , s .eth .BlockChain (), msg , parent .Header (), vm.Config {Debug : true , Logger : logger })
1824
+ vmenv := core .NewEnv (stateDb , s .config , s .eth .BlockChain (), msg , parent .Header (), vm.Config {Debug : true , Logger : * logger })
1819
1825
ret , gas , err := core .ApplyMessage (vmenv , msg , new (core.GasPool ).AddGas (tx .Gas ()))
1820
1826
if err != nil {
1821
1827
return nil , fmt .Errorf ("tracing failed: %v" , err )
0 commit comments