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

Make tracing work for fee currency txs #211

Merged
merged 6 commits into from
Sep 2, 2024
Merged

Make tracing work for fee currency txs #211

merged 6 commits into from
Sep 2, 2024

Conversation

karlb
Copy link

@karlb karlb commented Aug 30, 2024

Closes #69

Added tests for the following tracers:

  • Call tracer: same result as when paying in native token (debit/credit ignored)
  • Prestate tracer: includes debit/credit, since the point of the prestate tracer is to have everything you need to execute the tx and we would miss out on the necessary fee currency code and state otherwise
  • Prestate tracer diff mode: includes debit/credit => the gas payment is visible in the diff, as it is for native token

karlb added 6 commits August 30, 2024 14:17
If we want to execute fee currency txs in tracing tests, we need a
FeeCurrencyContext. Rather then setting a fixed on in the test setup
code, it is more flexible to read it from the test JSON file, like all
other test input.
Without including it in that case, we would miss out on the fee currency
code and state, which would make the prestate useless for executing the tx.
We need to look up the fee currency address before using it, like it is
done with the to, from and coinbase.
@karlb karlb marked this pull request as ready for review August 30, 2024 12:46
Copy link

@palango palango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, awesome that we can use the test infrastructure.

Left two questions, but feel free to ignore them.

@@ -93,6 +93,8 @@ func newPrestateTracer(ctx *tracers.Context, cfg json.RawMessage) (*tracers.Trac
OnTxStart: t.OnTxStart,
OnTxEnd: t.OnTxEnd,
OnOpcode: t.OnOpcode,
// Celo
TraceDebitCredit: true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add an explicit TraceDebitCredit: false to the call tracer as well?

@@ -158,6 +160,9 @@ func (t *prestateTracer) OnTxStart(env *tracing.VMContext, tx *types.Transaction
t.lookupAccount(from)
t.lookupAccount(t.to)
t.lookupAccount(env.Coinbase)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is added here, should we add accounts which receive fees here as well, like the FeeHandler?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only thought about the fee currency txs in this PR, where the FeeHandler is part of the fee currency's storage. But for a normal tx and enables Cel2, that might be necessary. I'll take a look at that case.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followup issue is at #216.

@karlb
Copy link
Author

karlb commented Aug 30, 2024

Todo: should the FeeHandler address show up in the diff mode tracing?

EDIT: tipReceiver and baseFeeReceiver are the same in the test, therefore only a single address (plus tx sender) is touched.

@karlb karlb merged commit 8439f9e into celo8 Sep 2, 2024
7 checks passed
@karlb karlb deleted the karlb/tracing-celo8 branch September 2, 2024 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check and correct tracing after fee currency addition
2 participants