Commit Graph
118 Commits
Author SHA1 Message Date
Marvin Jones 0ef2d61fee refactor(lee): migrate program self/caller identity from ProgramId to AccountId
ProgramInput/ProgramOutput.self_program_id/caller_program_id, and the
dispatcher's CallerData.program_id, now carry AccountId (renamed to
self_account_id/caller_account_id) instead of ProgramId. These fields
are self-reported/cross-checked dispatch bookkeeping, not RISC0 image
identity, and AccountId already crosses the guest/host boundary this
way via every pre_state.account_id.

ProgramId is now confined to what's actually image-id-keyed:
env::verify, Program.id (from compute_image_id()), and the
for_public_pda/for_private_pda derivation formulas, each recovering
the real ProgramId from AccountId via the existing bijection exactly
where needed.

Rebuilds artifacts and the prebuilt sequencer db fixture to match.
2026-08-14 16:43:59 -04:00
Marvin Jones 7ce202c64e refactor(lee): migrate ChainedCall/Message program reference from ProgramId to AccountId
Chained-call and public-transaction dispatch now address the target
program directly by AccountId instead of routing through ProgramId and
converting internally, closing the gap that blocked PDA-addressed
program invocation. The field is named program_account_id (not
account_id) to stay unambiguous next to the account_ids list it sits
beside in the same structs.

Execution/PDA-derivation logic that fundamentally needs the RISC0 image
id (self_program_id, caller_program_id, env::verify, PDA seed
derivation) stays ProgramId-typed, recovering it from the dispatched
AccountId via the existing bijection where needed.
2026-08-14 15:54:50 -04:00
Marvin Jones 18cdd7a232 refactor(lee): centralize program-ownership check behind V03State::get_program 2026-08-13 21:28:19 -04:00
Marvin Jones 89b8b930e3 docs(lee): trim program lookup comment in validated_state_diff 2026-08-13 21:04:01 -04:00
Marvin JonesandClaude Sonnet 5 78013d753a docs(lee): trim PROGRAM_STORAGE_OWNER and public_state doc comments
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 21:04:01 -04:00
Marvin Jones 5894c5d548 feat(lee): fold program storage into public_state, drop the separate programs map
V03State.programs is gone; deployed programs now live directly in
public_state, keyed by AccountId::from(program_id) same as any other
account. insert_program sets program_owner to a new reserved sentinel,
PROGRAM_STORAGE_OWNER, instead of leaving it at the default.

That ownership choice is load-bearing now in a way it wasn't before:
once program accounts share the same map as everything else, they're
reachable through ordinary dispatch, so program_owner determines
whether they're claimable/writable. Left unclaimed, a program
invocation could legitimately claim a program's storage account via
the normal claim path and then rewrite its elf; self-ownership has
the same flaw, since it authorizes exactly the program whose own
invocation would touch its own storage account. The reserved sentinel
makes every program account unwritable by construction, since no real
chained_call.program_id will ever derive to it.

programs() is removed; dispatch and the deployment-existence check go
through get_account_by_id_ref like any other account lookup.
genesis_fingerprint drops its separate program-hashing loop, since
program accounts now fall out of the existing public_state loop.

Rebuilt all guest artifacts and the test fixture via just
build-artifacts as a precaution, since V03State's Borsh shape changed
even though Account's did not.
2026-08-13 21:04:01 -04:00
Marvin Jones 8bc32eab6b test(lee): add known-answer tests for ProgramId/AccountId conversion, rebuild artifacts 2026-08-13 20:58:04 -04:00
Marvin Jones 0490820f05 docs(lee): trim DEFAULT_PROGRAM_OWNER and From<AccountId> for ProgramId docs 2026-08-13 17:14:24 -04:00
Marvin Jones 087f6a6c69 feat(lee): migrate Account.program_owner from ProgramId to AccountId
Account.program_owner is now AccountId-typed instead of ProgramId,
via a new bijective From<ProgramId> for AccountId / From<AccountId>
for ProgramId conversion pair (pure byte reinterpretation, not a
hash - both types are exactly 32 bytes). Adds DEFAULT_PROGRAM_OWNER
as the AccountId-typed counterpart to DEFAULT_PROGRAM_ID, used at
every program_owner comparison/claim site instead of an inline
AccountId::default().

