Skip to content

feat: changes to support node alpha.12#489

Open
brunomenezes wants to merge 18 commits into
prerelease/v2-alphafrom
feat/cli-update-commands-deps
Open

feat: changes to support node alpha.12#489
brunomenezes wants to merge 18 commits into
prerelease/v2-alphafrom
feat/cli-update-commands-deps

Conversation

@brunomenezes

@brunomenezes brunomenezes commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

📝 Summary

This PR improves the CLI run flow, node compose generation, and configuration parsing, alongside dependency upgrades, test suite expansions, and comprehensive validation for fork mode configurations.

🚀 Key Changes

  • CLI & run Command Enhancements

    • Added a flag to list supported environment variables per service in JSON format.
    • Added support for a claim staging period in the run/deploy flow.
    • Added support for loading and passing withdrawal configurations via TOML files.
    • Enabled passing direct configuration file paths to the run command.
    • Added tty Docker option support in the fallback execution path (used by the shell command).
    • Fixed a bug by removing the --no-rollup flag passed to the cartesi-machine binary, ensuring compatibility with newer versions.
    • Integrated fork configuration assertions in run.ts before initiating a run session in fork mode.
  • Config System & Validation

    • Verification of Required Settings on Fork Mode: Created a new validation module validations.ts with assertForkConfig to execute pre-flight assertions. This ensures required contracts are deployed on the target chain/block and validates that on-chain calls like getInputBox or getDeploymentBlockNumber succeed.
    • Replaced getForkChainId with a more complete getForkConfig function inside rollups.ts to query the current Anvil service details and return a complete ForkConfig (containing chainId, url, and blockNumber).
    • Integrated validations into base.ts to verify the deployment and contract state within getAddressBook().
    • Introduced withdrawalConfig parsing and validation (including address and numeric validation).
    • Added InvalidAddressValueError, ForkChainValidationError, and UnsupportedForkChainError to improve error context.
    • Updated machine hash extraction to read from hash_tree.sht (root hash offset).
  • Rollups-Node Env Management & Proxy Updates

    • Implemented a strict allow-list for CARTESI-prefixed environment variables. Host-provided values take precedence over defaults set in the code.
    • Removed CARTESI_BLOCKCHAIN_WS_ENDPOINT from default node compose environments.
    • Added CORS middleware (wildcard origins, methods, and headers) definition to the node proxy's inspect and RPC routers.
  • Dependencies & SDK

    • Bumped default SDK to 0.12.0-alpha.41.
    • Bumped the rollups-explorer image integration version from 2.0.0-alpha.2 to 2.0.0-alpha.3 in rollups.ts.
    • Updated devnet dependencies and removed unused rollups dependencies.
    • Updated address book entries for renamed token constants and integrated TestUsdWithdrawalOutputBuilder.

⚠️ Scope & Impact (Note for Reviewers)

