-
Notifications
You must be signed in to change notification settings - Fork 14
Description
Summary
To balance development experience and on-chain performance, I propose maintaining two variants of our CosmWasm contracts:
- Development Version: Logging enabled for better debugging and observability.
- Production Version: Logging stripped out to reduce on-chain WASM overhead.
WASM logging incurs non-negligible execution costs, which makes a logging-free build preferable for production deployments. This issue tracks the design and implementation of tooling and workflows to support this approach.
Tasks
-
Created
cosmwasm-loggingCrate- Standard Rust
logcrate integration with CosmWasm'sapi.debug() - Zero-cost production builds using conditional compilation
- Custom logger that formats output as
target: [LEVEL] message
- Standard Rust
-
Contract Integration
-
Feature-Based Build System
- logging feature: Full logging with
logcrate dependency - No features (default): No-op macros, zero runtime cost, no log dependency
- Organized code structure with enabled/disabled modules
- logging feature: Full logging with
-
Dual-Build Integration
- Configured via
[package.metadata.optimizer]in Cargo.toml- Production: babylon_contract.wasm (no logging)
- Development: babylon_contract-dev.wasm (full logging)
- Configured via
-
Added logging to contracts with structured targets
-
Called
init_cosmwasm_logger()in all entry points:instantiate(),execute(),query(),reply(),migrate(), ensuring logging works in all unit tests regardless of entry point
-
-
Update babylon-sdk to use the dev version of contracts so that we can have the proper logging in development. We should integrate the logging into the rollup-bsn-contracts once everything goes well.
Optionally, we can support automated size/gas/cost comparison between the two builds.