Touches every call site across lee_core, lee (including the
guest-side privacy-preserving circuit), all 16 deployed guest
programs, wallet/wallet-ffi, indexer_ffi/indexer_service/
indexer_service_protocol, sequencer_core, testnet_initial_state,
system_accounts, cross_zone, storage, cycle_bench, and
integration_tests - mostly mechanical .into() conversions, plus two
simplifications: wallet's manual base58 encode/decode of
program_owner was dead code once it's AccountId (which already has
Display/FromStr), and the FFI crates' program_owner field now reuses
the existing generic FfiBytes32 wrapper instead of the now-unused
FfiProgramId one.

Rebuilds every guest ELF artifact and the prebuilt sequencer test
fixture via just build-artifacts, since execute_and_prove runs
against the checked-in precompiled privacy_preserving_circuit.bin,
which isn't rebuilt automatically by cargo test/check.
2026-08-13 16:55:51 -04:00
Marvin JonesandClaude Sonnet 5 efbd0a3563 fix(lee): store deployed programs as Account-shaped state, correct SeenShard cap
Corrects lee/state_machine internals for the Program-as-Account migration
and fixes SeenShard::MAX_DELIVERIES, which was still calibrated for the
old 100 KiB DATA_MAX_LENGTH instead of the current 700 KiB cap. Rebuilds
program artifacts and the sequencer test fixture to match.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-13 16:52:32 -04:00
Marvin Jones 960bdfbb33 feat(lee): store deployed programs as Account-shaped state, keyed by AccountId
Program-as-Account migration, first slice: V03State.programs becomes
HashMap<AccountId, Account> instead of HashMap<ProgramId, Program>,
with the elf held directly in Account.data. The map key is derived
from ProgramId via a new 1:1 From<ProgramId> for AccountId conversion
(both types are exactly 32 bytes) rather than a hash, since ProgramId
is already content-derived from the elf.

Account.program_owner stays ProgramId-typed everywhere - this only
changes how deployed programs are stored and looked up host-side, not
the dispatch/authorization model any guest program logic depends on.
Dispatch resolves a ChainedCall's program_id by converting to
AccountId, fetching the Account, and reconstructing a Program via
new_unchecked for execution.

DATA_MAX_LENGTH is raised from 100 KiB to 700 KiB to fit real program
elfs (observed 375 KB-631 KB) directly in Account.data; noted in its
docstring as a rough placeholder pending real transaction/block-size
budget analysis.
2026-08-13 14:26:34 -04:00
agureev 1f7a4c4162 doc: fix typo 2026-08-10 12:32:57 +04:00
Artem Gureev 5a1524dcb9 refactor(lee): update stale domain for keytree parent 2026-08-07 17:13:41 +04:00
Artem Gureev 279a9b8313 feat!(lee): derive private authorization from an authorization secret key
BREAKING!

Before: Providing `nsk` was the same as authorizing a regular private
account.

After: A separate `ask` is required, making unauthorized private
updates possible.
2026-08-07 10:41:56 +00:00
Artem Gureev fc8f7f2d42 refactor(lee): verbose key domains and the ask key chain 2026-08-07 10:40:04 +00:00
Artem Gureev ca23f12f7a refactor(lee): keep the authorization precondition match wildcard-free 2026-08-05 11:43:02 +04:00
agureev d05035eb9e refactor(lee): refactor private kinds 2026-08-04 15:55:09 +04:00
agureev ccb426960f Merge remote-tracking branch 'origin/dev' into artem/bundle-actions 2026-08-04 14:21:00 +04:00
Roman 54743142e9 test: bridge guard account flags modification 2026-07-31 17:56:00 -03:00
agureev 0e957b5c08 chore: docs for PrivateAction commitment field 2026-07-31 00:47:04 +04:00
agureev dbcdbb29f3 Merge remote-tracking branch 'origin/dev' into artem/bundle-actions 2026-07-31 00:16:31 +04:00
erhant 0659774e43 chore(state_machine); rename get_public_account to get_account_by_id_ref [skip ci] 2026-07-30 14:23:49 +03:00
erhant 57759d8953 fix(bridge): enforce deposit exactly-once via a per-op-id receipt PDA 2026-07-30 14:21:10 +03:00
Artem Gureev 75326d031a refactor(verifier): consume bundled public_actions directly 2026-07-29 18:18:08 +00:00
Artem Gureev f16c3bd1e2 refactor: bundle private/public i/o into action struccts 2026-07-29 18:16:13 +00:00
Artem Gureev 7a80ab026d refactor!(lee_core): bump the note-encryption KDF domain to v0.3
BREAKING!

