Skip to content

fix(program-logs): pair logs with instructions by one rule in the Logs and CU cards - #1497

Open
askov wants to merge 13 commits into
solana-foundation:masterfrom
hoodieshq:fix/cu-profiling-precompile
Open

askov wants to merge 13 commits into
solana-foundation:masterfrom
hoodieshq:fix/cu-profiling-precompile

Conversation

@askov

@askov askov commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fixes the CU figure of each instruction on the CU profiling card, and replaces the log parser and the two Logs cards with one parser and one card. A transaction with a precompile instruction showed each later figure one row early, and an instruction with no CU figure in the logs showed ~200,000.

Changes

  • Replaces parseProgramLogs with a parser that returns an invocation tree and accepts any lines without an error.
  • Adds pairLogsWithInstructions, so the Logs card, the CU profiling card and Anchor events pair logs with instructions by one rule.
  • Replaces ProgramLogsCardBody and the log list of the IDL page with one ProgramLogs card.
  • Names the rows of the Logs card with useResolvedInstructionNames, so the card no longer decodes Anchor instructions itself.
  • Replaces defaultUnits and scheduledUnits in InstructionCUData with one computeUnits field.
  • Renames formatInstructionLogs to toInstructionCUData and removes its epoch argument, so simulateTransaction no longer calls getEpochInfo.

Behavior Changes

  • A precompile instruction now shows 0 on the CU profiling card, and each later instruction shows its own figure.
  • A ZK ElGamal Proof instruction now shows the cost of its instruction type instead of ~200,000.
  • An instruction with no CU figure in the logs now shows its fixed cost when it ran, and Unknown otherwise, instead of ~200,000.
  • An instruction after the failed instruction now shows Not executed.
  • A row title on the Logs card now shows the instruction name that the CU profiling card shows, for example Token Transfer Checked instead of Token Instruction.
  • The Logs card now shows Runtime error: … on the instruction that the transaction error names, also when a precompile instruction precedes it.
  • The Program logs tab of the IDL page now shows logs with the same card as the inspector.
  • The CUs Consumed column of the block page now shows the compute units that the transaction recorded, also when a transaction in the block has no logs.

Type of change

  • Bug fix
  • Other (please describe): replaces the log parser and the two Logs cards with one parser and one card in app/entities/program-logs

Screenshots

Testing

Bug fixes

  • A precompile instruction shows 0. Open the devnet transaction (localhost · production) and read the legend of the CU profiling card. Expect 0 on rows 1, 3, 5, 7 and 9, and 42,835 on row 2. Production shows 42,835 on row 1.
    Cause: production pairs logs with instructions by index, and a precompile instruction writes no logs.
  • An Ed25519 instruction shows 0. Open the mainnet transaction (localhost · production) and read the legend of the CU profiling card. Expect 0 on row 4 and 176,292 on row 5. Production shows 176,292 on row 4.
    Cause: the same pairing by index.
  • A ZK ElGamal Proof instruction shows its own cost. Open the devnet transaction (localhost · production) and read the CU profiling card. Expect 6,400 on row 2, 16,400 on row 4, 200,000 on row 6, 3,300 on rows 8, 9 and 10, and a full bar under Total: 247,852 CU. The ten rows add up to the total. Production shows ~200,000 on those six rows.
    Cause: production shows the 200,000 CU reserve for an instruction with no CU figure in the logs.
  • A Logs row link keeps the inspected transaction. Open the inspector on devnet (localhost · production), click Simulate, and click the title of row #1 on the Logs card. Expect the page to scroll to instruction card #1, with the transaction and the simulation result still shown. Production drops message from the URL and shows the empty inspector.
    Cause: production builds the link from the pathname and the cluster only.
  • The block page shows the recorded compute units. Open the block (localhost · production). Expect a CUs Consumed column, with 150 on row 6. Production shows no CUs Consumed column.
    Cause: production reads the figure from the logs and hides the column when a transaction has none, and ten transactions in the block have no logs.

Changed behavior

  • A Logs row shows the instruction name. On the three transactions above (precompile (localhost · production), Ed25519 (localhost · production), ZK ElGamal (localhost · production)), compare the Logs section with the legend of the CU profiling card. Expect each Logs row title to end with the instruction name of the same row in the legend, and the same log lines as production. Production shows Instruction in the title of a row whose program has no Anchor IDL.

