Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix constructing Message from Transaction for internal transactions (Transaction tracing) #491

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions ethapi/tx_trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,13 @@ func (s *PublicTxTraceAPI) traceBlock(ctx context.Context, block *evmcore.EvmBlo
// get full transaction info
tx, _, index, err := s.b.GetTransaction(ctx, tx.Hash())
if err != nil {
log.Debug("Cannot get transaction", "txHash", tx.Hash().String(), "err", err.Error())
callTrace.AddTrace(txtrace.GetErrorTrace(block.Hash, *block.Number, nil, tx.To(), tx.Hash(), index, err))
continue
log.Error("cannot replay tranasction", "txHash", tx.Hash().String(), "err", err.Error())
return nil, fmt.Errorf("cannot replay tranasction %s, error %s", tx.Hash().String(), err)
}
msg, err := tx.AsMessage(signer, block.BaseFee)
msg, err := evmcore.TxAsMessage(tx, signer, block.BaseFee)
if err != nil {
callTrace.AddTrace(txtrace.GetErrorTrace(block.Hash, *block.Number, nil, tx.To(), tx.Hash(), index, errors.New("not able to decode tx")))
continue
log.Error("cannot get message from transaction", "txHash", tx.Hash().String(), "err", err.Error())
return nil, fmt.Errorf("cannot get message from transaction %s, error %s", tx.Hash().String(), err)
}
from := msg.From()
if tx.To() != nil && *tx.To() == sfc.ContractAddress {
Expand Down Expand Up @@ -250,8 +249,10 @@ func (s *PublicTxTraceAPI) traceBlock(ctx context.Context, block *evmcore.EvmBlo
} else if txHash != nil {
log.Info("Replaying transaction without trace", "txHash", tx.Hash().String())
// Generate the next state snapshot fast without tracing
msg, _ := tx.AsMessage(signer, block.BaseFee)

msg, err := evmcore.TxAsMessage(tx, signer, block.BaseFee)
if err != nil {
return nil, fmt.Errorf("cannot replay tranasction %s, error %s", tx.Hash().String(), err)
}
state.Prepare(tx.Hash(), i)
vmConfig := opera.DefaultVMConfig
vmConfig.NoBaseFee = true
Expand Down
Loading