Company Simulator

First Flight #51
Beginner FriendlyDeFi
100 EXP
View results
Submission Details
Impact: low
Likelihood: high
Invalid

Gas & Bytecode Bloat Due to Long assert Messages

Root + Impact

Description

  • Normal behavior:
    assert statements should check conditions efficiently.

  • Specific issue:
    The contract uses assert with long string messages:

// Root cause in the codebase with @> marks to highlight the relevant section
@external
def produce(amount: uint256):
@> assert msg.sender == OWNER, "Not the owner!!!"
@> assert self.company_balance >= total_cost, "Insufficient balance!!!"

Risk

Likelihood:

High — All functions using long asserts contribute to this issue.

Impact:

Low — No funds are lost, but users pay more gas unnecessarily.

Proof of Concept

Explanation:

Every call to a function with long error messages consumes slightly more gas due to the storage of the string in the bytecode. Across many functions, this increases deployment and interaction cost.

// Example of gas-heavy assert equivalent
function example(uint256 x) public pure {
require(x > 0, "Very long custom message stored on-chain consumes extra gas!");
}

Recommended Mitigation

Explanation:

Use short or no messages in assert statements.

For user-facing errors, use raise with a short string.

This reduces bytecode size and gas cost without changing logic.

- remove this code
+ add this code
@@
- assert msg.sender == OWNER, "Not the owner!!!"
+ assert msg.sender == OWNER # shorter, gas-efficient
@@
- assert self.company_balance >= total_cost, "Insufficient balance!!!"
+ assert self.company_balance >= total_cost
Updates

Lead Judging Commences

0xshaedyw Lead Judge
4 days ago
0xshaedyw Lead Judge 3 days ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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