Skip to content

Commit

Permalink
ut fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyaniarun1993 committed Nov 25, 2024
1 parent 79c9666 commit b22cb87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 32 deletions.
40 changes: 12 additions & 28 deletions eth/tracers/js/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,18 @@ func (t *jsTracer) OnTxStart(env *tracing.VMContext, tx types.Transaction, from
t.activePrecompiles = vm.ActivePrecompiles(rules)
t.ctx["block"] = t.vm.ToValue(t.env.BlockNumber)
t.ctx["gas"] = t.vm.ToValue(tx.GetGas())
t.ctx["gasPrice"] = t.vm.ToValue(t.env.GasPrice.ToBig())
gasPriceBig, err := t.toBig(t.vm, env.GasPrice.String())
if err != nil {
t.err = err
return
}
t.ctx["gasPrice"] = gasPriceBig
coinbase, err := t.toBuf(t.vm, env.Coinbase.Bytes())
if err != nil {
t.err = err
return
}
t.ctx["coinbase"] = t.vm.ToValue(coinbase)
}

// OnTxEnd implements the Tracer interface and is invoked at the end of
Expand All @@ -252,33 +263,6 @@ func (t *jsTracer) OnTxEnd(receipt *types.Receipt, err error) {
t.ctx["gasUsed"] = t.vm.ToValue(receipt.GasUsed)
}

// // CaptureStart implements the Tracer interface to initialize the tracing operation.
// func (t *jsTracer) CaptureStart(env *vm.EVM, from libcommon.Address, to libcommon.Address, precompile bool, create bool, input []byte, gas uint64, value *uint256.Int, code []byte) {
// t.env = env
// db := &dbObj{ibs: env.IntraBlockState(), vm: t.vm, toBig: t.toBig, toBuf: t.toBuf, fromBuf: t.fromBuf}
// t.dbValue = db.setupObject()
// if create {
// t.ctx["type"] = t.vm.ToValue("CREATE")
// } else {
// t.ctx["type"] = t.vm.ToValue("CALL")
// }
// t.ctx["from"] = t.vm.ToValue(from.Bytes())
// t.ctx["to"] = t.vm.ToValue(to.Bytes())
// t.ctx["input"] = t.vm.ToValue(input)
// t.ctx["gas"] = t.vm.ToValue(t.gasLimit)
// t.ctx["gasPrice"] = t.vm.ToValue(env.GasPrice.ToBig())
// valueBig, err := t.toBig(t.vm, value.ToBig().String())
// if err != nil {
// t.err = err
// return
// }
// t.ctx["value"] = valueBig
// t.ctx["block"] = t.vm.ToValue(env.Context.BlockNumber)
// // Update list of precompiles based on current block
// rules := env.ChainRules()
// t.activePrecompiles = vm.ActivePrecompiles(rules)
// }

// onStart implements the Tracer interface to initialize the tracing operation.
func (t *jsTracer) onStart(from libcommon.Address, to libcommon.Address, create bool, input []byte, gas uint64, value *uint256.Int) {
if t.err != nil {
Expand Down
4 changes: 0 additions & 4 deletions turbo/jsonrpc/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp

if msg.FeeCap().IsZero() && engine != nil {
syscall := func(contract common.Address, data []byte) ([]byte, error) {
// FIXME (tracing): The `nil` tracer (at the very end) should be replaced with a real tracer, so those you be reflected
// when used by the RPC tracing APIs. The tracer will need to be changed to be at the root of `traceBlock`, this will
// requires changes to the overall calls here as `ComputeTxEnv` will need to receive the tracer as well as some changes
// to the `transactions.TraceTx` call to pass the tracer through and also on Polygon side to pass the tracer there also.
return core.SysCallContract(contract, data, chainConfig, ibs, block.Header(), engine, true /* constCall */, nil)
}
msg.SetIsFree(engine.IsServiceTransaction(msg.From(), syscall))
Expand Down
1 change: 1 addition & 0 deletions turbo/transactions/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ func TraceTx(
tracer.OnTxEnd(&types.Receipt{GasUsed: result.UsedGas}, nil)
}
}
usedGas = result.UsedGas
return result, err
}

Expand Down

0 comments on commit b22cb87

Please sign in to comment.