fix: resolve stack-too-deep in EthScarcityAbundance test

Extract _decodeVwapTick and _logEvent helpers to reduce stack depth
in _recenterAndLog. Also add via_ir=true to maxperf profile.
This commit is contained in:
openhands 2026-02-23 15:35:34 +00:00
parent a46c30cff6
commit 491c8f65b6
5 changed files with 26 additions and 32 deletions

View file

@ -11,6 +11,7 @@ via_ir = true
bytecode_size_limit = 0
[profile.maxperf]
via_ir = true
bytecode_size_limit = 0
# See more config options https://github.com/foundry-rs/foundry/tree/master/config

View file

@ -407,6 +407,19 @@ contract EthScarcityAbundance is Test {
_recoverStuck();
}
function _decodeVwapTick(bytes memory data) internal pure returns (int24) {
(,,,, int24 vwap) = abi.decode(data, (int24, uint256, uint256, uint256, int24));
return vwap;
}
function _logEvent(bytes memory data, string memory label, string memory eventName) internal view {
(int24 tick, uint256 ethBal, uint256 supply,,) = abi.decode(data, (int24, uint256, uint256, uint256, int24));
console2.log(string.concat(" ", eventName, ":"), label);
console2.log(" tick:", tick);
console2.log(" ethBal:", ethBal / 1e18);
console2.log(" supply:", supply / 1e18);
}
function _recenterAndLog(string memory label) internal returns (bool sawScarcity, bool sawAbundance, int24 eventVwapTick) {
vm.warp(block.timestamp + 1 hours);
vm.roll(block.number + 1);
@ -422,23 +435,13 @@ contract EthScarcityAbundance is Test {
for (uint256 i = 0; i < logs.length; i++) {
if (logs[i].topics.length == 0) continue;
if (logs[i].topics[0] == SCARCITY_SIG) {
(int24 tick, uint256 ethBal, uint256 supply,, int24 vwapTick) = abi.decode(logs[i].data, (int24, uint256, uint256, uint256, int24));
sawScarcity = true;
eventVwapTick = vwapTick;
console2.log(" EthScarcity:", label);
console2.log(" tick:", tick);
console2.log(" ethBal:", ethBal / 1e18);
console2.log(" supply:", supply / 1e18);
console2.log(" vwapTick:", vwapTick);
eventVwapTick = _decodeVwapTick(logs[i].data);
_logEvent(logs[i].data, label, "EthScarcity");
} else if (logs[i].topics[0] == ABUNDANCE_SIG) {
(int24 tick, uint256 ethBal, uint256 supply,, int24 vwapTick) = abi.decode(logs[i].data, (int24, uint256, uint256, uint256, int24));
sawAbundance = true;
eventVwapTick = vwapTick;
console2.log(" EthAbundance:", label);
console2.log(" tick:", tick);
console2.log(" ethBal:", ethBal / 1e18);
console2.log(" supply:", supply / 1e18);
console2.log(" vwapTick:", vwapTick);
eventVwapTick = _decodeVwapTick(logs[i].data);
_logEvent(logs[i].data, label, "EthAbundance");
}
}