-
Notifications
You must be signed in to change notification settings - Fork 101
test(rpc): add ERC-20 eth_call tests with proxy support #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add comprehensive eth_call tests for ERC-20 operations: - transfer, mint, burn, approve+transferFrom - TransparentProxy (USDC-style) variants for all operations Closes base#151
✅ Heimdall Review Status
|
…all tests - Use explicit block numbers instead of BlockNumberOrTag::Latest - Replace U256::from_str parsing with U256::abi_decode for proper ABI decoding - Remove unnecessary sleep() delays - Track block numbers after each transaction to query correct state
…bility issue Tests are temporarily ignored because TestHarness commits blocks via Engine API, but eth_call queries don't see the committed contract state. FlashblocksHarness works differently by maintaining pending state that eth_call can query. Tests should be re-enabled once TestHarness state visibility is fixed or tests are rewritten to use FlashblocksHarness with proper flashblock payload construction.
Rewrite eth_call ERC-20 tests to use FlashblocksHarness with manually constructed flashblock payloads instead of TestHarness. Tests now include: - test_erc20_deployment: Basic token deployment and name/symbol/decimals queries - test_proxy_erc20_deployment: TransparentProxy deployment and delegatecall queries - test_erc20_mint: Token minting and balance verification - test_proxy_erc20_mint: Minting through proxy contract This approach properly tests eth_call against contract state by using flashblock payloads that expose pending state to RPC queries.
|
Quick update on what I tried:
Basically TestHarness commits to canonical chain but RPC doesn't see it, while FlashblocksHarness exposes state as pending block which eth_call can read. |
crates/rpc/tests/eth_call_erc20.rs
Outdated
| sol!( | ||
| #[sol(rpc)] | ||
| TestERC20, | ||
| concat!( | ||
| env!("CARGO_MANIFEST_DIR"), | ||
| "/../test-utils/contracts/out/TestERC20.sol/TestERC20.json" | ||
| ) | ||
| ); | ||
|
|
||
| sol!( | ||
| #[sol(rpc)] | ||
| TransparentProxy, | ||
| concat!( | ||
| env!("CARGO_MANIFEST_DIR"), | ||
| "/../test-utils/contracts/out/TransparentProxy.sol/TransparentProxy.json" | ||
| ) | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have base_reth_test_utils as a dependency here, could we localize these into the test-utils crate and then export whatever is needed? That way we don't need to use an external path like "/../test-utils/" which is subject to change + breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okey noted , i will do it
refcell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the tests look good, but I think we can move a few things to test-utils that don't need to be in the rpc tests module so we're not relying on external files from inside the rpc crate.
|
@refcell i am still working to solve CI/Test . |
- Increase gas limit from 500k to 3M for larger contract deployments (ERC-20 bytecode ~5KB requires more gas for CREATE opcode) - Simplify TestERC20 constructor to use hardcoded values - Fix cumulative_gas_used in mint payload (must be cumulative, not per-tx) - Add deployer balance to base payload for EVM transaction execution - Remove proxy name() assertion (proxy uses own storage, not impl storage) Fixes tests: test_erc20_deployment, test_proxy_erc20_deployment, test_erc20_mint, test_proxy_erc20_mint
|
All 4 ERC-20 tests now pass locally:
Existing |
|
Can you replace the contract implementations with just to ensure it works with widely used things instead of needing to maintain these handwritten contracts in the repo. To have them compiled and outputted as artifacts you can do a simple script similar to the |
Move sol! macro contract bindings from test files to base_reth_test_utils::contracts module: - Add contracts.rs with DoubleCounter, TestERC20, and TransparentProxy bindings - Update flashblocks_rpc.rs to import DoubleCounter from test-utils - Update eth_call_erc20.rs to import TestERC20 and TransparentProxy from test-utils - Add alloy-sol-macro, alloy-sol-types, and alloy-contract dependencies to test-utils This eliminates relative path references like '/../test-utils/contracts/out/' which are subject to breakage when paths change.
Okey okey it make sense. |
…radeableProxy Replace handwritten test contracts with widely-used library implementations: - MockERC20 from Solmate (lib/solmate) - TransparentUpgradeableProxy from OpenZeppelin (lib/openzeppelin-contracts) Add DeployERC20.s.sol script following DeployDoubleCounter.s.sol pattern. Update Rust bindings and tests to use new contract artifacts.
|
Done. Updated in commit 9a9252e: |
Closes #151
Summary
Adds integration tests for
eth_callwith ERC-20 token operations, addressing the gap identified after the v13.3 bug where proxy-based tokens broke on mainnet.Changes
New Contracts:
TestERC20.sol- Simple ERC-20 with mint/burn for testingTransparentProxy.sol- EIP-1967 compliant proxy (USDC-style)New Tests (8 total):
test_erc20_transfer- basic transfertest_erc20_mint- minting tokenstest_erc20_burn- burning tokenstest_erc20_approve_transfer_from- approval flowtest_transparent_proxy_erc20_transfer- transfer via proxytest_transparent_proxy_erc20_mint- mint via proxytest_transparent_proxy_erc20_burn- burn via proxytest_transparent_proxy_erc20_approve_transfer_from- approval via proxyEach test verifies state changes through
eth_callafter executing transactions, catching issues with delegatecall behavior that caused the mainnet bug.