feat(contracts): Wasm bytecode size optimization via sub-contract mod…#299
Merged
Solomonsolomonsolomon merged 1 commit intogear5labs:masterfrom Mar 31, 2026
Conversation
…ular architecture - Extract heavy Bitcoin crypto helpers (double_sha256, merkle proof, PoW target decoding) from btc_relay into a new btc_relay_crypto sub-contract - btc_relay now delegates all crypto ops via BtcCryptoClient cross-contract calls, keeping each Wasm binary within Soroban's size limit - Add crypto_contract: Address to btc_relay Config; update initialize sig - Register all 7 previously missing contracts in workspace Cargo.toml - Fix pre-existing moved-value compile error in relayer_slashing - Fix pre-existing invalid token::Client::total_supply() call in por_validator Deployment: deploy btc_relay_crypto first, pass its address as crypto_contract when initializing btc_relay.
|
@devJaja Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(contracts): Wasm bytecode size optimization via sub-contract modular architecture
Problem
Soroban enforces a strict Wasm bytecode size limit per contract. The btc_relay contract exceeded this limit due to
its inline Bitcoin cryptographic helpers (double-SHA256, Merkle proof traversal, PoW target decoding).
Additionally, 7 of the 11 contracts were missing from the workspace, making them unbuildable.
Solution
Extracted the heavy crypto logic from btc_relay into a new btc_relay_crypto sub-contract. The relay contract now
delegates all crypto operations via #[contractclient] cross-contract calls, keeping each Wasm binary well within
Soroban's size limit.
Changes
flash_loan_guard, htlc, lending_liquidation, multi_hop_swap, rbac)
hash_meets_target, compute_merkle_root
Config now includes crypto_contract: Address
initialize
owns circulating_supply
Deployment note
btc_relay_crypto must be deployed first. Its contract address is then passed as crypto_contract when initializing
btc_relay.
Testing
cargo check --workspace passes clean across all 13 contracts.
Closes: #270