Skip to content

Tron version#16

Merged
reednaa merged 4 commits intots-libraryfrom
tron-version
Apr 9, 2026
Merged

Tron version#16
reednaa merged 4 commits intots-libraryfrom
tron-version

Conversation

@reednaa
Copy link
Copy Markdown
Member

@reednaa reednaa commented Apr 7, 2026

Create a custom library for Tron contracts that uses 0x41 as the create2 prefix instead of 0xff.

Summary by CodeRabbit

  • New Features

    • Added Tron blockchain support for Catapultar contract deployment with deterministic clone creation.
    • Introduced a factory contract enabling deployment of both minimal and upgradeable Catapultar instances on Tron.
    • Added digest-based signature support for deployment modes.
  • Tests

    • Added comprehensive test coverage for Tron-based deployments and deterministic address prediction.

@reednaa reednaa requested a review from mirooon April 7, 2026 17:26
@reednaa reednaa self-assigned this Apr 7, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

Added Tron-specific implementations for Catapultar clone factory and cloning utilities, including a deterministic clone library (LibCloneTron), factory contract (CatapultarFactoryTron) supporting multiple deployment modes, test contracts for minimal and upgradeable variants, and baseline snapshot files for Tron test scenarios.

Changes

Cohort / File(s) Summary
Snapshot Files
solidity/snapshots/CatapultarFactoryTronTest.json, solidity/snapshots/CatapultarMinimalTronTest.json, solidity/snapshots/CatapultarUpgradeableTronTest.json
Baseline snapshot records for deployment identifiers and ERC-20 transfer gas metrics across factory and minimal/upgradeable test variants.
Tron Clone Library
solidity/src/libs/LibClone.tron.sol
New Tron-specific clone library with deterministic address calculation using Tron's 0x41 prefix, supporting PUSH0 clones and ERC1967 proxies via delegation to Solady's LibClone.
Factory Contract
solidity/src/CatapultarFactory.tron.sol
New factory contract providing deterministic deployment of Catapultar clones in two modes (non-upgradeable PUSH0 and ERC1967-proxy), with digest-based signature support and salt validation enforcing owner-derived prefixes.
Test Contracts - Implementations
solidity/test/Tron/Catapultar/Catapultar.minimal.tron.t.sol, solidity/test/Tron/Catapultar/Catapultar.upgradable.tron.t.sol
Test contract variants extending CatapultarTest, overriding deployment to use LibCloneTron for minimal (non-upgradeable) and upgradeable (ERC1967) Tron clones respectively.
Factory Test Suite
solidity/test/Tron/CatapultarFactory.tron.t.sol
Comprehensive test suite validating factory deployment, address prediction determinism, digest and salt variant behaviors, and SaltDoesNotStartWith() revert conditions across all deployment methods.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant CatapultarFactoryTron
    participant LibCloneTron
    participant Catapultar as Catapultar (Proxy)
    
    Caller->>CatapultarFactoryTron: deploy(ktp, owner, salt)
    CatapultarFactoryTron->>CatapultarFactoryTron: ownerInSalt validation
    CatapultarFactoryTron->>LibCloneTron: cloneDeterministic_PUSH0(EXECUTOR, salt)
    LibCloneTron->>LibCloneTron: predictDeterministicAddress_PUSH0
    LibCloneTron->>Catapultar: CREATE2 (deterministic)
    Catapultar-->>LibCloneTron: address (created)
    LibCloneTron-->>CatapultarFactoryTron: instance address
    CatapultarFactoryTron->>Catapultar: init(ktp, owner, msg.value)
    Catapultar-->>Caller: proxy address
Loading
sequenceDiagram
    participant Caller
    participant CatapultarFactoryTron
    participant EfficientHashLib
    participant LibCloneTron
    participant Catapultar as Catapultar (Proxy)
    
    Caller->>CatapultarFactoryTron: deployWithDigest(ktp, owner, salt, digest, isSignature)
    CatapultarFactoryTron->>CatapultarFactoryTron: ownerInSalt validation
    CatapultarFactoryTron->>EfficientHashLib: hash(salt, digest, nonce)
    EfficientHashLib-->>CatapultarFactoryTron: derived_salt
    CatapultarFactoryTron->>LibCloneTron: cloneDeterministic_PUSH0(EXECUTOR, derived_salt)
    LibCloneTron->>Catapultar: CREATE2
    Catapultar-->>LibCloneTron: address (created)
    LibCloneTron-->>CatapultarFactoryTron: instance address
    CatapultarFactoryTron->>Catapultar: setSignature(digest, DigestApproval)
    CatapultarFactoryTron->>Catapultar: init(ktp, owner, msg.value)
    Catapultar-->>Caller: proxy address
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Poem

🐰 Through Tron's CREATE2 prefix, clones dance with deterministic grace,
A factory births Catapultars at precise, predicted space,
With salt-wrapped owners and digests sealed tight,
Minimal proxies and ERC1967 take flight!
Tests snapshot the journey—from deploy to digest delight. 🚀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Tron version' is vague and does not clearly convey the specific changes introduced in this pull request, using a generic term that lacks descriptive detail about what was actually implemented. Consider a more descriptive title such as 'Add Tron-specific contract implementations with custom CREATE2 address derivation' to clearly communicate the main change to future readers.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tron-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@reednaa
Copy link
Copy Markdown
Member Author

