Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: high

`gasPerPubdataByte` should be taken into account in development on the zkSync chain

Summary

gasPerPubdataByte should be taken into account in development on the zkSync chain.

Vulnerability Details

The delegatecall function is a low-level call that allows one contract to execute the code of another contract, while preserving the storage, msg.sender, and msg.value of the original calling contract. This makes it a critical component in certain design patterns, particularly those involving proxy contracts and upgradeability.The delegatecall function can accept a gas stipend, indicating how much gas should be allocated for the call.
According to the description in the document, the contracts are supposed to be deployed to any EVM-compatible chains.The protocol might be deployed on the zkSync chain.
zkSync Era has its own gas logic, which differs from Ethereum. This is primarily due to the state diff-based fee model and the unique computational trade-offs of zkEVM. Gas prices and opcode costs may vary compared to Ethereum, and relying solely on gas calculations can be insufficient.

One specific aspect to consider is the gasPerPubdataByte constant included in every transaction. While the operator currently controls this value, users sign an upper bound for it. However, the operator can still choose any value within that range, influenced by the L1 gas price. Failing to account for gasPerPubdata can lead to transaction failures and unnecessarily high gas consumption.
https://era.zksync.io/docs/dev/building-on-zksync/best-practices.html#gasperpubdatabyte-should-be-taken-into-account-in-development

fallback() external {
address implementation = _implementation;
assembly {
let ptr := mload(0x40)
calldatacopy(ptr, 0, calldatasize())
let result := delegatecall(gas(), implementation, ptr, calldatasize(), 0, 0)
let size := returndatasize()
returndatacopy(ptr, 0, size)
switch result
case 0 { revert(ptr, size) }
default { return(ptr, size) }
}
}
```·
## Impact
The transaction might fail
## Tools Used
Vscode
## Recommendations

Support

FAQs

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