Migration risk is low, but note the following behavioral changes:

  1. Environment Filtering: Unsupported environment variables are now explicitly filtered out by the new allow-list.
  2. Machine Hash Source: The machine hash source has shifted to hash_tree.sht. (Don't forget to execute cartesi build on existing dapps)
  3. Flag Removal: The --no-rollup flag has been removed as it is not available as an option in cartesi-machine versions 0.20 and previous 0.19. This ensures the CLI works correctly with newer CM versions.
  4. Fork Mode Safety: Fork-mode runs will now fail early if pre-flight assertions on contract bytecode or vital on-chain calls (like getInputBox) fail.

🧪 Testing & Validation

  • Unit Testing: Added comprehensive test cases for validations.ts that dynamically derive contract baseline call indices (avoiding fragile, hardcoded call-count assumptions) and explicitly assert contract checks.
  • Expanded unit tests covering node compose allow-lists, default build behaviors, and withdrawal config parsing.

@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ffb74ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cartesi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brunomenezes brunomenezes moved this from Todo to In progress in Rollups SDK Jun 15, 2026
@socket-security

socket-security Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​cartesi/​devnet@​2.0.0-alpha.11 ⏵ 2.0.0-alpha.14511003696100

View full report

@brunomenezes brunomenezes force-pushed the chore/sdk-machine-emulator-bump branch from 0499c68 to c063bb0 Compare June 18, 2026 10:16
Base automatically changed from chore/sdk-machine-emulator-bump to prerelease/v2-alpha June 18, 2026 14:09
…devnet-contracts [address-book]

* Replaced Fungible and Non Fungible token addresses to use the new ones exported by Devnet package.
* Refactor deposit ERC-20 and ERC-721 to the new addresses as defaults.
…me and bump required-version for cartesi-machine tests.
@brunomenezes brunomenezes force-pushed the feat/cli-update-commands-deps branch from 2969b12 to 6cb5268 Compare June 18, 2026 19:46
@brunomenezes brunomenezes changed the title Feat/cli update commands deps feat: change to support node alpha.12 Jun 18, 2026
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 98.82% (🎯 0%) 4792 / 4849
🔵 Statements 98.82% 4792 / 4849
🔵 Functions 96.15% 125 / 130
🔵 Branches 0% 0 / 0
📁 File Coverage (18 files)
File Lines Statements Functions Branches Uncovered Lines
apps/cli/src/builder/directory.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/docker.ts 🟢 88.68% 🟢 88.68% 🟡 75% 🔴 0% 83-85, 139-147
apps/cli/src/builder/empty.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/none.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/builder/tar.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/builder.ts 🟢 99.79% 🟢 99.79% 🟢 100% 🔴 0% 228
apps/cli/src/compose/common.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/compose/node.ts 🟢 99.24% 🟢 99.24% 🟢 100% 🔴 0% 106
apps/cli/src/config.ts 🟢 93.69% 🟢 93.69% 🟢 94.87% 🔴 0% 75-76, 240, 249, 258, 307, ...
apps/cli/src/contracts.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...rc/errors/ForkChainValidationError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
...c/errors/UnsupportedForkChainError.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/cartesi-machine.ts 🟡 75% 🟡 75% 🟡 66.67% 🔴 0% 10-12, 28-30
apps/cli/src/exec/genext2fs.ts 🟢 96.92% 🟢 96.92% 🟢 100% 🔴 0% 87-88
apps/cli/src/exec/index.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -
apps/cli/src/exec/mksquashfs.ts 🟢 91.23% 🟢 91.23% 🟢 100% 🔴 0% 68-72
apps/cli/src/exec/util.ts 🟢 94.74% 🟢 94.74% 🟢 100% 🔴 0% 49-50
apps/cli/src/validations.ts 🟢 100% 🟢 100% 🟢 100% 🔴 0% -

@brunomenezes brunomenezes force-pushed the feat/cli-update-commands-deps branch from f494f64 to 3ac391f Compare June 19, 2026 14:18
@brunomenezes brunomenezes changed the title feat: change to support node alpha.12 feat: changes to support node alpha.12 Jun 19, 2026
@brunomenezes brunomenezes linked an issue Jun 19, 2026 that may be closed by this pull request
5 tasks
@brunomenezes brunomenezes marked this pull request as ready for review June 19, 2026 14:38
@brunomenezes

Copy link
Copy Markdown
Contributor Author

I am making that ready to review, but a release will also need to have an explorer ready

The PR is here: cartesi/rollups-explorer#464.

Once we have a tag and release for the explorer, I will just update the image tag for the service.

@endersonmaia endersonmaia left a comment

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 see there's --prt that enables prt mode and default is Authority, what about Quorum, will it be possible to use Quorum in dev mode?

Comment thread apps/cli/src/commands/run.ts
@brunomenezes

Copy link
Copy Markdown
Contributor Author

I see there's --prt that enables prt mode and default is Authority, what about Quorum, will it be possible to use Quorum in dev mode?

Not for this release.

@brunomenezes brunomenezes linked an issue Jun 22, 2026 that may be closed by this pull request
@brunomenezes

Copy link
Copy Markdown
Contributor Author

I did one extra commit to include a fix to the following bug

@brunomenezes brunomenezes force-pushed the feat/cli-update-commands-deps branch 3 times, most recently from c3d1b2a to 791b9c7 Compare June 22, 2026 13:46
* Add parse function related to the configuration
* Add a few type check parsers for address and number.
…when using RUN command.

- Add --claim-staging-period flag. default to 0
- Add --config flag. default to cartesi.toml
… property.

- The application status and enabled has separate meanings. It can be in a FAILED state but still enabled.
… allow external access.

- Allow specific methods, headers with max-age control of 24 hours and a vary-header to avoid intermittent CORS bug when tightening the domain list.
- Fix "unable to open a TTY: No such device or address" error returned by cartesi-machine.
…ESI and pass it down to rollups-node.

* There is a list of allowed environment variable configured for rollups-node. Only these are picked on from the big bag of possible variables.
* Solve lint blocker problems.
@brunomenezes brunomenezes force-pushed the feat/cli-update-commands-deps branch from 791b9c7 to afe3049 Compare June 22, 2026 13:51
@brunomenezes brunomenezes moved this from In progress to Waiting review in Rollups SDK Jun 23, 2026
* A number of environment variables are rule out to avoid confusion e.g. CORS, FEATURE Enablement, etc.
*/
export const nodeAllowedEnvironmentVariables = [
"CARTESI_AUTH_MNEMONIC",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it really worth the burden of maintaining this list over time?

Comment thread apps/cli/src/base.ts
export const getMachineHash = (): Hash | undefined => {
// read hash of the cartesi machine snapshot, if one exists
const hashPath = getContextPath("image", "hash");
const hashPath = getContextPath("image", "hash_tree.sht");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wouldn't read this file. Instead I'd rather call the cartesi-machine-stored-hash utility

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Waiting review

3 participants