Skip to content

[REHEARSAL] scaffold: emit a program-id output block per program - #7

Open
michael-moffett wants to merge 3 commits into
mainfrom
p032/scaffold-339-program-id-output
Open

[REHEARSAL] scaffold: emit a program-id output block per program#7
michael-moffett wants to merge 3 commits into
mainfrom
p032/scaffold-339-program-id-output

Conversation

@michael-moffett

Copy link
Copy Markdown
Member

Fork-internal CI rehearsal. Not for merge, not for upstream.

Rehearses p032/scaffold-339-program-id-output (head e0de52b) against .github/workflows/ on real
runner images before the change is offered anywhere else. Base is this fork's main.

Change under test: crates/cli/src/scaffold/mod.rs, +42 / −0, one file.

Base branch note: this fork's main is 4971d40d, exactly one commit behind
solana-foundation/surfpool@de6a055. main was deliberately not fast-forwarded, because
release_crates.yaml and release_cli.yaml fire on push: branches: [main] and firing a publish
workflow to rehearse a test workflow is not a trade worth making. 4971d40d is an ancestor of de6a055,
so refs/pull/N/merge resolves to e0de52b's tree exactly and CI tests the intended bytes.

@greptile-apps

greptile-apps Bot commented Aug 21, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds generated program-ID output blocks to scaffolded deployment runbooks and introduces configurable startup funding for the Node Kit plugin in embedded and attach modes.

  • Emits one <program>_program_id output per scaffolded program.
  • Adds typed airdrop configuration, validation, deduplication, documentation, and tests.
  • Preserves synchronous attach-mode composition when startup funding is not requested.

Confidence Score: 4/5

The non-atomic startup funding update should be fixed before merging because it can overwrite concurrent balance changes on an attached Surfnet.

Startup funding computes an absolute replacement balance from a prior RPC read, so activity between the read and write can cause silent lost updates.

Files Needing Attention: crates/sdk-node/surfpool-sdk/kit/surfpool.ts

Important Files Changed

Filename Overview
crates/cli/src/scaffold/mod.rs Adds a shared template and appends a program-ID output block after each generated deployment action.
crates/sdk-node/surfpool-sdk/kit/surfpool.ts Adds startup funding in both modes, but its read-then-write balance update can overwrite concurrent account changes.
crates/sdk-node/surfpool-sdk/kit/index.ts Exports the newly introduced airdrop target and funded attach-mode configuration types.
crates/sdk-node/surfpool-sdk/kit/typetests/typetests.ts Verifies synchronous and asynchronous plugin overloads and rejects ambiguous funding configurations.
crates/sdk-node/scripts/kit-unit.js Adds unit coverage for startup funding, validation, deduplication, overflow, and failure reporting.
crates/sdk-node/scripts/kit-smoke.js Exercises embedded startup funding and additive behavior against a live Surfnet.
crates/sdk-node/README.md Documents airdrop configuration, defaults, additive behavior, and embedded-mode support.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Plugin as surfpool plugin
    participant RPC as Surfnet RPC
    participant Other as Concurrent client
    Client->>Plugin: compose with airdropAddresses
    Plugin->>RPC: getBalance(address)
    RPC-->>Plugin: current balance
    Other->>RPC: mutate same account balance
    Plugin->>RPC: setAccount(stale balance + amount)
    Note over RPC: Concurrent balance change is overwritten
    RPC-->>Plugin: success
    Plugin-->>Client: configured client
Loading

Reviews (1): Last reviewed commit: "test(scaffold): assert the program-outpu..." | Re-trigger Greptile

Comment on lines +127 to +132
if (lamports > MAX_LAMPORTS) {
throw new Error(
`balance ${balance} plus airdropAmount ${amount} exceeds the maximum lamport balance ${MAX_LAMPORTS}`,
);
}
await client.cheatcodes.setAccount(address, { lamports }).send();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Non-atomic airdrop balance update

If another client updates this address between getBalance and setAccount, this code writes the stale balance plus the airdrop amount as an absolute value, causing the concurrent balance change to be silently lost.

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.

2 participants