Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
39bcca1
update launch script path & remove duplicate
zsystm Jun 30, 2025
3cdf48f
chore: add private keys info in local_node.sh
zsystm Jun 30, 2025
5e5d68a
add bech32 and bank e2e tests
zsystm Jun 30, 2025
521cb75
add undelegate test
zsystm Jun 30, 2025
700d0e4
faster local node and udpate delegate test
zsystm Jun 30, 2025
7730135
add create validator tc
zsystm Jul 1, 2025
66762f5
update delegate tc
zsystm Jul 1, 2025
38c6b3e
update test codes
zsystm Jul 1, 2025
f1f2222
chore: remove un-used variable
zsystm Jul 1, 2025
59b0c5d
add edit validator tc
zsystm Jul 1, 2025
7ae0efb
add cancel unbonding tc
zsystm Jul 2, 2025
e9f5d63
chore: format test files
zsystm Jul 2, 2025
bd816d3
add redelegate tc
zsystm Jul 2, 2025
3e7f78f
skip gas estimation for faster tests
zsystm Jul 2, 2025
a6d581a
add redelegations query test
zsystm Jul 2, 2025
16cefb4
chore: refactor variable names
zsystm Jul 2, 2025
eb8018d
chore: change filename
zsystm Jul 3, 2025
cfab441
add validators query test and fix gov interface
zsystm Jul 3, 2025
15c16a1
add set withdraw address tc
zsystm Jul 3, 2025
69188bb
order test sequences and add withdraw delegator reward tc
zsystm Jul 3, 2025
493c781
add claim rewards tc
zsystm Jul 4, 2025
52ae413
add withdraw validator commission
zsystm Jul 4, 2025
0dbd25a
Merge remote-tracking branch 'upstream/main' into tests/precompile-e2…
zsystm Jul 7, 2025
0e8e714
add fund community pool tc
zsystm Jul 7, 2025
04ee14f
add deposit validator rewards pool tc
zsystm Jul 7, 2025
05667ef
add validator queries tc
zsystm Jul 8, 2025
40be276
chore: unify convention
zsystm Jul 8, 2025
b016803
add erc20 tc
zsystm Jul 8, 2025
987e026
update local node script
zsystm Jul 8, 2025
e1f4400
fix slashing query and add e2e tests for it
zsystm Jul 8, 2025
f7477c2
fix: decode bech32 consensus address before converting to bytes
zsystm Jul 8, 2025
8882b2c
add gov tc
zsystm Jul 10, 2025
f26aa13
add more tcs to gov precompile (should fix cancel)
zsystm Jul 10, 2025
054b0ff
fix cancel proposal tc
zsystm Jul 10, 2025
9a567d3
add p256 tc
zsystm Jul 10, 2025
d063c7a
remove un-used variables
zsystm Jul 10, 2025
4071ca1
Merge remote-tracking branch 'origin/precompiles/slashing-signing-inf…
zsystm Jul 11, 2025
4db49ee
add werc20 tc
zsystm Jul 11, 2025
a78959d
more timeout and verbose log
zsystm Jul 11, 2025
5b088e8
fix local_node.sh
zsystm Jul 11, 2025
7a76e82
add edgecase test for staking precompile and lint local node script
zsystm Jul 11, 2025
f347e42
revert solidity test script change
zsystm Jul 11, 2025
2a3438a
chore: trim comments
zsystm Jul 11, 2025
84b3160
p256 happy case
zsystm Jul 11, 2025
4e21385
Merge branch 'main' into tests/precompile-e2e-tests-hardhat
vladjdk Jul 15, 2025
18c1d39
Merge branch 'main' into tests/precompile-e2e-tests-hardhat
zsystm Jul 16, 2025
1ac961a
Merge branch 'main' into tests/precompile-e2e-tests-hardhat
Jul 16, 2025
27e8e47
Merge branch 'main' into tests/precompile-e2e-tests-hardhat
Jul 17, 2025
0693d09
refactoring
zsystm Jul 18, 2025
ff99df8
refactor: make findEvent as common
zsystm Jul 18, 2025
6350282
Merge remote-tracking branch 'upstream/main' into tests/precompile-e2…
zsystm Jul 21, 2025
109ab85
check delegation shares and balance also
zsystm Jul 21, 2025
bd74eda
add checking user balance for withdraw delegator reward test
zsystm Jul 21, 2025
b08b07a
add checking user balance for claim rewards tc
zsystm Jul 21, 2025
f814266
strict balance check
zsystm Jul 21, 2025
8a17f8f
add user balance check for fund community pool tc
zsystm Jul 21, 2025
4f69fb6
add user balance check for deposit validator rewards pool tc
zsystm Jul 21, 2025
d4042b6
should use owner, not contract address itself
zsystm Jul 21, 2025
1cb044a
Merge remote-tracking branch 'origin/fix/erc20-approve-event' into te…
zsystm Jul 21, 2025
43d0962
add event checks for erc20 precompile tc
zsystm Jul 21, 2025
3b084be
add balance checks for werc20 tc
zsystm Jul 21, 2025
9320fa5
add balance check for gov deposit tc
zsystm Jul 21, 2025
ae29f95
add balance check for gov cancel proposal tc
zsystm Jul 21, 2025
15e4a88
Merge remote-tracking branch 'upstream/main' into tests/precompile-e2…
zsystm Jul 22, 2025
61bb46b
Merge remote-tracking branch 'upstream/main' into tests/precompile-e2…
zsystm Jul 24, 2025
e16881c
add revert e2e test cases
zsystm Jul 24, 2025
3fde716
lint: unused variable
zsystm Jul 25, 2025
e4dd88c
Merge branch 'main' into tests/revert-caess
cloudgray Aug 18, 2025
6994845
chore(tests): set default evm chain id - 262144
cloudgray Aug 18, 2025
98aa4e4
Merge branch 'main' into tests/revert-caess
vladjdk Aug 18, 2025
7ffff03
WIP: test: enhance revert test
cloudgray Aug 20, 2025
6e83303
WIP: test: enhance revert test
cloudgray Aug 20, 2025
1752b4a
WIP: test: enhance revert test
cloudgray Aug 20, 2025
111fb3b
test: enhance revert test
cloudgray Aug 20, 2025
9ed6424
chore(tests): refine code
cloudgray Aug 20, 2025
e283365
chore: update changelog
cloudgray Aug 20, 2025
62390e5
chore: add semi-colon
cloudgray Aug 20, 2025
d083c53
Merge branch 'main' into tests/revert-caess
cloudgray Aug 20, 2025
d9835aa
Merge branch 'main' into tests/revert-caess
vladjdk Aug 20, 2025
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 @@ -62,6 +62,7 @@
- [\#398](https://github.com/cosmos/evm/pull/398) Post-audit security fixes (batch 4)
- [\#442](https://github.com/cosmos/evm/pull/442) Prevent nil pointer by checking error in gov precompile FromResponse.
- [\#387](https://github.com/cosmos/evm/pull/387) (Experimental) EVM-compatible appside mempool
- [\#476](https://github.com/cosmos/evm/pull/476) Add revert error e2e tests for contract and precompile calls

### FEATURES

Expand Down
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

145 changes: 0 additions & 145 deletions tests/solidity/init-node.sh

This file was deleted.

221 changes: 221 additions & 0 deletions tests/solidity/suites/revert_cases/contracts/RevertTestContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./cosmos/staking/StakingI.sol";
import "./cosmos/distribution/DistributionI.sol";
import "./cosmos/bank/IBank.sol";
import "./cosmos/common/Types.sol";

/**
* @title RevertTestContract
* @dev Contract for testing Cosmos precompile revert scenarios and error message handling
* Focuses specifically on precompile calls and interactions with Cosmos SDK modules
*/
contract RevertTestContract {
uint256 public counter = 0;

// Events to track what operations are performed
event PrecompileCallMade(string precompileName, bool success);
event OutOfGasSimulated(uint256 gasLeft);

constructor() payable {}

// ============ DIRECT PRECOMPILE CALL REVERTS ============

/**
* @dev Direct staking precompile call that will revert
*/
function directStakingRevert(string calldata invalidValidator) external {
counter++;
emit PrecompileCallMade("staking", false);
// This should revert with invalid validator address
STAKING_CONTRACT.delegate(address(this), invalidValidator, 1);
}

/**
* @dev Direct distribution precompile call that will revert
*/
function directDistributionRevert(string calldata invalidValidator) external {
counter++;
emit PrecompileCallMade("distribution", false);
// This should revert with invalid validator address
DISTRIBUTION_CONTRACT.withdrawDelegatorRewards(address(this), invalidValidator);
}

/**
* @dev Direct bank precompile call that will revert
*/
function directBankRevert() external pure {
revert("intended revert");
}

// ============ PRECOMPILE CALL VIA CONTRACT REVERTS ============

/**
* @dev Precompile call via contract that reverts
*/
function precompileViaContractRevert(string calldata invalidValidator) external {
counter++;
try this.internalStakingCall(invalidValidator) {
// Should not reach here
} catch (bytes memory reason) {
// Re-throw the error to maintain the revert
assembly {
revert(add(reason, 0x20), mload(reason))
}
}
}

/**
* @dev Internal function for precompile call via contract
*/
function internalStakingCall(string calldata validatorAddress) external {
require(msg.sender == address(this), "Only self can call");
emit PrecompileCallMade("staking_internal", false);
STAKING_CONTRACT.delegate(address(this), validatorAddress, 1);
}

/**
* @dev Complex scenario: multiple precompile calls with revert
*/
function multiplePrecompileCallsWithRevert(string calldata validatorAddress) external {
counter++;

// First, make a successful call
try IBANK_CONTRACT.balances(address(this)) returns (Balance[] memory) {
emit PrecompileCallMade("bank", true);
} catch {
emit PrecompileCallMade("bank", false);
}

// Then make a call that will revert
emit PrecompileCallMade("staking_multi", false);
STAKING_CONTRACT.delegate(address(this), validatorAddress, 1);
}

// ============ PRECOMPILE OUT OF GAS ERROR CASES ============

/**
* @dev Direct precompile call that runs out of gas
*/
function directStakingOutOfGas(string calldata validatorAddress) external {
counter++;
emit OutOfGasSimulated(gasleft());

// First consume most gas
for (uint256 i = 0; i < 1000000; i++) {
counter++;
}

// Then try precompile call with remaining gas
STAKING_CONTRACT.delegate(address(this), validatorAddress, 1);
}

/**
* @dev Precompile call via contract that runs out of gas
*/
function precompileViaContractOutOfGas(string calldata validatorAddress) external {
counter++;
emit OutOfGasSimulated(gasleft());

// Consume most gas first
for (uint256 i = 0; i < 1000000; i++) {
counter++;
}

// Then try internal precompile call
this.internalStakingCall(validatorAddress);
}

/**
* @dev Wrapper precompile call that runs out of gas
*/
function wrappedPrecompileOutOfGas(string calldata validatorAddress) external {
counter++;
emit OutOfGasSimulated(gasleft());

// Consume most gas in expensive operations
for (uint256 i = 0; i < 500000; i++) {
keccak256(abi.encode(i, block.timestamp, msg.sender));
counter++;
}

// Then try multiple precompile calls
STAKING_CONTRACT.delegate(address(this), validatorAddress, 1);
DISTRIBUTION_CONTRACT.withdrawDelegatorRewards(address(this), validatorAddress);
}

// ============ UTILITY FUNCTIONS ============

/**
* @dev Get current counter value
*/
function getCounter() external view returns (uint256) {
return counter;
}

/**
* @dev Reset counter (for testing)
*/
function resetCounter() external {
counter = 0;
}

/**
* @dev Fund contract with native tokens
*/
receive() external payable {}

/**
* @dev Withdraw funds (for testing)
*/
function withdraw() external {
payable(msg.sender).transfer(address(this).balance);
}
}

/**
* @title PrecompileWrapper
* @dev Helper contract for testing precompile calls via external contracts
*/
contract PrecompileWrapper {
event WrapperCall(string operation, bool success);

constructor() payable {}

/**
* @dev Wrapper function that calls staking precompile and reverts
*/
function wrappedStakingCall(string calldata validatorAddress, uint256 amount) external {
emit WrapperCall("staking", false);
STAKING_CONTRACT.delegate(address(this), validatorAddress, amount);
revert("Wrapper intentional revert");
}

/**
* @dev Wrapper function that calls distribution precompile and reverts
*/
function wrappedDistributionCall(string calldata validatorAddress) external {
emit WrapperCall("distribution", false);
DISTRIBUTION_CONTRACT.withdrawDelegatorRewards(address(this), validatorAddress);
revert("Wrapper intentional revert");
}

/**
* @dev Wrapper function that runs out of gas
*/
function wrappedOutOfGasCall(string calldata validatorAddress) external {
// Consume all gas
for (uint256 i = 0; i < 1000000; i++) {
// Gas consuming operation
keccak256(abi.encode(i));
}

STAKING_CONTRACT.delegate(address(this), validatorAddress, 1);
}

/**
* @dev Fund wrapper contract
*/
receive() external payable {}
}
Loading
Loading