Regression checks

  • An upgrade line shows under the loader instruction. Open the mainnet transaction (localhost · production). Expect the Upgraded program line under the BPF Upgradeable Loader row of the Logs section, as on production.

Related Issues

Closes HOO-2022
Closes HOO-2481
Closes HOO-1515

Checklist

  • My code follows the project's style guidelines
  • I have added tests that prove my fix/feature works
  • All checks pass locally (pnpm test, pnpm lint, pnpm typecheck)
  • I have run build:info script to update build information

Additional Notes

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@askov is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@askov
askov force-pushed the fix/cu-profiling-precompile branch from 9aa3f13 to 137e7e6 Compare November 20, 2026 08:53
@askov askov changed the title fix(cu-profiling): show the CU figure of each instruction on its own row fix(program-logs): pair logs with instructions by one rule in the Logs and CU cards Nov 20, 2026
@askov
askov force-pushed the fix/cu-profiling-precompile branch from 37bcf4c to 95ce25a Compare November 20, 2026 14:53
@askov
askov marked this pull request as ready for review November 23, 2026 07:38
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues remain.

Summary

The PR gives Logs, CU profiling, and Anchor events one rule for pairing logs with instructions.

  • The Logs views pair each instruction with its matching program invocation.
  • CU profiling reports each instruction's figure instead of a shifted or estimated amount.
  • Block history shows recorded compute units when a transaction has them.
  • Build notes and lint settings change without changing explorer behavior.

Reviews (11) · Last reviewed commit: "fix(program-logs): skip every block of l..." · Reviewed by Greptile

@askov
askov force-pushed the fix/cu-profiling-precompile branch 4 times, most recently from b74bbfa to 22e87e6 Compare November 27, 2026 07:40
askov added 11 commits November 27, 2026 14:41
…tity

The Logs card paired logs with instructions inline. `pairLogsWithInstructions`
holds that rule, so another card can call it.
A precompile logs nothing, so pairing by index gave each later instruction the
CU figure of the next one. An instruction with no figure showed the 200,000 CU
reserve. The card now shows `Unknown` for it.
An export of `ProgramLogsCardBody` from the entity index adds
`@coral-xyz/anchor` to every route that imports the index.
The Logs card, the CU card, the block page and Anchor events each read the
log lines by their own rule. One parser returns a tree, one rule pairs it
with the instructions, and one card shows it on the transaction page, the
inspector and the IDL page. A ZK ElGamal Proof row takes its cost from the
instruction data.
… run

An instruction after the one that failed has no invocation in the logs, and
it took the fixed cost of its program: 200,000 CU for a ZK ElGamal range
proof. It shows Unknown. A precompile shows 0.
One transaction with no CU figure hides the column for the whole block. The
parser does not read the transaction error, so a failed transaction with no
logs had no figure. It counts as 0.
The sum of the logs left out the cost of each builtin, and a failed transaction
with no logs counted as 0. The logged sum stays the source for a block with no
recorded figure.
A row took the fixed cost of its program when the logs had no figure. That cost
is false for an instruction that did not run, and for Stake or Address Lookup
Table in truncated logs, because both programs log a figure since a feature gate
moved them on chain. The costs of the two older loaders were also swapped.
…n card

The link held the pathname and the cluster params only, so a click on the
inspector dropped `message` and cleared the transaction. A fragment-only href
keeps the query string.
… lint rules

The rebase onto master added security/detect-object-injection, which reports an index read by a variable. Refreshes bench/BUILD.md for the new base.
@askov
askov force-pushed the fix/cu-profiling-precompile branch from 22e87e6 to 792f9bb Compare November 27, 2026 07:46
… on chain

Config is a builtin that a feature gate moved on chain, as Stake and Address Lookup Table are.
A Config instruction from before the move logs no figure, so it takes the fixed cost of 450.
The pairing skipped at most one block of lines with no `invoke` line.
Two such blocks in a row left each later instruction with no invocation.

@rogaldh rogaldh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Except this, LGTM

const ran = invocation !== undefined || execution === 'completed';
if (!ran) return undefined;

return logsTruncated ? getNonMigratingBuiltinComputeUnits(programId) : getDefaultComputeUnits(programId, data);

@rogaldh rogaldh Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: when the logs are truncated, a migrated builtin (ALT, Stake, Config) shows Unknown instead of its fixed cost. I think that we may not fix this. Let's just add an acknowledgement comment on the logsTruncated branch.

This branch has not been deployed

No deployments
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.

3 participants