Skip to content

Refactor code and address issues #493, #530, #532, #534 - #535

Merged
guidanoli merged 21 commits into
next/3.0from
feature/issues-493-530-532-534-and-refactor
Jun 22, 2026
Merged

Refactor code and address issues #493, #530, #532, #534#535
guidanoli merged 21 commits into
next/3.0from
feature/issues-493-530-532-534-and-refactor

Conversation

@guidanoli

Copy link
Copy Markdown
Collaborator

Continue the work of #533, this PR enriches the root Makefile, making it the reference for the project's name, version, Foundry version, as well as many other project-wide definitions. It also addresses several issues blocking the next alpha release:

  • Remove IApplicationForeclosure and IApplicationWithdrawal interfaces: We realized this separation was not benefitial to the code organization. So, we merged them back into the IApplication interface.

  • Support withdrawals for applications with zero claims: We used to assume that the machine initial state had an empty accounts drive, and therefore, it wouldn't be necessary to prove its Merkle root in order to validate accounts and execute withdrawal outputs. Now, if the application has zero claims, it uses the template hash when proving the accounts drive Merkle root, seamlessly covering this obscure edge case.

  • Make the Foreclosure() event single-emission: This was a request by the node team. The foreclose() function now can only be called once by the guardian.

  • Bump Foundry from 1.4.3 to 1.5.1: Benefits from improved test performance and fuzzer hability to finds bugs, new cast erc20 commands, and single-line imports formatting. Clients can already test integration with the new devnet state dump by running make devnet.

  • Enrich Makefile and simplify workflow files: The root Makefile now concentrates version definitions and recipes that make the workflows slimmer and more locally reproducible. The version file is now generated through a Forge script and from the version definition in the Makefile.

  • Deploy a test USD withdrawal output builder to devnet: Essential for locally testing applications that leverage the initial emergency-withdrawal support for accounts backed by USDC-like tokens. This will simplify the cartesi CLI codebase (see cartesi/cli#486).


Closes #493
Closes #530
Closes #532
Closes #534

guidanoli added 3 commits June 9, 2026 20:43
- Move definitions to `IApplication` to simplify codebase
- Adjust client contracts to use `IApplication` instead
- We achieve this new property by making the `foreclose()` function
  revert (with the already-defined custom error `Foreclosed()`) if the
  application is already foreclosed (`isForeclosed() == true`).
@guidanoli
guidanoli force-pushed the feature/issues-493-530-532-534-and-refactor branch from 12935fc to b87116d Compare June 12, 2026 14:49
guidanoli added 15 commits June 12, 2026 12:31
- On devnet, we deploy a UsdWithdrawalOutputBuilder contract through the
  UsdWithdrawalOutputBuilderFactory core contract, with the test
  fungible token (TestFungibleToken) as the backing ERC-20 token. The
  deployment of this test withdrawal output builder is stored as
  TestUsdWithdrawalOutputBuilder to make it clear that it is only
  available on devnet, just like the test token contracts.
- In the `proveAccountsDriveMerkleRoot` function, if the application's
  current outputs Merkle root validator contract returns a
  last-finalized machine Merkle root equal to zero, the application's
  template hash is used instead. This enables EW even when there are no
  finalized claims. This is mostly covering an obscure edge case, in
  which the accounts drive is not initially empty.
- The problem with recursive make calls was that `make -n devnet` would
  actually run Anvil instead of just printing out the commands that
  would be executed. Also, recursive make calls have a convoluted way of
  passing options down through variables. Having the deployment command
  as a variable is much cleaner (IMO).
- Adds build target as prerequisites to all deployment targets. This
  avoids concurrent Forge processes from trying to fetch the same
  Solidity compiler version (in a clean environment), and avoids
  redundant concurrent build processes.
- On releases, this make target may be more useful than deploy-all
  (which also deploys to devnet).
- Bumps Foundry toolchain action from 1.3.1 to 1.8.0, which uses GitHub
  attestations and allows for version strings with no v prefix.
- This target is useful for testing artifact builds locally in a
  reproducible way (without having to extract steps from workflow
  files). This commit also adjusts the artifact-uploading workflow.
- With this target, the CI doesn't need to extract the project version
  from the triggering event's metadata and fallback to a fake version if
  the triggering event is not a tag push. The version originates from
  the Makefile, and a DRY_RUN option is also supported.
- This target leverages the project name and version definitions in the
  Makefile. The version comes from the Makefile itself, and not from the
  git repository tag push event metadata, nor does it need to fallback
  to a fake version in other triggering events.

- Remove foundry-version output from setup action, as all workflows that
  use it no longer use the foundry-version output, as the version now
  comes from the Makefile.
- Taking inspiration from the step-by-step guide in PR #348, but
  assuming lcov 2.0 instead of checking the version of lcov installed.
- Tests LibBytes32Array.split raising InvalidArrayIndex
- Removes unnecessary return statement of named variable
- These functions make TestFungibleToken compatible with the new cast
  erc20 mint and burn commands added in Foundry 1.5.0.
- Foundry 1.5.0 introduced the `fmt.single_line_imports` option to avoid
  those ugly line breaks when the import directory exceeds the
  configured line length.
@guidanoli
guidanoli force-pushed the feature/issues-493-530-532-534-and-refactor branch from b87116d to c30172d Compare June 12, 2026 15:37
@guidanoli
guidanoli marked this pull request as ready for review June 12, 2026 15:42
@guidanoli guidanoli self-assigned this Jun 12, 2026
@guidanoli guidanoli moved this from Todo to In progress in Rollups SDK Jun 12, 2026
@guidanoli guidanoli added this to the 3.0.0-alpha.7 milestone Jun 12, 2026
@guidanoli guidanoli added A-workflows Area: workflows A-contracts Area: contracts A-deployment Area: deployment labels Jun 12, 2026
@guidanoli
guidanoli requested a review from vfusco June 12, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the refactor started in #533 by centralizing project-wide definitions (name, version, Foundry version, release recipes) in the root Makefile, while also addressing release blockers around application interface structure, foreclosure semantics, and emergency-withdrawal edge cases (including devnet tooling for USD withdrawals).

Changes:

  • Consolidate IApplicationForeclosure + IApplicationWithdrawal back into IApplication, and update contracts/tests accordingly.
  • Handle the “zero accepted claims” EW edge case by falling back to the template hash when retrieving the last finalized machine Merkle root; update tests to exercise this path.
  • Expand build/release automation: Makefile becomes the source of truth for versions, adds release/coverage/bindings targets, and workflows call these targets; devnet deploys a test USD withdrawal output builder.

Reviewed changes

Copilot reviewed 34 out of 36 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/withdrawal/UsdWithdrawalOutputBuilderFactory.t.sol Import formatting updates for withdrawal output builder tests.
test/util/RollupsTest.sol Update dev contracts deployment to depend on core suite.
test/util/LibEmulator.sol Minor refactor/cleanup of Merkle proof helper return handling.
test/util/LibBytes32Array.t.sol Add revert-path fuzz test for invalid split index.
test/util/ConsensusTestUtils.sol Switch foreclosure calls to the unified IApplication interface.
test/util/ApplicationCheckerTestUtils.sol Switch isForeclosed encoding to IApplication and reformat helper signature.
test/portals/ERC721Portal.t.sol Import formatting update.
test/portals/ERC1155SinglePortal.t.sol Import formatting update.
test/portals/ERC1155BatchPortal.t.sol Import formatting update.
test/library/LibUsdAccount.t.sol Import formatting update.
test/dapp/Application.t.sol Update tests for unified IApplication, single-emission foreclosure, and template-hash EW fallback simulation.
test/common/Version.t.sol Switch SemVer validation to new script/utils/SemanticVersioning.sol.
src/withdrawal/UsdWithdrawalOutputBuilderFactory.sol Import formatting update.
src/library/LibUsdAccount.sol Import formatting update.
src/devnet/TestFungibleToken.sol Add mint(to,value) and burn(value) for cast erc20 compatibility.
src/dapp/IApplicationWithdrawal.sol Remove interface (merged back into IApplication).
src/dapp/IApplicationForeclosure.sol Remove interface (merged back into IApplication).
src/dapp/IApplication.sol Merge foreclosure + withdrawal events/errors/APIs into IApplication.
src/dapp/ApplicationChecker.sol Use IApplication.isForeclosed selector for low-level foreclosure checks.
src/dapp/Application.sol Enforce single-call foreclosure and add template-hash fallback when no claim finalized.
src/common/CanonicalMachine.sol Import formatting update.
script/utils/SemanticVersioning.sol Add semver pre-release/build-metadata validators for codegen/test use.
script/utils/DevContracts.sol Deploy a test USD withdrawal output builder on devnet (depends on core factory + test token).
script/utils/CoreContracts.sol Import formatting update.
script/utils/ContractDeployers.sol Add deploy helper for UsdWithdrawalOutputBuilder and extra post-deploy code assertions.
script/Deployment.s.sol Pass core suite into dev deployment for devnet.
script/CodeGeneration.s.sol Extend codegen helpers; add generator for Version.sol.
README.md Update documented Foundry version to 1.5.1.
Makefile Centralize project/version/foundry definitions; add coverage/release/bindings targets; streamline deploy/devnet.
foundry.toml Allow writing generated Version.sol; enable single-line imports and docs style.
.gitignore Ignore dist/ release output directory.
.github/workflows/upload-rust-bindings.yml Use make rust-bindings instead of duplicating flags in workflow.
.github/workflows/upload-contracts.yml Use make publish-soldeer-package.
.github/workflows/upload-artifacts.yml Use make release-artifacts and upload dist/*.
.github/workflows/check-generated-code.yml Also enforce that src/common/Version.sol is in sync with generator.
.github/actions/setup/action.yml Read Foundry version from Makefile and bump foundry-toolchain action version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread script/CodeGeneration.s.sol
Comment thread Makefile
Comment thread .github/actions/setup/action.yml
@endersonmaia

Copy link
Copy Markdown
Contributor

For consistency, I suggest using either the full chain name always or the shortname.

Or this, all short:

ARB_MAINNET
ARB_SEPOLIA
BASE_MAINNET
BASE_SEPOLIA
ETH_MAINNET
ETH_SEPOLIA
OP_MAINNET
OP_SEPOLIA

Or this, full name:

ARBITRUM_MAINNET
ARBITRUM_SEPOLIA
BASE_MAINNET
BASE_SEPOLIA
ETHEREUM_MAINNET
ETHEREUM_SEPOLIA
OPTIMISM_MAINNET
OPTIMISM_SEPOLIA

I prefer the first (short ones), where I use for the infra and also follow Alchemy's URL naming.

@guidanoli

Copy link
Copy Markdown
Collaborator Author

Good idea. Let's use the short ones.

@guidanoli
guidanoli force-pushed the feature/issues-493-530-532-534-and-refactor branch from ff63275 to d4cfb84 Compare June 19, 2026 21:11
@guidanoli
guidanoli requested a review from endersonmaia June 19, 2026 21:12
@github-project-automation github-project-automation Bot moved this from In progress to Waiting Merge in Rollups SDK Jun 22, 2026
@guidanoli
guidanoli merged commit 9d229db into next/3.0 Jun 22, 2026
8 checks passed
@guidanoli
guidanoli deleted the feature/issues-493-530-532-534-and-refactor branch June 22, 2026 18:51
@github-project-automation github-project-automation Bot moved this from Waiting Merge to Done in Rollups SDK Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-contracts Area: contracts A-deployment Area: deployment A-workflows Area: workflows

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants