FoundrySolidityLayer 2
7.25 ETH
Submission Details
Impact: low
Likelihood: low

Constructors Not Marked payable Waste Deploy Gas

Author Revealed upon completion

Description

Solidity generates a non-payable msg.value check for constructors that are not declared payable. Declaring the constructor payable removes this check, slightly reducing deployment bytecode and deployment gas. This optimization is applicable only if accepting Ether during contract creation is consistent with the intended contract interface.

Link to affected codes:
https://github.com/CodeHawks-Contests/2026-07-bc-confidence-pools/blob/main/src/ConfidencePool.sol#L157
https://github.com/CodeHawks-Contests/2026-07-bc-confidence-pools/blob/main/src/ConfidencePoolFactory.sol#L45

// Root cause in the codebase with @> marks to highlight the relevant section
// src/ConfidencePool.sol:157
@> constructor() Ownable(msg.sender) {
// ^^^^^^^^^ → compiler inserts CALLVALUE checks
// src/ConfidencePoolFactory.sol:45
@> constructor() {
// ^^ → compiler inserts CALLVALUE checks
Likelihood: Always — Every deployment of a non-payable constructor executes the compiler-generated non-payable value check.

Impact

Gas

Recommended Mitigation

- constructor() Ownable(msg.sender) {
+ constructor() payable Ownable(msg.sender) {
_disableInitializers();
}
- constructor() {
+ constructor() payable {
_disableInitializers();
}

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!