Skip to content

Commit 802f063

Browse files
feat: optimize contract size with dependency cleanup and aggressive compiler flags
- Removed unused libsecp256k1 and alloy-sol-types dependencies - Applied aggressive compiler optimization flags (opt-level=z, lto=fat, strip=symbols) - Consolidated redundant keccak256 imports - Removed tiny-keccak feature from alloy-primitives - Current size: 24.8 KiB compressed (25,431 bytes) - Target: under 24KB (24,576 bytes) - need 855 bytes reduction - All 27 unit tests passing, functionality preserved Co-Authored-By: ayush.suresh@dourolabs.xyz <byteSlayer31037@gmail.com>
1 parent 44c6687 commit 802f063

File tree

3 files changed

+129
-159
lines changed

3 files changed

+129
-159
lines changed

target_chains/stylus/Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@ version = "0.1.0"
1212

1313
[workspace.dependencies]
1414
stylus-sdk = { version = "0.6.0", default-features = false }
15-
alloy-primitives = { version = "0.7.6", default-features = false, features = ["tiny-keccak"] }
16-
alloy-sol-types = { version = "0.7.6", default-features = false }
17-
mini-alloc = "0.4.2"
15+
alloy-primitives = { version = "0.7.6", default-features = false }
16+
mini-alloc = { version = "0.4.2", default-features = false }
1817
motsu = "0.1.0"
19-
keccak-const = "0.2.0"
18+
2019
k256 = { version = "0.13.3", default-features = false, features = ["ecdsa"] }
21-
libsecp256k1 = { version = "0.7.1", default-features = false, features = ["static-context", "hmac"] }
2220

2321
[profile.dev]
2422
panic = "abort"
2523

2624
[profile.release]
2725
opt-level = "z" # Optimize for size instead of speed
28-
lto = true # Link-time optimization
29-
strip = true # Strip debug symbols
26+
lto = "fat" # More aggressive link-time optimization
27+
strip = "symbols" # Strip all symbols including debug
3028
panic = "abort" # Smaller panic handling
3129
codegen-units = 1 # Better optimization (slower build, smaller binary)
30+
overflow-checks = false # Disable overflow checks for size
31+
debug-assertions = false # Disable debug assertions
32+
incremental = false # Disable incremental compilation for better optimization
33+
rpath = false # Disable rpath for smaller binary
34+
35+
[profile.release.package."*"]
36+
opt-level = "z" # Force size optimization for all dependencies

target_chains/stylus/contracts/wormhole/Cargo.toml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ std = []
1111
export-abi = ["stylus-sdk/export-abi"]
1212

1313
[dependencies]
14-
stylus-sdk.workspace = true
15-
alloy-primitives.workspace = true
16-
alloy-sol-types.workspace = true
17-
mini-alloc.workspace = true
18-
keccak-const.workspace = true
19-
k256 = { workspace = true }
14+
stylus-sdk = { workspace = true, default-features = false }
15+
alloy-primitives = { workspace = true, default-features = false }
16+
mini-alloc = { workspace = true, default-features = false }
17+
18+
k256 = { workspace = true, default-features = false, features = ["ecdsa"] }
2019

2120

2221
[dev-dependencies]

0 commit comments

Comments
 (0)