Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [\#467](https://github.com/cosmos/evm/pull/467) Replace GlobalEVMMempool by passing to JSONRPC on initiate.
- [\#352](https://github.com/cosmos/evm/pull/352) Remove the creation of a Geth EVM instance, stateDB during the AnteHandler balance check.
- [\#496](https://github.com/cosmos/evm/pull/496) Simplify mempool instantiation by using configs instead of objects.
- [\#535](https://github.com/cosmos/evm/pull/535) Add nested precompile reversion tests.

### FEATURES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,36 @@ contract StakingReverter {
STAKING_CONTRACT.delegate(address(this), validatorAddress, 10);
}

/// @dev nestedTryCatchDelegations performs nested try/catch calls to precompile
/// where inner calls revert intentionally. Only the successful delegations
/// outside the reverting scope should persist.
///
/// Expected successful delegations: 1 (before loop) + outerTimes (after each catch) + 1 (after loop)
function nestedTryCatchDelegations(uint outerTimes, uint innerTimes, string calldata validatorAddress) external {
// Initial successful delegate before any nested reverts
STAKING_CONTRACT.delegate(address(this), validatorAddress, 10);

for (uint i = 0; i < outerTimes; i++) {
// Outer call that will revert and be caught
try StakingReverter(address(this)).performDelegation(validatorAddress) {
// no-op
} catch {
// After catching the revert, perform a successful delegate
STAKING_CONTRACT.delegate(address(this), validatorAddress, 10);

// Inner nested loop of reverting calls
for (uint j = 0; j < innerTimes; j++) {
try StakingReverter(address(this)).performDelegation(validatorAddress) {
// no-op
} catch {}
}
}
}

// Final successful delegate after the loops
STAKING_CONTRACT.delegate(address(this), validatorAddress, 10);
}

function performDelegation(string calldata validatorAddress) external {
STAKING_CONTRACT.delegate(address(this), validatorAddress, 10);
revert();
Expand Down
Loading
Loading