Skip to content

chore: Tron counterfactual deployment tooling#1338

Open
tbwebb22 wants to merge 24 commits intomasterfrom
taylor/tron-counterfactual-tooling
Open

chore: Tron counterfactual deployment tooling#1338
tbwebb22 wants to merge 24 commits intomasterfrom
taylor/tron-counterfactual-tooling

Conversation

@tbwebb22
Copy link
Copy Markdown
Contributor

@tbwebb22 tbwebb22 commented Feb 26, 2026

Adds TypeScript deploy scripts for deploying counterfactual deposit contracts to Tron via TronWeb. Foundry can't broadcast to Tron directly (Tron uses protobuf + SHA-256 signing vs RLP + keccak256), so each script validates typed args, ABI-encodes constructor params, and calls a shared deployer that handles TronWeb deployment and writes Foundry-compatible broadcast artifacts. Includes scripts for the factory, all three deposit implementations (CCTP, OFT, SpokePool), WithdrawImplementation, and a clone deployment script that verifies CREATE2 address prediction. Also adds a README documenting prerequisites (Tron solc fork), deploy commands, TronScan verification steps, and broadcast artifact format.

Deployed contracts are on Tron testnet, with dummy configurations - they are in this PR just to show the json format the deploy script is writing. We can delete these deployments before merging this.

tbwebb22 and others added 4 commits February 23, 2026 01:16
* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* executor address

* EIP-712 for signatures

* tests passing

* remove executor as state variable in factory

* use OZ clones instead of custom proxy

* cleanup

* Deposit to CCTPSrcPeriphery instead of SpokePool

* rename immutables struct

* only store hash of immutables

* clean up withdraw functions

* add execution fee

* refactor & add OFT/Spoke implementations

* make refund recipient an immutable

* add base abstract contract & correct spoke pool max fee calc

* clean up SpokePool implementation

* polish

* add comments

* exclude counterfactual contracts from hardhat compilation

* more cleanup

* undo hardhat exclusion change

* clean up readme

* user and admin withdraw addresses as address rather than bytes32

* remove unneeded balance check reverts

* only pass in hash of params to deploy functions

* remove try/catch in factory

* rename PRECISION_SCALAR to PRICE_SCALAR

* update readme

* update readme

* change OFT token from bytes32 to address

* make exclusiveRelayer and exclusivityDeadline signed calldata

* rename price to stableExchangeRate

* split immutables structs into separate deposit & execution structs

* make verifyParams a modifier

* make quoteTimestamp signed

* make depositExecution events more descriptive

* add native asset support

* update imports

* add signature deadline

* add counterfactual contracts to hardhat test compilation exclusion

* add comments for caller passing msg.value for LZ fee

* make SpokePool maxFee have fixed and bps components

* make DepositExecuted events separate per implementation

* add deployAndExecuteIfNeeded function to factory

* add AdminWithdrawManager and cleanup withdraw functions & param hash verification

---------

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: Matt Rice <matthewcrice32@gmail.com>
…ctual deposits (#1331)

* replace params-hash dispatcher with merkle-dispatched counterfactual deposits

Single dispatcher contract stores a merkle root as its immutable arg. Each
leaf is (implementation, keccak256(params)). Callers prove leaf inclusion
via merkle proof, then the dispatcher delegatecalls the implementation.
Withdrawals become a standard implementation (WithdrawImplementation) rather
than baked-in base logic, enabling one deposit address to support multiple
possible actions.

- Add CounterfactualDeposit dispatcher and ICounterfactualImplementation
- Add WithdrawImplementation with authorized caller + forced recipient
- Adapt SpokePool, CCTP, OFT implementations to ICounterfactualImplementation
- Adapt AdminWithdrawManager for merkle-based withdraw execution
- Delete CounterfactualDepositBase (replaced by dispatcher + WithdrawImpl)
- Rewrite all tests for merkle pattern (90 tests passing)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* remove unused bytes return from execute interfaces

The return value was never consumed by any caller (factory, AdminWithdrawManager,
or tests). Removing it simplifies the interfaces and saves gas by avoiding
ABI decode/re-encode of the delegatecall result in the dispatcher.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* simplify WithdrawParams to single {admin, user} merkle leaf

Replace {authorizedCaller, forcedRecipient} with {admin, user} so each
clone needs only one withdraw leaf instead of up to three. Both admin
and user can withdraw to any recipient. Recipient enforcement for
signed withdrawals moves to AdminWithdrawManager.signedWithdrawToUser,
which reads the user address from the merkle-committed params.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* extract shared NATIVE_ASSET and BPS_SCALAR into CounterfactualConstants

Addresses review feedback: both constants were duplicated across
WithdrawImplementation, CounterfactualDepositSpokePool, and
CounterfactualDepositCCTP. Now defined once as file-level constants
and imported by name.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ery (#1329)

* [WIP] feat: add TransferProxy to allow same-chain swaps via SpokePoolPeriphery

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* WIP

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>

* fix: remove payable from TransferProxy deposit functions

ETH sent to these functions would be permanently trapped since
TransferProxy only handles ERC-20 transfers. Removing payable
causes the EVM to reject any calls that send ETH.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Signed-off-by: Matt Rice <matthewcrice32@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@tbwebb22 tbwebb22 changed the base branch from master to taylor/tron-counterfactual-compatibility February 26, 2026 23:44
grasphoper and others added 2 commits February 26, 2026 16:10
Signed-off-by: Ihor Farion <ihor@umaproject.org>
* WIP tron factory compatibility changes

* add foundry Tron profile

* add natspec

* make tron factory inherit from base counterfactual factory

* move TronClones.sol into libraries folder

* add references to OZ libraries forked from in comments
Base automatically changed from taylor/tron-counterfactual-compatibility to audit-feb23 February 27, 2026 00:11
@tbwebb22 tbwebb22 changed the title Taylor/tron counterfactual tooling chore: tron deployment tooling Feb 27, 2026
@tbwebb22 tbwebb22 force-pushed the taylor/tron-counterfactual-tooling branch from 3ae3331 to 72f699d Compare March 4, 2026 19:06
@tbwebb22 tbwebb22 changed the title chore: tron deployment tooling chore: Tron counterfactual deployment tooling Mar 4, 2026
@tbwebb22 tbwebb22 added the do not merge do not merge label Mar 4, 2026
@tbwebb22 tbwebb22 marked this pull request as ready for review March 4, 2026 22:18
@tbwebb22 tbwebb22 requested review from fusmanii and grasphoper March 4, 2026 22:18
@socket-security
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
Addedeslint@​7.32.09110010050100
Added@​solana-program/​token@​0.9.0991008592100
Addedbs58@​6.0.01001009385100
Addedmultiformats@​9.9.010010010086100
Addedyargs@​17.7.29910010087100

View full report

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Protestware or unwanted behavior: npm es5-ext

Note: The script attempts to run a local post-install script, which could potentially contain malicious code. The error handling suggests that it is designed to fail silently, which is a common tactic in malicious scripts.

From: ?npm/es5-ext@0.10.64

ℹ Read more on: This package | This alert | What is protestware?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Consider that consuming this package may come along with functionality unrelated to its primary purpose.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/es5-ext@0.10.64. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Base automatically changed from audit-feb23 to master March 18, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge do not merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants