forked from cosmos/evm
-
Notifications
You must be signed in to change notification settings - Fork 0
feat(erc20factory): erc20factory precompile #1
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
Open
GuillemGarciaDev
wants to merge
68
commits into
main
Choose a base branch
from
feat/erc20-factory-precompile
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Conflicts: # local_node.sh # precompiles/common/interfaces.go
…mos#415) * feat: remove allow-unprotected-txs(non eip-155) from x/vm params * fix: build --------- Co-authored-by: Vlad J <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]>
…smos#467) * chore: ensure SetGlobalEVMMempool is thread-safe and only set once keep singleton behavior on concurrent initialization * doc * keep reset * pass in mempool * cleanup --------- Co-authored-by: Vlad J <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]>
* Problem: eip-2935 is not implemented Solution: - adapt the implementation from geth * change BLOCKHASH opcode to query contract storage * commit statedb * fix panic * temp * just emulate the contract behavior with native code * fix test * fix lint * fix lint * revert unneeded changes * fix test * revert * only set contract storage if it's deployed * fix build * add history serve window parameter * cleanup * fix lint --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]>
* refactor: decouple keeper using interface on precompile - Define a set of keeper interfaces in precompiles/common/interfaces.go that specify the exact methods required by the precompiles. - Update all precompile constructors and internal structs to use these new interfaces. - Modifie the precompile assembly in `evmd/precompiles.go` to inject the concrete `MsgServer` and `Querier` implementations, which satisfy the required interfaces. - Removed unnecessary keeper dependencies from the function signatures of several precompiles * docs: add changelog
* test: adjusts GasTipCap to equal GasFeeCap when it exceeds the maximum fee cap * ensures adequate fees for bank msg send * Optimize CanTransfer AnteHandler * refactor(antehandler): remove stateDB allocation * chore: replace GlobalEVMMempool by passing to JSONRPC on initiate (cosmos#467) * chore: ensure SetGlobalEVMMempool is thread-safe and only set once keep singleton behavior on concurrent initialization * doc * keep reset * pass in mempool * cleanup --------- Co-authored-by: Vlad J <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]> * Problem: eip-2935 is not implemented (cosmos#407) * Problem: eip-2935 is not implemented Solution: - adapt the implementation from geth * change BLOCKHASH opcode to query contract storage * commit statedb * fix panic * temp * just emulate the contract behavior with native code * fix test * fix lint * fix lint * revert unneeded changes * fix test * revert * only set contract storage if it's deployed * fix build * add history serve window parameter * cleanup * fix lint --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]> * fix : EVMKeeper GetBalance missed when version upgrades * add CHANGELOG --------- Co-authored-by: mmsqe <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]> Co-authored-by: yihuang <[email protected]>
…osmos#476) * update launch script path & remove duplicate We should use only one launch script. Managing both is extra un-necessary overhead * chore: add private keys info in local_node.sh * add bech32 and bank e2e tests * add undelegate test * faster local node and udpate delegate test * add create validator tc * update delegate tc include event checking also * update test codes added event checking to undelegate tc receipt has hash field instead of transactionHash * chore: remove un-used variable * add edit validator tc * add cancel unbonding tc * chore: format test files * add redelegate tc * skip gas estimation for faster tests * add redelegations query test * chore: refactor variable names * chore: change filename * add validators query test and fix gov interface * add set withdraw address tc * order test sequences and add withdraw delegator reward tc * add claim rewards tc * add withdraw validator commission * add fund community pool tc * add deposit validator rewards pool tc * add validator queries tc * chore: unify convention * add erc20 tc * update local node script it should contains every precompiles by default * fix slashing query and add e2e tests for it * fix: decode bech32 consensus address before converting to bytes The consensus address was previously used in its bech32-encoded form (a 52-character string), which is incorrect. This led to attempts to interpret a bech32 string directly as a 20-byte address, resulting in invalid conversions and data loss. This fix ensures the bech32 consensus address is properly decoded into its original 20-byte form before further processing, preserving the correct address representation expected in EVM-compatible byte format. * add gov tc * add more tcs to gov precompile (should fix cancel) * fix cancel proposal tc * add p256 tc * remove un-used variables * add werc20 tc * more timeout and verbose log * fix local_node.sh * add edgecase test for staking precompile and lint local node script * revert solidity test script change * chore: trim comments * p256 happy case * refactoring * refactor: make findEvent as common * check delegation shares and balance also * add checking user balance for withdraw delegator reward test * add checking user balance for claim rewards tc * strict balance check * add user balance check for fund community pool tc * add user balance check for deposit validator rewards pool tc * should use owner, not contract address itself * add event checks for erc20 precompile tc * add balance checks for werc20 tc * add balance check for gov deposit tc * add balance check for gov cancel proposal tc * add revert e2e test cases * lint: unused variable * chore(tests): set default evm chain id - 262144 * WIP: test: enhance revert test * WIP: test: enhance revert test * WIP: test: enhance revert test * test: enhance revert test * chore(tests): refine code * chore: update changelog * chore: add semi-colon --------- Co-authored-by: zsystm <[email protected]> Co-authored-by: Vlad J <[email protected]> Co-authored-by: Hyunwoo Lee <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]>
* Problem: IsStorageEmpty is not implemented Closes: cosmos#486 * update deps
…mos#479) * feat: allow PostProcessingTx to run on failures and persist data * linf fix * add check for hooks --------- Co-authored-by: Vlad J <[email protected]>
… error (cosmos#471) * fix: avoid insufficient funds error when fund and send tx within same block get SpendableCoin from sdk ctx to reflect uncommitted balance change * wrong hash * fix test * cleanup doc * notify * revert * cleanup * doc * unsubscribe * lint * cleanup * align shutdown timeout to avoid stuck on closing JSON-RPC * cleanup * Apply suggestions from code review * Apply suggestions from code review * lint * lint --------- Co-authored-by: Alex | Interchain Labs <[email protected]>
* apply 3eb2135 * apply 4f9b8c2 * apply 0e7fd50 * apply 5cfe96d * apply 0e7fd50: fix lint workflow * apply 679305d * Fix middleware test * Format * apply 9fae984: fix conflicts * consolidate diverging test suite structures * apply 9fae984: fix conflicts * consolidate diverging test suite structures * apply b9a4d41 * apply 96ad38f * fix lint * apply b9a4d41 * apply 96ad38f * apply 578b346 * apply fd7badc * apply f7a3922 * apply 0e511d3 * apply 09e1895 * apply fb7e407 * apply 8cd184f * apply 9b96d1f * apply 029ed3b * apply e6fe094 * apply 76d8d10 * apply 0517dcf * apply af6f8d4 * apply 17cb0d5 * apply cb64292 * apply cbae613 * apply e57a44e * apply 66dd661 * apply 16ec2d0 * apply ec1a928 * apply 058eb6d * apply 82a7981 * apply 71d26cf * apply 4c27407 * apply bda7ad0 * apply bb811f4 * apply 6644e35 * apply 8d21baf * apply ebcaefa * apply 4913831 * apply 76819ba * apply cd9cd1a * apply 60a6cd2 * apply 2518c1b * apply bb9d02e * apply 5e7359e * apply a8112f4 * apply 388b5c0 * apply 727407e * apply a5ddd15 * apply 03ede6c * apply 9ad7d66 * apply e921750 * apply 17c65a7 * apply 9ddd976 * apply cffad65 * apply 6085578 * apply 099f44e * apply 2934281 * apply f9ca3ea * apply b826e3a * apply 5024129 * apply bfa2f05 * apply fb20472 * apply 4b0d478 * apply b065764 * apply ebc4b6c * apply 0f22f9f * clean up gh workflows * add-test-chain-id * pointer to precise bank keeper * cover all * apply balance handler patch * fix lint * fix solidity test * add evmd tests fix * add omitted fractional balance clear * fix lint * clean up panic message * try 16 core depot * try 8 core * Add debug flags to init-node.sh * More logging * Fix denom * Remove logging additions * default runner * update hardhat config * fix * re-opening branch to merge into main * add solidity to push group * regen contracts and fix solidity group * use default runner for solidity (again) * rebase and add stubs * add trace call with accesslist tracer config * fix lint: * conform to auto registration * revert tracer logic * fix signatures * fix nil pointer issues * rev local node pruning settings * remove custom pruning settings * rename var to be clearer * fix typo * remove unsigned tx logic from tests * group vars * add debug logs * update test pointer * fix nil gas * clean up traceTx conditional handling * fix vmerr * fix lint * add debug logs * add error and info logs * add test suite with actual backend mock * lint: add helper marker * standardize vars * remove unnecessary flag in run json compat * add back to exclusion * add godocs * add permalink * clarify auth checks * add changelog --------- Co-authored-by: Vlad J <[email protected]> Co-authored-by: Eric Warehime <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Aditya <[email protected]> Co-authored-by: Haber <[email protected]> Co-authored-by: Hyunwoo Lee <[email protected]>
* duplicate switch * add changelog
* wip upgrade test * upgrade test complete * make script * fix the order * remove that * fixes * fetch tags
* refactor mempool initialization to accept configs instead of objects * clean * add changelog
…log entry (cosmos#499) * attempt fix * test * read granularity * remove all conditions * default af * some more * try this * making a change * ok this should make it pass * and if i change it back it should fail * remove all go code cahnges to see if wf passes * re adding go code changes should trigger it * only run on specific types of PRs * an update * revert that * when its edited too * revert go code change
* chore: align balance change reason for tracing for more info, https://github.com/ethereum/go-ethereum/blob/v1.16.2/core/evm.go#L143 * cleanup deprecated BalanceChangeEntry for more info, https://github.com/cosmos/evm/pull/201/files * Revert "chore: align balance change reason for tracing" This reverts commit 07a628c.
* refactor: replace TestEncodingConfig with production EncodingConfig Replace the usage of sdktestutil.TestEncodingConfig with a proper production-ready EncodingConfig struct. This removes the dependency on test utilities in production code while maintaining full compatibility. Changes: - Define custom EncodingConfig struct with same fields as TestEncodingConfig - Remove import of cosmos-sdk/types/module/testutil - Update MakeConfig return type to use the new production struct This improves code quality by avoiding test dependencies in production code. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * chore: fix golangci-lint errors - Fix import ordering (gci) - Rename EncodingConfig to Config to avoid stuttering (revive) The type name change from EncodingConfig to Config addresses the lint warning about stuttering (encoding.EncodingConfig). Since the struct is only used as a return value from MakeConfig(), this change maintains backward compatibility. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * test: update ledger tests to use encoding.Config Update the ledger test files to use the new encoding.Config type instead of sdktestutil.TestEncodingConfig, following the changes made to the encoding package. Changes: - Update encCfg variable type from TestEncodingConfig to Config - Update NewKeyringAndCtxs parameter type to use Config - Add encoding import to evmosd_suite_test.go - Remove unused sdktestutil import 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> * docs: add CHANGELOG entry for encoding config refactor Add CHANGELOG.md entry documenting the replacement of TestEncodingConfig with production EncodingConfig in PR cosmos#513. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Kevin Kz <[email protected]> Co-authored-by: Claude <[email protected]>
* chore: allow value with slashes when query token_pairs * add doc --------- Co-authored-by: Alex | Interchain Labs <[email protected]>
…precompile # Conflicts: # tests/solidity/init-node.sh
cosmos#582) * add block max_gas and minimum_gas_prices to app * add changelog * move methods out to config * add godoc * add tests * try depot again * back to gh runner * fix changelog error * remove wack evmd argument * add new flag * update changelog desc * change spaces to tab * repoint constant and add log * add const docs and change log to warn * fix lint * rm flag change
* chore: bump to ibc-go v10.3.0 * chore: remove usage of subspace (cosmos#594) * chore: remove x/params and subspace usage * fix a whoopsie * lint * remove crisis module stuff for good measure * add changelog
* add mempool draft * add svg * update readme * add missing edge * make tx handler two lines * make ext mempool interface impl two lines
* add nested precompile reversion test case adds complex precompile reversions that occur within nested try catch blocks to test for cache stack reversions to specific IDs * changelog * Update tests/integration/precompiles/staking/test_integration.go Co-authored-by: Tyler <[email protected]> * remove changelog entry for test --------- Co-authored-by: Tyler <[email protected]> Co-authored-by: Alex | Interchain Labs <[email protected]>
* update blockchain context once per block * evmd tests pass but this is some pointer madness * no more pointer madness * changelog
cd x/precisebank/types && mockery --name BankKeeper --with-expecter --filename MockBankKeeper.go cd x/vm/types && mockery --name BankKeeper
* checkpoint * prometheus bridge * delete registry * some changes * enable metrics * move things to make more sense * some changes * fix lint * add some tests * add changelog entry * incredibly stupid simple way to do this * changelog --------- Co-authored-by: Alex | Interchain Labs <[email protected]>
* fix(mempool): checkTxHandler handles "invalid nonce" tx * chore: update CHANGELOG.md * test(mempool): fix integration test * test(mempool): refine test code * fix(mempool): fix checkTxHandler logic to prevent integer overflow. * test(ante) fix test code for sequence increment
* cache erc20 precompile abis instead * fix tests * lints
* feat: fill block and tx informations in json-rpc follow up for cosmos#576 (comment) add doc * fill ts --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]>
* fix: align tx not found in get_transaction_receipt * add doc * Revert "fix: align tx not found in get_transaction_receipt" This reverts commit d186723. * stop retry early for tx with unknown status --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]>
* separate geth metrics server * that should be a wrap * changelog lol * make server behave more like the others * move port to 8100, fix quoting problem * lint fix * expose in dockerfile
* move default static precompiles creator out of app.go and set as defaults * move defaults to precompile folder and use existing builder pattern * undo interface changes on tests * undo unnecessary changes * fix tests * lints * add sum docs
* imp: make erc20keeper optional in x/vm * add changelog --------- Co-authored-by: Vlad J <[email protected]>
* test(mempool): setup e2e test suite for mempool testing * WIP * test(mempool): refactor test * test(mempool): refactor system test suite * test(systemtest): refactor mempool test * test(systemtests): add cosmosClient * test(systemtests): refactor mempool test * test(systemtests): refactor mempool test * test(systemtests): refactor mempool test * test(systemtests): add txpool content verification to mempool tests * test(systemtests): fix mempool test suite * test(systemtests): fix mempool test suite * test(systemtests): fix mempool tests * test(systemtests): fix mempool test suite * test(systemtests): fix mempool test suite * test(systemtests): fix mempool test suite * test(systemtests): add mempool test cases * test(systemtests): add comments * test(systemtests): chore: enable replacement tests * chore: modify names of test cases * test(systemtests): enhance helper functions * test(systemtests): fix mempool test * chore(systemtests): change test name and add readme.md * chore: update CHANGELOG.md * fix(proto): restore removed data field during merge * test(systemtests): refactor * test(systemtests): fix map iteration * chore(systemtests): fix build tag * test(systemtests): add test case for mempool * test(systemtests): fix map iteration * test(systemtests): refactor and add test case for --minimum-gas-prices=0stake * test(systemtests): enhance validation * fix: restore removed changes from merge * fix: restore removed changes from merge * fix: restore removed changes from merge * fix: restore removed changes from merge * chore(systemtests): rename test suite hooks * fix(systemtests): fix test cases * chore: modify mempool e2e test README.md * test(systemtests): enhance post check of mempool test * chore: apply codeQL feedback * chore: update tests/systemtests/go.sum * chore: go mod tidy * fix(rpc): SendRawTransaction doesn't return error when tx.nonce is lower than pending nonce * chore(systemtests): remove unused fields of RPCTransaction type --------- Co-authored-by: Alex | Interchain Labs <[email protected]> Co-authored-by: Vlad J <[email protected]>
…precompile # Conflicts: # CHANGELOG.md
…nto feat/erc20-factory-precompile # Conflicts: # CHANGELOG.md
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days-before-close if no further activity occurs. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR implements event emission functionality for the ERC20 Factory precompile and fixes critical issues with event topic handling.
ERC20 Factory Precompile Overview
The ERC20 Factory precompile is a precompile deployed at address
0x0000000000000000000000000000000000000900that enables deterministic creation of ERC20 token pairs. It provides a factory pattern for deploying ERC20 tokens with predictable addresses.Core Functionality
The precompile bridges Ethereum-style ERC20 tokens with Cosmos SDK's bank module, automatically:
Available Methods
1.
create(uint8 tokenPairType, bytes32 salt, string name, string symbol, uint8 decimals) → addressTransaction Method | Gas Cost: 3,000,000
Creates a new ERC20 token pair and returns the deployed contract address.
Parameters:
tokenPairType: Type identifier for the token pair (uint8)salt: 32-byte salt for deterministic address generationname: Token name (3-128 characters)symbol: Token symbol (3-16 characters)decimals: Number of decimal places (uint8)Process:
Createevent2.
calculateAddress(uint8 tokenPairType, bytes32 salt) → addressView Method | Gas Cost: 3,000
Calculates the deterministic address where a token would be deployed without actually creating it.
Parameters:
tokenPairType: Type identifier for the token pairsalt: 32-byte salt for address calculationReturns: The calculated contract address using CREATE2 formula
Events Emitted
Create(address indexed tokenAddress, uint8 tokenPairType, bytes32 salt, string name, string symbol, uint8 decimals)Emitted when a new ERC20 token pair is successfully created.
Indexed Parameters:
tokenAddress: Address of the deployed token contractNon-Indexed Parameters:
tokenPairType: Type identifier used during creationsalt: Salt value used for deterministic deploymentname: Token namesymbol: Token symboldecimals: Decimal precisionIntegration with Cosmos SDK
The precompile seamlessly integrates with multiple Cosmos SDK modules:
Critical Files to Review
precompiles/erc20factory/events.go- Core event emission logicprecompiles/erc20factory/types.go- Event struct definitionsprecompiles/erc20factory/tx.go- Integration with Create methodtests/integration/precompiles/erc20factory/test_events.go- Go test coveragetests/solidity/suites/precompiles/test/erc20factory.js- JavaScript test coverageCloses: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
mainbranchReviewers Checklist
All items are required.
Please add a note if the item is not applicable
and please add your handle next to the items reviewed
if you only reviewed selected items.
I have...
Unreleasedsection inCHANGELOG.md