Skip to content

Upgrade Simulator, Contracts to 0.29.0#366

Merged
emnul merged 86 commits intomainfrom
upgrade-contracts-versions-0.28.0
Feb 19, 2026
Merged

Upgrade Simulator, Contracts to 0.29.0#366
emnul merged 86 commits intomainfrom
upgrade-contracts-versions-0.28.0

Conversation

@emnul
Copy link
Copy Markdown
Contributor

@emnul emnul commented Feb 3, 2026

This PR is part of #364 .

  • renames from variables to fromAddress to avoid new keyword collisions.
  • Updates language version across all contracts
  • Formats contracts using compact tool ( side effect of compact fixup )
  • Hard codes a temporary workaround in the compact compiler tool to avoid compilation of the archive contracts. It should be removed in Add new compiler flag to skip directories #367
  • Updates Simulators to use new createSimulator factory function
  • Removes deprecated simulator interface files
  • Updates address.ts files
  • Updates tests to use .as(ROLE) syntax
  • Refactors encodeToAddress to catch changes to ContractAddress requirements and meet new type expectations
  • Excludes archive contracts from tests

Summary by CodeRabbit

  • New Features

    • Added support for hierarchical artifact output and custom source/output directories in the Compact compiler.
    • Enhanced test setup automation with pre-test compilation.
  • Bug Fixes

    • Updated parameter naming for consistency in token transfer operations.
  • Chores

    • Bumped language version requirements to 0.21.0 across contracts.
    • Updated compiler version to 0.29.0.
    • Modernized simulator architecture and refactored test utilities.
    • Updated dependencies: compact-runtime to 0.14.0, ledger-v7 to 7.0.0.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 3, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Comprehensive upgrade and refactoring across the Compact smart contracts framework: bumps language version to 0.21.0, restructures simulator architecture using base factory pattern, renames token transfer parameters from from to fromAddress, updates runtime/ledger dependencies, and converts witness/private state objects to factory functions with generators.

Changes

Cohort / File(s) Summary
Configuration & Versioning
.github/ISSUE_TEMPLATE/01_bug_report.yml, .github/actions/setup/action.yml, package.json, packages/compact/package.json
Updated default Compact version from 0.26.0 to 0.29.0 in templates and builds; bumped compact-runtime to 0.14.0; replaced ledger with ledger-v7 7.0.0; updated package filter names from @openzeppelin-compact/contracts to @openzeppelin/compact-contracts.
Compact Language Pragma Updates
contracts/src/access/AccessControl.compact, contracts/src/access/Ownable.compact, contracts/src/access/ZOwnablePK.compact, contracts/src/access/test/mocks/Mock*.compact, contracts/src/archive/ShieldedToken.compact, contracts/src/archive/test/mocks/MockShieldedToken.compact, contracts/src/security/...compact, contracts/src/token/.../...compact, contracts/src/utils/...compact, packages/simulator/test/fixtures/sample-contracts/...compact
Bumped language_version pragma from 0.18.0 to 0.21.0 across all Compact contract files; minor formatting adjustments in multi-line signatures.
Token Parameter Renaming: fromfromAddress
contracts/src/token/FungibleToken.compact, contracts/src/token/MultiToken.compact, contracts/src/token/NonFungibleToken.compact, contracts/src/token/test/mocks/Mock*.compact
Systematically renamed first transfer parameter across all token contracts from from to fromAddress to improve semantic clarity; updated all internal call sites and balance updates.
Test Access Pattern Refactoring
contracts/src/access/test/AccessControl.test.ts, contracts/src/access/test/Ownable.test.ts, contracts/src/token/test/FungibleToken.test.ts, contracts/src/token/test/MultiToken.test.ts, contracts/src/token/test/nonFungibleToken.test.ts
Replaced direct method calls with context-wrapped pattern: method(args, caller)as(caller).method(args), eliminating explicit caller parameters in favor of fluent context binding.
Address Utilities Updates
contracts/src/access/test/utils/address.ts, contracts/src/archive/test/utils/address.ts, contracts/src/security/test/utils/address.ts, contracts/src/token/test/utils/address.ts, contracts/src/utils/test/utils/address.ts, packages/simulator/test/fixtures/utils/address.ts
Updated encodeContractAddress imports from ledger to ledger-v7; added runtime validation via isContractAddress; introduced generatePubKeyPair, generateEitherPubKeyPair, and zeroUint8Array helpers; updated return types to EncodedContractAddress.
Witness Factory Refactoring
contracts/src/access/witnesses/AccessControlWitnesses.ts, contracts/src/access/witnesses/OwnableWitnesses.ts, contracts/src/access/witnesses/ZOwnablePKWitnesses.ts, contracts/src/security/witnesses/InitializableWitnesses.ts, contracts/src/security/witnesses/PausableWitnesses.ts, contracts/src/token/witnesses/...Witnesses.ts, contracts/src/utils/witnesses/UtilsWitnesses.ts
Converted witness exports from static empty objects to factory functions returning witness interfaces; added PrivateState.generate() utility methods; introduced IWitnesses generic type interfaces.
Simulator Base Architecture Refactoring
contracts/src/access/test/simulators/AccessControlSimulator.ts, contracts/src/access/test/simulators/OwnableSimulator.ts, contracts/src/security/test/simulators/InitializableSimulator.ts, contracts/src/security/test/simulators/PausableSimulator.ts, contracts/src/token/test/simulators/FungibleTokenSimulator.ts, contracts/src/token/test/simulators/MultiTokenSimulator.ts, contracts/src/token/test/simulators/NonFungibleTokenSimulator.ts, contracts/src/utils/test/simulators/UtilsSimulator.ts
Replaced manual contract-context wiring with createSimulator base factory pattern; removed explicit circuit context management in favor of circuits.pure/impure delegation; added privateState field; updated constructors to accept BaseSimulatorOptions.
Removed Test Utilities & Interfaces
contracts/src/access/test/types/test.ts, contracts/src/access/test/utils/AbstractContractSimulator.ts, contracts/src/access/test/utils/SimualatorStateManager.ts, contracts/src/access/test/utils/createCircuitProxies.ts, contracts/src/access/test/utils/test.ts, contracts/src/security/test/types/test.ts, contracts/src/security/test/utils/test.ts, contracts/src/token/test/types/test.ts, contracts/src/token/test/utils/test.ts, contracts/src/utils/test/types/test.ts, contracts/src/utils/test/utils/test.ts
Removed legacy IContractSimulator interface, AbstractContractSimulator base class, and CircuitContext construction utilities (useCircuitContext, useCircuitContextSender); these are replaced by the new base simulator factory pattern.
Import Path Normalization
contracts/src/access/test/ZOwnablePK.test.ts, contracts/src/archive/test/ShieldedToken.test.ts, contracts/src/archive/test/simulators/ShieldedTokenSimulator.ts, contracts/src/archive/test/utils/address.ts, packages/simulator/test/fixtures/sample-contracts/witnesses/...Witnesses.ts, packages/simulator/test/integration/..., packages/simulator/test/fixtures/utils/address.ts
Systematically updated artifact imports from index.cjs to index.js; aligns with ESM module format across all test and simulator files.
Compiler & Builder Refactoring
packages/compact/src/Compiler.ts, packages/compact/src/Builder.ts, packages/compact/src/runCompiler.ts, packages/compact/src/runBuilder.ts, packages/compact/test/Compiler.test.ts, packages/compact/test/runCompiler.test.ts
Introduced CompilerOptions interface replacing discrete constructor parameters; added hierarchical artifact output support; updated CLI flags (--src, --out, --hierarchical); replaced version constants with options-based configuration; refactored fromArgs to parseArgs factory.
Simulator Core Architecture
packages/simulator/src/core/AbstractSimulator.ts, packages/simulator/src/core/CircuitContextManager.ts, packages/simulator/src/core/ContractSimulator.ts, packages/simulator/src/factory/createSimulator.ts, packages/simulator/src/factory/SimulatorConfig.ts, packages/simulator/src/types/Simulator.ts, packages/simulator/src/utils/CircuitContextUtils.ts
Updated CircuitContext to use currentQueryContext instead of originalState/transactionContext; replaced ContractState with StateValue; introduced ChargedState parameter; added cost model tracking; enhanced type parameters with TContract generic for type-safe contracts.
Test Fixtures Cleanup
packages/simulator/test/fixtures/test-artifacts/SampleZOwnable/..., packages/simulator/test/fixtures/test-artifacts/Simple/..., packages/simulator/test/fixtures/test-artifacts/Witness/...
Removed pre-compiled test artifact files (contract/index.cjs, index.d.cts, compiler/contract-info.json, zkir/*.zkir) in favor of runtime compilation via setup.ts.
Test Setup & Integration
packages/simulator/test/setup.ts, packages/simulator/vitest.config.ts, packages/simulator/test/integration/SampleZOwnableSimulator.ts, packages/simulator/test/integration/SimpleSimulator.ts, packages/simulator/test/integration/WitnessSimulator.ts, packages/simulator/test/unit/core/StateManager.test.ts
Added global Vitest setup hook to compile sample contracts before tests; updated integration tests to use new artifact paths and explicit generic type parameters; replaced legacy state/coin types with shielded equivalents; added currentQueryContext references.
Sample Contract Updates
packages/simulator/test/fixtures/sample-contracts/SampleZOwnable.compact, packages/simulator/test/fixtures/sample-contracts/Simple.compact, packages/simulator/test/fixtures/sample-contracts/Witness.compact
Updated language pragmas and replaced broad CompactStandardLibrary imports with targeted named imports; added test-context header comments.
Documentation & Build Config
packages/compact/README.md, packages/simulator/README.md, contracts/vitest.config.ts, turbo.json
Added comprehensive CLI documentation for compact tools; updated example imports to use .js paths; excluded archive tests from test suite; removed compact:archive dependency from consolidated compact task.
Version & Utility Cleanup
packages/compact/src/versions.ts
Removed exported COMPACT_VERSION and LANGUAGE_VERSION constants (now supplied via options).

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Suggested reviewers

  • 0xisk
  • andrew-fleming

🐰 A grand refactoring hops through the code,
From circuits old to bases new encoded,
With fromAddress clarity, witnesses grow wise,
The simulators spring forward with factory-based cries!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'Upgrade Simulator, Contracts to 0.29.0' directly and clearly summarizes the primary change—upgrading core simulator and contract components to version 0.29.0, which aligns with the file summaries showing language version bumps from 0.18.0/0.26.0 to 0.21.0/0.29.0.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch upgrade-contracts-versions-0.28.0

Comment @coderabbitai help to get the list of available commands and usage tips.

@emnul emnul changed the title Update language version across contracts Upgrade Contracts to 0.28.0 Feb 4, 2026
@emnul emnul marked this pull request as ready for review February 4, 2026 03:42
@emnul emnul requested review from a team as code owners February 4, 2026 03:42
@emnul emnul marked this pull request as draft February 4, 2026 04:32
emnul and others added 3 commits February 13, 2026 08:52
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
@emnul
Copy link
Copy Markdown
Contributor Author

emnul commented Feb 13, 2026

@andrew-fleming RE: Compact tools changes

Really the only change that's 100% necessary is the archive directory filtering in Compiler.ts to pass CI. All the other changes were made in an attempt to sync this repo's compact-tools packages with the unpublished version in a separate repo. I did not realize that pulling in those changes would break our contracts packaging behavior.

Should those sync changes be reverted for now?

@andrew-fleming
Copy link
Copy Markdown
Contributor

Really the only change that's 100% necessary is the archive directory filtering in Compiler.ts to pass CI. All the other changes were made in an attempt to sync this repo's compact-tools packages with the unpublished version in a separate repo. I did not realize that pulling in those changes would break our contracts packaging behavior.

@emnul aint no thing. To be fair, we haven't been able to publish 😢 now, I'm wondering if we should be running build for contracts from the tools package bc it's pretty specific for how we use it

Should those sync changes be reverted for now?

I'd say yeah, if you don't mind. Let's revert those changes to keep this PR clean so we're not yoloing anything. Measure twice, cut once

Comment on lines +9 to +13
type ZswapCoinPublicKey = { bytes: Uint8Array };

type ContractAddress = { bytes: Uint8Array };

type Either<A, B> = { is_left: boolean; left: A; right: B };
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that's a good idea. It's a small dx improvement but everyone benefits. Worst case, it's something we can offer

emnul and others added 13 commits February 17, 2026 11:06
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
@emnul emnul requested a review from andrew-fleming February 18, 2026 15:04
Copy link
Copy Markdown
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

Left a tiny suggestion but LGTM! Nice work, sir 🚀

emnul and others added 2 commits February 18, 2026 19:04
Co-authored-by: Andrew Fleming <fleming-andrew@protonmail.com>
Signed-off-by: ⟣ €₥ℵ∪ℓ ⟢ <34749913+emnul@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@andrew-fleming andrew-fleming left a comment

Choose a reason for hiding this comment

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

LGTM!

@emnul emnul merged commit d7da7d7 into main Feb 19, 2026
9 checks passed
@github-project-automation github-project-automation bot moved this from Needs Review to Complete/Stable Release in OZ Development for Midnight Feb 19, 2026
@coderabbitai coderabbitai bot mentioned this pull request Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete/Stable Release

Development

Successfully merging this pull request may close these issues.

3 participants