reednaa commented Apr 7, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (2)
solidity/src/libs/LibClone.tron.sol (1)

89-92: Remove unnecessary return keyword.

LibClone.checkStartsWith has no return value (it reverts on failure). The return keyword is syntactically valid but misleading and unnecessary.

Suggested fix
     function checkStartsWith(bytes32 salt, address by) internal pure {
-        return LibClone.checkStartsWith(salt, by);
+        LibClone.checkStartsWith(salt, by);
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@solidity/src/libs/LibClone.tron.sol` around lines 89 - 92, The function
checkStartsWith currently uses a misleading "return" when calling
LibClone.checkStartsWith(salt, by) even though that callee is non-returning
(reverts on failure); remove the unnecessary "return" keyword and call
LibClone.checkStartsWith(salt, by); directly so the function remains a
void/internal call (keep parameter names salt and by and the function signature
unchanged).
solidity/test/Tron/CatapultarFactory.tron.t.sol (1)

172-184: Salt validation fuzz tests may have unexpected pass/fail cases.

The test logic sets vm.expectRevert conditionally based on the salt prefix. However, when the condition is false (salt starts with 0x00... or matches owner), the test proceeds to call the function without revert expectation.

For deploy specifically, if salt is valid but the deployment has already occurred (e.g., from a previous fuzz run with same salt), the call would revert with DeploymentFailed() instead, potentially causing unexpected test failures.

Consider using vm.assume to filter out salts that would cause deployment collisions, or use try/catch to distinguish expected reverts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@solidity/test/Tron/CatapultarFactory.tron.t.sol` around lines 172 - 184, The
fuzz test testRevert_deploy_salt_does_not_contain_owner can spuriously fail when
a valid salt collides with a previous deployment (causing DeploymentFailed)
because you only set vm.expectRevert conditionally; update the test to filter
out collision salts (use vm.assume to exclude salts whose computed address has
already been deployed) or wrap the factory.deploy call in a try/catch and assert
the revert reason is either SaltDoesNotStartWith() or DeploymentFailed(),
referencing the existing test function name
testRevert_deploy_salt_does_not_contain_owner and the factory.deploy call and
the SaltDoesNotStartWith/DeploymentFailed revert signatures so the logic
distinguishes salt-validation failures from deployment-collision failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@solidity/src/CatapultarFactory.tron.sol`:
- Around line 6-8: The import statements (LibCloneTron, Catapultar,
KeyedOwnable) are misformatted causing forge fmt --check to fail; fix by running
formatter (forge fmt) or manually reorder/adjust spacing so imports follow
standard Solidity/forge formatting conventions (consistent spacing, no extra
blank lines, correct alphabetical/order grouping) in the
CatapultarFactory.tron.sol imports section; ensure the final file passes forge
fmt --check.

In `@solidity/src/libs/LibClone.tron.sol`:
- Around line 28-93: CI flagged formatting issues in LibCloneTron — run forge
fmt and fix spacing/comment alignment and function signature breaks so the file
passes `forge fmt --check`; specifically normalize comment spacing and line
breaks around function declarations like predictDeterministicAddress,
cloneDeterministic_PUSH0, predictDeterministicAddress_PUSH0,
deployDeterministicERC1967, predictDeterministicAddressERC1967, and
checkStartsWith to match project style (wrap long parameter lists consistently,
ensure doc-comments have a single space after triple slashes, and align
braces/indentation) then re-run `forge fmt` to verify.

In `@solidity/test/Tron/Catapultar/Catapultar.minimal.tron.t.sol`:
- Around line 4-8: The import ordering in Catapultar.minimal.tron.t.sol is
failing CI's `forge fmt --check`; fix by reordering the import statements (or
run `forge fmt`) so they comply with Forge's formatting rules—e.g., ensure
imports are grouped and sorted (place "../../../src/libs/LibClone.tron.sol",
then "../../Catapultar/Catapultar.base.t.sol", then
"../../mocks/MockCatapultar.sol" or simply run `forge fmt` to apply the correct
ordering for the imports referencing LibCloneTron, CatapultarTest, and
MockCatapultar.

In `@solidity/test/Tron/Catapultar/Catapultar.upgradable.tron.t.sol`:
- Around line 4-8: CI failed due to import ordering in the test file; run `forge
fmt` to auto-fix or manually reorder the import statements so they follow the
project's formatting rules (group and/or alphabetize imports): place the
LibCloneTron import (LibCloneTron) before the mock and test imports, then
MockCatapultar, then CatapultarTest, and re-run `forge fmt --check` to verify
resolution.

In `@solidity/test/Tron/CatapultarFactory.tron.t.sol`:
- Around line 97-169: CI flagged formatting issues in the test functions (e.g.,
test_predictDeploy_different_salts, test_predictDeployWithDigest_deterministic,
test_predictDeployWithDigest_digest_affects_address,
test_predictDeployUpgradeable_deterministic,
test_predictDeployUpgradeable_differs_from_minimal): run the formatter and fix
signature/line-wrapping so the functions and long factory calls conform to the
project's style; specifically run `forge fmt` (or apply the same formatting
rules) to reflow long argument lists for factory.predictDeployWithDigest,
factory.predictDeployUpgradeable, and ensure function declarations use the
canonical spacing/line breaks, then commit the formatted changes.

---

Nitpick comments:
In `@solidity/src/libs/LibClone.tron.sol`:
- Around line 89-92: The function checkStartsWith currently uses a misleading
"return" when calling LibClone.checkStartsWith(salt, by) even though that callee
is non-returning (reverts on failure); remove the unnecessary "return" keyword
and call LibClone.checkStartsWith(salt, by); directly so the function remains a
void/internal call (keep parameter names salt and by and the function signature
unchanged).

In `@solidity/test/Tron/CatapultarFactory.tron.t.sol`:
- Around line 172-184: The fuzz test
testRevert_deploy_salt_does_not_contain_owner can spuriously fail when a valid
salt collides with a previous deployment (causing DeploymentFailed) because you
only set vm.expectRevert conditionally; update the test to filter out collision
salts (use vm.assume to exclude salts whose computed address has already been
deployed) or wrap the factory.deploy call in a try/catch and assert the revert
reason is either SaltDoesNotStartWith() or DeploymentFailed(), referencing the
existing test function name testRevert_deploy_salt_does_not_contain_owner and
the factory.deploy call and the SaltDoesNotStartWith/DeploymentFailed revert
signatures so the logic distinguishes salt-validation failures from
deployment-collision failures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1754c03b-3180-4007-b5c7-ba90111bb873

📥 Commits

Reviewing files that changed from the base of the PR and between 8207107 and 4faad03.

📒 Files selected for processing (8)
  • solidity/snapshots/CatapultarFactoryTronTest.json
  • solidity/snapshots/CatapultarMinimalTronTest.json
  • solidity/snapshots/CatapultarUpgradeableTronTest.json
  • solidity/src/CatapultarFactory.tron.sol
  • solidity/src/libs/LibClone.tron.sol
  • solidity/test/Tron/Catapultar/Catapultar.minimal.tron.t.sol
  • solidity/test/Tron/Catapultar/Catapultar.upgradable.tron.t.sol
  • solidity/test/Tron/CatapultarFactory.tron.t.sol

Comment on lines +4 to +8
import { LibCloneTron } from "../../../src/libs/LibClone.tron.sol";

import { MockCatapultar } from "../../mocks/MockCatapultar.sol";
import { CatapultarTest } from "../../Catapultar/Catapultar.base.t.sol";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix import ordering flagged by CI.

The pipeline reports forge fmt --check failures for import ordering. Run forge fmt to resolve.

🧰 Tools
🪛 GitHub Actions: Forge Test & Coverage

[error] 6-8: forge fmt --check failed due to formatting diffs in import ordering.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@solidity/test/Tron/Catapultar/Catapultar.minimal.tron.t.sol` around lines 4 -
8, The import ordering in Catapultar.minimal.tron.t.sol is failing CI's `forge
fmt --check`; fix by reordering the import statements (or run `forge fmt`) so
they comply with Forge's formatting rules—e.g., ensure imports are grouped and
sorted (place "../../../src/libs/LibClone.tron.sol", then
"../../Catapultar/Catapultar.base.t.sol", then "../../mocks/MockCatapultar.sol"
or simply run `forge fmt` to apply the correct ordering for the imports
referencing LibCloneTron, CatapultarTest, and MockCatapultar.

Comment on lines +4 to +8
import { LibCloneTron } from "../../../src/libs/LibClone.tron.sol";

import { MockCatapultar } from "../../mocks/MockCatapultar.sol";
import { CatapultarTest } from "../../Catapultar/Catapultar.base.t.sol";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix import ordering flagged by CI.

The pipeline reports forge fmt --check failures for import ordering. Run forge fmt to resolve.

🧰 Tools
🪛 GitHub Actions: Forge Test & Coverage

[error] 6-8: forge fmt --check failed due to formatting diffs in import ordering.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@solidity/test/Tron/Catapultar/Catapultar.upgradable.tron.t.sol` around lines
4 - 8, CI failed due to import ordering in the test file; run `forge fmt` to
auto-fix or manually reorder the import statements so they follow the project's
formatting rules (group and/or alphabetize imports): place the LibCloneTron
import (LibCloneTron) before the mock and test imports, then MockCatapultar,
then CatapultarTest, and re-run `forge fmt --check` to verify resolution.

@mirooon
Copy link
Copy Markdown

mirooon commented Apr 8, 2026

lgtm, only gh action is failing. Please run forge fmt --check

Base automatically changed from remove-unused-contracts to ts-library April 9, 2026 08:50
@reednaa reednaa merged commit a74eaac into ts-library Apr 9, 2026
2 of 3 checks passed
@reednaa reednaa deleted the tron-version branch April 9, 2026 08:50
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