Before: note encryption KDF used 0.2 tag

After: now uses 0.3 tag

Mitigation: cipher keygen needs to utilize 0.3 tag after this commit
2026-07-28 16:13:14 +04:00
Artem Gureev 626ba01449 test: order-independent output assertions + wrong-nullifier decrypt 2026-07-28 11:13:19 +00:00
Artem Gureev 590ad2b53c test(circuit): assert obfuscate_output_ordering sorts and keeps notes paired 2026-07-28 11:12:21 +00:00
Artem Gureev e282ef30e1 refactor(circuit): extract obfuscate_output_ordering 2026-07-28 11:10:23 +00:00
Artem Gureev 29ee254322 feat!: byte-sort private outputs to obfuscate note order
BREAKING!

Before: Commitments, nullifier, and ciphertexts of a transaction were
position-aligned. The position revealed which nullifier was hiding a
pre-state to a commitment to which post-state. Similarly with
ciphertexts.

After: The nullifier-cipher connection remains, but now they (and
commitments independently) are shuffled by the byte-order of the
hashes.

Mitigation: Expect the circuit outputs to be jumbled.
2026-07-28 11:09:44 +00:00
Artem Gureev e13b4cb237 feat!: key note encryption on the nullifier, drop the output index
BREAKING!

Before: The ciphertext key got generated via using the commmitment and
its index as the key.

After: The ciphertext key replaces the commitment dependence by a
nullifier dependence, still making the key unique by global state. The
nullifier is assumed to be the nullifier of the pre-state of the account.

Mitigation: Use the new decryption algorithm.
2026-07-28 11:09:28 +00:00
Artem Gureev a9f492bb3f refactor(lee_core): expose nullifier byte-array 2026-07-28 10:58:57 +00:00
Artem Gureev 2e8a01ac95 refactor: warn on private-padding saturation and rename to execute_and_prove_with_padded_inputs 2026-07-24 17:00:36 +00:00
Artem Gureev 2999288a57 test(lee): pin for_dummy nullifier and commitment derivations 2026-07-24 16:38:04 +00:00
Artem Gureev d30490442d fix(wallet): encapsulate dummy note epk in wallet 2026-07-24 16:37:52 +00:00
Artem Gureev 4ba0268bab feat(wallet): construct and submit dummy inputs
Ciphers submitted currently have no data
2026-07-24 16:36:13 +00:00
Artem Gureev 5d13e0acc5 feat(circuit): use dummy_inputs in ppc 2026-07-24 16:36:13 +00:00
Artem Gureev 31a17d74a3 feat(lee): add for_dummy nullifier and commitment derivations 2026-07-24 16:36:13 +00:00
Artem Gureev b9c03d3805 feat(lee): add dummy account type for function-privacy padding 2026-07-24 16:36:13 +00:00
moudyellaz 150cd17ff5 Merge origin/dev 2026-07-24 00:56:00 +02:00
moudyellaz 124bbee6c6 Merge origin/dev 2026-07-23 23:59:36 +02:00
jonesmarvin8andClaude Sonnet 5 6c0bd71523 refactor: PrivateUnauthorized authorization changed to true (#621)
* refactor: rename PrivateUnauthorized to PrivateForeignInit

The account_identity's is_authorized flag no longer determines
authorization for this variant, so keep the name tied to what
actually distinguishes it: no nsk, only npk (a foreign account init).

* chore: rebuild guest artifacts and bump spin to clear yanked advisory

Regenerate ELF artifacts after the PrivateForeignInit rename in lee_core
(compiled into every guest program), and update spin 0.9.8 -> 0.9.9 since
0.9.8 was yanked from crates.io, per cargo deny check advisories.

* test: align is_authorized with PrivateForeignInit's flipped semantics

Recipient pre-states built for PrivateForeignInit now need is_authorized:
true to match the assertion in output.rs. Also rewrites the boundary test
that checked the old invalid case to check the new one, and updates
stale "unauthorized" wording left over from the PrivateUnauthorized name.

* chore: rebuild guest artifacts

Reproducible across repeated local builds; likely toolchain drift since
the prior artifact commit rather than a source change, since no
guest-relevant source or Cargo.lock changed in between.

* fix(tests): align integration tests with PrivateForeignInit and regenerate fixture

prove_init_with_commitment_root (private.rs) and build_privacy_transaction
(tps.rs) still built PrivateForeignInit recipients with is_authorized: false,
same stale-semantics bug fixed earlier in the lee crate's own tests.

The prebuilt sequencer DB dump embeds program IDs derived from guest ELF
bytes, which shifted once the PrivateForeignInit rename changed lee_core
(compiled into every guest program). The stale dump caused widespread
"Unknown program" failures across integration test suites that exercise
deployed programs (wallet_ffi, auth_transfer, bridge, amm, token, pinata,
ata, indexer state-consistency checks). Regenerated via
`just regenerate-test-fixture`.

* fix(tests): rename leftover PrivateUnauthorized to PrivateForeignInit and regenerate fixture

* test: align is_authorized with PrivateForeignInit's flipped semantics

* chore: regenerate test fixture after rebase onto dev

* chore: regenerate test fixture after rebase onto dev

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-23 17:32:01 -04:00
moudyellaz dc977db7ab refactor: destructure genesis fingerprint and return an iterator from bridge_lock_holdings 2026-07-23 21:55:55 +02:00
jonesmarvin8 7bc4c460a2 fix!(state_machine): reject public transactions that silently drop a d… (#625)
* fix(state_machine): reject public transactions that silently drop a declared account

ValidatedStateDiff::from_public_transaction never checked that the accounts
touched in a program's output matched the caller-declared message.account_ids
— it just folded whatever pairs the program returned into the diff. A program
(or a macro-generated dispatcher wrapping one) that silently drops an account
from both sides of its own output together stays internally consistent
(pre_states.len() == post_states.len()) and passes validate_execution's
existing checks, so the dropped account simply vanishes with no error.

Add a check after the chained-call loop: every account_id in
message.account_ids must appear in the final state_diff, or the transaction is
rejected with the new DeclaredAccountMissingFromOutput error.

Add a dropped_account test-guest program that reproduces the exact shape of
the bug (two pre_states in, one consistent (pre, post) pair out) and a
regression test proving the transaction is now rejected. Verified the test
fails with Ok(()) when the check is removed, and passes once it's restored.

* style: tighten comments and apply nightly rustfmt

Condense the explanatory comments on the new account-accounting check and the
dropped_account test guest, and fix imprecise wording (the account is dropped
from both pre_state and post_states together, not just pre_state). Also
applies cargo +nightly fmt's wrapping of the new error message.

* chore: regenerate test fixture after rebase onto dev
2026-07-23 12:09:16 -04:00
erhantandClaude Fable 5 8d09ffd733 feat(sequencer): two-tier chain state and multi-sequencer support
Decentralized-sequencing foundation: a shared chain_state crate (two-tier
head/final ChainState, apply_block, AcceptOutcome, StallReason, and the
absorbed channel-consistency machinery), turn-gated block production, the
publisher follow path for adopted/orphaned/finalized peer blocks, and
persistence that keeps disk order equal to apply order under the chain lock.

Rebased onto dev after #600/#606: chain_consistency is absorbed into
chain_state, the sequencer bootstrap's verify_and_reconstruct is re-wired
onto the two-tier ChainState (reconstruction applies channel history
through the final tier and persists via the follow-path primitives), and
test fixtures adopt the SequencerSetup builder extended with
with_bedrock_signing_key.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-23 11:43:57 +03:00
moudyellaz 72195ce09e Merge origin/dev 2026-07-23 02:43:53 +02:00
Artem Gureev 3474b375e4 test(circuit): view_tag is derived on init, passed through on update 2026-07-22 22:31:32 +04:00
agureev 61cad70f9b feat(circuit): supply a view_tag on private-account updates 2026-07-22 22:31:31 +04:00
moudyellaz a806ebb94a refactor(cross-zone)!: register cross-zone programs as base builtins
BREAKING CHANGE: GenesisAction::DeployProgram and IndexerConfig.deploy_programs are removed. The cross-zone programs (inbox, outbox, ping_sender, ping_receiver, bridge_lock, wrapped_token) are now base builtins in testnet_initial_state, because program bytecode exceeds the genesis block inscription limit, so they cannot be shipped through genesis transactions.
2026-07-21 10:50:41 +02:00
moudyellaz 0f88fda054 Merge origin/dev 2026-07-16 12:44:07 +02:00