├── .gitignore
├── .semgrepignore
├── .solhint.json
├── LICENSE
├── Makefile
├── README.md
├── app
├── ante
│ ├── ante.go
│ ├── comission.go
│ ├── doc.go
│ ├── handler_options.go
│ └── interfaces.go
├── app.go
├── app_test.go
├── export.go
├── sigverify.go
├── sigverify_test.go
├── test_helpers.go
├── tps_counter.go
├── tps_counter_test.go
└── upgrades
│ └── v1_2_0
│ ├── constants.go
│ └── upgrades.go
├── client
└── docs
│ ├── statik
│ ├── init.go
│ └── statik.go
│ └── swagger-ui
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── index.html
│ ├── oauth2-redirect.html
│ ├── swagger-ui-bundle.js
│ ├── swagger-ui-standalone-preset.js
│ └── swagger-ui.css
├── cmd
├── acred
│ ├── cmd_test.go
│ ├── genaccounts.go
│ ├── genesis.go
│ ├── init.go
│ ├── main.go
│ ├── migrate.go
│ ├── root.go
│ └── testnet.go
└── config
│ ├── config.go
│ └── observability.go
├── contracts
├── ERC20Burnable.sol
├── ERC20DirectBalanceManipulation.sol
├── ERC20MaliciousDelayed.sol
├── ERC20MinterBurnerDecimals.sol
├── compiled_contracts
│ ├── ERC20Burnable.json
│ ├── ERC20DirectBalanceManipulation.json
│ ├── ERC20MaliciousDelayed.json
│ └── ERC20MinterBurnerDecimals.json
├── erc20.go
├── erc20DirectBalanceManipulation.go
├── erc20burnable.go
├── erc20maliciousdelayed.go
├── package-lock.json
└── package.json
├── crypto
└── keyring
│ └── options.go
├── dev_guide.md
├── ethermint
├── .bencher
│ └── config.yaml
├── .clang-format
├── .dockerignore
├── .flake8
├── .gitattributes
├── .gitignore
├── .golangci.yml
├── .goreleaser.yml
├── .markdownlint.yml
├── .markdownlintignore
├── .mergify.yml
├── .semgrepignore
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── Dockerfile
├── LICENSE
├── Makefile
├── README.md
├── app
│ ├── ante
│ │ ├── ante.go
│ │ ├── ante_test.go
│ │ ├── doc.go
│ │ ├── eip712.go
│ │ ├── eth.go
│ │ ├── eth_test.go
│ │ ├── fee_market.go
│ │ ├── fee_market_test.go
│ │ ├── fees.go
│ │ ├── fees_test.go
│ │ ├── handler_options.go
│ │ ├── interfaces.go
│ │ ├── reject_msgs.go
│ │ ├── sigs_test.go
│ │ └── utils_test.go
│ ├── app.go
│ ├── app_test.go
│ ├── benchmark_test.go
│ ├── export.go
│ ├── simulation_test.go
│ ├── utils.go
│ └── utils_test.go
├── buf.work.yaml
├── client
│ ├── config.go
│ ├── config_test.go
│ ├── debug
│ │ └── debug.go
│ ├── docs
│ │ ├── config.json
│ │ ├── statik
│ │ │ ├── init.go
│ │ │ └── statik.go
│ │ ├── swagger-ui
│ │ │ ├── favicon-16x16.png
│ │ │ ├── favicon-32x32.png
│ │ │ ├── index.html
│ │ │ ├── oauth2-redirect.html
│ │ │ ├── swagger-ui-bundle.js
│ │ │ ├── swagger-ui-standalone-preset.js
│ │ │ ├── swagger-ui.css
│ │ │ └── swagger.yaml
│ │ └── swagger_legacy.yaml
│ ├── export.go
│ ├── import.go
│ ├── keys.go
│ ├── keys
│ │ ├── add.go
│ │ ├── keys.go
│ │ └── utils.go
│ └── testnet.go
├── cmd
│ ├── config
│ │ ├── config.go
│ │ └── config_test.go
│ └── ethermintd
│ │ ├── cmd_test.go
│ │ ├── flags.go
│ │ ├── genaccounts.go
│ │ ├── main.go
│ │ └── root.go
├── codecov.yml
├── contrib
│ └── scripts
│ │ └── test_localnet_liveness.sh
├── crypto
│ ├── codec
│ │ ├── amino.go
│ │ └── codec.go
│ ├── ethsecp256k1
│ │ ├── benchmark_test.go
│ │ ├── ethsecp256k1.go
│ │ ├── ethsecp256k1_test.go
│ │ └── keys.pb.go
│ └── hd
│ │ ├── algorithm.go
│ │ ├── algorithm_test.go
│ │ └── benchmark_test.go
├── default.nix
├── docker-compose.yml
├── docs
│ ├── api
│ │ └── proto-docs.md
│ ├── architecture
│ │ ├── PROCESS.md
│ │ ├── README.md
│ │ ├── adr-001-state.md
│ │ ├── adr-002-evm-hooks.md
│ │ └── adr-template.md
│ ├── ethermint.jpg
│ └── protodoc-markdown.tmpl
├── encoding
│ ├── codec
│ │ └── codec.go
│ ├── config.go
│ └── config_test.go
├── ethereum
│ └── eip712
│ │ └── eip712.go
├── go.mod
├── go.sum
├── gomod2nix.toml
├── indexer
│ ├── kv_indexer.go
│ └── kv_indexer_test.go
├── init.bat
├── init.sh
├── networks
│ └── local
│ │ ├── Makefile
│ │ └── ethermintnode
│ │ └── Dockerfile
├── nix
│ ├── default.nix
│ ├── go-ethereum.nix
│ ├── go_1_18_overlay.nix
│ ├── scripts.nix
│ ├── sources.json
│ ├── sources.nix
│ └── testenv.nix
├── proto
│ ├── buf.yaml
│ └── ethermint
│ │ ├── crypto
│ │ └── v1
│ │ │ └── ethsecp256k1
│ │ │ └── keys.proto
│ │ ├── evm
│ │ └── v1
│ │ │ ├── evm.proto
│ │ │ ├── genesis.proto
│ │ │ ├── query.proto
│ │ │ └── tx.proto
│ │ ├── feemarket
│ │ └── v1
│ │ │ ├── feemarket.proto
│ │ │ ├── genesis.proto
│ │ │ └── query.proto
│ │ └── types
│ │ └── v1
│ │ ├── account.proto
│ │ ├── indexer.proto
│ │ └── web3.proto
├── rpc
│ ├── apis.go
│ ├── backend
│ │ ├── account_info.go
│ │ ├── backend.go
│ │ ├── backend_suite_test.go
│ │ ├── blocks_info.go
│ │ ├── call_tx.go
│ │ ├── chain_info.go
│ │ ├── client_test.go
│ │ ├── evm_backend_test.go
│ │ ├── filters.go
│ │ ├── mocks
│ │ │ ├── client.go
│ │ │ └── query_client.go
│ │ ├── node_info.go
│ │ ├── query_client_test.go
│ │ ├── sign_tx.go
│ │ ├── tracing.go
│ │ ├── tx_info.go
│ │ └── utils.go
│ ├── doc.go
│ ├── ethereum
│ │ └── pubsub
│ │ │ ├── pubsub.go
│ │ │ └── pubsub_test.go
│ ├── namespaces
│ │ └── ethereum
│ │ │ ├── debug
│ │ │ ├── api.go
│ │ │ ├── trace.go
│ │ │ ├── trace_fallback.go
│ │ │ └── utils.go
│ │ │ ├── eth
│ │ │ ├── api.go
│ │ │ └── filters
│ │ │ │ ├── api.go
│ │ │ │ ├── filter_system.go
│ │ │ │ ├── filters.go
│ │ │ │ ├── subscription.go
│ │ │ │ └── utils.go
│ │ │ ├── miner
│ │ │ ├── api.go
│ │ │ └── unsupported.go
│ │ │ ├── net
│ │ │ └── api.go
│ │ │ ├── personal
│ │ │ └── api.go
│ │ │ ├── txpool
│ │ │ └── api.go
│ │ │ └── web3
│ │ │ └── api.go
│ ├── types
│ │ ├── addrlock.go
│ │ ├── block.go
│ │ ├── block_test.go
│ │ ├── events.go
│ │ ├── events_test.go
│ │ ├── query_client.go
│ │ ├── types.go
│ │ └── utils.go
│ └── websockets.go
├── scripts
│ ├── .env
│ ├── contract-test.sh
│ ├── ethermint-devnet.yaml
│ ├── gen-tests-artifacts.sh
│ ├── geth-genesis.json
│ ├── integration-test-all.sh
│ ├── proto-tools-installer.sh
│ ├── protoc-swagger-gen.sh
│ ├── protocgen.sh
│ ├── run-integration-tests.sh
│ ├── run-solidity-tests.sh
│ ├── start-docker.sh
│ ├── start-ethermint.sh
│ ├── start-geth.sh
│ └── start.sh
├── server
│ ├── config
│ │ ├── config.go
│ │ ├── config_test.go
│ │ └── toml.go
│ ├── flags
│ │ └── flags.go
│ ├── indexer_cmd.go
│ ├── indexer_service.go
│ ├── json_rpc.go
│ ├── start.go
│ └── util.go
├── starport.yml
├── tests
│ ├── e2e
│ │ └── integration_test.go
│ ├── importer
│ │ ├── blockchain
│ │ ├── chain_ctx.go
│ │ ├── chain_ctx_test.go
│ │ └── importer_test.go
│ ├── integration_tests
│ │ ├── .isort.cfg
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── configs
│ │ │ ├── default.jsonnet
│ │ │ ├── enable-indexer.jsonnet
│ │ │ └── pruned_node.jsonnet
│ │ ├── conftest.py
│ │ ├── contracts
│ │ │ ├── .gitignore
│ │ │ ├── README.md
│ │ │ ├── contracts
│ │ │ │ ├── Greeter.sol
│ │ │ │ └── TestERC20A.sol
│ │ │ ├── hardhat.config.ts
│ │ │ ├── package-lock.json
│ │ │ ├── package.json
│ │ │ └── tsconfig.json
│ │ ├── expected_constants.py
│ │ ├── network.py
│ │ ├── poetry.lock
│ │ ├── pyproject.toml
│ │ ├── shell.nix
│ │ ├── test_basic.py
│ │ ├── test_filters.py
│ │ ├── test_pruned_node.py
│ │ ├── test_types.py
│ │ └── utils.py
│ ├── rpc
│ │ ├── net_test.go
│ │ ├── personal_test.go
│ │ ├── rpc_pending_test.go
│ │ ├── rpc_test.go
│ │ └── utils.go
│ ├── signer.go
│ ├── solidity
│ │ ├── .gitattributes
│ │ ├── .gitignore
│ │ ├── README.md
│ │ ├── init-test-node.sh
│ │ ├── package.json
│ │ ├── patches
│ │ │ └── truffle+5.4.14.patch
│ │ ├── suites
│ │ │ ├── basic
│ │ │ │ ├── contracts
│ │ │ │ │ ├── Counter.sol
│ │ │ │ │ ├── Storage.sol
│ │ │ │ │ ├── TestMessageCall.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ └── Migrations.sol
│ │ │ │ ├── migrations
│ │ │ │ │ └── 1_initial_migration.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ ├── .gitkeep
│ │ │ │ │ └── counter.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── eip1559
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ └── eip1559.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── exception
│ │ │ │ ├── contracts
│ │ │ │ │ ├── TestRevert.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ └── Migrations.sol
│ │ │ │ ├── migrations
│ │ │ │ │ └── 1_initial_migration.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ ├── .gitkeep
│ │ │ │ │ └── revert.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── initializable-buidler
│ │ │ │ ├── .gitignore
│ │ │ │ ├── buidler.config.js
│ │ │ │ ├── contracts
│ │ │ │ │ ├── Initializable.sol
│ │ │ │ │ ├── Petrifiable.sol
│ │ │ │ │ ├── TimeHelpers.sol
│ │ │ │ │ ├── Uint256Helpers.sol
│ │ │ │ │ ├── UnstructuredStorage.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ └── InitializableMock.sol
│ │ │ │ ├── package.json
│ │ │ │ └── test
│ │ │ │ │ └── lifecycle.js
│ │ │ ├── initializable
│ │ │ │ ├── contracts
│ │ │ │ │ ├── Initializable.sol
│ │ │ │ │ ├── Petrifiable.sol
│ │ │ │ │ ├── TimeHelpers.sol
│ │ │ │ │ ├── Uint256Helpers.sol
│ │ │ │ │ ├── UnstructuredStorage.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ ├── InitializableMock.sol
│ │ │ │ │ │ └── Migrations.sol
│ │ │ │ ├── migrations
│ │ │ │ │ └── 1_initial_migration.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ ├── .gitkeep
│ │ │ │ │ └── lifecycle.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── opcode
│ │ │ │ ├── bytecode.js
│ │ │ │ ├── contracts
│ │ │ │ │ ├── Migrations.sol
│ │ │ │ │ └── OpCodes.sol
│ │ │ │ ├── migrations
│ │ │ │ │ ├── 1_initial_migration.js
│ │ │ │ │ └── 2_opCodes_migration.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ └── opCodes.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── proxy
│ │ │ │ ├── contracts
│ │ │ │ │ ├── DelegateProxy.sol
│ │ │ │ │ ├── DepositableDelegateProxy.sol
│ │ │ │ │ ├── DepositableStorage.sol
│ │ │ │ │ ├── ERCProxy.sol
│ │ │ │ │ ├── IsContract.sol
│ │ │ │ │ ├── UnstructuredStorage.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ ├── DepositableDelegateProxyMock.sol
│ │ │ │ │ │ ├── EthSender.sol
│ │ │ │ │ │ ├── Migrations.sol
│ │ │ │ │ │ └── ProxyTarget.sol
│ │ │ │ ├── migrations
│ │ │ │ │ └── 1_initial_migration.js
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ │ ├── .gitkeep
│ │ │ │ │ └── depositable_delegate_proxy.js
│ │ │ │ └── truffle-config.js
│ │ │ ├── staking
│ │ │ │ ├── .github
│ │ │ │ │ └── workflows
│ │ │ │ │ │ └── ci_contracts.yml
│ │ │ │ ├── contracts
│ │ │ │ │ ├── Staking.sol
│ │ │ │ │ ├── StakingFactory.sol
│ │ │ │ │ ├── lib
│ │ │ │ │ │ ├── Checkpointing.sol
│ │ │ │ │ │ └── os
│ │ │ │ │ │ │ ├── Autopetrified.sol
│ │ │ │ │ │ │ ├── DelegateProxy.sol
│ │ │ │ │ │ │ ├── ERC20.sol
│ │ │ │ │ │ │ ├── ERCProxy.sol
│ │ │ │ │ │ │ ├── Initializable.sol
│ │ │ │ │ │ │ ├── IsContract.sol
│ │ │ │ │ │ │ ├── Migrations.sol
│ │ │ │ │ │ │ ├── Petrifiable.sol
│ │ │ │ │ │ │ ├── SafeERC20.sol
│ │ │ │ │ │ │ ├── SafeMath.sol
│ │ │ │ │ │ │ ├── SafeMath64.sol
│ │ │ │ │ │ │ ├── ScriptHelpers.sol
│ │ │ │ │ │ │ ├── TimeHelpers.sol
│ │ │ │ │ │ │ ├── Uint256Helpers.sol
│ │ │ │ │ │ │ └── UnstructuredStorage.sol
│ │ │ │ │ ├── locking
│ │ │ │ │ │ ├── ILockManager.sol
│ │ │ │ │ │ ├── IStakingLocking.sol
│ │ │ │ │ │ └── TimeLockManager.sol
│ │ │ │ │ ├── proxies
│ │ │ │ │ │ ├── StakingProxy.sol
│ │ │ │ │ │ └── ThinProxy.sol
│ │ │ │ │ ├── standards
│ │ │ │ │ │ └── ERC900.sol
│ │ │ │ │ └── test
│ │ │ │ │ │ ├── TestImports.sol
│ │ │ │ │ │ ├── lib
│ │ │ │ │ │ ├── EchidnaStaking.sol
│ │ │ │ │ │ ├── ITokenController.sol
│ │ │ │ │ │ └── MiniMeToken.sol
│ │ │ │ │ │ └── mocks
│ │ │ │ │ │ ├── BadTokenMock.sol
│ │ │ │ │ │ ├── CheckpointingMock.sol
│ │ │ │ │ │ ├── ERC20.sol
│ │ │ │ │ │ ├── LockManagerMock.sol
│ │ │ │ │ │ ├── NoApproveTokenMock.sol
│ │ │ │ │ │ ├── StakingMock.sol
│ │ │ │ │ │ ├── StandardTokenMock.sol
│ │ │ │ │ │ ├── TimeHelpersMock.sol
│ │ │ │ │ │ └── TimeLockManagerMock.sol
│ │ │ │ ├── package.json
│ │ │ │ ├── patches
│ │ │ │ │ ├── @aragon+contract-helpers-test+0.0.3.patch
│ │ │ │ │ └── truffle+5.4.14.patch
│ │ │ │ ├── test
│ │ │ │ │ ├── approve_and_call.js
│ │ │ │ │ ├── gas.js
│ │ │ │ │ ├── helpers
│ │ │ │ │ │ ├── constants.js
│ │ │ │ │ │ ├── deploy.js
│ │ │ │ │ │ ├── errors.js
│ │ │ │ │ │ └── helpers.js
│ │ │ │ │ ├── lib
│ │ │ │ │ │ └── checkpointing.js
│ │ │ │ │ ├── locking
│ │ │ │ │ │ ├── funds_flows.js
│ │ │ │ │ │ ├── locking.js
│ │ │ │ │ │ └── locking_time.js
│ │ │ │ │ ├── staking.js
│ │ │ │ │ ├── staking_factory.js
│ │ │ │ │ ├── staking_proxy.js
│ │ │ │ │ └── transfers.js
│ │ │ │ └── truffle-config.js
│ │ │ └── storage
│ │ │ │ ├── contracts
│ │ │ │ ├── EventTest.sol
│ │ │ │ └── Storage.sol
│ │ │ │ ├── package.json
│ │ │ │ ├── test
│ │ │ │ ├── .gitkeep
│ │ │ │ ├── 0_test_contracts.test.js
│ │ │ │ ├── 1_test_evm_revert.test.js
│ │ │ │ └── 2_test_events.test.js
│ │ │ │ └── truffle-config.js
│ │ ├── test-helper.js
│ │ └── yarn.lock
│ └── tooling
│ │ └── ethers
│ │ └── ethers.js
├── testutil
│ ├── fund.go
│ └── network
│ │ ├── doc.go
│ │ ├── network.go
│ │ ├── network_test.go
│ │ └── util.go
├── third_party
│ └── proto
│ │ ├── buf.yaml
│ │ ├── cosmos
│ │ ├── auth
│ │ │ └── v1beta1
│ │ │ │ ├── auth.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ └── query.proto
│ │ ├── authz
│ │ │ └── v1beta1
│ │ │ │ ├── authz.proto
│ │ │ │ ├── event.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── bank
│ │ │ └── v1beta1
│ │ │ │ ├── authz.proto
│ │ │ │ ├── bank.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── base
│ │ │ ├── abci
│ │ │ │ └── v1beta1
│ │ │ │ │ └── abci.proto
│ │ │ ├── kv
│ │ │ │ └── v1beta1
│ │ │ │ │ └── kv.proto
│ │ │ ├── query
│ │ │ │ └── v1beta1
│ │ │ │ │ └── pagination.proto
│ │ │ ├── reflection
│ │ │ │ ├── v1beta1
│ │ │ │ │ └── reflection.proto
│ │ │ │ └── v2alpha1
│ │ │ │ │ └── reflection.proto
│ │ │ ├── snapshots
│ │ │ │ └── v1beta1
│ │ │ │ │ └── snapshot.proto
│ │ │ ├── store
│ │ │ │ └── v1beta1
│ │ │ │ │ ├── commit_info.proto
│ │ │ │ │ ├── listening.proto
│ │ │ │ │ └── snapshot.proto
│ │ │ ├── tendermint
│ │ │ │ └── v1beta1
│ │ │ │ │ └── query.proto
│ │ │ └── v1beta1
│ │ │ │ └── coin.proto
│ │ ├── capability
│ │ │ └── v1beta1
│ │ │ │ ├── capability.proto
│ │ │ │ └── genesis.proto
│ │ ├── crisis
│ │ │ └── v1beta1
│ │ │ │ ├── genesis.proto
│ │ │ │ └── tx.proto
│ │ ├── crypto
│ │ │ ├── ed25519
│ │ │ │ └── keys.proto
│ │ │ ├── multisig
│ │ │ │ ├── keys.proto
│ │ │ │ └── v1beta1
│ │ │ │ │ └── multisig.proto
│ │ │ ├── secp256k1
│ │ │ │ └── keys.proto
│ │ │ └── secp256r1
│ │ │ │ └── keys.proto
│ │ ├── distribution
│ │ │ └── v1beta1
│ │ │ │ ├── distribution.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── evidence
│ │ │ └── v1beta1
│ │ │ │ ├── evidence.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── feegrant
│ │ │ └── v1beta1
│ │ │ │ ├── feegrant.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── genutil
│ │ │ └── v1beta1
│ │ │ │ └── genesis.proto
│ │ ├── gov
│ │ │ └── v1beta1
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── gov.proto
│ │ │ │ ├── query.proto
│ │ │ │ └── tx.proto
│ │ ├── mint
│ │ │ └── v1beta1
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── mint.proto
│ │ │ │ └── query.proto
│ │ ├── params
│ │ │ └── v1beta1
│ │ │ │ ├── params.proto
│ │ │ │ └── query.proto
│ │ ├── slashing
│ │ │ └── v1beta1
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ ├── slashing.proto
│ │ │ │ └── tx.proto
│ │ ├── staking
│ │ │ └── v1beta1
│ │ │ │ ├── authz.proto
│ │ │ │ ├── genesis.proto
│ │ │ │ ├── query.proto
│ │ │ │ ├── staking.proto
│ │ │ │ └── tx.proto
│ │ ├── tx
│ │ │ ├── signing
│ │ │ │ └── v1beta1
│ │ │ │ │ └── signing.proto
│ │ │ └── v1beta1
│ │ │ │ ├── service.proto
│ │ │ │ └── tx.proto
│ │ ├── upgrade
│ │ │ └── v1beta1
│ │ │ │ ├── query.proto
│ │ │ │ └── upgrade.proto
│ │ └── vesting
│ │ │ └── v1beta1
│ │ │ ├── tx.proto
│ │ │ └── vesting.proto
│ │ ├── cosmos_proto
│ │ └── cosmos.proto
│ │ ├── gogoproto
│ │ └── gogo.proto
│ │ ├── google
│ │ ├── api
│ │ │ ├── annotations.proto
│ │ │ ├── http.proto
│ │ │ └── httpbody.proto
│ │ └── protobuf
│ │ │ ├── any.proto
│ │ │ └── descriptor.proto
│ │ └── tendermint
│ │ ├── abci
│ │ └── types.proto
│ │ ├── crypto
│ │ ├── keys.proto
│ │ └── proof.proto
│ │ ├── libs
│ │ └── bits
│ │ │ └── types.proto
│ │ ├── p2p
│ │ └── types.proto
│ │ ├── types
│ │ ├── block.proto
│ │ ├── evidence.proto
│ │ ├── params.proto
│ │ ├── types.proto
│ │ └── validator.proto
│ │ └── version
│ │ └── types.proto
├── tools
│ └── tools.go
├── types
│ ├── account.go
│ ├── account.pb.go
│ ├── account_test.go
│ ├── benchmark_test.go
│ ├── block.go
│ ├── chain_id.go
│ ├── chain_id_test.go
│ ├── codec.go
│ ├── coin.go
│ ├── errors.go
│ ├── gasmeter.go
│ ├── hdpath.go
│ ├── indexer.go
│ ├── indexer.pb.go
│ ├── int.go
│ ├── protocol.go
│ ├── validation.go
│ ├── validation_test.go
│ └── web3.pb.go
├── version
│ └── version.go
└── x
│ ├── README.md
│ ├── evm
│ ├── client
│ │ ├── cli
│ │ │ ├── query.go
│ │ │ ├── tx.go
│ │ │ ├── utils.go
│ │ │ └── utils_test.go
│ │ └── rest
│ │ │ └── rest.go
│ ├── genesis.go
│ ├── genesis_test.go
│ ├── handler.go
│ ├── handler_test.go
│ ├── keeper
│ │ ├── abci.go
│ │ ├── benchmark_test.go
│ │ ├── contracts
│ │ │ ├── ERC20Burnable.sol
│ │ │ ├── ERC20DirectBalanceManipulation.sol
│ │ │ ├── ERC20MaliciousDelayed.sol
│ │ │ ├── ERC20MinterBurnerDecimals.sol
│ │ │ ├── compiled_contracts
│ │ │ │ ├── ERC20Burnable.json
│ │ │ │ ├── ERC20DirectBalanceManipulation.json
│ │ │ │ ├── ERC20MaliciousDelayed.json
│ │ │ │ └── ERC20MinterBurnerDecimals.json
│ │ │ ├── erc20.go
│ │ │ ├── erc20DirectBalanceManipulation.go
│ │ │ ├── erc20burnable.go
│ │ │ ├── erc20maliciousdelayed.go
│ │ │ ├── package-lock.json
│ │ │ └── package.json
│ │ ├── erc20.go
│ │ ├── grpc_query.go
│ │ ├── grpc_query_test.go
│ │ ├── hooks.go
│ │ ├── hooks_test.go
│ │ ├── integration_test.go
│ │ ├── keeper.go
│ │ ├── keeper_test.go
│ │ ├── migrations.go
│ │ ├── msg_server.go
│ │ ├── params.go
│ │ ├── params_test.go
│ │ ├── state_transition.go
│ │ ├── state_transition_benchmark_test.go
│ │ ├── state_transition_test.go
│ │ ├── statedb.go
│ │ ├── statedb_benchmark_test.go
│ │ ├── statedb_test.go
│ │ ├── utils.go
│ │ └── utils_test.go
│ ├── migrations
│ │ ├── v2
│ │ │ ├── migrate.go
│ │ │ ├── migrate_test.go
│ │ │ └── types
│ │ │ │ ├── chain_config.go
│ │ │ │ ├── evm.pb.go
│ │ │ │ └── params.go
│ │ └── v3
│ │ │ ├── migrate.go
│ │ │ ├── migrate_test.go
│ │ │ └── types
│ │ │ ├── chain_config.go
│ │ │ ├── evm.pb.go
│ │ │ └── params.go
│ ├── module.go
│ ├── simulation
│ │ ├── decoder.go
│ │ ├── decoder_test.go
│ │ ├── genesis.go
│ │ ├── genesis_test.go
│ │ ├── operations.go
│ │ ├── params.go
│ │ └── params_test.go
│ ├── spec
│ │ ├── 01_concepts.md
│ │ ├── 02_state.md
│ │ ├── 03_state_transitions.md
│ │ ├── 04_transactions.md
│ │ ├── 05_abci.md
│ │ ├── 06_hooks.md
│ │ ├── 07_events.md
│ │ ├── 08_params.md
│ │ ├── 09_client.md
│ │ └── README.md
│ ├── statedb
│ │ ├── access_list.go
│ │ ├── config.go
│ │ ├── interfaces.go
│ │ ├── journal.go
│ │ ├── mock_test.go
│ │ ├── state_object.go
│ │ ├── statedb.go
│ │ └── statedb_test.go
│ └── types
│ │ ├── ERC20Contract.json
│ │ ├── SimpleStorageContract.json
│ │ ├── TestMessageCall.json
│ │ ├── access_list.go
│ │ ├── access_list_test.go
│ │ ├── access_list_tx.go
│ │ ├── access_list_tx_test.go
│ │ ├── chain_config.go
│ │ ├── chain_config_test.go
│ │ ├── codec.go
│ │ ├── codec_test.go
│ │ ├── compiled_contract.go
│ │ ├── config.go
│ │ ├── dynamic_fee_tx.go
│ │ ├── dynamic_fee_tx_test.go
│ │ ├── errors.go
│ │ ├── errors_test.go
│ │ ├── events.go
│ │ ├── evm.pb.go
│ │ ├── genesis.go
│ │ ├── genesis.pb.go
│ │ ├── genesis_test.go
│ │ ├── interfaces.go
│ │ ├── key.go
│ │ ├── legacy_tx.go
│ │ ├── legacy_tx_test.go
│ │ ├── logs.go
│ │ ├── logs_test.go
│ │ ├── msg.go
│ │ ├── msg_test.go
│ │ ├── params.go
│ │ ├── params_test.go
│ │ ├── query.go
│ │ ├── query.pb.go
│ │ ├── query.pb.gw.go
│ │ ├── storage.go
│ │ ├── storage_test.go
│ │ ├── tracer.go
│ │ ├── tracer_test.go
│ │ ├── tx.go
│ │ ├── tx.pb.go
│ │ ├── tx.pb.gw.go
│ │ ├── tx_args.go
│ │ ├── tx_data.go
│ │ ├── tx_data_test.go
│ │ ├── utils.go
│ │ └── utils_test.go
│ └── feemarket
│ ├── client
│ └── cli
│ │ └── query.go
│ ├── genesis.go
│ ├── keeper
│ ├── abci.go
│ ├── abci_test.go
│ ├── eip1559.go
│ ├── eip1559_test.go
│ ├── grpc_query.go
│ ├── grpc_query_test.go
│ ├── integration_test.go
│ ├── keeper.go
│ ├── keeper_test.go
│ ├── migrations.go
│ ├── migrations_test.go
│ ├── params.go
│ └── params_test.go
│ ├── migrations
│ ├── v010
│ │ ├── migrate.go
│ │ ├── migrate_test.go
│ │ └── types
│ │ │ ├── feemarket.pb.go
│ │ │ ├── genesis.pb.go
│ │ │ └── params.go
│ ├── v011
│ │ ├── migrate.go
│ │ └── migrate_test.go
│ └── v09
│ │ └── types
│ │ ├── feemarket.pb.go
│ │ └── genesis.pb.go
│ ├── module.go
│ ├── simulation
│ └── genesis.go
│ ├── spec
│ ├── 01_concepts.md
│ ├── 02_state.md
│ ├── 03_begin_block.md
│ ├── 04_end_block.md
│ ├── 05_keeper.md
│ ├── 06_events.md
│ ├── 07_params.md
│ ├── 08_client.md
│ ├── 09_antehandlers.md
│ ├── 10_future_improvements.md
│ └── README.md
│ └── types
│ ├── events.go
│ ├── feemarket.pb.go
│ ├── genesis.go
│ ├── genesis.pb.go
│ ├── genesis_test.go
│ ├── keys.go
│ ├── params.go
│ ├── params_test.go
│ ├── query.pb.go
│ └── query.pb.gw.go
├── go.mod
├── go.sum
├── ibc
├── module.go
├── module_test.go
├── testing
│ ├── README.md
│ ├── app.go
│ ├── chain.go
│ └── coordinator.go
├── utils.go
└── utils_test.go
├── init.sh
├── install.md
├── networks
├── mainnet
│ └── acre_9052-1
│ │ ├── README.md
│ │ ├── genesis.json
│ │ ├── gentx.md
│ │ ├── gentx
│ │ ├── ARABLE_Vanguard.json
│ │ ├── B-Harvest.json
│ │ ├── BitCat.json
│ │ ├── BitNordic.json
│ │ ├── CapitalMagnate.json
│ │ ├── ChainofSecrets-org.json
│ │ ├── Chrysoprase.json
│ │ ├── Coinstamp.json
│ │ ├── D-stake.json
│ │ ├── Enigma.json
│ │ ├── Everstake.json
│ │ ├── GalaxyStaking.json
│ │ ├── HashQuark.json
│ │ ├── HodlGlobal.json
│ │ ├── Illuminati.json
│ │ ├── InBWeT.json
│ │ ├── KaliaNetwork.json
│ │ ├── MachFund.json
│ │ ├── Masternode24.json
│ │ ├── MatrixStake.json
│ │ ├── Matrixed.Link.json
│ │ ├── MindHeartSoul.json
│ │ ├── Noderunners.json
│ │ ├── OrbitalApes.com.json
│ │ ├── P-OPS Team.json
│ │ ├── QwertySoftware.json
│ │ ├── Stake-Take.json
│ │ ├── Stake-or-Die!.json
│ │ ├── Stake.Works.json
│ │ ├── Staketab.json
│ │ ├── Synergy-Nodes-gentx.json
│ │ ├── TheNOP.io.json
│ │ ├── Validatorrun.json
│ │ ├── VaultStaking.json
│ │ ├── Web3ident.json
│ │ ├── Wetez.json
│ │ ├── Yurbason.json
│ │ ├── anonstake.json
│ │ ├── azstake.json
│ │ ├── blockscape.json
│ │ ├── blockswell.json
│ │ ├── ericet.json
│ │ ├── frenchchocolatine.json
│ │ ├── gentx-AutoStake.json
│ │ ├── gentx-NodeStake.json
│ │ ├── gentx-PFC.json
│ │ ├── gentx-dankuzone_w_daic.json
│ │ ├── gentx-frens.json
│ │ ├── gentx-mandragora.json
│ │ ├── gentx-zenscape.json
│ │ ├── highstakes.json
│ │ ├── itgoldio.json
│ │ ├── jet-node.json
│ │ ├── lux8net.json
│ │ ├── marionode.json
│ │ ├── namdokmai.json
│ │ ├── ramuchi.tech.json
│ │ ├── silent.json
│ │ ├── skynet-validators.json
│ │ ├── web34ever.json
│ │ └── windpowerstake.json
│ │ ├── peers.md
│ │ ├── rpc.md
│ │ └── validator.md
└── testnet
│ ├── bamboo_9051-1
│ ├── genesis.json
│ └── peers.md
│ └── bamboo_9051-2
│ ├── README.md
│ ├── genesis.json
│ ├── gentx.md
│ ├── gentx
│ ├── Everstake.json
│ ├── Kalia-Network.json
│ ├── MindHeartSoul.json
│ ├── Staketab.json
│ ├── Synergy-Nodes-bamboo_9051-2-gentx.json
│ ├── anonstake.json
│ ├── frenchchocolatine.json
│ ├── gentx-NodeStake.json
│ └── jet-node.json
│ ├── peers.md
│ └── rpc.md
├── proto
└── acrechain
│ ├── erc20
│ ├── erc20.proto
│ ├── genesis.proto
│ ├── query.proto
│ └── tx.proto
│ └── mint
│ └── v1beta1
│ ├── genesis.proto
│ ├── mint.proto
│ └── query.proto
├── scripts
├── proto-tools-installer.sh
└── protocgen.sh
├── testutil
├── fund.go
└── network
│ ├── doc.go
│ ├── network.go
│ ├── network_test.go
│ └── util.go
├── types
├── errors.go
└── utils.go
├── version
└── version.go
└── x
├── erc20
├── client
│ ├── cli
│ │ ├── query.go
│ │ ├── tx.go
│ │ └── utils.go
│ ├── proposal_handler.go
│ └── rest
│ │ └── rest.go
├── genesis.go
├── genesis_test.go
├── handler.go
├── keeper
│ ├── evm.go
│ ├── evm_hooks.go
│ ├── evm_hooks_test.go
│ ├── evm_test.go
│ ├── grpc_query.go
│ ├── grpc_query_test.go
│ ├── keeper.go
│ ├── keeper_test.go
│ ├── migrations.go
│ ├── mint.go
│ ├── mint_test.go
│ ├── msg_server.go
│ ├── msg_server_test.go
│ ├── params.go
│ ├── params_test.go
│ ├── proposals.go
│ ├── proposals_test.go
│ ├── token_pairs.go
│ └── token_pairs_test.go
├── module.go
├── proposal_handler.go
├── spec
│ ├── 01_concepts.md
│ ├── 02_state.md
│ ├── 03_state_transitions.md
│ ├── 04_transactions.md
│ ├── 05_hooks.md
│ ├── 06_events.md
│ ├── 07_parameters.md
│ ├── 08_clients.md
│ └── README.md
└── types
│ ├── codec.go
│ ├── erc20.pb.go
│ ├── errors.go
│ ├── events.go
│ ├── evm.go
│ ├── evm_test.go
│ ├── genesis.go
│ ├── genesis.pb.go
│ ├── genesis_test.go
│ ├── interfaces.go
│ ├── keys.go
│ ├── msg.go
│ ├── msg_test.go
│ ├── params.go
│ ├── params_test.go
│ ├── proposal.go
│ ├── proposal_test.go
│ ├── query.pb.go
│ ├── query.pb.gw.go
│ ├── token_pair.go
│ ├── token_pair_test.go
│ ├── tx.pb.go
│ ├── tx.pb.gw.go
│ ├── utils.go
│ └── utils_test.go
└── mint
├── client
└── cli
│ └── query.go
├── keeper
├── abci.go
├── abci_test.go
├── distribute.go
├── genesis.go
├── grpc_query.go
├── info.go
├── keeper.go
├── keeper_test.go
├── params.go
└── params_test.go
├── module.go
├── simulation
├── decoder.go
└── genesis.go
└── types
├── codec.go
├── errors.go
├── events.go
├── expected_keepers.go
├── genesis.go
├── genesis.pb.go
├── hooks.go
├── keys.go
├── mint.pb.go
├── minter.go
├── params.go
├── query.pb.go
└── query.pb.gw.go
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS
2 | .DS_Store
3 | *.swp
4 | *.swo
5 | *.swl
6 | *.swm
7 | *.swn
8 | .vscode
9 | .idea
10 | *.pyc
11 | *.exe
12 | *.exe~
13 | *.dll
14 | *.so
15 | *.dylib
16 | .dccache
17 |
18 | # Build
19 | *.test
20 | .glide/
21 | vendor
22 | build
23 | bin
24 | tools/bin/*
25 | docs/_build
26 | docs/tutorial
27 | docs/node_modules
28 | docs/modules
29 | docs/cosmos-sdk
30 | docs/ethermint
31 | docs/ibc-go
32 | dist
33 | tools-stamp
34 | docs-tools-stamp
35 | proto-tools-stamp
36 | golangci-lint
37 | keyring_test_cosmos
38 | ./**/dist
39 | secret.yml
40 | artifacts/*
41 | tmp-swagger-gen
42 | github.com/
43 | # vue/
44 |
45 | # Local docker volume mappings
46 | localnet-setup
47 | .testnets
48 |
49 | # Testing
50 | coverage.txt
51 | *.out
52 | sim_log_file
53 | tests/**/tmp/*
54 | yarn.lock
55 |
56 | # Vagrant
57 | .vagrant/
58 | *.box
59 | *.log
60 | vagrant
61 |
62 | # IDE
63 | .idea/
64 | *.iml
65 | *.code-workspace
66 |
67 | # Graphviz
68 | dependency-graph.png
69 |
70 | # Latex
71 | *.aux
72 | *.out
73 | *.synctex.gz
74 |
75 | # Contracts
76 | *.bin
77 | *.abi
78 |
79 | # Node.js
80 | **/node_modules
81 |
82 |
83 | # OpenZeppelin contracts
84 | contracts/@openzeppelin/*
85 |
--------------------------------------------------------------------------------
/.semgrepignore:
--------------------------------------------------------------------------------
1 | # Ignore git items
2 | .gitignore
3 | .git/
4 | :include .gitignore
5 |
6 | # Common large paths
7 | node_modules/
8 | build/
9 | dist/
10 | vendor/
11 | .env/
12 | .venv/
13 | .tox/
14 | *.min.js
15 |
16 | # Ignore proto
17 | *.proto
18 |
19 | # Common test paths
20 | test/
21 | tests/
22 | *_test.go
23 | *.pb.gw.go
24 | *.pb.go
25 |
26 | # Semgrep rules folder
27 | .semgrep
28 |
29 | # Semgrep-action log folder
30 | .semgrep_logs/
31 |
32 | # Documentation
33 | client/docs/
--------------------------------------------------------------------------------
/.solhint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "solhint:default"
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
Acrechain
8 |
9 |
10 | Acrechain is a scalable, high-throughput Proof-of-Stake blockchain that is fully compatible and
11 | interoperable with Ethereum. It's built using the [Cosmos SDK](https://github.com/cosmos/cosmos-sdk/) which runs on top of [Tendermint Core](https://github.com/tendermint/tendermint) consensus engine.
12 |
13 | **Note**: Requires [Go 1.18+](https://golang.org/dl/)
14 |
15 | ## Installation
16 |
17 | Once the dependencies are installed, run:
18 |
19 | ```bash
20 | make install
21 | ```
22 |
23 | ## Community
24 |
25 | The following chat channels and forums are a great spot to ask questions about Arable:
26 |
27 | - [Arable Twitter](https://twitter.com/ArableProtocol)
28 | - [Arable Discord](https://discord.com/invite/arable)
29 | - [Arable Telegram](https://t.me/ArableProtocol)
30 | - [Arable Medium](https://medium.com/@ArableProtocol)
31 |
--------------------------------------------------------------------------------
/app/ante/doc.go:
--------------------------------------------------------------------------------
1 | /*Package ante defines the SDK auth module's AnteHandler as well as an internal
2 | AnteHandler for an Ethereum transaction (i.e MsgEthereumTx).
3 |
4 | During CheckTx, the transaction is passed through a series of
5 | pre-message execution validation checks such as signature and account
6 | verification in addition to minimum fees being checked. Otherwise, during
7 | DeliverTx, the transaction is simply passed to the EVM which will also
8 | perform the same series of checks. The distinction is made in CheckTx to
9 | prevent spam and DoS attacks.
10 | */
11 | package ante
12 |
--------------------------------------------------------------------------------
/app/ante/interfaces.go:
--------------------------------------------------------------------------------
1 | package ante
2 |
3 | import (
4 | "math/big"
5 |
6 | sdk "github.com/cosmos/cosmos-sdk/types"
7 | "github.com/ethereum/go-ethereum/params"
8 | evmtypes "github.com/evmos/ethermint/x/evm/types"
9 | )
10 |
11 | // EvmKeeper defines the expected keeper interface used on the AnteHandler
12 | type EvmKeeper interface {
13 | GetParams(ctx sdk.Context) (params evmtypes.Params)
14 | ChainID() *big.Int
15 | GetBaseFee(ctx sdk.Context, ethCfg *params.ChainConfig) *big.Int
16 | }
17 |
--------------------------------------------------------------------------------
/app/upgrades/v1_2_0/constants.go:
--------------------------------------------------------------------------------
1 | package v1_2_0
2 |
3 | const (
4 | // UpgradeName is the shared upgrade plan name for mainnet
5 | UpgradeName = "v1.2.0"
6 | )
7 |
--------------------------------------------------------------------------------
/app/upgrades/v1_2_0/upgrades.go:
--------------------------------------------------------------------------------
1 | package v1_2_0
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | "github.com/cosmos/cosmos-sdk/types/module"
6 | upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
7 | )
8 |
9 | // CreateUpgradeHandler creates an SDK upgrade handler for v10
10 | func CreateUpgradeHandler(
11 | mm *module.Manager,
12 | configurator module.Configurator,
13 | ) upgradetypes.UpgradeHandler {
14 | return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
15 | return mm.RunMigrations(ctx, configurator, vm)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/client/docs/statik/init.go:
--------------------------------------------------------------------------------
1 | package statik
2 |
3 | // unnamed import of statik for swagger UI support
4 | // override ethermint statik by importing it
5 | // nolint
6 | import _ "github.com/evmos/ethermint/client/docs/statik"
7 |
8 | // This just for fixing the error in importing empty github.com/evmos/ethermint/client/docs/statik
9 |
--------------------------------------------------------------------------------
/client/docs/swagger-ui/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/client/docs/swagger-ui/favicon-16x16.png
--------------------------------------------------------------------------------
/client/docs/swagger-ui/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/client/docs/swagger-ui/favicon-32x32.png
--------------------------------------------------------------------------------
/cmd/acred/cmd_test.go:
--------------------------------------------------------------------------------
1 | package main_test
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 |
7 | "github.com/cosmos/cosmos-sdk/client/flags"
8 | svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
9 | "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
10 | "github.com/stretchr/testify/require"
11 |
12 | "github.com/ArableProtocol/acrechain/app"
13 | acred "github.com/ArableProtocol/acrechain/cmd/acred"
14 | )
15 |
16 | func TestInitCmd(t *testing.T) {
17 | rootCmd, _ := acred.NewRootCmd()
18 | rootCmd.SetArgs([]string{
19 | "init", // Test the init cmd
20 | "acre-test", // Moniker
21 | fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists
22 | fmt.Sprintf("--%s=%s", flags.FlagChainID, "acre_9051-1"),
23 | })
24 |
25 | err := svrcmd.Execute(rootCmd, app.DefaultNodeHome)
26 | require.NoError(t, err)
27 | }
28 |
29 | func TestAddKeyLedgerCmd(t *testing.T) {
30 | rootCmd, _ := acred.NewRootCmd()
31 | rootCmd.SetArgs([]string{
32 | "keys",
33 | "add",
34 | "mykey",
35 | fmt.Sprintf("--%s", flags.FlagUseLedger),
36 | })
37 |
38 | err := svrcmd.Execute(rootCmd, app.DefaultNodeHome)
39 | require.Error(t, err)
40 | }
41 |
--------------------------------------------------------------------------------
/cmd/acred/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 |
6 | "github.com/cosmos/cosmos-sdk/server"
7 | svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
8 | sdk "github.com/cosmos/cosmos-sdk/types"
9 |
10 | "github.com/ArableProtocol/acrechain/app"
11 | cmdcfg "github.com/ArableProtocol/acrechain/cmd/config"
12 | )
13 |
14 | func main() {
15 | setupConfig()
16 | cmdcfg.RegisterDenoms()
17 |
18 | rootCmd, _ := NewRootCmd()
19 |
20 | if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
21 | switch e := err.(type) {
22 | case server.ErrorCode:
23 | os.Exit(e.Code)
24 |
25 | default:
26 | os.Exit(1)
27 | }
28 | }
29 | }
30 |
31 | func setupConfig() {
32 | // set the address prefixes
33 | config := sdk.GetConfig()
34 | cmdcfg.SetBech32Prefixes(config)
35 | // TODO fix
36 | // if err := cmdcfg.EnableObservability(); err != nil {
37 | // panic(err)
38 | // }
39 | cmdcfg.SetBip44CoinType(config)
40 | config.Seal()
41 | }
42 |
--------------------------------------------------------------------------------
/contracts/ERC20DirectBalanceManipulation.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity ^0.8.0;
4 |
5 | import "./@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
6 |
7 | // This is an evil token. Whenever an A -> B transfer is called, half of the amount goes to B
8 | // and half to a predefined C
9 | contract ERC20DirectBalanceManipulation is ERC20PresetMinterPauser {
10 | address private _thief = 0x4dC6ac40Af078661fc43823086E1513635Eeab14;
11 | constructor(uint256 initialSupply)
12 | ERC20PresetMinterPauser("ERC20DirectBalanceManipulation", "ERC20DirectBalanceManipulation") {
13 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
14 | _mint(msg.sender, initialSupply);
15 | }
16 | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
17 | // Any time a transaction happens, the thief account siphons half.
18 | uint256 half = amount / 2;
19 |
20 | super.transfer(_thief, amount - half); // a - h for rounding
21 | return super.transfer(recipient, half);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/contracts/ERC20MaliciousDelayed.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity ^0.8.0;
4 |
5 | import "./@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
6 |
7 | // This is an evil token. Whenever an A -> B transfer is called,
8 | // a predefined C is given a massive allowance on B.
9 | contract ERC20MaliciousDelayed is ERC20PresetMinterPauser {
10 | address private _thief = 0x4dC6ac40Af078661fc43823086E1513635Eeab14;
11 | uint256 private _bigNum = 1000000000000000000; // ~uint256(0)
12 | constructor(uint256 initialSupply)
13 | ERC20PresetMinterPauser("ERC20MaliciousDelayed", "ERC20MALICIOUSDELAYED") {
14 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
15 | _mint(msg.sender, initialSupply);
16 |
17 | }
18 | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
19 | // Any time a transaction happens, the thief account is granted allowance in secret.
20 | // Still emits an Approve!
21 | super._approve(recipient, _thief, _bigNum);
22 | return super.transfer(recipient, amount);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/contracts/erc20.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | "github.com/ethereum/go-ethereum/common"
8 | evmtypes "github.com/evmos/ethermint/x/evm/types"
9 |
10 | "github.com/ArableProtocol/acrechain/x/erc20/types"
11 | )
12 |
13 | var (
14 | //go:embed compiled_contracts/ERC20MinterBurnerDecimals.json
15 | ERC20MinterBurnerDecimalsJSON []byte // nolint: golint
16 |
17 | // ERC20MinterBurnerDecimalsContract is the compiled erc20 contract
18 | ERC20MinterBurnerDecimalsContract evmtypes.CompiledContract
19 |
20 | // ERC20MinterBurnerDecimalsAddress is the erc20 module address
21 | ERC20MinterBurnerDecimalsAddress common.Address
22 | )
23 |
24 | func init() {
25 | ERC20MinterBurnerDecimalsAddress = types.ModuleAddress
26 |
27 | err := json.Unmarshal(ERC20MinterBurnerDecimalsJSON, &ERC20MinterBurnerDecimalsContract)
28 | if err != nil {
29 | panic(err)
30 | }
31 |
32 | if len(ERC20MinterBurnerDecimalsContract.Bin) == 0 {
33 | panic("load contract failed")
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/contracts/erc20burnable.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | evmtypes "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | var (
11 | //go:embed compiled_contracts/ERC20Burnable.json
12 | erc20BurnableJSON []byte
13 |
14 | // ERC20BurnableContract is the compiled ERC20Burnable contract
15 | ERC20BurnableContract evmtypes.CompiledContract
16 | )
17 |
18 | func init() {
19 | err := json.Unmarshal(erc20BurnableJSON, &ERC20BurnableContract)
20 | if err != nil {
21 | panic(err)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/contracts/erc20maliciousdelayed.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | "github.com/ethereum/go-ethereum/common"
8 | evmtypes "github.com/evmos/ethermint/x/evm/types"
9 |
10 | "github.com/ArableProtocol/acrechain/x/erc20/types"
11 | )
12 |
13 | // This is an evil token. Whenever an A -> B transfer is called,
14 | // a predefined C is given a massive allowance on B.
15 | var (
16 | //go:embed compiled_contracts/ERC20MaliciousDelayed.json
17 | ERC20MaliciousDelayedJSON []byte // nolint: golint
18 |
19 | // ERC20MaliciousDelayedContract is the compiled erc20 contract
20 | ERC20MaliciousDelayedContract evmtypes.CompiledContract
21 |
22 | // ERC20MaliciousDelayedAddress is the erc20 module address
23 | ERC20MaliciousDelayedAddress common.Address
24 | )
25 |
26 | func init() {
27 | ERC20MaliciousDelayedAddress = types.ModuleAddress
28 |
29 | err := json.Unmarshal(ERC20MaliciousDelayedJSON, &ERC20MaliciousDelayedContract)
30 | if err != nil {
31 | panic(err)
32 | }
33 |
34 | if len(ERC20MaliciousDelayedContract.Bin) == 0 {
35 | panic("load contract failed")
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/contracts/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "evmos",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@openzeppelin/contracts": {
8 | "version": "4.7.2",
9 | "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.2.tgz",
10 | "integrity": "sha512-4n/JL9izql8303mPqPdubuna/DWEMbmOzWYUWyCPhjhiEr2w3nQrjE7vZz1fBF+wzzP6dZbIcsgqACk53c9FGA=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/contracts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "evmos",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "directories": {
7 | "doc": "docs"
8 | },
9 | "dependencies": {
10 | "@openzeppelin/contracts": "^4.7.2"
11 | },
12 | "devDependencies": {},
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/evmos/evmos.git"
19 | },
20 | "author": "",
21 | "license": "ISC",
22 | "bugs": {
23 | "url": "https://github.com/evmos/evmos/issues"
24 | },
25 | "homepage": "https://github.com/evmos/evmos#readme"
26 | }
27 |
--------------------------------------------------------------------------------
/crypto/keyring/options.go:
--------------------------------------------------------------------------------
1 | package keyring
2 |
3 | import (
4 | "github.com/cosmos/cosmos-sdk/crypto/keyring"
5 |
6 | "github.com/evmos/ethermint/crypto/hd"
7 | )
8 |
9 | var (
10 | // SupportedAlgorithms defines the list of signing algorithms used on Acrechain:
11 | // - eth_secp256k1 (Ethereum)
12 | SupportedAlgorithms = keyring.SigningAlgoList{hd.EthSecp256k1}
13 | // SupportedAlgorithmsLedger defines the list of signing algorithms used on Acrechain for the Ledger device:
14 | // - eth_secp256k1 (Ethereum)
15 | SupportedAlgorithmsLedger = keyring.SigningAlgoList{hd.EthSecp256k1}
16 | )
17 |
18 | // EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve.
19 | // It supports eth_secp256k1 keys for accounts.
20 | func Option() keyring.Option {
21 | return func(options *keyring.Options) {
22 | options.SupportedAlgos = SupportedAlgorithms
23 | options.SupportedAlgosLedger = SupportedAlgorithmsLedger
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/.bencher/config.yaml:
--------------------------------------------------------------------------------
1 | # Configuration docs: https://bencher.orijtech.com/configuration/
2 | suppress_failure_on_regression: false
3 | global:
4 | reg_min: 10
5 | imp_min: -10
6 |
--------------------------------------------------------------------------------
/ethermint/.dockerignore:
--------------------------------------------------------------------------------
1 | # localnet-setup
2 | localnet-setup
3 |
4 | # build
5 | build
--------------------------------------------------------------------------------
/ethermint/.flake8:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length = 88
3 | extend-ignore = E203
4 | exclude = .git,__pycache__,node_modules,.direnv
5 |
--------------------------------------------------------------------------------
/ethermint/.gitattributes:
--------------------------------------------------------------------------------
1 | client/docs/swagger-ui/* linguist-vendored
2 | client/docs/statik/* linguist-vendored
3 | third-party/* linguist-vendored
4 | client/docs/* linguist-documentation
5 | docs/* linguist-documentation
6 | x/**/spec/* linguist-documentation
7 | **/*.pb.go linguist-generated
8 | **/*.pb.gw.go linguist-generated
--------------------------------------------------------------------------------
/ethermint/.gitignore:
--------------------------------------------------------------------------------
1 | # OS
2 | .DS_Store
3 | *.swp
4 | *.swo
5 | *.swl
6 | *.swm
7 | *.swn
8 | .vscode
9 | .idea
10 | *.pyc
11 | *.exe
12 | *.exe~
13 | *.dll
14 | *.so
15 | *.dylib
16 | .dccache
17 |
18 | # Build
19 | *.test
20 | .glide/
21 | vendor
22 | build
23 | bin
24 | tools/bin/*
25 | docs/_build
26 | docs/tutorial
27 | docs/node_modules
28 | docs/modules
29 | dist
30 | tools-stamp
31 | docs-tools-stamp
32 | proto-tools-stamp
33 | golangci-lint
34 | keyring_test_cosmos
35 | ./**/node_modules
36 | ./**/dist
37 | secret.yml
38 | # vue/
39 |
40 | # Local docker volume mappings
41 | localnet-setup
42 |
43 | # Testing
44 | coverage.txt
45 | *.out
46 | sim_log_file
47 | tests/**/tmp/*
48 | yarn.lock
49 |
50 | # Vagrant
51 | .vagrant/
52 | *.box
53 | *.log
54 | vagrant
55 |
56 | # IDE
57 | .idea/
58 | *.iml
59 |
60 | # Graphviz
61 | dependency-graph.png
62 |
63 | # Latex
64 | *.aux
65 | *.out
66 | *.synctex.gz
67 |
68 | # Contracts
69 | *.bin
70 | *.abi
71 |
72 | # Node.js
73 | tests/**/node_modules/*
74 | tests-solidity/**/node_modules/*
75 |
76 | # Nix
77 | /result
--------------------------------------------------------------------------------
/ethermint/.markdownlint.yml:
--------------------------------------------------------------------------------
1 | "default": true
2 | "MD001": false
3 | "MD004": false
4 | "MD007":
5 | "indent": 4
6 | "MD013": false
7 | "MD024":
8 | "siblings_only": true
9 | "MD025": false
10 | "MD026":
11 | "punctuation": ".;:"
12 | "MD029": false
13 | "MD033": false
14 | "MD034": false
15 | "MD036": false
16 | "MD040": false
17 | "MD041": false
18 | "MD049":
19 | "style": "asterisk"
20 | "no-hard-tabs": false
21 |
--------------------------------------------------------------------------------
/ethermint/.markdownlintignore:
--------------------------------------------------------------------------------
1 | CHANGELOG.md
2 | docs/protocol/proto-docs.md
3 | docs/node_modules
4 |
--------------------------------------------------------------------------------
/ethermint/.mergify.yml:
--------------------------------------------------------------------------------
1 | queue_rules:
2 | - name: default
3 | conditions:
4 | - "#approved-reviews-by>1"
5 |
6 | pull_request_rules:
7 | - name: automerge to main with label "automerge" and branch protection passing
8 | conditions:
9 | - "#approved-reviews-by>1"
10 | - base=main
11 | - label=automerge
12 | actions:
13 | queue:
14 | name: default
15 | method: squash
16 | commit_message_template: |
17 | {{ title }} (#{{ number }})
18 | {{ body }}
19 | - name: backport patches to main branch
20 | conditions:
21 | - label=backport/main
22 | actions:
23 | backport:
24 | branches:
25 | - main
26 | - name: backport patches to v0.17.x branch
27 | conditions:
28 | - base=main
29 | - label=backport/0.17.x
30 | actions:
31 | backport:
32 | branches:
33 | - release/v0.17.x
34 | - name: backport patches to v0.16.x branch
35 | conditions:
36 | - base=main
37 | - label=backport/0.16.x
38 | actions:
39 | backport:
40 | branches:
41 | - release/v0.16.x
42 |
--------------------------------------------------------------------------------
/ethermint/.semgrepignore:
--------------------------------------------------------------------------------
1 | # Ignore git items
2 | .gitignore
3 | .git/
4 | :include .gitignore
5 |
6 | # Common large paths
7 | node_modules/
8 | build/
9 | dist/
10 | vendor/
11 | .env/
12 | .venv/
13 | .tox/
14 | *.min.js
15 | *.pb.gw.go
16 |
17 | # Common test paths
18 | test/
19 | tests/
20 | *_test.go
21 |
22 | # Semgrep rules folder
23 | .semgrep
24 |
25 | # Semgrep-action log folder
26 | .semgrep_logs/
27 |
28 | # Documentation
29 | client/docs/
--------------------------------------------------------------------------------
/ethermint/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:alpine AS build-env
2 |
3 | # Set up dependencies
4 | ENV PACKAGES git build-base
5 |
6 | # Set working directory for the build
7 | WORKDIR /go/src/github.com/evmos/ethermint
8 |
9 | # Install dependencies
10 | RUN apk add --update $PACKAGES
11 | RUN apk add linux-headers
12 |
13 | # Add source files
14 | COPY . .
15 |
16 | # Make the binary
17 | RUN make build
18 |
19 | # Final image
20 | FROM alpine:3.16.0
21 |
22 | # Install ca-certificates
23 | RUN apk add --update ca-certificates jq
24 | WORKDIR /
25 |
26 | # Copy over binaries from the build-env
27 | COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /usr/bin/ethermintd
28 |
29 | # Run ethermintd by default
30 | CMD ["ethermintd"]
31 |
--------------------------------------------------------------------------------
/ethermint/app/ante/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Package ante defines the SDK auth module's AnteHandler as well as an internal
3 | AnteHandler for an Ethereum transaction (i.e MsgEthereumTx).
4 |
5 | During CheckTx, the transaction is passed through a series of
6 | pre-message execution validation checks such as signature and account
7 | verification in addition to minimum fees being checked. Otherwise, during
8 | DeliverTx, the transaction is simply passed to the EVM which will also
9 | perform the same series of checks. The distinction is made in CheckTx to
10 | prevent spam and DoS attacks.
11 | */
12 | package ante
13 |
--------------------------------------------------------------------------------
/ethermint/app/ante/reject_msgs.go:
--------------------------------------------------------------------------------
1 | package ante
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
6 | evmtypes "github.com/evmos/ethermint/x/evm/types"
7 | )
8 |
9 | // RejectMessagesDecorator prevents invalid msg types from being executed
10 | type RejectMessagesDecorator struct{}
11 |
12 | // AnteHandle rejects messages that requires ethereum-specific authentication.
13 | // For example `MsgEthereumTx` requires fee to be deducted in the antehandler in
14 | // order to perform the refund.
15 | func (rmd RejectMessagesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
16 | for _, msg := range tx.GetMsgs() {
17 | if _, ok := msg.(*evmtypes.MsgEthereumTx); ok {
18 | return ctx, sdkerrors.Wrapf(
19 | sdkerrors.ErrInvalidType,
20 | "MsgEthereumTx needs to be contained within a tx with 'ExtensionOptionsEthereumTx' option",
21 | )
22 | }
23 | }
24 | return next(ctx, tx, simulate)
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/buf.work.yaml:
--------------------------------------------------------------------------------
1 | version: v1
2 | directories:
3 | - proto
4 | - third_party/proto
5 |
--------------------------------------------------------------------------------
/ethermint/client/config_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "os"
5 | "path/filepath"
6 | "testing"
7 |
8 | "github.com/cosmos/cosmos-sdk/client/flags"
9 | "github.com/spf13/cobra"
10 | )
11 |
12 | func TestInitConfigNonNotExistError(t *testing.T) {
13 | tempDir := t.TempDir()
14 | subDir := filepath.Join(tempDir, "nonPerms")
15 | if err := os.Mkdir(subDir, 0o600); err != nil {
16 | t.Fatalf("Failed to create sub directory: %v", err)
17 | }
18 | cmd := &cobra.Command{}
19 | cmd.PersistentFlags().String(flags.FlagHome, "", "")
20 | if err := cmd.PersistentFlags().Set(flags.FlagHome, subDir); err != nil {
21 | t.Fatalf("Could not set home flag [%T] %v", err, err)
22 | }
23 |
24 | if err := InitConfig(cmd); !os.IsPermission(err) {
25 | t.Fatalf("Failed to catch permissions error, got: [%T] %v", err, err)
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/client/docs/statik/init.go:
--------------------------------------------------------------------------------
1 | package statik
2 |
3 | // This just for fixing the error in importing empty github.com/evmos/ethermint/client/docs/statik
4 |
--------------------------------------------------------------------------------
/ethermint/client/docs/swagger-ui/favicon-16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/client/docs/swagger-ui/favicon-16x16.png
--------------------------------------------------------------------------------
/ethermint/client/docs/swagger-ui/favicon-32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/client/docs/swagger-ui/favicon-32x32.png
--------------------------------------------------------------------------------
/ethermint/cmd/ethermintd/cmd_test.go:
--------------------------------------------------------------------------------
1 | package main_test
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 |
9 | "github.com/cosmos/cosmos-sdk/client/flags"
10 | svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
11 | "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
12 |
13 | "github.com/evmos/ethermint/app"
14 | ethermintd "github.com/evmos/ethermint/cmd/ethermintd"
15 | )
16 |
17 | func TestInitCmd(t *testing.T) {
18 | rootCmd, _ := ethermintd.NewRootCmd()
19 | rootCmd.SetArgs([]string{
20 | "init", // Test the init cmd
21 | "etherminttest", // Moniker
22 | fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists
23 | fmt.Sprintf("--%s=%s", flags.FlagChainID, "ethermint_9000-1"),
24 | })
25 |
26 | err := svrcmd.Execute(rootCmd, app.DefaultNodeHome)
27 | require.NoError(t, err)
28 | }
29 |
--------------------------------------------------------------------------------
/ethermint/cmd/ethermintd/flags.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/spf13/cobra"
7 |
8 | "github.com/evmos/ethermint/version"
9 | )
10 |
11 | const (
12 | flagLong = "long"
13 | )
14 |
15 | func init() {
16 | infoCmd.Flags().Bool(flagLong, false, "Print full information")
17 | }
18 |
19 | var infoCmd = &cobra.Command{
20 | Use: "info",
21 | Short: "Print version info",
22 | RunE: func(_ *cobra.Command, _ []string) error {
23 | fmt.Println(version.Version())
24 | return nil
25 | },
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/cmd/ethermintd/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 |
6 | "github.com/cosmos/cosmos-sdk/server"
7 | svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
8 | sdk "github.com/cosmos/cosmos-sdk/types"
9 |
10 | "github.com/evmos/ethermint/app"
11 | cmdcfg "github.com/evmos/ethermint/cmd/config"
12 | )
13 |
14 | func main() {
15 | setupConfig()
16 | cmdcfg.RegisterDenoms()
17 |
18 | rootCmd, _ := NewRootCmd()
19 |
20 | if err := svrcmd.Execute(rootCmd, app.DefaultNodeHome); err != nil {
21 | switch e := err.(type) {
22 | case server.ErrorCode:
23 | os.Exit(e.Code)
24 |
25 | default:
26 | os.Exit(1)
27 | }
28 | }
29 | }
30 |
31 | func setupConfig() {
32 | // set the address prefixes
33 | config := sdk.GetConfig()
34 | cmdcfg.SetBech32Prefixes(config)
35 | cmdcfg.SetBip44CoinType(config)
36 | config.Seal()
37 | }
38 |
--------------------------------------------------------------------------------
/ethermint/crypto/codec/amino.go:
--------------------------------------------------------------------------------
1 | package codec
2 |
3 | import (
4 | "github.com/cosmos/cosmos-sdk/client/keys"
5 | "github.com/cosmos/cosmos-sdk/codec"
6 | "github.com/cosmos/cosmos-sdk/codec/legacy"
7 | cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
8 | "github.com/cosmos/cosmos-sdk/crypto/keyring"
9 |
10 | "github.com/evmos/ethermint/crypto/ethsecp256k1"
11 | )
12 |
13 | // RegisterCrypto registers all crypto dependency types with the provided Amino
14 | // codec.
15 | func RegisterCrypto(cdc *codec.LegacyAmino) {
16 | cdc.RegisterConcrete(ðsecp256k1.PubKey{},
17 | ethsecp256k1.PubKeyName, nil)
18 | cdc.RegisterConcrete(ðsecp256k1.PrivKey{},
19 | ethsecp256k1.PrivKeyName, nil)
20 |
21 | keyring.RegisterLegacyAminoCodec(cdc)
22 | cryptocodec.RegisterCrypto(cdc)
23 |
24 | // NOTE: update SDK's amino codec to include the ethsecp256k1 keys.
25 | // DO NOT REMOVE unless deprecated on the SDK.
26 | legacy.Cdc = cdc
27 | keys.KeysCdc = cdc
28 | }
29 |
--------------------------------------------------------------------------------
/ethermint/crypto/codec/codec.go:
--------------------------------------------------------------------------------
1 | package codec
2 |
3 | import (
4 | codectypes "github.com/cosmos/cosmos-sdk/codec/types"
5 | cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
6 |
7 | "github.com/evmos/ethermint/crypto/ethsecp256k1"
8 | )
9 |
10 | // RegisterInterfaces register the Ethermint key concrete types.
11 | func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
12 | registry.RegisterImplementations((*cryptotypes.PubKey)(nil), ðsecp256k1.PubKey{})
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/crypto/ethsecp256k1/benchmark_test.go:
--------------------------------------------------------------------------------
1 | package ethsecp256k1
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 | )
7 |
8 | func BenchmarkGenerateKey(b *testing.B) {
9 | b.ReportAllocs()
10 | for i := 0; i < b.N; i++ {
11 | if _, err := GenerateKey(); err != nil {
12 | b.Fatal(err)
13 | }
14 | }
15 | }
16 |
17 | func BenchmarkPubKey_VerifySignature(b *testing.B) {
18 | privKey, err := GenerateKey()
19 | if err != nil {
20 | b.Fatal(err)
21 | }
22 | pubKey := privKey.PubKey()
23 |
24 | b.ResetTimer()
25 | b.ReportAllocs()
26 | for i := 0; i < b.N; i++ {
27 | msg := []byte(fmt.Sprintf("%10d", i))
28 | sig, err := privKey.Sign(msg)
29 | if err != nil {
30 | b.Fatal(err)
31 | }
32 | pubKey.VerifySignature(msg, sig)
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/ethermint/crypto/hd/benchmark_test.go:
--------------------------------------------------------------------------------
1 | package hd
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/cosmos/cosmos-sdk/crypto/keyring"
7 | ethermint "github.com/evmos/ethermint/types"
8 | )
9 |
10 | func BenchmarkEthSecp256k1Algo_Derive(b *testing.B) {
11 | b.ReportAllocs()
12 | for i := 0; i < b.N; i++ {
13 | deriveFn := EthSecp256k1.Derive()
14 | if _, err := deriveFn(mnemonic, keyring.DefaultBIP39Passphrase, ethermint.BIP44HDPath); err != nil {
15 | b.Fatal(err)
16 | }
17 | }
18 | }
19 |
20 | func BenchmarkEthSecp256k1Algo_Generate(b *testing.B) {
21 | bz, err := EthSecp256k1.Derive()(mnemonic, keyring.DefaultBIP39Passphrase, ethermint.BIP44HDPath)
22 | if err != nil {
23 | b.Fatal(err)
24 | }
25 |
26 | b.ResetTimer()
27 | b.ReportAllocs()
28 | for i := 0; i < b.N; i++ {
29 | (ðSecp256k1Algo{}).Generate()(bz)
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ethermint/docs/ethermint.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/docs/ethermint.jpg
--------------------------------------------------------------------------------
/ethermint/encoding/codec/codec.go:
--------------------------------------------------------------------------------
1 | package codec
2 |
3 | import (
4 | "github.com/cosmos/cosmos-sdk/codec"
5 | codectypes "github.com/cosmos/cosmos-sdk/codec/types"
6 | "github.com/cosmos/cosmos-sdk/std"
7 | sdk "github.com/cosmos/cosmos-sdk/types"
8 |
9 | cryptocodec "github.com/evmos/ethermint/crypto/codec"
10 | ethermint "github.com/evmos/ethermint/types"
11 | )
12 |
13 | // RegisterLegacyAminoCodec registers Interfaces from types, crypto, and SDK std.
14 | func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
15 | sdk.RegisterLegacyAminoCodec(cdc)
16 | cryptocodec.RegisterCrypto(cdc)
17 | codec.RegisterEvidences(cdc)
18 | }
19 |
20 | // RegisterInterfaces registers Interfaces from types, crypto, and SDK std.
21 | func RegisterInterfaces(interfaceRegistry codectypes.InterfaceRegistry) {
22 | std.RegisterInterfaces(interfaceRegistry)
23 | cryptocodec.RegisterInterfaces(interfaceRegistry)
24 | ethermint.RegisterInterfaces(interfaceRegistry)
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/encoding/config.go:
--------------------------------------------------------------------------------
1 | package encoding
2 |
3 | import (
4 | amino "github.com/cosmos/cosmos-sdk/codec"
5 | "github.com/cosmos/cosmos-sdk/codec/types"
6 | "github.com/cosmos/cosmos-sdk/simapp/params"
7 | "github.com/cosmos/cosmos-sdk/types/module"
8 | "github.com/cosmos/cosmos-sdk/x/auth/tx"
9 |
10 | enccodec "github.com/evmos/ethermint/encoding/codec"
11 | )
12 |
13 | // MakeConfig creates an EncodingConfig for testing
14 | func MakeConfig(mb module.BasicManager) params.EncodingConfig {
15 | cdc := amino.NewLegacyAmino()
16 | interfaceRegistry := types.NewInterfaceRegistry()
17 | marshaler := amino.NewProtoCodec(interfaceRegistry)
18 |
19 | encodingConfig := params.EncodingConfig{
20 | InterfaceRegistry: interfaceRegistry,
21 | Marshaler: marshaler,
22 | TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes),
23 | Amino: cdc,
24 | }
25 |
26 | enccodec.RegisterLegacyAminoCodec(encodingConfig.Amino)
27 | mb.RegisterLegacyAminoCodec(encodingConfig.Amino)
28 | enccodec.RegisterInterfaces(encodingConfig.InterfaceRegistry)
29 | mb.RegisterInterfaces(encodingConfig.InterfaceRegistry)
30 | return encodingConfig
31 | }
32 |
--------------------------------------------------------------------------------
/ethermint/networks/local/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | docker build --no-cache --tag ethermintd/node ../.. -f ethermintnode/Dockerfile
3 |
4 | .PHONY: all
5 |
--------------------------------------------------------------------------------
/ethermint/networks/local/ethermintnode/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:stretch as build-env
2 |
3 | # Install minimum necessary dependencies
4 | ENV PACKAGES curl make git libc-dev bash gcc
5 | RUN apt-get update && apt-get upgrade -y && \
6 | apt-get install -y $PACKAGES
7 |
8 | # Set working directory for the build
9 | WORKDIR /go/src/github.com/evmos/ethermint
10 |
11 | # Add source files
12 | COPY . .
13 |
14 | # build Ethermint
15 | RUN make build-linux
16 |
17 | # Final image
18 | FROM golang:1.18 as final
19 |
20 | WORKDIR /
21 |
22 | RUN apt-get update
23 |
24 | # Copy over binaries from the build-env
25 | COPY --from=build-env /go/src/github.com/evmos/ethermint/build/ethermintd /
26 | COPY --from=build-env /go/src/github.com/evmos/ethermint/scripts/start-docker.sh /
27 |
28 | EXPOSE 26656 26657 1317 8545 8546
29 |
30 | # Run ethermintd by default, omit entrypoint to ease using container with ethermintd
31 | ENTRYPOINT ["/bin/bash", "-c"]
--------------------------------------------------------------------------------
/ethermint/nix/go_1_18_overlay.nix:
--------------------------------------------------------------------------------
1 | final: prev: {
2 | go_1_18 = prev.go_1_18.override ({
3 | inherit (final.darwin.apple_sdk_11_0.frameworks) Security Foundation;
4 | xcbuild = prev.xcbuild.override {
5 | inherit (final.darwin.apple_sdk_11_0) stdenv;
6 | };
7 | } // final.lib.optionalAttrs final.stdenv.isDarwin {
8 | inherit (final.darwin.apple_sdk_11_0) stdenv;
9 | });
10 | }
11 |
--------------------------------------------------------------------------------
/ethermint/nix/scripts.nix:
--------------------------------------------------------------------------------
1 | { pkgs
2 | , config
3 | , ethermint ? (import ../. { inherit pkgs; })
4 | }: rec {
5 | start-ethermint = pkgs.writeShellScriptBin "start-ethermint" ''
6 | # rely on environment to provide ethermintd
7 | export PATH=${pkgs.test-env}/bin:$PATH
8 | ${../scripts/start-ethermint.sh} ${config.ethermint-config} ${config.dotenv} $@
9 | '';
10 | start-geth = pkgs.writeShellScriptBin "start-geth" ''
11 | export PATH=${pkgs.test-env}/bin:${pkgs.go-ethereum}/bin:$PATH
12 | source ${config.dotenv}
13 | ${../scripts/start-geth.sh} ${config.geth-genesis} $@
14 | '';
15 | start-scripts = pkgs.symlinkJoin {
16 | name = "start-scripts";
17 | paths = [ start-ethermint start-geth ];
18 | };
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/nix/testenv.nix:
--------------------------------------------------------------------------------
1 | { pkgs }:
2 | pkgs.poetry2nix.mkPoetryEnv {
3 | projectDir = ../tests/integration_tests;
4 | python = pkgs.python39;
5 | overrides = pkgs.poetry2nix.overrides.withDefaults (self: super: {
6 | eth-bloom = super.eth-bloom.overridePythonAttrs {
7 | preConfigure = ''
8 | substituteInPlace setup.py --replace \'setuptools-markdown\' ""
9 | '';
10 | };
11 |
12 | pystarport = super.pystarport.overridePythonAttrs (
13 | old: {
14 | nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.poetry ];
15 | }
16 | );
17 | });
18 | }
19 |
--------------------------------------------------------------------------------
/ethermint/proto/buf.yaml:
--------------------------------------------------------------------------------
1 | version: v1
2 | lint:
3 | use:
4 | - DEFAULT
5 | - COMMENTS
6 | - FILE_LOWER_SNAKE_CASE
7 | except:
8 | - UNARY_RPC
9 | - COMMENT_FIELD
10 | - SERVICE_SUFFIX
11 | - PACKAGE_VERSION_SUFFIX
12 | - RPC_REQUEST_STANDARD_NAME
13 | - RPC_REQUEST_RESPONSE_UNIQUE
14 | - RPC_RESPONSE_STANDARD_NAME
15 | - RPC_REQUEST_RESPONSE_UNIQUE
16 | - COMMENT_MESSAGE
17 | breaking:
18 | use:
19 | - FILE
--------------------------------------------------------------------------------
/ethermint/proto/ethermint/crypto/v1/ethsecp256k1/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package ethermint.crypto.v1.ethsecp256k1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/evmos/ethermint/crypto/ethsecp256k1";
7 |
8 | // PubKey defines a type alias for an ecdsa.PublicKey that implements
9 | // Tendermint's PubKey interface. It represents the 33-byte compressed public
10 | // key format.
11 | message PubKey {
12 | option (gogoproto.goproto_stringer) = false;
13 |
14 | bytes key = 1;
15 | }
16 |
17 | // PrivKey defines a type alias for an ecdsa.PrivateKey that implements
18 | // Tendermint's PrivateKey interface.
19 | message PrivKey { bytes key = 1; }
20 |
--------------------------------------------------------------------------------
/ethermint/proto/ethermint/feemarket/v1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package ethermint.feemarket.v1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "ethermint/feemarket/v1/feemarket.proto";
6 |
7 | option go_package = "github.com/evmos/ethermint/x/feemarket/types";
8 |
9 | // GenesisState defines the feemarket module's genesis state.
10 | message GenesisState {
11 | // params defines all the paramaters of the module.
12 | Params params = 1 [ (gogoproto.nullable) = false ];
13 | // DEPRECATED: base fee is the exported value from previous software version.
14 | // Zero by default.
15 | reserved 2;
16 | reserved "base_fee";
17 | // block gas is the amount of gas wanted on the last block before the upgrade.
18 | // Zero by default.
19 | uint64 block_gas = 3;
20 | }
--------------------------------------------------------------------------------
/ethermint/proto/ethermint/types/v1/account.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package ethermint.types.v1;
3 |
4 | import "cosmos/auth/v1beta1/auth.proto";
5 | import "cosmos_proto/cosmos.proto";
6 | import "gogoproto/gogo.proto";
7 |
8 | option go_package = "github.com/evmos/ethermint/types";
9 |
10 | // EthAccount implements the authtypes.AccountI interface and embeds an
11 | // authtypes.BaseAccount type. It is compatible with the auth AccountKeeper.
12 | message EthAccount {
13 | option (gogoproto.goproto_getters) = false;
14 | option (gogoproto.goproto_stringer) = false;
15 | option (gogoproto.equal) = false;
16 |
17 | option (cosmos_proto.implements_interface) =
18 | "github.com/cosmos/cosmos-sdk/x/auth/types.AccountI";
19 |
20 | cosmos.auth.v1beta1.BaseAccount base_account = 1 [
21 | (gogoproto.embed) = true,
22 | (gogoproto.moretags) = "yaml:\"base_account\""
23 | ];
24 | string code_hash = 2 [ (gogoproto.moretags) = "yaml:\"code_hash\"" ];
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/proto/ethermint/types/v1/indexer.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package ethermint.types.v1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/evmos/ethermint/types";
7 |
8 | // TxResult is the value stored in eth tx indexer
9 | message TxResult {
10 | option (gogoproto.goproto_getters) = false;
11 |
12 | // the block height
13 | int64 height = 1;
14 | // cosmos tx index
15 | uint32 tx_index = 2;
16 | // the msg index in a batch tx
17 | uint32 msg_index = 3;
18 |
19 | // eth tx index, the index in the list of valid eth tx in the block,
20 | // aka. the transaction list returned by eth_getBlock api.
21 | int32 eth_tx_index = 4;
22 | // if the eth tx is failed
23 | bool failed = 5;
24 | // gas used by tx, if exceeds block gas limit,
25 | // it's set to gas limit which is what's actually deducted by ante handler.
26 | uint64 gas_used = 6;
27 | // the cumulative gas used within current batch tx
28 | uint64 cumulative_gas_used = 7;
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/proto/ethermint/types/v1/web3.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package ethermint.types.v1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/evmos/ethermint/types";
7 |
8 | message ExtensionOptionsWeb3Tx {
9 | option (gogoproto.goproto_getters) = false;
10 |
11 | // typed data chain id used only in EIP712 Domain and should match
12 | // Ethereum network ID in a Web3 provider (e.g. Metamask).
13 | uint64 typed_data_chain_id = 1 [
14 | (gogoproto.jsontag) = "typedDataChainID,omitempty",
15 | (gogoproto.customname) = "TypedDataChainID"
16 | ];
17 |
18 | // fee payer is an account address for the fee payer. It will be validated
19 | // during EIP712 signature checking.
20 | string fee_payer = 2 [ (gogoproto.jsontag) = "feePayer,omitempty" ];
21 |
22 | // fee payer sig is a signature data from the fee paying account,
23 | // allows to perform fee delegation when using EIP712 Domain.
24 | bytes fee_payer_sig = 3 [ (gogoproto.jsontag) = "feePayerSig,omitempty" ];
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/rpc/doc.go:
--------------------------------------------------------------------------------
1 | // Package rpc contains RPC handler methods, namespaces and utilities to start
2 | // Ethermint's Web3-compatible JSON-RPC server.
3 | //
4 | // The list of available namespaces are:
5 | //
6 | // * `rpc/namespaces/eth`: `eth` namespace. Exposes the `PublicEthereumAPI` and the `PublicFilterAPI`.
7 | // * `rpc/namespaces/personal`: `personal` namespace. Exposes the `PrivateAccountAPI`.
8 | // * `rpc/namespaces/net`: `net` namespace. Exposes the `PublicNetAPI`.
9 | // * `rpc/namespaces/web3`: `web3` namespace. Exposes the `PublicWeb3API`
10 | package rpc
11 |
--------------------------------------------------------------------------------
/ethermint/rpc/namespaces/ethereum/web3/api.go:
--------------------------------------------------------------------------------
1 | package web3
2 |
3 | import (
4 | "github.com/evmos/ethermint/version"
5 |
6 | "github.com/ethereum/go-ethereum/common/hexutil"
7 | "github.com/ethereum/go-ethereum/crypto"
8 | )
9 |
10 | // PublicAPI is the web3_ prefixed set of APIs in the Web3 JSON-RPC spec.
11 | type PublicAPI struct{}
12 |
13 | // NewPublicAPI creates an instance of the Web3 API.
14 | func NewPublicAPI() *PublicAPI {
15 | return &PublicAPI{}
16 | }
17 |
18 | // ClientVersion returns the client version in the Web3 user agent format.
19 | func (a *PublicAPI) ClientVersion() string {
20 | return version.Version()
21 | }
22 |
23 | // Sha3 returns the keccak-256 hash of the passed-in input.
24 | func (a *PublicAPI) Sha3(input string) hexutil.Bytes {
25 | return crypto.Keccak256(hexutil.Bytes(input))
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/scripts/.env:
--------------------------------------------------------------------------------
1 | export PASSWORD='123456'
2 | export VALIDATOR1_MNEMONIC="visit craft resemble online window solution west chuckle music diesel vital settle comic tribe project blame bulb armed flower region sausage mercy arrive release"
3 | export VALIDATOR2_MNEMONIC="direct travel shrug hand twice agent sail sell jump phone velvet pilot mango charge usual multiply orient garment bleak virtual action mention panda vast"
4 | export COMMUNITY_MNEMONIC="notable error gospel wave pair ugly measure elite toddler cost various fly make eye ketchup despair slab throw tribe swarm word fruit into inmate"
5 | export SIGNER1_MNEMONIC="shed crumble dismiss loyal latin million oblige gesture shrug still oxygen custom remove ribbon disorder palace addict again blanket sad flock consider obey popular"
6 | export SIGNER2_MNEMONIC="night renew tonight dinner shaft scheme domain oppose echo summer broccoli agent face guitar surface belt veteran siren poem alcohol menu custom crunch index"
7 |
--------------------------------------------------------------------------------
/ethermint/scripts/gen-tests-artifacts.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # prepare sloc v0.5.17 in PATH
4 | solc --combined-json bin,abi --allow-paths . ./tests/solidity/suites/staking/contracts/test/mocks/StandardTokenMock.sol \
5 | | jq ".contracts.\"./tests/solidity/suites/staking/contracts/test/mocks/StandardTokenMock.sol:StandardTokenMock\"" \
6 | > x/evm/types/ERC20Contract.json
7 |
8 | solc --combined-json bin,abi --allow-paths . ./tests/solidity/suites/basic/contracts/TestMessageCall.sol \
9 | | jq ".contracts.\"./tests/solidity/suites/basic/contracts/TestMessageCall.sol:TestMessageCall\"" \
10 | > x/evm/types/TestMessageCall.json
11 |
--------------------------------------------------------------------------------
/ethermint/scripts/run-integration-tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | cd "$(dirname "$0")"
4 |
5 | # explicitly set a short TMPDIR to prevent path too long issue on macosx
6 | export TMPDIR=/tmp
7 |
8 | echo "build test contracts"
9 | cd ../tests/integration_tests/contracts
10 | HUSKY_SKIP_INSTALL=1 npm install
11 | npm run typechain
12 | cd ..
13 | pytest -vv -s
14 |
--------------------------------------------------------------------------------
/ethermint/scripts/run-solidity-tests.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | export GOPATH=~/go
3 | export PATH=$PATH:$GOPATH/bin
4 |
5 | # remove existing daemon
6 | rm -rf ~/.ethermintd
7 |
8 | # build ethermint binary
9 | make install
10 |
11 | cd tests/solidity
12 |
13 | if command -v yarn &> /dev/null; then
14 | yarn install
15 | else
16 | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
17 | echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
18 | sudo apt update && sudo apt install yarn
19 | yarn install
20 | fi
21 |
22 | yarn test --network ethermint $@
--------------------------------------------------------------------------------
/ethermint/scripts/start-docker.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "prepare genesis: Run validate-genesis to ensure everything worked and that the genesis file is setup correctly"
4 | ./ethermintd validate-genesis --home /ethermint
5 |
6 | echo "starting ethermint node $ID in background ..."
7 | ./ethermintd start \
8 | --home /ethermint \
9 | --keyring-backend test
10 |
11 | echo "started ethermint node"
12 | tail -f /dev/null
--------------------------------------------------------------------------------
/ethermint/scripts/start-ethermint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | CONFIG=$1
5 | if [ -z "$CONFIG" ]; then
6 | echo "No config file supplied"
7 | exit 1
8 | fi
9 | shift
10 |
11 | DOTENV=$1
12 | if [ -z "$DOTENV" ]; then
13 | echo "No dotenv file supplied"
14 | exit 1
15 | fi
16 | shift
17 |
18 | DATA=$1
19 | if [ -z "$DATA" ]; then
20 | echo "No data directory supplied"
21 | exit 1
22 | fi
23 | shift
24 |
25 | echo 'pystarport:'
26 | echo ' config: '$CONFIG
27 | echo ' dotenv: '$DOTENV
28 | echo ' data: '$DATA
29 |
30 | pystarport init --config $CONFIG --dotenv $DOTENV --data $DATA $@
31 | supervisord -c $DATA/tasks.ini
32 |
--------------------------------------------------------------------------------
/ethermint/server/config/config_test.go:
--------------------------------------------------------------------------------
1 | package config
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/require"
7 | )
8 |
9 | func TestDefaultConfig(t *testing.T) {
10 | cfg := DefaultConfig()
11 | require.True(t, cfg.JSONRPC.Enable)
12 | require.Equal(t, cfg.JSONRPC.Address, DefaultJSONRPCAddress)
13 | require.Equal(t, cfg.JSONRPC.WsAddress, DefaultJSONRPCWsAddress)
14 | }
15 |
--------------------------------------------------------------------------------
/ethermint/tests/importer/blockchain:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/importer/blockchain
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/.isort.cfg:
--------------------------------------------------------------------------------
1 | [settings]
2 | # compatible with black
3 | # https://black.readthedocs.io/en/stable/the_black_code_style.html
4 | multi_line_output = 3
5 | include_trailing_comma = True
6 | force_grid_wrap = 0
7 | use_parentheses = True
8 | ensure_newline_before_comments = True
9 | line_length = 88
10 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/integration_tests/__init__.py
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/configs/enable-indexer.jsonnet:
--------------------------------------------------------------------------------
1 | local config = import 'default.jsonnet';
2 |
3 | config {
4 | 'ethermint_9000-1'+: {
5 | config+: {
6 | tx_index+: {
7 | indexer: 'null',
8 | },
9 | },
10 | 'app-config'+: {
11 | pruning: 'everything',
12 | 'state-sync'+: {
13 | 'snapshot-interval': 0,
14 | },
15 | 'json-rpc'+: {
16 | 'enable-indexer': true,
17 | },
18 | },
19 | },
20 | }
21 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/configs/pruned_node.jsonnet:
--------------------------------------------------------------------------------
1 | local config = import 'default.jsonnet';
2 |
3 | config {
4 | 'ethermint_9000-1'+: {
5 | 'app-config'+: {
6 | pruning: 'everything',
7 | 'state-sync'+: {
8 | 'snapshot-interval': 0,
9 | },
10 | },
11 | },
12 | }
13 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | .env
3 | coverage
4 | coverage.json
5 | typechain
6 | typechain-types
7 |
8 | #Hardhat files
9 | cache
10 | artifacts
11 |
12 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/README.md:
--------------------------------------------------------------------------------
1 | # Sample Hardhat Project
2 |
3 | This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract.
4 |
5 | Try running some of the following tasks:
6 |
7 | ```shell
8 | npx hardhat help
9 | npx hardhat test
10 | GAS_REPORT=true npx hardhat test
11 | npx hardhat node
12 | npx hardhat run scripts/deploy.js
13 | ```
14 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/contracts/Greeter.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >0.5.0;
2 |
3 | contract Greeter {
4 | string public greeting;
5 |
6 | event ChangeGreeting(address from, string value);
7 |
8 | constructor() public {
9 | greeting = "Hello";
10 | }
11 |
12 | function setGreeting(string memory _greeting) public {
13 | greeting = _greeting;
14 | emit ChangeGreeting(msg.sender, _greeting);
15 | }
16 |
17 | function greet() public view returns (string memory) {
18 | return greeting;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/contracts/TestERC20A.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.8.10;
2 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
3 |
4 | contract TestERC20A is ERC20 {
5 |
6 | constructor() public ERC20("TestERC20", "Test") {
7 | _mint(msg.sender, 100000000000000000000000000);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/hardhat.config.ts:
--------------------------------------------------------------------------------
1 | import { HardhatUserConfig } from "hardhat/config";
2 | import "hardhat-typechain";
3 |
4 | const config: HardhatUserConfig = {
5 | solidity: {
6 | compilers: [
7 | {
8 | version: "0.8.10",
9 | settings: {
10 | optimizer: {
11 | enabled: true
12 | }
13 | }
14 | },
15 | ],
16 | },
17 | typechain: {
18 | outDir: "typechain",
19 | target: "ethers-v5",
20 | },
21 | };
22 |
23 | export default config;
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "contracts",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "typechain": "npx hardhat typechain"
8 | },
9 | "keywords": [],
10 | "author": "",
11 | "license": "ISC",
12 | "dependencies": {
13 | "@nomiclabs/hardhat-ethers": "^2.1.0",
14 | "@nomiclabs/hardhat-waffle": "^2.0.3",
15 | "@openzeppelin/contracts": "^4.7.0",
16 | "@typechain/ethers-v5": "^5.0.0",
17 | "hardhat": "^2.10.1",
18 | "hardhat-typechain": "^0.3.5",
19 | "ts-generator": "^0.1.1",
20 | "typechain": "^4.0.3"
21 | },
22 | "devDependencies": {
23 | "ts-node": "^10.9.1",
24 | "typescript": "^4.7.4"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/contracts/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es2020",
4 | "module": "commonjs",
5 | "esModuleInterop": true,
6 | "forceConsistentCasingInFileNames": true,
7 | "strict": true,
8 | "skipLibCheck": true
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/pyproject.toml:
--------------------------------------------------------------------------------
1 | [tool.poetry]
2 | name = "integration_tests"
3 | version = "0.1.0"
4 | description = ""
5 | authors = ["chain-dev "]
6 |
7 | [tool.poetry.dependencies]
8 | python = "^3.8"
9 | pytest = "^7.0.1"
10 | pytest-github-actions-annotate-failures = "^0.1.1"
11 | flake8 = "^4.0.1"
12 | black = "^22.3.0"
13 | flake8-black = "^0.3.2"
14 | flake8-isort = "^4.1.1"
15 | pep8-naming = "^0.11.1"
16 | protobuf = "^3.13.0"
17 | grpcio = "^1.33.2"
18 | PyYAML = "^5.3.1"
19 | python-dateutil = "^2.8.1"
20 | web3 = "^5.20.1"
21 | eth-bloom = "^1.0.4"
22 | python-dotenv = "^0.19.2"
23 | pystarport = { git = "https://github.com/crypto-com/pystarport.git", branch = "main" }
24 | websockets = "^9.1"
25 | toml = "^0.10.2"
26 | pysha3 = "^1.0.2"
27 | jsonnet = "^0.18.0"
28 |
29 | [tool.poetry.dev-dependencies]
30 |
31 | [build-system]
32 | requires = ["poetry>=0.12"]
33 | build-backend = "poetry.masonry.api"
34 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/shell.nix:
--------------------------------------------------------------------------------
1 | { system ? builtins.currentSystem, pkgs ? import ../../nix { inherit system; } }:
2 | pkgs.mkShell {
3 | buildInputs = [
4 | pkgs.jq
5 | (pkgs.callPackage ../../. { }) # ethermintd
6 | pkgs.start-scripts
7 | pkgs.go-ethereum
8 | pkgs.cosmovisor
9 | pkgs.nodejs
10 | pkgs.test-env
11 | ];
12 | shellHook = ''
13 | . ${../../scripts/.env}
14 | '';
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/tests/integration_tests/test_basic.py:
--------------------------------------------------------------------------------
1 | def test_basic(cluster):
2 | w3 = cluster.w3
3 | assert w3.eth.chain_id == 9000
4 |
--------------------------------------------------------------------------------
/ethermint/tests/rpc/net_test.go:
--------------------------------------------------------------------------------
1 | package rpc
2 |
3 | import (
4 | "encoding/json"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/require"
8 | )
9 |
10 | func TestNet_Version(t *testing.T) {
11 | rpcRes := Call(t, "net_version", []string{})
12 |
13 | var res string
14 | err := json.Unmarshal(rpcRes.Result, &res)
15 | require.NoError(t, err)
16 | require.Equal(t, "9000", res)
17 | }
18 |
19 | func TestNet_Listening(t *testing.T) {
20 | rpcRes := Call(t, "net_listening", []string{})
21 |
22 | var res bool
23 | err := json.Unmarshal(rpcRes.Result, &res)
24 | require.NoError(t, err)
25 | require.True(t, res)
26 | }
27 |
28 | func TestNet_PeerCount(t *testing.T) {
29 | rpcRes := Call(t, "net_peerCount", []string{})
30 |
31 | var res int
32 | err := json.Unmarshal(rpcRes.Result, &res)
33 | require.NoError(t, err)
34 | require.Equal(t, 0, res)
35 | }
36 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/.gitattributes:
--------------------------------------------------------------------------------
1 | *.sol linguist-language=Solidity
2 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules/
3 |
4 | # ignore package-lock files (only use yarn.lock)
5 | package-lock.json
6 | !yarn.lock
--------------------------------------------------------------------------------
/ethermint/tests/solidity/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "tests-solidity",
3 | "private": true,
4 | "version": "1.0.0",
5 | "author": "Aragon Association ",
6 | "license": "GPL-3.0-or-later",
7 | "workspaces": {
8 | "packages": [
9 | "suites/*"
10 | ],
11 | "nohoist": [
12 | "**/@aragon/contract-helpers-test"
13 | ]
14 | },
15 | "dependencies": {
16 | "truffle": "5.5.8",
17 | "yargs": "^17.0.1",
18 | "patch-package": "^6.4.7"
19 | },
20 | "scripts": {
21 | "test": "node test-helper.js",
22 | "postinstall": "patch-package"
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/contracts/Counter.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.11;
2 |
3 | contract Counter {
4 | uint256 counter = 0;
5 | string internal constant ERROR_TOO_LOW = "COUNTER_TOO_LOW";
6 | event Changed(uint256 counter);
7 | event Added(uint256 counter);
8 |
9 | function add() public {
10 | counter++;
11 | emit Added(counter);
12 | emit Changed(counter);
13 | }
14 |
15 | function subtract() public {
16 | require(counter > 0, ERROR_TOO_LOW);
17 | counter--;
18 | emit Changed(counter);
19 | }
20 |
21 | function getCounter() public view returns (uint256) {
22 | return counter;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/contracts/Storage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity ^0.5.11;
4 |
5 | /**
6 | * @title Storage
7 | * @dev Store & retrieve value in a variable
8 | */
9 | contract Storage {
10 |
11 | uint256 number;
12 |
13 | /**
14 | * @dev Store value in variable
15 | * @param num value to store
16 | */
17 | function store(uint256 num) public {
18 | number = num + 1;
19 | number = num;
20 | }
21 |
22 | /**
23 | * @dev Return value
24 | * @return value of 'number'
25 | */
26 | function retrieve() public view returns (uint256){
27 | return number;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/contracts/TestMessageCall.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.5.17;
2 |
3 | contract Inner {
4 | event TestEvent(uint256);
5 | function test() public returns (uint256) {
6 | emit TestEvent(42);
7 | return 42;
8 | }
9 | }
10 |
11 | contract TestMessageCall {
12 | Inner _inner;
13 | constructor() public {
14 | _inner = new Inner();
15 | }
16 |
17 | // benchmarks
18 | function benchmarkMessageCall(uint iterations) public returns (uint256) {
19 | uint256 n = 0;
20 | for (uint i=0; i < iterations; i++) {
21 | n += _inner.test();
22 | }
23 | return n;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/contracts/test/Migrations.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity >=0.4.22 <0.8.0;
3 |
4 | contract Migrations {
5 | address public owner = msg.sender;
6 | uint public last_completed_migration;
7 |
8 | modifier restricted() {
9 | require(
10 | msg.sender == owner,
11 | "This function is restricted to the contract's owner"
12 | );
13 | _;
14 | }
15 |
16 | function setCompleted(uint completed) public restricted {
17 | last_completed_migration = completed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "basic",
3 | "version": "1.0.0",
4 | "author": "Aragon Association ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn truffle test",
8 | "test-ethermint": "yarn truffle test --network ethermint"
9 | },
10 | "devDependencies": {
11 | "truffle-assertions": "^0.9.2"
12 | }
13 | }
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/solidity/suites/basic/test/.gitkeep
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/basic/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.5.17",
15 | },
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/eip1559/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eip1559",
3 | "version": "1.0.0",
4 | "license": "GPL-3.0-or-later",
5 | "scripts": {
6 | "test-ganache": "yarn truffle test",
7 | "test-ethermint": "yarn truffle test --network ethermint"
8 | },
9 | "devDependencies": {
10 | "truffle": "^5.4.14",
11 | "truffle-assertions": "^0.9.2"
12 | },
13 | "dependencies": {
14 | "@truffle/hdwallet-provider": "^1.6.0"
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/eip1559/test/eip1559.js:
--------------------------------------------------------------------------------
1 | contract('Transaction', async function(accounts) {
2 |
3 | it('should send a transaction with EIP-1559 flag', async function() {
4 | console.log(`Accounts: `, accounts);
5 | console.log(web3.version);
6 | const tx = await web3.eth.sendTransaction({
7 | from: accounts[0],
8 | to: !!accounts[1] ? accounts[1] : "0x0000000000000000000000000000000000000000",
9 | value: '10000000',
10 | gas: '21000',
11 | type: "0x2",
12 | common: {
13 | hardfork: 'london'
14 | }
15 | });
16 | console.log(tx);
17 | assert.equal(tx.type, '0x2', 'Tx type should be 0x2');
18 | });
19 |
20 | });
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/eip1559/truffle-config.js:
--------------------------------------------------------------------------------
1 | // const HDWalletProvider = require('@truffle/hdwallet-provider');
2 |
3 | module.exports = {
4 | networks: {
5 | // Development network is just left as truffle's default settings
6 | ethermint: {
7 | host: "127.0.0.1", // Localhost (default: none)
8 | port: 8545, // Standard Ethereum port (default: none)
9 | network_id: "*", // Any network (default: none)
10 | gas: 5000000, // Gas sent with each transaction
11 | gasPrice: 1000000000, // 1 gwei (in wei)
12 | },
13 | },
14 | compilers: {
15 | solc: {
16 | version: "0.5.17",
17 | },
18 | },
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/exception/contracts/test/Migrations.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity >=0.8.0;
3 |
4 | contract Migrations {
5 | address public owner = msg.sender;
6 | uint public last_completed_migration;
7 |
8 | modifier restricted() {
9 | require(
10 | msg.sender == owner,
11 | "This function is restricted to the contract's owner"
12 | );
13 | _;
14 | }
15 |
16 | function setCompleted(uint completed) public restricted {
17 | last_completed_migration = completed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/exception/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/exception/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "exception",
3 | "version": "1.0.0",
4 | "author": "huangyi ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn truffle test",
8 | "test-ethermint": "yarn truffle test --network ethermint"
9 | },
10 | "devDependencies": {
11 | "truffle-assertions": "^0.9.2"
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/exception/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/solidity/suites/exception/test/.gitkeep
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/exception/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.8.6",
15 | },
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/.gitignore:
--------------------------------------------------------------------------------
1 | # Buidler
2 | artifacts
3 | cache
4 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/buidler.config.js:
--------------------------------------------------------------------------------
1 | const { usePlugin } = require('@nomiclabs/buidler/config')
2 |
3 | usePlugin("@nomiclabs/buidler-ganache")
4 | usePlugin('@nomiclabs/buidler-truffle5')
5 |
6 | module.exports = {
7 | networks: {
8 | // Development network is just left as truffle's default settings
9 | ganache: {
10 | url: 'http://localhost:8545',
11 | gasLimit: 5000000,
12 | gasPrice: 1000000000, // 1 gwei (in wei)
13 | defaultBalanceEther: 100
14 | },
15 | ethermint: {
16 | url: 'http://localhost:8545',
17 | gasLimit: 5000000, // Gas sent with each transaction
18 | gasPrice: 1000000000, // 1 gwei (in wei)
19 | },
20 | },
21 | solc: {
22 | version: '0.4.24',
23 | optimizer: {
24 | enabled: true,
25 | runs: 10000,
26 | },
27 | },
28 | }
29 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/contracts/Petrifiable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 | import "./Initializable.sol";
4 |
5 |
6 | contract Petrifiable is Initializable {
7 | // Use block UINT256_MAX (which should be never) as the initializable date
8 | uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
9 |
10 | function isPetrified() public view returns (bool) {
11 | return getInitializationBlock() == PETRIFIED_BLOCK;
12 | }
13 |
14 | /**
15 | * @dev Function to be called by top level contract to prevent being initialized.
16 | * Useful for freezing base contracts when they're used behind proxies.
17 | */
18 | function petrify() internal onlyInit {
19 | initializedAt(PETRIFIED_BLOCK);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/contracts/Uint256Helpers.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 |
4 | library Uint256Helpers {
5 | uint256 private constant MAX_UINT64 = uint64(-1);
6 |
7 | string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
8 |
9 | function toUint64(uint256 a) internal pure returns (uint64) {
10 | require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG);
11 | return uint64(a);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/contracts/test/InitializableMock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 | import "../Initializable.sol";
4 | import "../Petrifiable.sol";
5 |
6 |
7 | contract LifecycleMock is Initializable, Petrifiable {
8 | function initializeMock() public {
9 | initialized();
10 | }
11 |
12 | function petrifyMock() public {
13 | petrify();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable-buidler/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "initializable-buidler",
3 | "version": "1.0.0",
4 | "author": "Aragon Association ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn buidler test --network ganache",
8 | "test-ethermint": "yarn buidler test --network ethermint"
9 | },
10 | "devDependencies": {
11 | "@aragon/contract-helpers-test": "^0.1.0",
12 | "@nomiclabs/buidler": "^1.4.3",
13 | "@nomiclabs/buidler-ganache": "^1.3.3",
14 | "@nomiclabs/buidler-truffle5": "^1.3.4",
15 | "@nomiclabs/buidler-web3": "^1.3.4",
16 | "chai": "^4.2.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/contracts/Petrifiable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 | import "./Initializable.sol";
4 |
5 |
6 | contract Petrifiable is Initializable {
7 | // Use block UINT256_MAX (which should be never) as the initializable date
8 | uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
9 |
10 | function isPetrified() public view returns (bool) {
11 | return getInitializationBlock() == PETRIFIED_BLOCK;
12 | }
13 |
14 | /**
15 | * @dev Function to be called by top level contract to prevent being initialized.
16 | * Useful for freezing base contracts when they're used behind proxies.
17 | */
18 | function petrify() internal onlyInit {
19 | initializedAt(PETRIFIED_BLOCK);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/contracts/Uint256Helpers.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 |
4 | library Uint256Helpers {
5 | uint256 private constant MAX_UINT64 = uint64(-1);
6 |
7 | string private constant ERROR_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
8 |
9 | function toUint64(uint256 a) internal pure returns (uint64) {
10 | require(a <= MAX_UINT64, ERROR_NUMBER_TOO_BIG);
11 | return uint64(a);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/contracts/test/InitializableMock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 | import "../Initializable.sol";
4 | import "../Petrifiable.sol";
5 |
6 |
7 | contract LifecycleMock is Initializable, Petrifiable {
8 | function initializeMock() public {
9 | initialized();
10 | }
11 |
12 | function petrifyMock() public {
13 | petrify();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/contracts/test/Migrations.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity >=0.4.22 <0.8.0;
3 |
4 | contract Migrations {
5 | address public owner = msg.sender;
6 | uint public last_completed_migration;
7 |
8 | modifier restricted() {
9 | require(
10 | msg.sender == owner,
11 | "This function is restricted to the contract's owner"
12 | );
13 | _;
14 | }
15 |
16 | function setCompleted(uint completed) public restricted {
17 | last_completed_migration = completed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "initializable",
3 | "version": "1.0.0",
4 | "author": "Aragon Association ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "contract-compile": "yarn truffle compile",
8 | "contract-migrate": "yarn truffle migrate --network ethermint",
9 | "test-ganache": "yarn truffle test",
10 | "test-ethermint": "yarn truffle test --network ethermint"
11 | },
12 | "devDependencies": {
13 | "@aragon/contract-helpers-test": "^0.1.0",
14 | "chai": "^4.2.0",
15 | "sleep": "^6.3.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/solidity/suites/initializable/test/.gitkeep
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/initializable/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.4.24",
15 | settings: {
16 | optimizer: {
17 | enabled: true,
18 | runs: 10000,
19 | },
20 | },
21 | },
22 | },
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/contracts/Migrations.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.4.21 <0.6.0;
2 |
3 | contract Migrations {
4 | address public owner;
5 | uint public last_completed_migration;
6 |
7 | constructor() public {
8 | owner = msg.sender;
9 | }
10 |
11 | modifier restricted() {
12 | if (msg.sender == owner) _;
13 | }
14 |
15 | function setCompleted(uint completed) public restricted {
16 | last_completed_migration = completed;
17 | }
18 |
19 | function upgrade(address new_address) public restricted {
20 | Migrations upgraded = Migrations(new_address);
21 | upgraded.setCompleted(last_completed_migration);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function(deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/migrations/2_opCodes_migration.js:
--------------------------------------------------------------------------------
1 | var OpCodes = artifacts.require("./OpCodes.sol");
2 |
3 | module.exports = function(deployer) {
4 | deployer.deploy(OpCodes);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "opcode",
3 | "version": "1.0.0",
4 | "author": "Go Ethereum",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn truffle test",
8 | "test-ethermint": "yarn truffle test --network ethermint"
9 | },
10 | "devDependencies": {
11 | "truffle-assertions": "^0.9.2"
12 | }
13 | }
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/test/opCodes.js:
--------------------------------------------------------------------------------
1 | const TodoList = artifacts.require('./OpCodes.sol')
2 | const assert = require('assert')
3 | let contractInstance
4 | const Web3 = require('web3');
5 | const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:8545'));
6 | // const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:9545'));
7 |
8 | contract('OpCodes', (accounts) => {
9 | beforeEach(async () => {
10 | contractInstance = await TodoList.deployed()
11 | })
12 | // it('Should run without errors the majorit of opcodes', async () => {
13 | // await contractInstance.test()
14 | // await contractInstance.test_stop()
15 |
16 | // })
17 |
18 | it('Should throw invalid op code', async () => {
19 | try{
20 | await contractInstance.test_invalid()
21 | }
22 | catch(error) {
23 | console.error(error);
24 | }
25 | })
26 |
27 | it('Should revert', async () => {
28 | try{
29 | await contractInstance.test_revert() }
30 | catch(error) {
31 | console.error(error);
32 | }
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/opcode/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.5.17",
15 | },
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/DepositableStorage.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 | import "./UnstructuredStorage.sol";
4 |
5 |
6 | contract DepositableStorage {
7 | using UnstructuredStorage for bytes32;
8 |
9 | // keccak256("aragonOS.depositableStorage.depositable")
10 | bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea;
11 |
12 | function isDepositable() public view returns (bool) {
13 | return DEPOSITABLE_POSITION.getStorageBool();
14 | }
15 |
16 | function setDepositable(bool _depositable) internal {
17 | DEPOSITABLE_POSITION.setStorageBool(_depositable);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/ERCProxy.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 |
4 | contract ERCProxy {
5 | uint256 internal constant FORWARDING = 1;
6 | uint256 internal constant UPGRADEABLE = 2;
7 |
8 | function proxyType() public pure returns (uint256 proxyTypeId);
9 | function implementation() public view returns (address codeAddr);
10 | }
11 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/IsContract.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.4.24;
2 |
3 |
4 | contract IsContract {
5 | /*
6 | * NOTE: this should NEVER be used for authentication
7 | * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
8 | *
9 | * This is only intended to be used as a sanity check that an address is actually a contract,
10 | * RATHER THAN an address not being a contract.
11 | */
12 | function isContract(address _target) internal view returns (bool) {
13 | if (_target == address(0)) {
14 | return false;
15 | }
16 |
17 | uint256 size;
18 | assembly { size := extcodesize(_target) }
19 | return size > 0;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/test/DepositableDelegateProxyMock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 | import "../DepositableDelegateProxy.sol";
4 |
5 |
6 | contract DepositableDelegateProxyMock is DepositableDelegateProxy {
7 | address private implementationMock;
8 |
9 | function enableDepositsOnMock() external {
10 | setDepositable(true);
11 | }
12 |
13 | function setImplementationOnMock(address _implementationMock) external {
14 | implementationMock = _implementationMock;
15 | }
16 |
17 | function implementation() public view returns (address) {
18 | return implementationMock;
19 | }
20 |
21 | function proxyType() public pure returns (uint256 proxyTypeId) {
22 | return UPGRADEABLE;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/test/EthSender.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 |
4 | contract EthSender {
5 | function sendEth(address to) external payable {
6 | to.transfer(msg.value);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/test/Migrations.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 | pragma solidity >=0.4.22 <0.8.0;
3 |
4 | contract Migrations {
5 | address public owner = msg.sender;
6 | uint public last_completed_migration;
7 |
8 | modifier restricted() {
9 | require(
10 | msg.sender == owner,
11 | "This function is restricted to the contract's owner"
12 | );
13 | _;
14 | }
15 |
16 | function setCompleted(uint completed) public restricted {
17 | last_completed_migration = completed;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/contracts/test/ProxyTarget.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.4.24;
2 |
3 | contract ProxyTargetWithoutFallback {
4 | event Pong();
5 |
6 | function ping() external {
7 | emit Pong();
8 | }
9 | }
10 |
11 | contract ProxyTargetWithFallback is ProxyTargetWithoutFallback {
12 | event ReceivedEth();
13 |
14 | function () external payable {
15 | emit ReceivedEth();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function (deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "proxy",
3 | "version": "1.0.0",
4 | "author": "Aragon Association ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn truffle test",
8 | "test-ethermint": "yarn truffle test --network ethermint"
9 | },
10 | "devDependencies": {
11 | "@aragon/contract-helpers-test": "^0.1.0",
12 | "chai": "^4.2.0"
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/solidity/suites/proxy/test/.gitkeep
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/proxy/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.4.24",
15 | settings: {
16 | optimizer: {
17 | enabled: true,
18 | runs: 10000,
19 | },
20 | },
21 | },
22 | },
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/.github/workflows/ci_contracts.yml:
--------------------------------------------------------------------------------
1 | name: contracts
2 |
3 | on:
4 | push:
5 | branches:
6 | - main
7 | pull_request:
8 | branches:
9 | - '*'
10 |
11 | jobs:
12 | CI:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v2.4.0
16 | - name: Install node
17 | uses: actions/setup-node@v2.4.1
18 | with:
19 | node-version: 12
20 | - name: Install
21 | run: yarn
22 | - name: Lint
23 | run: yarn lint
24 | - name: Test
25 | run: yarn test
26 | - name: coverage
27 | continue-on-error: true
28 | run: yarn coverage
29 | env:
30 | CI: true
31 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/Autopetrified.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/Autopetrified.sol
2 | // Adapted to use pragma ^0.5.17 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.17;
5 |
6 | import "./Petrifiable.sol";
7 |
8 |
9 | contract Autopetrified is Petrifiable {
10 | constructor() public {
11 | // Immediately petrify base (non-proxy) instances of inherited contracts on deploy.
12 | // This renders them uninitializable (and unusable without a proxy).
13 | petrify();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/ERC20.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/lib/token/ERC20.sol
2 | // Adapted to use pragma ^0.5.8 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.8;
5 |
6 |
7 | /**
8 | * @title ERC20 interface
9 | * @dev see https://github.com/ethereum/EIPs/issues/20
10 | */
11 | contract ERC20 {
12 | function totalSupply() public view returns (uint256);
13 |
14 | function balanceOf(address _who) public view returns (uint256);
15 |
16 | function allowance(address _owner, address _spender) public view returns (uint256);
17 |
18 | function transfer(address _to, uint256 _value) public returns (bool);
19 |
20 | function approve(address _spender, uint256 _value) public returns (bool);
21 |
22 | function transferFrom(address _from, address _to, uint256 _value) public returns (bool);
23 |
24 | event Transfer(
25 | address indexed from,
26 | address indexed to,
27 | uint256 value
28 | );
29 |
30 | event Approval(
31 | address indexed owner,
32 | address indexed spender,
33 | uint256 value
34 | );
35 | }
36 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/ERCProxy.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/lib/misc/ERCProxy.sol
2 | // Adapted to use pragma ^0.5.17 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.17;
5 |
6 |
7 | contract ERCProxy {
8 | uint256 internal constant FORWARDING = 1;
9 | uint256 internal constant UPGRADEABLE = 2;
10 |
11 | function proxyType() public pure returns (uint256 proxyTypeId);
12 | function implementation() public view returns (address codeAddr);
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/IsContract.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/IsContract.sol
2 | // Adapted to use pragma ^0.5.8 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.8;
5 |
6 |
7 | contract IsContract {
8 | /*
9 | * NOTE: this should NEVER be used for authentication
10 | * (see pitfalls: https://github.com/fergarrui/ethereum-security/tree/master/contracts/extcodesize).
11 | *
12 | * This is only intended to be used as a sanity check that an address is actually a contract,
13 | * RATHER THAN an address not being a contract.
14 | */
15 | function isContract(address _target) internal view returns (bool) {
16 | if (_target == address(0)) {
17 | return false;
18 | }
19 |
20 | uint256 size;
21 | assembly { size := extcodesize(_target) }
22 | return size > 0;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/Migrations.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/lib/misc/Migrations.sol
2 | // Adapted to use pragma ^0.5.8 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.8;
5 |
6 |
7 | contract Migrations {
8 | address public owner;
9 | uint256 public lastCompletedMigration;
10 |
11 | modifier restricted() {
12 | if (msg.sender == owner) {
13 | _;
14 | }
15 | }
16 |
17 | constructor() public {
18 | owner = msg.sender;
19 | }
20 |
21 | function setCompleted(uint256 completed) public restricted {
22 | lastCompletedMigration = completed;
23 | }
24 |
25 | function upgrade(address newAddress) public restricted {
26 | Migrations upgraded = Migrations(newAddress);
27 | upgraded.setCompleted(lastCompletedMigration);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/Petrifiable.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/Petrifiable.sol
2 | // Adapted to use pragma ^0.5.17 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.17;
5 |
6 | import "./Initializable.sol";
7 |
8 |
9 | contract Petrifiable is Initializable {
10 | // Use block UINT256_MAX (which should be never) as the initializable date
11 | uint256 internal constant PETRIFIED_BLOCK = uint256(-1);
12 |
13 | function isPetrified() public view returns (bool) {
14 | return getInitializationBlock() == PETRIFIED_BLOCK;
15 | }
16 |
17 | /**
18 | * @dev Function to be called by top level contract to prevent being initialized.
19 | * Useful for freezing base contracts when they're used behind proxies.
20 | */
21 | function petrify() internal onlyInit {
22 | initializedAt(PETRIFIED_BLOCK);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/lib/os/Uint256Helpers.sol:
--------------------------------------------------------------------------------
1 | // Brought from https://github.com/aragon/aragonOS/blob/v4.3.0/contracts/common/Uint256Helpers.sol
2 | // Adapted to use pragma ^0.5.8 and satisfy our linter rules
3 |
4 | pragma solidity ^0.5.8;
5 |
6 |
7 | library Uint256Helpers {
8 | uint256 private constant MAX_UINT8 = uint8(-1);
9 | uint256 private constant MAX_UINT64 = uint64(-1);
10 |
11 | string private constant ERROR_UINT8_NUMBER_TOO_BIG = "UINT8_NUMBER_TOO_BIG";
12 | string private constant ERROR_UINT64_NUMBER_TOO_BIG = "UINT64_NUMBER_TOO_BIG";
13 |
14 | function toUint8(uint256 a) internal pure returns (uint8) {
15 | require(a <= MAX_UINT8, ERROR_UINT8_NUMBER_TOO_BIG);
16 | return uint8(a);
17 | }
18 |
19 | function toUint64(uint256 a) internal pure returns (uint64) {
20 | require(a <= MAX_UINT64, ERROR_UINT64_NUMBER_TOO_BIG);
21 | return uint64(a);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/locking/ILockManager.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.17;
2 |
3 |
4 | interface ILockManager {
5 | /**
6 | * @notice Check if `_user`'s by `_lockManager` can be unlocked
7 | * @param _user Owner of lock
8 | * @param _amount Amount of locked tokens to unlock
9 | * @return Whether given lock of given owner can be unlocked by given sender
10 | */
11 | function canUnlock(address _user, uint256 _amount) external view returns (bool);
12 | }
13 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/proxies/ThinProxy.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.17;
2 |
3 | import "../lib/os/DelegateProxy.sol";
4 | import "../lib/os/UnstructuredStorage.sol";
5 |
6 |
7 | contract ThinProxy is DelegateProxy {
8 | using UnstructuredStorage for bytes32;
9 |
10 | constructor(address _implementation) public {
11 | _implementationSlot().setStorageAddress(_implementation);
12 | }
13 |
14 | function () external {
15 | delegatedFwd(implementation(), msg.data);
16 | }
17 |
18 | function proxyType() public pure returns (uint256) {
19 | return FORWARDING;
20 | }
21 |
22 | function implementation() public view returns (address) {
23 | return _implementationSlot().getStorageAddress();
24 | }
25 |
26 | function _implementationSlot() internal pure returns (bytes32);
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/test/TestImports.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.5.17;
2 |
3 | import "./lib/MiniMeToken.sol";
4 | import "../lib/os/Migrations.sol";
5 |
6 | // You might think this file is a bit odd, but let me explain.
7 | // We only use some contracts in our tests, which means Truffle
8 | // will not compile it for us, because it is from an external
9 | // dependency.
10 | //
11 | // We are now left with three options:
12 | // - Copy/paste these contracts
13 | // - Run the tests with `truffle compile --all` on
14 | // - Or trick Truffle by claiming we use it in a Solidity test
15 | //
16 | // You know which one I went for.
17 |
18 |
19 | contract TestImports {
20 | constructor() public {
21 | // solium-disable-previous-line no-empty-blocks
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/test/mocks/CheckpointingMock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.5.17;
2 |
3 | import "../../lib/Checkpointing.sol";
4 |
5 |
6 | contract CheckpointingMock {
7 | using Checkpointing for Checkpointing.History;
8 |
9 | Checkpointing.History history;
10 |
11 | function add(uint64 value, uint256 time) public {
12 | history.add(value, time);
13 | }
14 |
15 | function getLast() public view returns (uint256) {
16 | return history.getLast();
17 | }
18 |
19 | function get(uint64 time) public view returns (uint256) {
20 | return history.get(time);
21 | }
22 |
23 | function getHistorySize() public view returns (uint256) {
24 | return history.history.length;
25 | }
26 |
27 | function lastUpdate() public view returns (uint256) {
28 | return history.lastUpdate();
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/test/mocks/ERC20.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.17;
2 |
3 |
4 | /**
5 | * @title ERC20 interface
6 | * @dev see https://github.com/ethereum/EIPs/issues/20
7 | */
8 | contract ERC20 {
9 | function totalSupply() public view returns (uint256);
10 |
11 | function balanceOf(address _who) public view returns (uint256);
12 |
13 | function allowance(address _owner, address _spender)
14 | public view returns (uint256);
15 |
16 | function transfer(address _to, uint256 _value) public returns (bool);
17 |
18 | function approve(address _spender, uint256 _value)
19 | public returns (bool);
20 |
21 | function transferFrom(address _from, address _to, uint256 _value)
22 | public returns (bool);
23 |
24 | event Transfer(address indexed from, address indexed to, uint256 value);
25 | event Approval(address indexed owner, address indexed spender, uint256 value);
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/contracts/test/mocks/TimeLockManagerMock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity 0.5.17;
2 |
3 | import "../../locking/TimeLockManager.sol";
4 | import "../../Staking.sol";
5 |
6 |
7 | contract TimeLockManagerMock is TimeLockManager {
8 | uint64 public constant MAX_UINT64 = uint64(-1);
9 |
10 | uint256 _mockTime = now;
11 | uint256 _mockBlockNumber = block.number;
12 |
13 | function getTimestampExt() external view returns (uint256) {
14 | return getTimestamp();
15 | }
16 |
17 | function getBlockNumberExt() external view returns (uint256) {
18 | return getBlockNumber();
19 | }
20 |
21 | function setTimestamp(uint256 i) public {
22 | _mockTime = i;
23 | }
24 |
25 | function setBlockNumber(uint256 i) public {
26 | _mockBlockNumber = i;
27 | }
28 |
29 | function getTimestamp() internal view returns (uint256) {
30 | return _mockTime;
31 | }
32 |
33 | function getBlockNumber() internal view returns (uint256) {
34 | return _mockBlockNumber;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "staking",
3 | "version": "1.0.0",
4 | "author": "Aragon Association ",
5 | "license": "GPL-3.0-or-later",
6 | "scripts": {
7 | "test-ganache": "yarn truffle test",
8 | "test-ethermint": "yarn truffle test --network ethermint",
9 | "postinstall": "patch-package"
10 | },
11 | "devDependencies": {
12 | "@aragon/contract-helpers-test": "^0.0.3",
13 | "chai": "^4.2.0",
14 | "ganache-cli": "^6.1.0",
15 | "web3-eth-abi": "^1.2.11",
16 | "web3-utils": "^1.2.11"
17 | },
18 | "dependencies": {
19 | "patch-package": "^6.4.7"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/test/helpers/constants.js:
--------------------------------------------------------------------------------
1 | const { bn, bigExp } = require('@aragon/contract-helpers-test/numbers')
2 | const DEFAULT_STAKE_AMOUNT = bigExp(120, 18)
3 |
4 | module.exports = {
5 | DEFAULT_STAKE_AMOUNT,
6 | DEFAULT_LOCK_AMOUNT: DEFAULT_STAKE_AMOUNT.div(bn(3)),
7 | EMPTY_DATA: '0x',
8 | ZERO_ADDRESS: '0x' + '0'.repeat(40),
9 | ACTIVATED_LOCK: '0x01'
10 | }
11 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/staking/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 7000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.5.17", // A version or constraint - Ex. "^0.5.0".
15 | settings: {
16 | optimizer: {
17 | enabled: true,
18 | runs: 10000,
19 | },
20 | },
21 | },
22 | },
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/contracts/EventTest.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity >=0.7.0 <0.9.0;
4 |
5 | /**
6 | * @title Storage
7 | * @dev Store & retrieve value in a variable
8 | */
9 | contract EventTest {
10 |
11 | uint256 number;
12 |
13 | event ValueStored1(
14 | uint value1
15 | );
16 | event ValueStored2(
17 | string msg,
18 | uint value1
19 | );
20 | event ValueStored3(
21 | string msg,
22 | uint indexed value1,
23 | uint value2
24 | );
25 |
26 | function store(uint256 num) public {
27 | number = num;
28 | }
29 |
30 | function storeWithEvent(uint256 num) public {
31 | number = num;
32 | emit ValueStored1(num);
33 | emit ValueStored2("TestMsg", num);
34 | emit ValueStored3("TestMsg", num, num);
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/contracts/Storage.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: GPL-3.0
2 |
3 | pragma solidity >=0.7.0 <0.9.0;
4 |
5 | /**
6 | * @title Storage
7 | * @dev Store & retrieve value in a variable
8 | */
9 | contract Storage {
10 |
11 | uint256 number;
12 |
13 | /**
14 | * @dev Store value in variable
15 | * @param num value to store
16 | */
17 | function store(uint256 num) public {
18 | number = num;
19 | }
20 |
21 | /**
22 | * @dev Return value
23 | * @return value of 'number'
24 | */
25 | function retrieve() public view returns (uint256){
26 | return number;
27 | }
28 |
29 | function shouldRevert() public {
30 | require(false, 'This must REVERT');
31 | }
32 | }
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eth-call-test",
3 | "version": "1.0.0",
4 | "main": "index.js",
5 | "license": "MIT",
6 | "dependencies": {
7 | "@truffle/hdwallet-provider": "^1.6.0",
8 | "concurrently": "^6.2.0",
9 | "truffle-assertions": "^0.9.2"
10 | },
11 | "scripts": {
12 | "test-ganache": "yarn truffle test",
13 | "test-ethermint": "yarn truffle test --network ethermint"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/test/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ArableProtocol/acrechain/9f06935257d8682e04e14fac3ee71dfbd2d5e708/ethermint/tests/solidity/suites/storage/test/.gitkeep
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/test/0_test_contracts.test.js:
--------------------------------------------------------------------------------
1 | const Storage = artifacts.require('Storage');
2 |
3 |
4 | contract('Test Storage Contract', async function (accounts) {
5 |
6 | let storageInstance;
7 |
8 | before(function () {
9 | console.log(`Using Accounts (${accounts.length}): \n${accounts.join('\n')}`);
10 | console.log('==========================\n');
11 | })
12 |
13 | it('should deploy Stroage contract', async function () {
14 | storageInstance = await Storage.new();
15 | console.log(`Deployed Storage at: ${storageInstance.address}`);
16 | expect(storageInstance.address).not.to.be.undefined;
17 | });
18 |
19 | it('should succesfully stored a value', async function () {
20 | const tx = await storageInstance.store(888);
21 | console.log(`Stored value 888 by tx: ${tx.tx}`);
22 | expect(tx.tx).not.to.be.undefined;
23 | });
24 |
25 | it('should succesfully retrieve a value', async function () {
26 | const value = await storageInstance.retrieve();
27 | expect(value.toString()).to.equal('888');
28 | });
29 |
30 | })
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/test/1_test_evm_revert.test.js:
--------------------------------------------------------------------------------
1 | const Storage = artifacts.require('Storage');
2 |
3 | async function expectRevert(promise) {
4 | try {
5 | await promise;
6 | } catch (error) {
7 | if (error.message.indexOf('revert') === -1) {
8 | expect('revert').to.equal(error.message, 'Wrong kind of exception received');
9 | }
10 | return;
11 | }
12 | expect.fail('Expected an exception but none was received');
13 | }
14 |
15 |
16 | contract('Test EVM Revert', async function (accounts) {
17 |
18 | before(function () {
19 | console.log(`Using Accounts (${accounts.length}): \n${accounts.join('\n')}`);
20 | console.log('==========================\n');
21 | })
22 |
23 | let storageInstance;
24 | it('should deploy Stroage contract', async function () {
25 | storageInstance = await Storage.new();
26 | console.log(`Deployed Storage at: ${storageInstance.address}`);
27 | expect(storageInstance.address).not.to.be.undefined;
28 | });
29 |
30 | it('should revert when call `shouldRevert()`', async function () {
31 | await expectRevert(storageInstance.shouldRevert());
32 | });
33 |
34 | })
--------------------------------------------------------------------------------
/ethermint/tests/solidity/suites/storage/truffle-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | networks: {
3 | // Development network is just left as truffle's default settings
4 | ethermint: {
5 | host: "127.0.0.1", // Localhost (default: none)
6 | port: 8545, // Standard Ethereum port (default: none)
7 | network_id: "*", // Any network (default: none)
8 | gas: 5000000, // Gas sent with each transaction
9 | gasPrice: 1000000000, // 1 gwei (in wei)
10 | },
11 | },
12 | compilers: {
13 | solc: {
14 | version: "0.8.3",
15 | },
16 | },
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/tests/tooling/ethers/ethers.js:
--------------------------------------------------------------------------------
1 | import { ethers } from "ethers";
2 |
3 | // connects to localhost:8545
4 | const provider = new ethers.providers.JsonRpcProvider()
5 |
6 | // const signer = provider.getSigner();
7 |
8 | const blockNumber = await provider.getBlockNumber()
--------------------------------------------------------------------------------
/ethermint/third_party/proto/buf.yaml:
--------------------------------------------------------------------------------
1 | version: v1
2 | build:
3 | excludes:
4 | - google/protobuf
5 | lint:
6 | use:
7 | - DEFAULT
8 | - COMMENTS
9 | - FILE_LOWER_SNAKE_CASE
10 | except:
11 | - UNARY_RPC
12 | - COMMENT_FIELD
13 | - SERVICE_SUFFIX
14 | - PACKAGE_VERSION_SUFFIX
15 | - RPC_REQUEST_STANDARD_NAME
16 | - RPC_REQUEST_RESPONSE_UNIQUE
17 | - RPC_RESPONSE_STANDARD_NAME
18 | - RPC_REQUEST_RESPONSE_UNIQUE
19 | - COMMENT_MESSAGE
20 | ignore:
21 | - tendermint
22 | - gogoproto
23 | - cosmos_proto
24 | - google
25 | - confio
26 | breaking:
27 | use:
28 | - FILE
29 | ignore:
30 | - tendermint
31 | - gogoproto
32 | - cosmos_proto
33 | - google
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/auth/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.auth.v1beta1;
3 |
4 | import "google/protobuf/any.proto";
5 | import "gogoproto/gogo.proto";
6 | import "cosmos/auth/v1beta1/auth.proto";
7 |
8 | option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
9 |
10 | // GenesisState defines the auth module's genesis state.
11 | message GenesisState {
12 | // params defines all the paramaters of the module.
13 | Params params = 1 [(gogoproto.nullable) = false];
14 |
15 | // accounts are the accounts present at genesis.
16 | repeated google.protobuf.Any accounts = 2;
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/authz/v1beta1/authz.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.authz.v1beta1;
3 |
4 | import "cosmos_proto/cosmos.proto";
5 | import "google/protobuf/timestamp.proto";
6 | import "gogoproto/gogo.proto";
7 | import "google/protobuf/any.proto";
8 |
9 | option go_package = "github.com/cosmos/cosmos-sdk/x/authz";
10 | option (gogoproto.goproto_getters_all) = false;
11 |
12 | // GenericAuthorization gives the grantee unrestricted permissions to execute
13 | // the provided method on behalf of the granter's account.
14 | message GenericAuthorization {
15 | option (cosmos_proto.implements_interface) = "Authorization";
16 |
17 | // Msg, identified by it's type URL, to grant unrestricted permissions to execute
18 | string msg = 1;
19 | }
20 |
21 | // Grant gives permissions to execute
22 | // the provide method with expiration time.
23 | message Grant {
24 | google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"];
25 | google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false];
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/authz/v1beta1/event.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.authz.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/authz";
5 |
6 | // EventGrant is emitted on Msg/Grant
7 | message EventGrant {
8 | // Msg type URL for which an autorization is granted
9 | string msg_type_url = 2;
10 | // Granter account address
11 | string granter = 3;
12 | // Grantee account address
13 | string grantee = 4;
14 | }
15 |
16 | // EventRevoke is emitted on Msg/Revoke
17 | message EventRevoke {
18 | // Msg type URL for which an autorization is revoked
19 | string msg_type_url = 2;
20 | // Granter account address
21 | string granter = 3;
22 | // Grantee account address
23 | string grantee = 4;
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/authz/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.authz.v1beta1;
3 |
4 | import "google/protobuf/timestamp.proto";
5 | import "google/protobuf/any.proto";
6 | import "gogoproto/gogo.proto";
7 | import "cosmos_proto/cosmos.proto";
8 |
9 | option go_package = "github.com/cosmos/cosmos-sdk/x/authz";
10 |
11 | // GenesisState defines the authz module's genesis state.
12 | message GenesisState {
13 | repeated GrantAuthorization authorization = 1 [(gogoproto.nullable) = false];
14 | }
15 |
16 | // GrantAuthorization defines the GenesisState/GrantAuthorization type.
17 | message GrantAuthorization {
18 | string granter = 1;
19 | string grantee = 2;
20 |
21 | google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"];
22 | google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/bank/v1beta1/authz.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.bank.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "cosmos_proto/cosmos.proto";
6 | import "cosmos/base/v1beta1/coin.proto";
7 |
8 | option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";
9 |
10 | // SendAuthorization allows the grantee to spend up to spend_limit coins from
11 | // the granter's account.
12 | message SendAuthorization {
13 | option (cosmos_proto.implements_interface) = "Authorization";
14 |
15 | repeated cosmos.base.v1beta1.Coin spend_limit = 1
16 | [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/base/kv/v1beta1/kv.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.base.kv.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/types/kv";
7 |
8 | // Pairs defines a repeated slice of Pair objects.
9 | message Pairs {
10 | repeated Pair pairs = 1 [(gogoproto.nullable) = false];
11 | }
12 |
13 | // Pair defines a key/value bytes tuple.
14 | message Pair {
15 | bytes key = 1;
16 | bytes value = 2;
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/base/snapshots/v1beta1/snapshot.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.base.snapshots.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/snapshots/types";
7 |
8 | // Snapshot contains Tendermint state sync snapshot info.
9 | message Snapshot {
10 | uint64 height = 1;
11 | uint32 format = 2;
12 | uint32 chunks = 3;
13 | bytes hash = 4;
14 | Metadata metadata = 5 [(gogoproto.nullable) = false];
15 | }
16 |
17 | // Metadata contains SDK-specific snapshot metadata.
18 | message Metadata {
19 | repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes
20 | }
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/base/store/v1beta1/commit_info.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.base.store.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/store/types";
7 |
8 | // CommitInfo defines commit information used by the multi-store when committing
9 | // a version/height.
10 | message CommitInfo {
11 | int64 version = 1;
12 | repeated StoreInfo store_infos = 2 [(gogoproto.nullable) = false];
13 | }
14 |
15 | // StoreInfo defines store-specific commit information. It contains a reference
16 | // between a store name and the commit ID.
17 | message StoreInfo {
18 | string name = 1;
19 | CommitID commit_id = 2 [(gogoproto.nullable) = false];
20 | }
21 |
22 | // CommitID defines the committment information when a specific store is
23 | // committed.
24 | message CommitID {
25 | option (gogoproto.goproto_stringer) = false;
26 |
27 | int64 version = 1;
28 | bytes hash = 2;
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/base/store/v1beta1/listening.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.base.store.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/store/types";
5 |
6 | // StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes)
7 | // It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and
8 | // Deletes
9 | message StoreKVPair {
10 | string store_key = 1; // the store key for the KVStore this pair originates from
11 | bool delete = 2; // true indicates a delete operation, false indicates a set operation
12 | bytes key = 3;
13 | bytes value = 4;
14 | }
15 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/base/store/v1beta1/snapshot.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.base.store.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/store/types";
7 |
8 | // SnapshotItem is an item contained in a rootmulti.Store snapshot.
9 | message SnapshotItem {
10 | // item is the specific type of snapshot item.
11 | oneof item {
12 | SnapshotStoreItem store = 1;
13 | SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"];
14 | }
15 | }
16 |
17 | // SnapshotStoreItem contains metadata about a snapshotted store.
18 | message SnapshotStoreItem {
19 | string name = 1;
20 | }
21 |
22 | // SnapshotIAVLItem is an exported IAVL node.
23 | message SnapshotIAVLItem {
24 | bytes key = 1;
25 | bytes value = 2;
26 | int64 version = 3;
27 | int32 height = 4;
28 | }
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/capability/v1beta1/capability.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.capability.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // Capability defines an implementation of an object capability. The index
9 | // provided to a Capability must be globally unique.
10 | message Capability {
11 | option (gogoproto.goproto_stringer) = false;
12 |
13 | uint64 index = 1 [(gogoproto.moretags) = "yaml:\"index\""];
14 | }
15 |
16 | // Owner defines a single capability owner. An owner is defined by the name of
17 | // capability and the module name.
18 | message Owner {
19 | option (gogoproto.goproto_stringer) = false;
20 | option (gogoproto.goproto_getters) = false;
21 |
22 | string module = 1 [(gogoproto.moretags) = "yaml:\"module\""];
23 | string name = 2 [(gogoproto.moretags) = "yaml:\"name\""];
24 | }
25 |
26 | // CapabilityOwners defines a set of owners of a single Capability. The set of
27 | // owners must be unique.
28 | message CapabilityOwners {
29 | repeated Owner owners = 1 [(gogoproto.nullable) = false];
30 | }
31 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/capability/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.capability.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "cosmos/capability/v1beta1/capability.proto";
6 |
7 | option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types";
8 |
9 | // GenesisOwners defines the capability owners with their corresponding index.
10 | message GenesisOwners {
11 | // index is the index of the capability owner.
12 | uint64 index = 1;
13 |
14 | // index_owners are the owners at the given index.
15 | CapabilityOwners index_owners = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"index_owners\""];
16 | }
17 |
18 | // GenesisState defines the capability module's genesis state.
19 | message GenesisState {
20 | // index is the capability global index.
21 | uint64 index = 1;
22 |
23 | // owners represents a map from index to owners of the capability index
24 | // index key is string to allow amino marshalling.
25 | repeated GenesisOwners owners = 2 [(gogoproto.nullable) = false];
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crisis/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crisis.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "cosmos/base/v1beta1/coin.proto";
8 |
9 | // GenesisState defines the crisis module's genesis state.
10 | message GenesisState {
11 | // constant_fee is the fee used to verify the invariant in the crisis
12 | // module.
13 | cosmos.base.v1beta1.Coin constant_fee = 3
14 | [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"constant_fee\""];
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crisis/v1beta1/tx.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crisis.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/crisis/types";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // Msg defines the bank Msg service.
9 | service Msg {
10 | // VerifyInvariant defines a method to verify a particular invariance.
11 | rpc VerifyInvariant(MsgVerifyInvariant) returns (MsgVerifyInvariantResponse);
12 | }
13 |
14 | // MsgVerifyInvariant represents a message to verify a particular invariance.
15 | message MsgVerifyInvariant {
16 | option (gogoproto.equal) = false;
17 | option (gogoproto.goproto_getters) = false;
18 |
19 | string sender = 1;
20 | string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""];
21 | string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""];
22 | }
23 |
24 | // MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type.
25 | message MsgVerifyInvariantResponse {}
26 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crypto/ed25519/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crypto.ed25519;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519";
7 |
8 | // PubKey is an ed25519 public key for handling Tendermint keys in SDK.
9 | // It's needed for Any serialization and SDK compatibility.
10 | // It must not be used in a non Tendermint key context because it doesn't implement
11 | // ADR-28. Nevertheless, you will like to use ed25519 in app user level
12 | // then you must create a new proto message and follow ADR-28 for Address construction.
13 | message PubKey {
14 | option (gogoproto.goproto_stringer) = false;
15 |
16 | bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PublicKey"];
17 | }
18 |
19 | // Deprecated: PrivKey defines a ed25519 private key.
20 | // NOTE: ed25519 keys must not be used in SDK apps except in a tendermint validator context.
21 | message PrivKey {
22 | bytes key = 1 [(gogoproto.casttype) = "crypto/ed25519.PrivateKey"];
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crypto/multisig/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crypto.multisig;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "google/protobuf/any.proto";
6 |
7 | option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/multisig";
8 |
9 | // LegacyAminoPubKey specifies a public key type
10 | // which nests multiple public keys and a threshold,
11 | // it uses legacy amino address rules.
12 | message LegacyAminoPubKey {
13 | option (gogoproto.goproto_getters) = false;
14 |
15 | uint32 threshold = 1 [(gogoproto.moretags) = "yaml:\"threshold\""];
16 | repeated google.protobuf.Any public_keys = 2
17 | [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""];
18 | }
19 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crypto/multisig/v1beta1/multisig.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crypto.multisig.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/crypto/types";
7 |
8 | // MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey.
9 | // See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
10 | // signed and with which modes.
11 | message MultiSignature {
12 | option (gogoproto.goproto_unrecognized) = true;
13 | repeated bytes signatures = 1;
14 | }
15 |
16 | // CompactBitArray is an implementation of a space efficient bit array.
17 | // This is used to ensure that the encoded data takes up a minimal amount of
18 | // space after proto encoding.
19 | // This is not thread safe, and is not intended for concurrent usage.
20 | message CompactBitArray {
21 | option (gogoproto.goproto_stringer) = false;
22 |
23 | uint32 extra_bits_stored = 1;
24 | bytes elems = 2;
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crypto/secp256k1/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crypto.secp256k1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1";
7 |
8 | // PubKey defines a secp256k1 public key
9 | // Key is the compressed form of the pubkey. The first byte depends is a 0x02 byte
10 | // if the y-coordinate is the lexicographically largest of the two associated with
11 | // the x-coordinate. Otherwise the first byte is a 0x03.
12 | // This prefix is followed with the x-coordinate.
13 | message PubKey {
14 | option (gogoproto.goproto_stringer) = false;
15 |
16 | bytes key = 1;
17 | }
18 |
19 | // PrivKey defines a secp256k1 private key.
20 | message PrivKey {
21 | bytes key = 1;
22 | }
23 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/crypto/secp256r1/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.crypto.secp256r1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1";
7 | option (gogoproto.messagename_all) = true;
8 | option (gogoproto.goproto_stringer_all) = false;
9 | option (gogoproto.goproto_getters_all) = false;
10 |
11 | // PubKey defines a secp256r1 ECDSA public key.
12 | message PubKey {
13 | // Point on secp256r1 curve in a compressed representation as specified in section
14 | // 4.3.6 of ANSI X9.62: https://webstore.ansi.org/standards/ascx9/ansix9621998
15 | bytes key = 1 [(gogoproto.customtype) = "ecdsaPK"];
16 | }
17 |
18 | // PrivKey defines a secp256r1 ECDSA private key.
19 | message PrivKey {
20 | // secret number serialized using big-endian encoding
21 | bytes secret = 1 [(gogoproto.customtype) = "ecdsaSK"];
22 | }
23 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/evidence/v1beta1/evidence.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.evidence.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types";
5 | option (gogoproto.equal_all) = true;
6 |
7 | import "gogoproto/gogo.proto";
8 | import "google/protobuf/timestamp.proto";
9 |
10 | // Equivocation implements the Evidence interface and defines evidence of double
11 | // signing misbehavior.
12 | message Equivocation {
13 | option (gogoproto.goproto_stringer) = false;
14 | option (gogoproto.goproto_getters) = false;
15 | option (gogoproto.equal) = false;
16 |
17 | int64 height = 1;
18 | google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
19 | int64 power = 3;
20 | string consensus_address = 4 [(gogoproto.moretags) = "yaml:\"consensus_address\""];
21 | }
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/evidence/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.evidence.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types";
5 |
6 | import "google/protobuf/any.proto";
7 |
8 | // GenesisState defines the evidence module's genesis state.
9 | message GenesisState {
10 | // evidence defines all the evidence at genesis.
11 | repeated google.protobuf.Any evidence = 1;
12 | }
13 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/feegrant/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.feegrant.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "cosmos/feegrant/v1beta1/feegrant.proto";
6 |
7 | option go_package = "github.com/cosmos/cosmos-sdk/x/feegrant";
8 |
9 | // GenesisState contains a set of fee allowances, persisted from the store
10 | message GenesisState {
11 | repeated Grant allowances = 1 [(gogoproto.nullable) = false];
12 | }
13 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/genutil/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.genutil.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 |
6 | option go_package = "github.com/cosmos/cosmos-sdk/x/genutil/types";
7 |
8 | // GenesisState defines the raw genesis transaction in JSON.
9 | message GenesisState {
10 | // gen_txs defines the genesis transactions.
11 | repeated bytes gen_txs = 1 [
12 | (gogoproto.casttype) = "encoding/json.RawMessage",
13 | (gogoproto.jsontag) = "gentxs",
14 | (gogoproto.moretags) = "yaml:\"gentxs\""
15 | ];
16 | }
17 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/mint/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.mint.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "cosmos/mint/v1beta1/mint.proto";
6 |
7 | option go_package = "github.com/cosmos/cosmos-sdk/x/mint/types";
8 |
9 | // GenesisState defines the mint module's genesis state.
10 | message GenesisState {
11 | // minter is a space for holding current inflation information.
12 | Minter minter = 1 [(gogoproto.nullable) = false];
13 |
14 | // params defines all the paramaters of the module.
15 | Params params = 2 [(gogoproto.nullable) = false];
16 | }
17 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/params/v1beta1/params.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.params.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal";
5 | option (gogoproto.equal_all) = true;
6 |
7 | import "gogoproto/gogo.proto";
8 |
9 | // ParameterChangeProposal defines a proposal to change one or more parameters.
10 | message ParameterChangeProposal {
11 | option (gogoproto.goproto_getters) = false;
12 | option (gogoproto.goproto_stringer) = false;
13 |
14 | string title = 1;
15 | string description = 2;
16 | repeated ParamChange changes = 3 [(gogoproto.nullable) = false];
17 | }
18 |
19 | // ParamChange defines an individual parameter change, for use in
20 | // ParameterChangeProposal.
21 | message ParamChange {
22 | option (gogoproto.goproto_stringer) = false;
23 |
24 | string subspace = 1;
25 | string key = 2;
26 | string value = 3;
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/params/v1beta1/query.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.params.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "google/api/annotations.proto";
6 | import "cosmos/params/v1beta1/params.proto";
7 |
8 | option go_package = "github.com/cosmos/cosmos-sdk/x/params/types/proposal";
9 |
10 | // Query defines the gRPC querier service.
11 | service Query {
12 | // Params queries a specific parameter of a module, given its subspace and
13 | // key.
14 | rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
15 | option (google.api.http).get = "/cosmos/params/v1beta1/params";
16 | }
17 | }
18 |
19 | // QueryParamsRequest is request type for the Query/Params RPC method.
20 | message QueryParamsRequest {
21 | // subspace defines the module to query the parameter for.
22 | string subspace = 1;
23 |
24 | // key defines the key of the parameter in the subspace.
25 | string key = 2;
26 | }
27 |
28 | // QueryParamsResponse is response type for the Query/Params RPC method.
29 | message QueryParamsResponse {
30 | // param defines the queried parameter.
31 | ParamChange param = 1 [(gogoproto.nullable) = false];
32 | }
33 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos/slashing/v1beta1/tx.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos.slashing.v1beta1;
3 |
4 | option go_package = "github.com/cosmos/cosmos-sdk/x/slashing/types";
5 | option (gogoproto.equal_all) = true;
6 |
7 | import "gogoproto/gogo.proto";
8 |
9 | // Msg defines the slashing Msg service.
10 | service Msg {
11 | // Unjail defines a method for unjailing a jailed validator, thus returning
12 | // them into the bonded validator set, so they can begin receiving provisions
13 | // and rewards again.
14 | rpc Unjail(MsgUnjail) returns (MsgUnjailResponse);
15 | }
16 |
17 | // MsgUnjail defines the Msg/Unjail request type
18 | message MsgUnjail {
19 | option (gogoproto.goproto_getters) = false;
20 | option (gogoproto.goproto_stringer) = true;
21 |
22 | string validator_addr = 1 [(gogoproto.moretags) = "yaml:\"address\"", (gogoproto.jsontag) = "address"];
23 | }
24 |
25 | // MsgUnjailResponse defines the Msg/Unjail response type
26 | message MsgUnjailResponse {}
--------------------------------------------------------------------------------
/ethermint/third_party/proto/cosmos_proto/cosmos.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package cosmos_proto;
3 |
4 | import "google/protobuf/descriptor.proto";
5 |
6 | option go_package = "github.com/regen-network/cosmos-proto";
7 |
8 | extend google.protobuf.MessageOptions {
9 | string interface_type = 93001;
10 |
11 | string implements_interface = 93002;
12 | }
13 |
14 | extend google.protobuf.FieldOptions {
15 | string accepts_interface = 93001;
16 | }
17 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/crypto/keys.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.crypto;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // PublicKey defines the keys available for use with Tendermint Validators
9 | message PublicKey {
10 | option (gogoproto.compare) = true;
11 | option (gogoproto.equal) = true;
12 |
13 | oneof sum {
14 | bytes ed25519 = 1;
15 | bytes secp256k1 = 2;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/crypto/proof.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.crypto;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/crypto";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | message Proof {
9 | int64 total = 1;
10 | int64 index = 2;
11 | bytes leaf_hash = 3;
12 | repeated bytes aunts = 4;
13 | }
14 |
15 | message ValueOp {
16 | // Encoded in ProofOp.Key.
17 | bytes key = 1;
18 |
19 | // To encode in ProofOp.Data
20 | Proof proof = 2;
21 | }
22 |
23 | message DominoOp {
24 | string key = 1;
25 | string input = 2;
26 | string output = 3;
27 | }
28 |
29 | // ProofOp defines an operation used for calculating Merkle root
30 | // The data could be arbitrary format, providing nessecary data
31 | // for example neighbouring node hash
32 | message ProofOp {
33 | string type = 1;
34 | bytes key = 2;
35 | bytes data = 3;
36 | }
37 |
38 | // ProofOps is Merkle proof defined by the list of ProofOps
39 | message ProofOps {
40 | repeated ProofOp ops = 1 [(gogoproto.nullable) = false];
41 | }
42 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/libs/bits/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.libs.bits;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/libs/bits";
5 |
6 | message BitArray {
7 | int64 bits = 1;
8 | repeated uint64 elems = 2;
9 | }
10 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/types/block.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.types;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "tendermint/types/types.proto";
8 | import "tendermint/types/evidence.proto";
9 |
10 | message Block {
11 | Header header = 1 [(gogoproto.nullable) = false];
12 | Data data = 2 [(gogoproto.nullable) = false];
13 | tendermint.types.EvidenceList evidence = 3 [(gogoproto.nullable) = false];
14 | Commit last_commit = 4;
15 | }
16 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/types/validator.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.types;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/types";
5 |
6 | import "gogoproto/gogo.proto";
7 | import "tendermint/crypto/keys.proto";
8 |
9 | message ValidatorSet {
10 | repeated Validator validators = 1;
11 | Validator proposer = 2;
12 | int64 total_voting_power = 3;
13 | }
14 |
15 | message Validator {
16 | bytes address = 1;
17 | tendermint.crypto.PublicKey pub_key = 2 [(gogoproto.nullable) = false];
18 | int64 voting_power = 3;
19 | int64 proposer_priority = 4;
20 | }
21 |
22 | message SimpleValidator {
23 | tendermint.crypto.PublicKey pub_key = 1;
24 | int64 voting_power = 2;
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/third_party/proto/tendermint/version/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package tendermint.version;
3 |
4 | option go_package = "github.com/tendermint/tendermint/proto/tendermint/version";
5 |
6 | import "gogoproto/gogo.proto";
7 |
8 | // App includes the protocol and software version for the application.
9 | // This information is included in ResponseInfo. The App.Protocol can be
10 | // updated in ResponseEndBlock.
11 | message App {
12 | uint64 protocol = 1;
13 | string software = 2;
14 | }
15 |
16 | // Consensus captures the consensus rules for processing a block in the blockchain,
17 | // including all blockchain data structures and the rules of the application's
18 | // state transition machine.
19 | message Consensus {
20 | option (gogoproto.equal) = true;
21 |
22 | uint64 block = 1;
23 | uint64 app = 2;
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/tools/tools.go:
--------------------------------------------------------------------------------
1 | //go:build tools
2 |
3 | package tools
4 |
5 | import (
6 | _ "github.com/onsi/ginkgo/v2"
7 | )
8 |
9 | // This file imports packages that are used when running go generate, or used
10 | // during the development process but not otherwise depended on by built code.
11 |
--------------------------------------------------------------------------------
/ethermint/types/benchmark_test.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "fmt"
5 | "testing"
6 | )
7 |
8 | func BenchmarkParseChainID(b *testing.B) {
9 | b.ReportAllocs()
10 | // Start at 1, for valid EIP155, see regexEIP155 variable.
11 | for i := 1; i < b.N; i++ {
12 | chainID := fmt.Sprintf("ethermint_1-%d", i)
13 | if _, err := ParseChainID(chainID); err != nil {
14 | b.Fatal(err)
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/types/block.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import sdk "github.com/cosmos/cosmos-sdk/types"
4 |
5 | // BlockGasLimit returns the max gas (limit) defined in the block gas meter. If the meter is not
6 | // set, it returns the max gas from the application consensus params.
7 | // NOTE: see https://github.com/cosmos/cosmos-sdk/issues/9514 for full reference
8 | func BlockGasLimit(ctx sdk.Context) uint64 {
9 | blockGasMeter := ctx.BlockGasMeter()
10 |
11 | // Get the limit from the gas meter only if its not null and not an InfiniteGasMeter
12 | if blockGasMeter != nil && blockGasMeter.Limit() != 0 {
13 | return blockGasMeter.Limit()
14 | }
15 |
16 | // Otherwise get from the consensus parameters
17 | cp := ctx.ConsensusParams()
18 | if cp == nil || cp.Block == nil {
19 | return 0
20 | }
21 |
22 | maxGas := cp.Block.MaxGas
23 | if maxGas > 0 {
24 | return uint64(maxGas)
25 | }
26 |
27 | return 0
28 | }
29 |
--------------------------------------------------------------------------------
/ethermint/types/codec.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | codectypes "github.com/cosmos/cosmos-sdk/codec/types"
5 | authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
6 | )
7 |
8 | type ExtensionOptionsWeb3TxI interface{}
9 |
10 | // RegisterInterfaces registers the tendermint concrete client-related
11 | // implementations and interfaces.
12 | func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
13 | registry.RegisterImplementations(
14 | (*authtypes.AccountI)(nil),
15 | &EthAccount{},
16 | )
17 | registry.RegisterImplementations(
18 | (*authtypes.GenesisAccount)(nil),
19 | &EthAccount{},
20 | )
21 | registry.RegisterInterface(
22 | "ethermint.v1.ExtensionOptionsWeb3Tx",
23 | (*ExtensionOptionsWeb3TxI)(nil),
24 | &ExtensionOptionsWeb3Tx{},
25 | )
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/types/errors.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
5 | )
6 |
7 | const (
8 | // RootCodespace is the codespace for all errors defined in this package
9 | RootCodespace = "ethermint"
10 | )
11 |
12 | // NOTE: We can't use 1 since that error code is reserved for internal errors.
13 |
14 | var (
15 | // ErrInvalidValue returns an error resulting from an invalid value.
16 | ErrInvalidValue = sdkerrors.Register(RootCodespace, 2, "invalid value")
17 |
18 | // ErrInvalidChainID returns an error resulting from an invalid chain ID.
19 | ErrInvalidChainID = sdkerrors.Register(RootCodespace, 3, "invalid chain ID")
20 |
21 | // ErrMarshalBigInt returns an error resulting from marshaling a big.Int to a string.
22 | ErrMarshalBigInt = sdkerrors.Register(RootCodespace, 5, "cannot marshal big.Int to string")
23 |
24 | // ErrUnmarshalBigInt returns an error resulting from unmarshaling a big.Int from a string.
25 | ErrUnmarshalBigInt = sdkerrors.Register(RootCodespace, 6, "cannot unmarshal big.Int from string")
26 | )
27 |
--------------------------------------------------------------------------------
/ethermint/types/hdpath.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | ethaccounts "github.com/ethereum/go-ethereum/accounts"
5 | )
6 |
7 | var (
8 | // Bip44CoinType satisfies EIP84. See https://github.com/ethereum/EIPs/issues/84 for more info.
9 | Bip44CoinType uint32 = 60
10 |
11 | // BIP44HDPath is the default BIP44 HD path used on Ethereum.
12 | BIP44HDPath = ethaccounts.DefaultBaseDerivationPath.String()
13 | )
14 |
15 | type (
16 | HDPathIterator func() ethaccounts.DerivationPath
17 | )
18 |
19 | // HDPathIterator receives a base path as a string and a boolean for the desired iterator type and
20 | // returns a function that iterates over the base HD path, returning the string.
21 | func NewHDPathIterator(basePath string, ledgerIter bool) (HDPathIterator, error) {
22 | hdPath, err := ethaccounts.ParseDerivationPath(basePath)
23 | if err != nil {
24 | return nil, err
25 | }
26 |
27 | if ledgerIter {
28 | return ethaccounts.LedgerLiveIterator(hdPath), nil
29 | }
30 |
31 | return ethaccounts.DefaultIterator(hdPath), nil
32 | }
33 |
--------------------------------------------------------------------------------
/ethermint/types/indexer.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "github.com/ethereum/go-ethereum/common"
5 | abci "github.com/tendermint/tendermint/abci/types"
6 | tmtypes "github.com/tendermint/tendermint/types"
7 | )
8 |
9 | // EVMTxIndexer defines the interface of custom eth tx indexer.
10 | type EVMTxIndexer interface {
11 | // LastIndexedBlock returns -1 if indexer db is empty
12 | LastIndexedBlock() (int64, error)
13 | IndexBlock(*tmtypes.Block, []*abci.ResponseDeliverTx) error
14 |
15 | // GetByTxHash returns nil if tx not found.
16 | GetByTxHash(common.Hash) (*TxResult, error)
17 | // GetByBlockAndIndex returns nil if tx not found.
18 | GetByBlockAndIndex(int64, int32) (*TxResult, error)
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/types/int.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | fmt "fmt"
5 | math "math"
6 | "math/big"
7 |
8 | sdk "github.com/cosmos/cosmos-sdk/types"
9 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
10 | )
11 |
12 | const maxBitLen = 256
13 |
14 | // SafeInt64 checks for overflows while casting a uint64 to int64 value.
15 | func SafeInt64(value uint64) (int64, error) {
16 | if value > uint64(math.MaxInt64) {
17 | return 0, sdkerrors.Wrapf(sdkerrors.ErrInvalidHeight, "uint64 value %v cannot exceed %v", value, int64(math.MaxInt64))
18 | }
19 |
20 | return int64(value), nil
21 | }
22 |
23 | // SafeNewIntFromBigInt constructs Int from big.Int, return error if more than 256bits
24 | func SafeNewIntFromBigInt(i *big.Int) (sdk.Int, error) {
25 | if !IsValidInt256(i) {
26 | return sdk.NewInt(0), fmt.Errorf("big int out of bound: %s", i)
27 | }
28 | return sdk.NewIntFromBigInt(i), nil
29 | }
30 |
31 | // IsValidInt256 check the bound of 256 bit number
32 | func IsValidInt256(i *big.Int) bool {
33 | return i == nil || i.BitLen() <= maxBitLen
34 | }
35 |
--------------------------------------------------------------------------------
/ethermint/types/protocol.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // Constants to match up protocol versions and messages
4 | const (
5 | eth65 = 65
6 |
7 | // ProtocolVersion is the latest supported version of the eth protocol.
8 | ProtocolVersion = eth65
9 | )
10 |
--------------------------------------------------------------------------------
/ethermint/version/version.go:
--------------------------------------------------------------------------------
1 | package version
2 |
3 | import (
4 | "fmt"
5 | "runtime"
6 | )
7 |
8 | var (
9 | AppVersion = ""
10 | GitCommit = ""
11 | BuildDate = ""
12 |
13 | GoVersion = ""
14 | GoArch = ""
15 | )
16 |
17 | func init() {
18 | if len(AppVersion) == 0 {
19 | AppVersion = "dev"
20 | }
21 |
22 | GoVersion = runtime.Version()
23 | GoArch = runtime.GOARCH
24 | }
25 |
26 | func Version() string {
27 | return fmt.Sprintf(
28 | "Version %s (%s)\nCompiled at %s using Go %s (%s)",
29 | AppVersion,
30 | GitCommit,
31 | BuildDate,
32 | GoVersion,
33 | GoArch,
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/ethermint/x/README.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # List of Modules
6 |
7 | Here are the modules required in Ethermint :
8 |
9 | - [EVM](evm/spec/README.md) - Implement the EVM as a Cosmos SDK module.
10 | - [Fee Market](feemarket/spec/README.md) - Define a global variable fee for Cosmos transactions based on EIP-1559.
11 |
--------------------------------------------------------------------------------
/ethermint/x/evm/handler.go:
--------------------------------------------------------------------------------
1 | package evm
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
6 |
7 | "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | // NewHandler returns a handler for Ethermint type messages.
11 | func NewHandler(server types.MsgServer) sdk.Handler {
12 | return func(ctx sdk.Context, msg sdk.Msg) (result *sdk.Result, err error) {
13 | ctx = ctx.WithEventManager(sdk.NewEventManager())
14 |
15 | switch msg := msg.(type) {
16 | case *types.MsgEthereumTx:
17 | // execute state transition
18 | res, err := server.EthereumTx(sdk.WrapSDKContext(ctx), msg)
19 | return sdk.WrapServiceResult(ctx, res, err)
20 |
21 | default:
22 | err := sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
23 | return nil, err
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/abci.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | abci "github.com/tendermint/tendermint/abci/types"
5 |
6 | sdk "github.com/cosmos/cosmos-sdk/types"
7 |
8 | ethtypes "github.com/ethereum/go-ethereum/core/types"
9 | )
10 |
11 | // BeginBlock sets the sdk Context and EIP155 chain id to the Keeper.
12 | func (k *Keeper) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
13 | k.WithChainID(ctx)
14 | }
15 |
16 | // EndBlock also retrieves the bloom filter value from the transient store and commits it to the
17 | // KVStore. The EVM end block logic doesn't update the validator set, thus it returns
18 | // an empty slice.
19 | func (k *Keeper) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
20 | // Gas costs are handled within msg handler so costs should be ignored
21 | infCtx := ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
22 |
23 | bloom := ethtypes.BytesToBloom(k.GetBlockBloomTransient(infCtx).Bytes())
24 | k.EmitBlockBloomEvent(infCtx, bloom)
25 |
26 | return []abci.ValidatorUpdate{}
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/ERC20DirectBalanceManipulation.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity ^0.8.0;
4 |
5 | import "./@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
6 |
7 | // This is an evil token. Whenever an A -> B transfer is called, half of the amount goes to B
8 | // and half to a predefined C
9 | contract ERC20DirectBalanceManipulation is ERC20PresetMinterPauser {
10 | address private _thief = 0x4dC6ac40Af078661fc43823086E1513635Eeab14;
11 | constructor(uint256 initialSupply)
12 | ERC20PresetMinterPauser("ERC20DirectBalanceManipulation", "ERC20DirectBalanceManipulation") {
13 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
14 | _mint(msg.sender, initialSupply);
15 | }
16 | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
17 | // Any time a transaction happens, the thief account siphons half.
18 | uint256 half = amount / 2;
19 |
20 | super.transfer(_thief, amount - half); // a - h for rounding
21 | return super.transfer(recipient, half);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/ERC20MaliciousDelayed.sol:
--------------------------------------------------------------------------------
1 | // SPDX-License-Identifier: MIT
2 |
3 | pragma solidity ^0.8.0;
4 |
5 | import "./@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";
6 |
7 | // This is an evil token. Whenever an A -> B transfer is called,
8 | // a predefined C is given a massive allowance on B.
9 | contract ERC20MaliciousDelayed is ERC20PresetMinterPauser {
10 | address private _thief = 0x4dC6ac40Af078661fc43823086E1513635Eeab14;
11 | uint256 private _bigNum = 1000000000000000000; // ~uint256(0)
12 | constructor(uint256 initialSupply)
13 | ERC20PresetMinterPauser("ERC20MaliciousDelayed", "ERC20MALICIOUSDELAYED") {
14 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
15 | _mint(msg.sender, initialSupply);
16 |
17 | }
18 | function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
19 | // Any time a transaction happens, the thief account is granted allowance in secret.
20 | // Still emits an Approve!
21 | super._approve(recipient, _thief, _bigNum);
22 | return super.transfer(recipient, amount);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/erc20.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | evmtypes "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | var (
11 | //go:embed compiled_contracts/ERC20MinterBurnerDecimals.json
12 | ERC20MinterBurnerDecimalsJSON []byte // nolint: golint
13 |
14 | // ERC20MinterBurnerDecimalsContract is the compiled erc20 contract
15 | ERC20MinterBurnerDecimalsContract evmtypes.CompiledContract
16 | )
17 |
18 | func init() {
19 | err := json.Unmarshal(ERC20MinterBurnerDecimalsJSON, &ERC20MinterBurnerDecimalsContract)
20 | if err != nil {
21 | panic(err)
22 | }
23 |
24 | if len(ERC20MinterBurnerDecimalsContract.Bin) == 0 {
25 | panic("load contract failed")
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/erc20DirectBalanceManipulation.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | evmtypes "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | // This is an evil token. Whenever an A -> B transfer is called,
11 | // a predefined C is given a massive allowance on B.
12 | var (
13 | //go:embed compiled_contracts/ERC20DirectBalanceManipulation.json
14 | ERC20DirectBalanceManipulationJSON []byte // nolint: golint
15 |
16 | // ERC20DirectBalanceManipulationContract is the compiled erc20 contract
17 | ERC20DirectBalanceManipulationContract evmtypes.CompiledContract
18 | )
19 |
20 | func init() {
21 | err := json.Unmarshal(ERC20DirectBalanceManipulationJSON, &ERC20DirectBalanceManipulationContract)
22 | if err != nil {
23 | panic(err)
24 | }
25 |
26 | if len(ERC20DirectBalanceManipulationContract.Bin) == 0 {
27 | panic("load contract failed")
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/erc20burnable.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | evmtypes "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | var (
11 | //go:embed compiled_contracts/ERC20Burnable.json
12 | erc20BurnableJSON []byte
13 |
14 | // ERC20BurnableContract is the compiled ERC20Burnable contract
15 | ERC20BurnableContract evmtypes.CompiledContract
16 | )
17 |
18 | func init() {
19 | err := json.Unmarshal(erc20BurnableJSON, &ERC20BurnableContract)
20 | if err != nil {
21 | panic(err)
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/erc20maliciousdelayed.go:
--------------------------------------------------------------------------------
1 | package contracts
2 |
3 | import (
4 | _ "embed" // embed compiled smart contract
5 | "encoding/json"
6 |
7 | evmtypes "github.com/evmos/ethermint/x/evm/types"
8 | )
9 |
10 | // This is an evil token. Whenever an A -> B transfer is called,
11 | // a predefined C is given a massive allowance on B.
12 | var (
13 | //go:embed compiled_contracts/ERC20MaliciousDelayed.json
14 | ERC20MaliciousDelayedJSON []byte // nolint: golint
15 |
16 | // ERC20MaliciousDelayedContract is the compiled erc20 contract
17 | ERC20MaliciousDelayedContract evmtypes.CompiledContract
18 | )
19 |
20 | func init() {
21 | err := json.Unmarshal(ERC20MaliciousDelayedJSON, &ERC20MaliciousDelayedContract)
22 | if err != nil {
23 | panic(err)
24 | }
25 |
26 | if len(ERC20MaliciousDelayedContract.Bin) == 0 {
27 | panic("load contract failed")
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "evmos",
3 | "version": "1.0.0",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "@openzeppelin/contracts": {
8 | "version": "4.7.2",
9 | "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-4.7.2.tgz",
10 | "integrity": "sha512-4n/JL9izql8303mPqPdubuna/DWEMbmOzWYUWyCPhjhiEr2w3nQrjE7vZz1fBF+wzzP6dZbIcsgqACk53c9FGA=="
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/contracts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "evmos",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "directories": {
7 | "doc": "docs"
8 | },
9 | "dependencies": {
10 | "@openzeppelin/contracts": "^4.7.2"
11 | },
12 | "devDependencies": {},
13 | "scripts": {
14 | "test": "echo \"Error: no test specified\" && exit 1"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "git+https://github.com/evmos/evmos.git"
19 | },
20 | "author": "",
21 | "license": "ISC",
22 | "bugs": {
23 | "url": "https://github.com/evmos/evmos/issues"
24 | },
25 | "homepage": "https://github.com/evmos/evmos#readme"
26 | }
27 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/hooks.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
6 | "github.com/ethereum/go-ethereum/core"
7 | ethtypes "github.com/ethereum/go-ethereum/core/types"
8 | "github.com/evmos/ethermint/x/evm/types"
9 | )
10 |
11 | var _ types.EvmHooks = MultiEvmHooks{}
12 |
13 | // MultiEvmHooks combine multiple evm hooks, all hook functions are run in array sequence
14 | type MultiEvmHooks []types.EvmHooks
15 |
16 | // NewMultiEvmHooks combine multiple evm hooks
17 | func NewMultiEvmHooks(hooks ...types.EvmHooks) MultiEvmHooks {
18 | return hooks
19 | }
20 |
21 | // PostTxProcessing delegate the call to underlying hooks
22 | func (mh MultiEvmHooks) PostTxProcessing(ctx sdk.Context, msg core.Message, receipt *ethtypes.Receipt) error {
23 | for i := range mh {
24 | if err := mh[i].PostTxProcessing(ctx, msg, receipt); err != nil {
25 | return sdkerrors.Wrapf(err, "EVM hook %T failed", mh[i])
26 | }
27 | }
28 | return nil
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/migrations.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | v2 "github.com/evmos/ethermint/x/evm/migrations/v2"
6 | v3 "github.com/evmos/ethermint/x/evm/migrations/v3"
7 | )
8 |
9 | // Migrator is a struct for handling in-place store migrations.
10 | type Migrator struct {
11 | keeper Keeper
12 | }
13 |
14 | // NewMigrator returns a new Migrator.
15 | func NewMigrator(keeper Keeper) Migrator {
16 | return Migrator{
17 | keeper: keeper,
18 | }
19 | }
20 |
21 | // Migrate1to2 migrates the store from consensus version v1 to v2
22 | func (m Migrator) Migrate1to2(ctx sdk.Context) error {
23 | return v2.MigrateStore(ctx, &m.keeper.paramSpace)
24 | }
25 |
26 | // Migrate2to3 migrates the store from consensus version v2 to v3
27 | func (m Migrator) Migrate2to3(ctx sdk.Context) error {
28 | return v3.MigrateStore(ctx, &m.keeper.paramSpace)
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/params.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 |
6 | "github.com/evmos/ethermint/x/evm/types"
7 | )
8 |
9 | // GetParams returns the total set of evm parameters.
10 | func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
11 | // TODO: update once https://github.com/cosmos/cosmos-sdk/pull/12615 is merged
12 | // and released
13 | for _, pair := range params.ParamSetPairs() {
14 | k.paramSpace.GetIfExists(ctx, pair.Key, pair.Value)
15 | }
16 |
17 | return params
18 | }
19 |
20 | // SetParams sets the evm parameters to the param space.
21 | func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
22 | k.paramSpace.SetParamSet(ctx, ¶ms)
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/x/evm/keeper/params_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import (
4 | "github.com/evmos/ethermint/x/evm/types"
5 | )
6 |
7 | func (suite *KeeperTestSuite) TestParams() {
8 | params := suite.app.EvmKeeper.GetParams(suite.ctx)
9 | suite.Require().Equal(types.DefaultParams(), params)
10 | params.EvmDenom = "inj"
11 | suite.app.EvmKeeper.SetParams(suite.ctx, params)
12 | newParams := suite.app.EvmKeeper.GetParams(suite.ctx)
13 | suite.Require().Equal(newParams, params)
14 | }
15 |
--------------------------------------------------------------------------------
/ethermint/x/evm/migrations/v2/migrate.go:
--------------------------------------------------------------------------------
1 | package v2
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
6 | "github.com/evmos/ethermint/x/evm/types"
7 | )
8 |
9 | // MigrateStore sets the default AllowUnprotectedTxs parameter.
10 | func MigrateStore(ctx sdk.Context, paramstore *paramtypes.Subspace) error {
11 | if !paramstore.HasKeyTable() {
12 | ps := paramstore.WithKeyTable(types.ParamKeyTable())
13 | paramstore = &ps
14 | }
15 |
16 | // add RejectUnprotected
17 | paramstore.Set(ctx, types.ParamStoreKeyAllowUnprotectedTxs, types.DefaultAllowUnprotectedTxs)
18 | return nil
19 | }
20 |
--------------------------------------------------------------------------------
/ethermint/x/evm/migrations/v3/migrate.go:
--------------------------------------------------------------------------------
1 | package v3
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
6 | "github.com/evmos/ethermint/x/evm/types"
7 | )
8 |
9 | // MigrateStore sets the default for GrayGlacierBlock and MergeNetsplitBlock in ChainConfig parameter.
10 | func MigrateStore(ctx sdk.Context, paramstore *paramtypes.Subspace) error {
11 | if !paramstore.HasKeyTable() {
12 | ps := paramstore.WithKeyTable(types.ParamKeyTable())
13 | paramstore = &ps
14 | }
15 | prevConfig := &types.ChainConfig{}
16 | paramstore.GetIfExists(ctx, types.ParamStoreKeyChainConfig, prevConfig)
17 |
18 | defaultConfig := types.DefaultChainConfig()
19 |
20 | prevConfig.GrayGlacierBlock = defaultConfig.GrayGlacierBlock
21 | prevConfig.MergeNetsplitBlock = defaultConfig.MergeNetsplitBlock
22 |
23 | paramstore.Set(ctx, types.ParamStoreKeyChainConfig, prevConfig)
24 | return nil
25 | }
26 |
--------------------------------------------------------------------------------
/ethermint/x/evm/simulation/decoder.go:
--------------------------------------------------------------------------------
1 | package simulation
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 |
7 | "github.com/cosmos/cosmos-sdk/types/kv"
8 | "github.com/ethereum/go-ethereum/common"
9 | "github.com/evmos/ethermint/x/evm/types"
10 | )
11 |
12 | // NewDecodeStore returns a decoder function closure that unmarshals the KVPair's
13 | // value to the corresponding EVM type.
14 | func NewDecodeStore() func(kvA, kvB kv.Pair) string {
15 | return func(kvA, kvB kv.Pair) string {
16 | switch {
17 | case bytes.Equal(kvA.Key[:1], types.KeyPrefixStorage):
18 | storageA := common.BytesToHash(kvA.Value).Hex()
19 | storageB := common.BytesToHash(kvB.Value).Hex()
20 |
21 | return fmt.Sprintf("%v\n%v", storageA, storageB)
22 | case bytes.Equal(kvA.Key[:1], types.KeyPrefixCode):
23 | codeHashA := common.Bytes2Hex(kvA.Value)
24 | codeHashB := common.Bytes2Hex(kvB.Value)
25 |
26 | return fmt.Sprintf("%v\n%v", codeHashA, codeHashB)
27 | default:
28 | panic(fmt.Sprintf("invalid evm key prefix %X", kvA.Key[:1]))
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ethermint/x/evm/statedb/config.go:
--------------------------------------------------------------------------------
1 | package statedb
2 |
3 | import "github.com/ethereum/go-ethereum/common"
4 |
5 | // TxConfig encapulates the readonly information of current tx for `StateDB`.
6 | type TxConfig struct {
7 | BlockHash common.Hash // hash of current block
8 | TxHash common.Hash // hash of current tx
9 | TxIndex uint // the index of current transaction
10 | LogIndex uint // the index of next log within current block
11 | }
12 |
13 | // NewTxConfig returns a TxConfig
14 | func NewTxConfig(bhash, thash common.Hash, txIndex, logIndex uint) TxConfig {
15 | return TxConfig{
16 | BlockHash: bhash,
17 | TxHash: thash,
18 | TxIndex: txIndex,
19 | LogIndex: logIndex,
20 | }
21 | }
22 |
23 | // NewEmptyTxConfig construct an empty TxConfig,
24 | // used in context where there's no transaction, e.g. `eth_call`/`eth_estimateGas`.
25 | func NewEmptyTxConfig(bhash common.Hash) TxConfig {
26 | return TxConfig{
27 | BlockHash: bhash,
28 | TxHash: common.Hash{},
29 | TxIndex: 0,
30 | LogIndex: 0,
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/ethermint/x/evm/statedb/interfaces.go:
--------------------------------------------------------------------------------
1 | package statedb
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | "github.com/ethereum/go-ethereum/common"
6 | )
7 |
8 | // Keeper provide underlying storage of StateDB
9 | type Keeper interface {
10 | // Read methods
11 | GetAccount(ctx sdk.Context, addr common.Address) *Account
12 | GetState(ctx sdk.Context, addr common.Address, key common.Hash) common.Hash
13 | GetCode(ctx sdk.Context, codeHash common.Hash) []byte
14 | // the callback returns false to break early
15 | ForEachStorage(ctx sdk.Context, addr common.Address, cb func(key, value common.Hash) bool)
16 |
17 | // Write methods, only called by `StateDB.Commit()`
18 | SetAccount(ctx sdk.Context, addr common.Address, account Account) error
19 | SetState(ctx sdk.Context, addr common.Address, key common.Hash, value []byte)
20 | SetCode(ctx sdk.Context, codeHash []byte, code []byte)
21 | DeleteAccount(ctx sdk.Context, addr common.Address) error
22 | }
23 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/access_list_test.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "github.com/ethereum/go-ethereum/common"
5 | ethtypes "github.com/ethereum/go-ethereum/core/types"
6 | )
7 |
8 | func (suite *TxDataTestSuite) TestTestNewAccessList() {
9 | testCases := []struct {
10 | name string
11 | ethAccessList *ethtypes.AccessList
12 | expAl AccessList
13 | }{
14 | {
15 | "ethAccessList is nil",
16 | nil,
17 | nil,
18 | },
19 | {
20 | "non-empty ethAccessList",
21 | ðtypes.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}},
22 | AccessList{{Address: suite.hexAddr, StorageKeys: []string{common.Hash{}.Hex()}}},
23 | },
24 | }
25 | for _, tc := range testCases {
26 | al := NewAccessList(tc.ethAccessList)
27 |
28 | suite.Require().Equal(tc.expAl, al)
29 | }
30 | }
31 |
32 | func (suite *TxDataTestSuite) TestAccessListToEthAccessList() {
33 | ethAccessList := ethtypes.AccessList{{Address: suite.addr, StorageKeys: []common.Hash{{0}}}}
34 | al := NewAccessList(ðAccessList)
35 | actual := al.ToEthAccessList()
36 |
37 | suite.Require().Equal(ðAccessList, actual)
38 | }
39 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/config.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "math/big"
5 |
6 | "github.com/ethereum/go-ethereum/common"
7 | "github.com/ethereum/go-ethereum/params"
8 | )
9 |
10 | // EVMConfig encapsulates common parameters needed to create an EVM to execute a message
11 | // It's mainly to reduce the number of method parameters
12 | type EVMConfig struct {
13 | Params Params
14 | ChainConfig *params.ChainConfig
15 | CoinBase common.Address
16 | BaseFee *big.Int
17 | }
18 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/events.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // Evm module events
4 | const (
5 | EventTypeEthereumTx = TypeMsgEthereumTx
6 | EventTypeBlockBloom = "block_bloom"
7 | EventTypeTxLog = "tx_log"
8 |
9 | AttributeKeyContractAddress = "contract"
10 | AttributeKeyRecipient = "recipient"
11 | AttributeKeyTxHash = "txHash"
12 | AttributeKeyEthereumTxHash = "ethereumTxHash"
13 | AttributeKeyTxIndex = "txIndex"
14 | AttributeKeyTxGasUsed = "txGasUsed"
15 | AttributeKeyTxType = "txType"
16 | AttributeKeyTxLog = "txLog"
17 | // tx failed in eth vm execution
18 | AttributeKeyEthereumTxFailed = "ethereumTxFailed"
19 | AttributeValueCategory = ModuleName
20 | AttributeKeyEthereumBloom = "bloom"
21 |
22 | MetricKeyTransitionDB = "transition_db"
23 | MetricKeyStaticCall = "static_call"
24 | )
25 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/query.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | codectypes "github.com/cosmos/cosmos-sdk/codec/types"
5 | )
6 |
7 | // UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
8 | func (m QueryTraceTxRequest) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
9 | for _, msg := range m.Predecessors {
10 | if err := msg.UnpackInterfaces(unpacker); err != nil {
11 | return err
12 | }
13 | }
14 | return m.Msg.UnpackInterfaces(unpacker)
15 | }
16 |
17 | func (m QueryTraceBlockRequest) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
18 | for _, msg := range m.Txs {
19 | if err := msg.UnpackInterfaces(unpacker); err != nil {
20 | return err
21 | }
22 | }
23 | return nil
24 | }
25 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/tracer_test.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/require"
7 | )
8 |
9 | func TestNewNoOpTracer(t *testing.T) {
10 | require.Equal(t, &NoOpTracer{}, NewNoOpTracer())
11 | }
12 |
--------------------------------------------------------------------------------
/ethermint/x/evm/types/tx.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "github.com/ethereum/go-ethereum/common"
5 | "github.com/ethereum/go-ethereum/core/vm"
6 | )
7 |
8 | // Failed returns if the contract execution failed in vm errors
9 | func (m *MsgEthereumTxResponse) Failed() bool {
10 | return len(m.VmError) > 0
11 | }
12 |
13 | // Return is a helper function to help caller distinguish between revert reason
14 | // and function return. Return returns the data after execution if no error occurs.
15 | func (m *MsgEthereumTxResponse) Return() []byte {
16 | if m.Failed() {
17 | return nil
18 | }
19 | return common.CopyBytes(m.Ret)
20 | }
21 |
22 | // Revert returns the concrete revert reason if the execution is aborted by `REVERT`
23 | // opcode. Note the reason can be nil if no data supplied with revert opcode.
24 | func (m *MsgEthereumTxResponse) Revert() []byte {
25 | if m.VmError != vm.ErrExecutionReverted.Error() {
26 | return nil
27 | }
28 | return common.CopyBytes(m.Ret)
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/genesis.go:
--------------------------------------------------------------------------------
1 | package feemarket
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | abci "github.com/tendermint/tendermint/abci/types"
6 |
7 | "github.com/evmos/ethermint/x/feemarket/keeper"
8 | "github.com/evmos/ethermint/x/feemarket/types"
9 | )
10 |
11 | // InitGenesis initializes genesis state based on exported genesis
12 | func InitGenesis(
13 | ctx sdk.Context,
14 | k keeper.Keeper,
15 | data types.GenesisState,
16 | ) []abci.ValidatorUpdate {
17 | k.SetParams(ctx, data.Params)
18 | k.SetBlockGasWanted(ctx, data.BlockGas)
19 |
20 | return []abci.ValidatorUpdate{}
21 | }
22 |
23 | // ExportGenesis exports genesis state of the fee market module
24 | func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
25 | return &types.GenesisState{
26 | Params: k.GetParams(ctx),
27 | BlockGas: k.GetBlockGasWanted(ctx),
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/keeper/migrations.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 |
6 | v010 "github.com/evmos/ethermint/x/feemarket/migrations/v010"
7 | v011 "github.com/evmos/ethermint/x/feemarket/migrations/v011"
8 | )
9 |
10 | // Migrator is a struct for handling in-place store migrations.
11 | type Migrator struct {
12 | keeper Keeper
13 | }
14 |
15 | // NewMigrator returns a new Migrator.
16 | func NewMigrator(keeper Keeper) Migrator {
17 | return Migrator{
18 | keeper: keeper,
19 | }
20 | }
21 |
22 | // Migrate1to2 migrates the store from consensus version v1 to v2
23 | func (m Migrator) Migrate1to2(ctx sdk.Context) error {
24 | return v010.MigrateStore(ctx, &m.keeper.paramSpace, m.keeper.storeKey)
25 | }
26 |
27 | // Migrate2to3 migrates the store from consensus version v2 to v3
28 | func (m Migrator) Migrate2to3(ctx sdk.Context) error {
29 | return v011.MigrateStore(ctx, &m.keeper.paramSpace)
30 | }
31 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/keeper/migrations_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import (
4 | "math/big"
5 |
6 | "github.com/evmos/ethermint/x/feemarket/keeper"
7 | v010 "github.com/evmos/ethermint/x/feemarket/migrations/v010"
8 | )
9 |
10 | func (suite *KeeperTestSuite) TestMigration1To2() {
11 | suite.SetupTest()
12 | storeKey := suite.app.GetKey("feemarket")
13 | store := suite.ctx.KVStore(storeKey)
14 | baseFee := big.NewInt(1000)
15 | store.Set(v010.KeyPrefixBaseFeeV1, baseFee.Bytes())
16 | m := keeper.NewMigrator(suite.app.FeeMarketKeeper)
17 | err := m.Migrate1to2(suite.ctx)
18 | suite.Require().NoError(err)
19 | suite.Require().Equal(baseFee, suite.app.FeeMarketKeeper.GetBaseFee(suite.ctx))
20 | }
21 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/keeper/params_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import (
4 | "github.com/evmos/ethermint/x/feemarket/types"
5 | )
6 |
7 | func (suite *KeeperTestSuite) TestSetGetParams() {
8 | params := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
9 | suite.Require().Equal(types.DefaultParams(), params)
10 | params.ElasticityMultiplier = 3
11 | suite.app.FeeMarketKeeper.SetParams(suite.ctx, params)
12 | newParams := suite.app.FeeMarketKeeper.GetParams(suite.ctx)
13 | suite.Require().Equal(newParams, params)
14 | }
15 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/simulation/genesis.go:
--------------------------------------------------------------------------------
1 | package simulation
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 |
7 | sdk "github.com/cosmos/cosmos-sdk/types"
8 | "github.com/cosmos/cosmos-sdk/types/module"
9 |
10 | "github.com/evmos/ethermint/x/feemarket/types"
11 | )
12 |
13 | // RandomizedGenState generates a random GenesisState for nft
14 | func RandomizedGenState(simState *module.SimulationState) {
15 | params := types.NewParams(simState.Rand.Uint32()%2 == 0, simState.Rand.Uint32(), simState.Rand.Uint32(), simState.Rand.Uint64(), simState.Rand.Int63(), sdk.ZeroDec(), types.DefaultMinGasMultiplier)
16 |
17 | blockGas := simState.Rand.Uint64()
18 | feemarketGenesis := types.NewGenesisState(params, blockGas)
19 |
20 | bz, err := json.MarshalIndent(feemarketGenesis, "", " ")
21 | if err != nil {
22 | panic(err)
23 | }
24 | fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz)
25 |
26 | simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(feemarketGenesis)
27 | }
28 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/02_state.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # State
6 |
7 | The x/feemarket module keeps in the state variable needed to the fee calculation:
8 |
9 | Only BlockGasUsed in previous block needs to be tracked in state for the next base fee calculation.
10 |
11 | | | Description | Key | Value | Store |
12 | | ----------- | ------------------------------ | ---------------| ------------------- | --------- |
13 | | BlockGasUsed | gas used in the block | `[]byte{1}` | `[]byte{gas_used}` | KV |
14 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/04_end_block.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # End block
6 |
7 | The block_gas_used value is updated at the end of each block.
8 |
9 | ## Block Gas Used
10 |
11 | The total gas used by current block is stored in the KVStore at `EndBlock`.
12 |
13 | It is initialized to `block_gas` defined in the genesis.
14 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/05_keeper.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # Keeper
6 |
7 | The feemarket module provides this exported keeper that can be passed to other modules that need to get access to the base fee value
8 |
9 | ```go
10 |
11 | type Keeper interface {
12 | GetBaseFee(ctx sdk.Context) *big.Int
13 | }
14 |
15 | ```
16 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/06_events.md:
--------------------------------------------------------------------------------
1 |
3 |
4 | # Events
5 |
6 | The `x/feemarket` module emits the following events:
7 |
8 | ## BeginBlocker
9 |
10 | | Type | Attribute Key | Attribute Value |
11 | | ---------- | --------------- | --------------- |
12 | | fee_market | base_fee | {baseGasPrices} |
13 |
14 | ## EndBlocker
15 |
16 | | Type | Attribute Key | Attribute Value |
17 | | ---------- | --------------- | --------------- |
18 | | block_gas | height | {blockHeight} |
19 | | block_gas | amount | {blockGasUsed} |
20 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/07_params.md:
--------------------------------------------------------------------------------
1 |
3 |
4 | # Parameters
5 |
6 | The `x/feemarket` module contains the following parameters:
7 |
8 | | Key | Type | Default Values | Description |
9 | | ----------------------------- | ------ | ----------- |------------- |
10 | | NoBaseFee | bool | false | control the base fee adjustment |
11 | | BaseFeeChangeDenominator | uint32 | 8 | bounds the amount the base fee that can change between blocks |
12 | | ElasticityMultiplier | uint32 | 2 | bounds the threshold which the base fee will increase or decrease depending on the total gas used in the previous block|
13 | | BaseFee | uint32 | 1000000000 | base fee for EIP-1559 blocks |
14 | | EnableHeight | uint32 | 0 | height which enable fee adjustment |
15 | | MinGasPrice | sdk.Dec | 0 | global minimum gas price that needs to be paid to include a transaction in a block |
16 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/10_future_improvements.md:
--------------------------------------------------------------------------------
1 |
3 |
4 | # Future Improvements
5 |
6 | - The feemarket module has been designed mainly to support EIP-1559 on EVM-based chain on cosmos, supporting non-EVM chain could be done as a future improvements.
7 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/spec/README.md:
--------------------------------------------------------------------------------
1 |
7 |
8 | # Feemarket
9 |
10 | ## Abstract
11 |
12 | This document specifies the feemarket module which allows to define a global transaction fee for the network.
13 |
14 | This module has been designed to support EIP1559 in cosmos-sdk.
15 |
16 | The `MempoolFeeDecorator` in `x/auth` module needs to be overrided to check the `baseFee` along with the `minimal-gas-prices` allowing to implement a global fee mechanism which vary depending on the network activity.
17 |
18 | For more reference to EIP1559:
19 |
20 |
21 |
22 | ## Contents
23 |
24 | 1. **[Concepts](01_concepts.md)**
25 | 2. **[State](02_state.md)**
26 | 3. **[Begin Block](03_begin_block.md)**
27 | 4. **[End Block](04_end_block.md)**
28 | 5. **[Keeper](05_keeper.md)**
29 | 6. **[Events](06_events.md)**
30 | 7. **[Params](07_params.md)**
31 | 8. **[Client](08_client.md)**
32 | 9. **[Future Improvements](09_future_improvements.md)**
33 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/types/events.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // feemarket module events
4 | const (
5 | EventTypeFeeMarket = "fee_market"
6 |
7 | AttributeKeyBaseFee = "base_fee"
8 | )
9 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/types/genesis.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // DefaultGenesisState sets default fee market genesis state.
4 | func DefaultGenesisState() *GenesisState {
5 | return &GenesisState{
6 | Params: DefaultParams(),
7 | BlockGas: 0,
8 | }
9 | }
10 |
11 | // NewGenesisState creates a new genesis state.
12 | func NewGenesisState(params Params, blockGas uint64) *GenesisState {
13 | return &GenesisState{
14 | Params: params,
15 | BlockGas: blockGas,
16 | }
17 | }
18 |
19 | // Validate performs basic genesis state validation returning an error upon any
20 | // failure.
21 | func (gs GenesisState) Validate() error {
22 | return gs.Params.Validate()
23 | }
24 |
--------------------------------------------------------------------------------
/ethermint/x/feemarket/types/keys.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | const (
4 | // ModuleName string name of module
5 | ModuleName = "feemarket"
6 |
7 | // StoreKey key for base fee and block gas used.
8 | // The Fee Market module should use a prefix store.
9 | StoreKey = ModuleName
10 |
11 | // RouterKey uses module name for routing
12 | RouterKey = ModuleName
13 |
14 | // TransientKey is the key to access the FeeMarket transient store, that is reset
15 | // during the Commit phase.
16 | TransientKey = "transient_" + ModuleName
17 | )
18 |
19 | // prefix bytes for the feemarket persistent store
20 | const (
21 | prefixBlockGasWanted = iota + 1
22 | deprecatedPrefixBaseFee //nolint
23 | )
24 |
25 | const (
26 | prefixTransientBlockGasUsed = iota + 1
27 | )
28 |
29 | // KVStore key prefixes
30 | var (
31 | KeyPrefixBlockGasWanted = []byte{prefixBlockGasWanted}
32 | )
33 |
34 | // Transient Store key prefixes
35 | var (
36 | KeyPrefixTransientBlockGasWanted = []byte{prefixTransientBlockGasUsed}
37 | )
38 |
--------------------------------------------------------------------------------
/ibc/testing/coordinator.go:
--------------------------------------------------------------------------------
1 | package ibctesting
2 |
3 | import (
4 | "testing"
5 | "time"
6 |
7 | ibctesting "github.com/cosmos/ibc-go/v3/testing"
8 | )
9 |
10 | var globalStartTime = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC)
11 |
12 | // NewCoordinator initializes Coordinator with N EVM TestChain's (Acre apps) and M Cosmos chains (Simulation Apps)
13 | func NewCoordinator(t *testing.T, nEVMChains, mCosmosChains int) *ibctesting.Coordinator {
14 | chains := make(map[string]*ibctesting.TestChain)
15 | coord := &ibctesting.Coordinator{
16 | T: t,
17 | CurrentTime: globalStartTime,
18 | }
19 |
20 | // setup EVM chains
21 | ibctesting.DefaultTestingAppInit = DefaultTestingAppInit
22 |
23 | for i := 1; i <= nEVMChains; i++ {
24 | chainID := ibctesting.GetChainID(i)
25 | chains[chainID] = NewTestChain(t, coord, chainID)
26 | }
27 |
28 | // setup Cosmos chains
29 | ibctesting.DefaultTestingAppInit = ibctesting.SetupTestingApp
30 |
31 | for j := 1 + nEVMChains; j <= nEVMChains+mCosmosChains; j++ {
32 | chainID := ibctesting.GetChainID(j)
33 | chains[chainID] = ibctesting.NewTestChain(t, coord, chainID)
34 | }
35 |
36 | coord.Chains = chains
37 |
38 | return coord
39 | }
40 |
--------------------------------------------------------------------------------
/ibc/utils_test.go:
--------------------------------------------------------------------------------
1 | package ibc
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | )
6 |
7 | func init() {
8 | cfg := sdk.GetConfig()
9 | cfg.SetBech32PrefixForAccount("acre", "acrepub")
10 | }
11 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/README.md:
--------------------------------------------------------------------------------
1 | # Running a validator
2 |
3 | ## Hardware Requirements
4 |
5 | ```
6 | 4+ CPU cores
7 | 500+GB of SSD disk storage
8 | 32+GB of memory (RAM)
9 | 100+Mbps network bandwidth
10 | ```
11 |
12 | Note: As the usage of the blockchain grows, the server requirements would increase.
13 |
14 | ## Supported OS
15 |
16 | We support macOS, Windows and Linux:
17 |
18 | ```
19 | darwin/arm64
20 | darwin/x86_64
21 | linux/arm64
22 | linux/amd64
23 | windows/x86_64
24 | ```
25 |
26 | ## [Peers](./peers.md)
27 |
28 | ## [RPC](./rpc.md)
29 |
30 | ## [Joining as a validator](./validator.md)
31 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/gentx/InBWeT.json:
--------------------------------------------------------------------------------
1 | {"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"InBWeT","identity":"","website":"","security_contact":"","details":""},"commission":{"rate":"0.050000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1000000000000000000","delegator_address":"acre1ke8tvwj0vdk72m80y5rzu97t2fy9wu3npaelug","validator_address":"acrevaloper1ke8tvwj0vdk72m80y5rzu97t2fy9wu3nc9g074","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"dlFHwfOHfNQsOWPC/yVa3Lq01CAJyHRNYMkckNJGQyw="},"value":{"denom":"aacre","amount":"100000000000000000000"}}],"memo":"8b8d98c49ce4daa9e54b2ab3f93ce1001ccc0250@173.212.252.17:26656","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"An/Iu4+FHdbVfo7ebWg2MYBNal39M9Cm1IrT219gr/4R"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["mPb7N5P7369r8EclhdjAXki4QgK1UzwZyTRQjFBvVx14I7Di9QBeHnclhq3FMhutWwd93yagP13fftJFK/TIWgE="]}
2 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/gentx/Web3ident.json:
--------------------------------------------------------------------------------
1 | {"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"Web3ident","identity":"","website":"","security_contact":"","details":""},"commission":{"rate":"0.050000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1000000000000000000","delegator_address":"acre1rl5h39q804mxypn5gyy0a2uzyrqeydg2eqhteh","validator_address":"acrevaloper1rl5h39q804mxypn5gyy0a2uzyrqeydg2qcxmm2","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"lu3UWSNAypGQ3Is0zYkpmAG3waeXMzIBSK12O7GL/xI="},"value":{"denom":"aacre","amount":"100000000000000000000"}}],"memo":"379e05155c15ec10cda93589f0191c830d2c2fab@164.92.234.115:26656","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"A7G3h3PxoXqv38WCoQpUfGmDC5MC1cIHOo7LTnQMyR/d"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["yI7/5b5Df88/+Eo9rO+iEfD8aUDIPRSFoqQ18txrxjVfx8G3+Ghqt8i5FgZzeko7ahy3kVMS6SS3HywKutbM3AA="]}
2 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/gentx/azstake.json:
--------------------------------------------------------------------------------
1 | {"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"azstake","identity":"","website":"","security_contact":"","details":""},"commission":{"rate":"0.050000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1000000000000000000","delegator_address":"acre1kqlnqxf8clakdm8dqlxyjc7qcvvd88m080ftau","validator_address":"acrevaloper1kqlnqxf8clakdm8dqlxyjc7qcvvd88m07hcmlp","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"oYphNN2aKvTsz7G+L/HdqPpQ+ozSB95IFUCeVKyOCrU="},"value":{"denom":"aacre","amount":"100000000000000000000"}}],"memo":"69baecad2ec55a69baa1082aa38b6abfa1b81142@168.119.89.31:26656","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AmEEwlulXSDmW02D/bJNzUdi/NFJ7Cvq26Xvi1wnAmfH"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["3lDFwfByTqV0y/xiCe5UHdpGdK5ammBgCFkL/ph0BrMcBA7GvUhPj5noVnbFWXElD7pZlupIfmDVFmzvMVI3PAA="]}
2 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/gentx/blockswell.json:
--------------------------------------------------------------------------------
1 | {"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"BlocksWell","identity":"","website":"","security_contact":"","details":""},"commission":{"rate":"0.050000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1000000000000000000","delegator_address":"acre1nq9utvcs99tqj680670vf60vmpypl0njuvstea","validator_address":"acrevaloper1nq9utvcs99tqj680670vf60vmpypl0nj95pmmq","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"MmBkFi5guUYoR0maErpfipHb7G+4pCR0Rlc4pw0cIgI="},"value":{"denom":"aacre","amount":"100000000000000000000"}}],"memo":"0712fe6b3b204badcff43864211eff43357f163b@154.53.42.192:26656","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"A8HjfkC97xyDT092Qz3MrT58rraTuf+Wvb3Bke9RAXab"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["rX1hJ5nJdNIclLJ/tObspdBhmJUinIx3wvlte4e450Rrb+EYt1kdH6JcKvqpdJGRV2y8XdiSNYL/4ajwJh3aHwA="]}
2 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/gentx/jet-node.json:
--------------------------------------------------------------------------------
1 | {"body":{"messages":[{"@type":"/cosmos.staking.v1beta1.MsgCreateValidator","description":{"moniker":"jet-node","identity":"","website":"","security_contact":"","details":""},"commission":{"rate":"0.050000000000000000","max_rate":"0.200000000000000000","max_change_rate":"0.010000000000000000"},"min_self_delegation":"1000000000000000000","delegator_address":"acre16ta5jvmvj90l3zgry98p3gafqnn8e3aq00987r","validator_address":"acrevaloper16ta5jvmvj90l3zgry98p3gafqnn8e3aqkh5hu7","pubkey":{"@type":"/cosmos.crypto.ed25519.PubKey","key":"o4kedcrkN1KoHWUF+zjZzFKbFXDE99AYEJZ7uKHYB8s="},"value":{"denom":"aacre","amount":"100000000000000000000"}}],"memo":"3de85bbe5cd59f9e2615c0d71c649f8785f6cadc@123.193.196.217:26656","timeout_height":"0","extension_options":[],"non_critical_extension_options":[]},"auth_info":{"signer_infos":[{"public_key":{"@type":"/ethermint.crypto.v1.ethsecp256k1.PubKey","key":"AlBHLodtpBb6vx6W40h4pOlvf4KSgZQj5vXVAo4Xj7aj"},"mode_info":{"single":{"mode":"SIGN_MODE_DIRECT"}},"sequence":"0"}],"fee":{"amount":[],"gas_limit":"200000","payer":"","granter":""}},"signatures":["xWojR+ib7Bt+tElnNrZRCXts1KPf+qt87h1/h329NjlmOYx3K4xVHJb7d+elwhVG8MCb3rmP3awTgDbSvLP7hwA="]}
2 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/peers.md:
--------------------------------------------------------------------------------
1 | # Peers
2 |
3 | - Kalia Network - `ef28f065e24d60df275b06ae9f7fed8ba0823448@46.4.81.204:34656`
4 | - ramuchi - `e29de0ba5c6eb3cc813211887af4e92a71c54204@65.108.1.225:46656`
5 | - High Stakes - `276be584b4a8a3fd9c3ee1e09b7a447a60b201a4@116.203.29.162:26656`
6 | - Stake-Take - `e2d029c95a3476a23bad36f98b316b6d04b26001@49.12.33.189:36656`
7 | - D-stake - `1264ee73a2f40a16c2cbd80c1a824aad7cb082e4@149.102.146.252:26656`
8 | - Yurbason - `dbe9c383a709881f6431242de2d805d6f0f60c9e@65.109.52.156:7656`
9 | - Anonstake - `d01fb8d008cb5f194bc27c054e0246c4357256b3@31.7.196.72:26656`
10 | - PFC - `91c0b06f0539348a412e637ebb8208a1acdb71a9@178.162.165.193:21095`
11 | - Synergy Nodes - `bac90a590452337700e0033315e96430d19a3ffa@23.106.238.167:26656`
12 |
--------------------------------------------------------------------------------
/networks/mainnet/acre_9052-1/rpc.md:
--------------------------------------------------------------------------------
1 | # RPCs
2 |
--------------------------------------------------------------------------------
/networks/testnet/bamboo_9051-1/peers.md:
--------------------------------------------------------------------------------
1 | # Peers
2 |
3 | ```
4 | persistent_peers = "44dd124ca34742245ad906f9f6ea377fae3af0cf@168.100.9.100:26656,6477921cdd4ba4503a1a2ff1f340c9d6a0e7b4a0@168.100.10.133:26656,9b53496211e75dbf33680b75e617830e874c8d93@168.100.8.9:26656,c55d79d6f76045ff7b68dc2bf6655348ebbfd795@168.100.8.60:26656"
5 | ```
6 |
--------------------------------------------------------------------------------
/networks/testnet/bamboo_9051-2/README.md:
--------------------------------------------------------------------------------
1 | # Running a validator
2 |
3 | ## Hardware Requirements
4 |
5 | ```
6 | 4+ CPU cores
7 | 500+GB of SSD disk storage
8 | 32+GB of memory (RAM)
9 | 100+Mbps network bandwidth
10 | ```
11 |
12 | Note: As the usage of the blockchain grows, the server requirements would increase.
13 |
14 | ## Supported OS
15 |
16 | We support macOS, Windows and Linux:
17 |
18 | ```
19 | darwin/arm64
20 | darwin/x86_64
21 | linux/arm64
22 | linux/amd64
23 | windows/x86_64
24 | ```
25 |
26 | ## [Peers](./peers.md)
27 |
28 | ## [RPC](./rpc.md)
29 |
--------------------------------------------------------------------------------
/networks/testnet/bamboo_9051-2/peers.md:
--------------------------------------------------------------------------------
1 | # Peers
2 |
3 | ```
4 | 67e0590482bb10886a2198cafa2497ec73b86aea@109.205.182.9:26656
5 | 7f9e2aa9b22ee0ff5a0b99e0efc45d4a345f1684@51.91.208.178:26656
6 | c55656fb1c75c08178618b5470139c8aca900a75@seed-testnet2-acre.synergynodes.com:26656
7 | c6f4ced5409b8b2fb30cf77b0fa47c5ef354815a@94.237.27.199:26656
8 | 34d09ce5bef8fad34dbeed9cb8523838a002a6b8@123.193.196.217:36656
9 | 28a6835ddf1c38ddcd4d1a4ddb62d23a8a358edc@31.7.196.67:26656
10 | e6650cdf36ca61ea4ac47c2fe5aa7153cb36c7a2@31.7.196.68:26656
11 | 07c7e3478bba7a0e0c5d2cb0c32613ea63868111@31.7.196.65:26656
12 | ```
13 |
--------------------------------------------------------------------------------
/networks/testnet/bamboo_9051-2/rpc.md:
--------------------------------------------------------------------------------
1 | # RPC
2 |
3 | - Synergy Nodes - https://rpc-testnet2-acre.synergynodes.com:443
4 |
--------------------------------------------------------------------------------
/proto/acrechain/erc20/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package acrechain.erc20.v1;
3 |
4 | import "acrechain/erc20/erc20.proto";
5 | import "gogoproto/gogo.proto";
6 |
7 | option go_package = "github.com/ArableProtocol/acrechain/x/erc20/types";
8 |
9 | // GenesisState defines the module's genesis state.
10 | message GenesisState {
11 | // module parameters
12 | Params params = 1 [ (gogoproto.nullable) = false ];
13 | // registered token pairs
14 | repeated TokenPair token_pairs = 2 [ (gogoproto.nullable) = false ];
15 | }
16 |
17 | // Params defines the erc20 module params
18 | message Params {
19 | // parameter to enable the conversion of Cosmos coins <--> ERC20 tokens.
20 | bool enable_erc20 = 1;
21 | // parameter to enable the EVM hook that converts an ERC20 token to a Cosmos
22 | // Coin by transferring the Tokens through a MsgEthereumTx to the
23 | // ModuleAddress Ethereum address.
24 | bool enable_evm_hook = 2 [ (gogoproto.customname) = "EnableEVMHook" ];
25 | }
--------------------------------------------------------------------------------
/proto/acrechain/mint/v1beta1/genesis.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 | package acrechain.mint.v1beta1;
3 |
4 | import "gogoproto/gogo.proto";
5 | import "acrechain/mint/v1beta1/mint.proto";
6 |
7 | option go_package = "github.com/ArableProtocol/acrechain/x/mint/types";
8 |
9 | // GenesisState defines the mint module's genesis state.
10 | message GenesisState {
11 | // params defines all the paramaters of the module.
12 | Params params = 1 [ (gogoproto.nullable) = false ];
13 | }
14 |
--------------------------------------------------------------------------------
/scripts/protocgen.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -x
3 | set -e
4 | set -o pipefail
5 |
6 | # get protoc executions
7 | go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
8 |
9 | # get evmos from github
10 | go get github.com/evmos/evmos/v8@v8.0.0 2>/dev/null
11 | evmos_dir=$(go list -f '{{ .Dir }}' -m github.com/evmos/evmos/v8)
12 |
13 | # Get the path of the cosmos-sdk repo from go/pkg/mod
14 | proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
15 |
16 | for dir in $proto_dirs; do
17 | # generate protobuf bind
18 | buf protoc \
19 | -I "proto" \
20 | -I "$evmos_dir/third_party/proto" \
21 | --gocosmos_out=plugins=interfacetype+grpc,\
22 | Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
23 | $(find "${dir}" -maxdepth 1 -name '*.proto')
24 |
25 | # generate grpc gateway
26 | buf protoc \
27 | -I "proto" \
28 | -I "$evmos_dir/third_party/proto" \
29 | --grpc-gateway_out=logtostderr=true:. \
30 | $(find "${dir}" -maxdepth 1 -name '*.proto')
31 | done
32 |
33 | # move proto files to the right places
34 | cp -r github.com/ArableProtocol/acrechain/* ./
35 | rm -rf github.com
36 |
--------------------------------------------------------------------------------
/types/errors.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
5 | )
6 |
7 | // RootCodespace is the codespace for all errors defined in this package
8 | const RootCodespace = "acreapp"
9 |
10 | // root error codes for acreapp
11 | const (
12 | codeKeyTypeNotSupported = iota + 2
13 | )
14 |
15 | // errors
16 | var (
17 | ErrKeyTypeNotSupported = sdkerrors.Register(RootCodespace, codeKeyTypeNotSupported, "key type 'secp256k1' not supported")
18 | )
19 |
--------------------------------------------------------------------------------
/version/version.go:
--------------------------------------------------------------------------------
1 | package version
2 |
3 | import (
4 | "fmt"
5 | "runtime"
6 | )
7 |
8 | var (
9 | AppVersion = ""
10 | GitCommit = ""
11 | BuildDate = ""
12 |
13 | GoVersion = ""
14 | GoArch = ""
15 | )
16 |
17 | func init() {
18 | if len(AppVersion) == 0 {
19 | AppVersion = "dev"
20 | }
21 |
22 | GoVersion = runtime.Version()
23 | GoArch = runtime.GOARCH
24 | }
25 |
26 | func Version() string {
27 | return fmt.Sprintf(
28 | "Version %s (%s)\nCompiled at %s using Go %s (%s)",
29 | AppVersion,
30 | GitCommit,
31 | BuildDate,
32 | GoVersion,
33 | GoArch,
34 | )
35 | }
36 |
--------------------------------------------------------------------------------
/x/erc20/client/cli/utils.go:
--------------------------------------------------------------------------------
1 | package cli
2 |
3 | import (
4 | "os"
5 | "path/filepath"
6 |
7 | "github.com/cosmos/cosmos-sdk/codec"
8 | banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
9 | )
10 |
11 | // ParseRegisterCoinProposal reads and parses a ParseRegisterCoinProposal from a file.
12 | func ParseMetadata(cdc codec.JSONCodec, metadataFile string) (banktypes.Metadata, error) {
13 | metadata := banktypes.Metadata{}
14 |
15 | contents, err := os.ReadFile(filepath.Clean(metadataFile))
16 | if err != nil {
17 | return metadata, err
18 | }
19 |
20 | if err = cdc.UnmarshalJSON(contents, &metadata); err != nil {
21 | return metadata, err
22 | }
23 |
24 | return metadata, nil
25 | }
26 |
--------------------------------------------------------------------------------
/x/erc20/client/proposal_handler.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
5 |
6 | "github.com/ArableProtocol/acrechain/x/erc20/client/cli"
7 | "github.com/ArableProtocol/acrechain/x/erc20/client/rest"
8 | )
9 |
10 | var (
11 | RegisterCoinProposalHandler = govclient.NewProposalHandler(cli.NewRegisterCoinProposalCmd, rest.RegisterCoinProposalRESTHandler)
12 | RegisterERC20ProposalHandler = govclient.NewProposalHandler(cli.NewRegisterERC20ProposalCmd, rest.RegisterERC20ProposalRESTHandler)
13 | ToggleTokenConversionProposalHandler = govclient.NewProposalHandler(cli.NewToggleTokenConversionProposalCmd, rest.ToggleTokenConversionRESTHandler)
14 | )
15 |
--------------------------------------------------------------------------------
/x/erc20/handler.go:
--------------------------------------------------------------------------------
1 | package erc20
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
6 |
7 | "github.com/ArableProtocol/acrechain/x/erc20/types"
8 | )
9 |
10 | // NewHandler defines the erc20 module handler instance
11 | func NewHandler(server types.MsgServer) sdk.Handler {
12 | return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
13 | ctx = ctx.WithEventManager(sdk.NewEventManager())
14 |
15 | switch msg := msg.(type) {
16 | case *types.MsgConvertCoin:
17 | res, err := server.ConvertCoin(sdk.WrapSDKContext(ctx), msg)
18 | return sdk.WrapServiceResult(ctx, res, err)
19 | case *types.MsgConvertERC20:
20 | res, err := server.ConvertERC20(sdk.WrapSDKContext(ctx), msg)
21 | return sdk.WrapServiceResult(ctx, res, err)
22 | default:
23 | err := sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg)
24 | return nil, err
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/x/erc20/keeper/migrations.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | // Migrator is a struct for handling in-place store migrations.
4 | type Migrator struct {
5 | keeper Keeper
6 | }
7 |
8 | // NewMigrator returns a new Migrator.
9 | func NewMigrator(keeper Keeper) Migrator {
10 | return Migrator{
11 | keeper: keeper,
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/x/erc20/keeper/params.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 |
6 | "github.com/ArableProtocol/acrechain/x/erc20/types"
7 | )
8 |
9 | // GetParams returns the total set of erc20 parameters.
10 | func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
11 | k.paramstore.GetParamSet(ctx, ¶ms)
12 | return params
13 | }
14 |
15 | // SetParams sets the erc20 parameters to the param space.
16 | func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
17 | k.paramstore.SetParamSet(ctx, ¶ms)
18 | }
19 |
--------------------------------------------------------------------------------
/x/erc20/keeper/params_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import "github.com/ArableProtocol/acrechain/x/erc20/types"
4 |
5 | func (suite *KeeperTestSuite) TestParams() {
6 | params := suite.app.Erc20Keeper.GetParams(suite.ctx)
7 | suite.Require().Equal(types.DefaultParams(), params)
8 | params.EnableErc20 = false
9 | suite.app.Erc20Keeper.SetParams(suite.ctx, params)
10 | newParams := suite.app.Erc20Keeper.GetParams(suite.ctx)
11 | suite.Require().Equal(newParams, params)
12 | }
13 |
--------------------------------------------------------------------------------
/x/erc20/spec/07_parameters.md:
--------------------------------------------------------------------------------
1 |
4 |
5 | # Parameters
6 |
7 | The erc20 module contains the following parameters:
8 |
9 | | Key | Type | Default Value |
10 | | ----------------------- | ------------- | ----------------------------- |
11 | | `EnableErc20` | bool | `true` |
12 | | `EnableEVMHook` | bool | `true` |
13 |
14 | ## Enable ERC20
15 |
16 | The `EnableErc20` parameter toggles all state transitions in the module. When the parameter is disabled, it will prevent all token pair registration and conversion functionality.
17 |
18 | ## Enable EVM Hook
19 |
20 | The `EnableEVMHook` parameter enables the EVM hook to convert an ERC20 token to a Cosmos Coin by transferring the Tokens through a `MsgEthereumTx` to the `ModuleAddress` Ethereum address.
21 |
--------------------------------------------------------------------------------
/x/erc20/types/events.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "math/big"
5 |
6 | "github.com/ethereum/go-ethereum/common"
7 | )
8 |
9 | // erc20 events
10 | const (
11 | EventTypeTokenLock = "token_lock"
12 | EventTypeTokenUnlock = "token_unlock"
13 | EventTypeMint = "mint"
14 | EventTypeConvertCoin = "convert_coin"
15 | EventTypeConvertERC20 = "convert_erc20"
16 | EventTypeBurn = "burn"
17 | EventTypeRegisterCoin = "register_coin"
18 | EventTypeRegisterERC20 = "register_erc20"
19 | EventTypeToggleTokenConversion = "toggle_token_conversion" // #nosec
20 |
21 | AttributeKeyCosmosCoin = "cosmos_coin"
22 | AttributeKeyERC20Token = "erc20_token" // #nosec
23 | AttributeKeyReceiver = "receiver"
24 |
25 | ERC20EventTransfer = "Transfer"
26 | )
27 |
28 | // Event type for Transfer(address from, address to, uint256 value)
29 | type LogTransfer struct {
30 | From common.Address
31 | To common.Address
32 | Tokens *big.Int
33 | }
34 |
--------------------------------------------------------------------------------
/x/erc20/types/evm.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // ERC20Data represents the ERC20 token details used to map
4 | // the token to a Cosmos Coin
5 | type ERC20Data struct {
6 | Name string
7 | Symbol string
8 | Decimals uint8
9 | }
10 |
11 | // ERC20StringResponse defines the string value from the call response
12 | type ERC20StringResponse struct {
13 | Value string
14 | }
15 |
16 | // ERC20Uint8Response defines the uint8 value from the call response
17 | type ERC20Uint8Response struct {
18 | Value uint8
19 | }
20 |
21 | // ERC20BoolResponse defines the bool value from the call response
22 | type ERC20BoolResponse struct {
23 | Value bool
24 | }
25 |
26 | // NewERC20Data creates a new ERC20Data instance
27 | func NewERC20Data(name, symbol string, decimals uint8) ERC20Data {
28 | return ERC20Data{
29 | Name: name,
30 | Symbol: symbol,
31 | Decimals: decimals,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/x/erc20/types/evm_test.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/require"
7 | )
8 |
9 | func TestNewERC20Data(t *testing.T) {
10 | data := NewERC20Data("test", "ERC20", uint8(18))
11 | exp := ERC20Data(ERC20Data{Name: "test", Symbol: "ERC20", Decimals: 0x12})
12 | require.Equal(t, exp, data)
13 | }
14 |
--------------------------------------------------------------------------------
/x/erc20/types/keys.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
5 | "github.com/ethereum/go-ethereum/common"
6 | )
7 |
8 | // constants
9 | const (
10 | // module name
11 | ModuleName = "erc20"
12 |
13 | // StoreKey to be used when creating the KVStore
14 | StoreKey = ModuleName
15 |
16 | // RouterKey to be used for message routing
17 | RouterKey = ModuleName
18 | )
19 |
20 | // ModuleAddress is the native module address for EVM
21 | var ModuleAddress common.Address
22 |
23 | func init() {
24 | ModuleAddress = common.BytesToAddress(authtypes.NewModuleAddress(ModuleName).Bytes())
25 | }
26 |
27 | // prefix bytes for the EVM persistent store
28 | const (
29 | prefixTokenPair = iota + 1
30 | prefixTokenPairByERC20
31 | prefixTokenPairByDenom
32 | )
33 |
34 | // KVStore key prefixes
35 | var (
36 | KeyPrefixTokenPair = []byte{prefixTokenPair}
37 | KeyPrefixTokenPairByERC20 = []byte{prefixTokenPairByERC20}
38 | KeyPrefixTokenPairByDenom = []byte{prefixTokenPairByDenom}
39 | )
40 |
--------------------------------------------------------------------------------
/x/mint/keeper/grpc_query.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | "context"
5 |
6 | sdk "github.com/cosmos/cosmos-sdk/types"
7 |
8 | "github.com/ArableProtocol/acrechain/x/mint/types"
9 | )
10 |
11 | var _ types.QueryServer = Querier{}
12 |
13 | // Querier defines a wrapper around the x/mint keeper providing gRPC method
14 | // handlers.
15 | type Querier struct {
16 | Keeper
17 | }
18 |
19 | func NewQuerier(k Keeper) Querier {
20 | return Querier{Keeper: k}
21 | }
22 |
23 | // Params returns params of the mint module.
24 | func (q Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
25 | ctx := sdk.UnwrapSDKContext(c)
26 | params := q.Keeper.GetParams(ctx)
27 |
28 | return &types.QueryParamsResponse{Params: params}, nil
29 | }
30 |
31 | // DailyProvisions returns minter.DailyProvisions of the mint module.
32 | func (q Querier) DailyProvisions(c context.Context, _ *types.QueryDailyProvisionsRequest) (*types.QueryDailyProvisionsResponse, error) {
33 | ctx := sdk.UnwrapSDKContext(c)
34 | minter := q.Keeper.GetMinter(ctx)
35 |
36 | return &types.QueryDailyProvisionsResponse{DailyProvisions: minter.DailyProvisions}, nil
37 | }
38 |
--------------------------------------------------------------------------------
/x/mint/keeper/info.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | "github.com/ArableProtocol/acrechain/x/mint/types"
5 | sdk "github.com/cosmos/cosmos-sdk/types"
6 | )
7 |
8 | // GetNextReductionTime returns next reduction time.
9 | func (k Keeper) GetNextReductionTime(ctx sdk.Context) int64 {
10 | params := k.GetParams(ctx)
11 | return params.NextRewardsReductionTime
12 | }
13 |
14 | // SetNextReductionTime set next reduction time.
15 | func (k Keeper) SetNextReductionTime(ctx sdk.Context, time int64) {
16 | params := k.GetParams(ctx)
17 | params.NextRewardsReductionTime = time
18 | k.SetParams(ctx, params)
19 | }
20 |
21 | // get the minter.
22 | func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
23 | store := ctx.KVStore(k.storeKey)
24 | b := store.Get(types.MinterKey)
25 | if b == nil {
26 | panic("stored minter should not have been nil")
27 | }
28 |
29 | k.cdc.MustUnmarshal(b, &minter)
30 | return
31 | }
32 |
33 | // set the minter.
34 | func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) {
35 | store := ctx.KVStore(k.storeKey)
36 | b := k.cdc.MustMarshal(&minter)
37 | store.Set(types.MinterKey, b)
38 | }
39 |
--------------------------------------------------------------------------------
/x/mint/keeper/keeper_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import (
4 | "testing"
5 |
6 | simapp "github.com/ArableProtocol/acrechain/app"
7 | "github.com/cosmos/cosmos-sdk/codec"
8 | sdk "github.com/cosmos/cosmos-sdk/types"
9 | feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
10 | "github.com/stretchr/testify/suite"
11 | tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
12 | )
13 |
14 | const (
15 | isCheckTx = false
16 | )
17 |
18 | type KeeperTestSuite struct {
19 | suite.Suite
20 |
21 | legacyAmino *codec.LegacyAmino
22 | ctx sdk.Context
23 | app *simapp.AcreApp
24 | }
25 |
26 | func (suite *KeeperTestSuite) SetupTest() {
27 | app := simapp.Setup(isCheckTx, feemarkettypes.DefaultGenesisState())
28 |
29 | suite.legacyAmino = app.LegacyAmino()
30 | suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{})
31 | suite.app = app
32 | }
33 |
34 | func TestKeeperSuite(t *testing.T) {
35 | suite.Run(t, new(KeeperTestSuite))
36 | }
37 |
--------------------------------------------------------------------------------
/x/mint/keeper/params.go:
--------------------------------------------------------------------------------
1 | package keeper
2 |
3 | import (
4 | "github.com/ArableProtocol/acrechain/x/mint/types"
5 | sdk "github.com/cosmos/cosmos-sdk/types"
6 | )
7 |
8 | // GetParams returns the total set of minting parameters.
9 | func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
10 | k.paramSpace.GetParamSet(ctx, ¶ms)
11 | return params
12 | }
13 |
14 | // SetParams sets the total set of minting parameters.
15 | func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
16 | k.paramSpace.SetParamSet(ctx, ¶ms)
17 | }
18 |
--------------------------------------------------------------------------------
/x/mint/keeper/params_test.go:
--------------------------------------------------------------------------------
1 | package keeper_test
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/ArableProtocol/acrechain/x/mint/types"
7 | sdk "github.com/cosmos/cosmos-sdk/types"
8 | )
9 |
10 | func (suite *KeeperTestSuite) TestParamsGetSet() {
11 | params := types.Params{
12 | MintDenom: "aacre",
13 | GenesisDailyProvisions: types.DefaultParams().GenesisDailyProvisions,
14 | ReductionPeriodInSeconds: 1000,
15 | ReductionFactor: sdk.NewDecWithPrec(66, 2),
16 | DistributionProportions: types.DistributionProportions{
17 | Staking: sdk.NewDecWithPrec(2, 1),
18 | },
19 | NextRewardsReductionTime: time.Now().Add(time.Second * 1000).Unix(),
20 | MintingRewardsDistributionStartTime: time.Now().Add(time.Second).Unix(),
21 | }
22 |
23 | suite.app.MintKeeper.SetParams(suite.ctx, params)
24 | newParams := suite.app.MintKeeper.GetParams(suite.ctx)
25 | suite.Require().Equal(params, newParams)
26 | }
27 |
--------------------------------------------------------------------------------
/x/mint/simulation/decoder.go:
--------------------------------------------------------------------------------
1 | package simulation
2 |
3 | import (
4 | "bytes"
5 | "fmt"
6 |
7 | "github.com/ArableProtocol/acrechain/x/mint/types"
8 |
9 | "github.com/cosmos/cosmos-sdk/codec"
10 | "github.com/cosmos/cosmos-sdk/types/kv"
11 | )
12 |
13 | // NewDecodeStore returns a decoder function closure that umarshals the KVPair's
14 | // Value to the corresponding mint type.
15 | func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string {
16 | return func(kvA, kvB kv.Pair) string {
17 | switch {
18 | case bytes.Equal(kvA.Key, types.MinterKey):
19 | var minterA, minterB types.Minter
20 | cdc.MustUnmarshal(kvA.Value, &minterA)
21 | cdc.MustUnmarshal(kvB.Value, &minterB)
22 | return fmt.Sprintf("%v\n%v", minterA, minterB)
23 | default:
24 | panic(fmt.Sprintf("invalid mint key %X", kvA.Key))
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/x/mint/simulation/genesis.go:
--------------------------------------------------------------------------------
1 | package simulation
2 |
3 | // DONTCOVER
4 |
5 | import (
6 | "github.com/cosmos/cosmos-sdk/types/module"
7 | )
8 |
9 | // RandomizedGenState generates a random GenesisState for mint.
10 | func RandomizedGenState(simState *module.SimulationState) {
11 | }
12 |
--------------------------------------------------------------------------------
/x/mint/types/codec.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | "github.com/cosmos/cosmos-sdk/codec"
5 | cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
6 | )
7 |
8 | var amino = codec.NewLegacyAmino()
9 |
10 | func init() {
11 | cryptocodec.RegisterCrypto(amino)
12 | amino.Seal()
13 | }
14 |
--------------------------------------------------------------------------------
/x/mint/types/errors.go:
--------------------------------------------------------------------------------
1 | package types
2 |
--------------------------------------------------------------------------------
/x/mint/types/events.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // Minting module event constants.
4 | const (
5 | AttributeKeyBlockProvisions = "block_provisions"
6 | AttributeBlockNumber = "block_number"
7 | )
8 |
--------------------------------------------------------------------------------
/x/mint/types/genesis.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // NewGenesisState creates a new GenesisState object.
4 | func NewGenesisState(params Params) *GenesisState {
5 | return &GenesisState{
6 | Params: params,
7 | }
8 | }
9 |
10 | // DefaultGenesisState creates a default GenesisState object.
11 | func DefaultGenesisState() *GenesisState {
12 | return &GenesisState{
13 | Params: DefaultParams(),
14 | }
15 | }
16 |
17 | // ValidateGenesis validates the provided genesis state to ensure the
18 | // expected invariants holds.
19 | func ValidateGenesis(data GenesisState) error {
20 | if err := data.Params.Validate(); err != nil {
21 | return err
22 | }
23 |
24 | return nil
25 | }
26 |
--------------------------------------------------------------------------------
/x/mint/types/hooks.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | )
6 |
7 | // MintHooks defines an interface for mint module's hooks.
8 | type MintHooks interface {
9 | AfterDistributeMintedCoin(ctx sdk.Context)
10 | }
11 |
12 | var _ MintHooks = MultiMintHooks{}
13 |
14 | // MultiMintHooks is a container for mint hooks.
15 | // All hooks are run in sequence.
16 | type MultiMintHooks []MintHooks
17 |
18 | // NewMultiMintHooks returns new MultiMintHooks given hooks.
19 | func NewMultiMintHooks(hooks ...MintHooks) MultiMintHooks {
20 | return hooks
21 | }
22 |
23 | // AfterDistributeMintedCoin is a hook that runs after minter mints and distributes coins
24 | // at the beginning of each block.
25 | func (h MultiMintHooks) AfterDistributeMintedCoin(ctx sdk.Context) {
26 | for i := range h {
27 | h[i].AfterDistributeMintedCoin(ctx)
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/x/mint/types/keys.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | // MinterKey is the key to use for the keeper store at which
4 | // the Minter and its DailyProvisions are stored.
5 | var MinterKey = []byte{0x00}
6 |
7 | const (
8 | // ModuleName is the module name.
9 | ModuleName = "mint"
10 |
11 | // StoreKey is the default store key for mint.
12 | StoreKey = ModuleName
13 |
14 | // QuerierRoute is the querier route for the minting store.
15 | QuerierRoute = StoreKey
16 | )
17 |
--------------------------------------------------------------------------------
/x/mint/types/minter.go:
--------------------------------------------------------------------------------
1 | package types
2 |
3 | import (
4 | sdk "github.com/cosmos/cosmos-sdk/types"
5 | )
6 |
7 | // NewMinter returns a new Minter object with the given block
8 | // provisions values.
9 | func NewMinter(dailyProvisions sdk.Dec, lastMintTime int64) Minter {
10 | return Minter{
11 | LastMintTime: lastMintTime,
12 | DailyProvisions: dailyProvisions,
13 | }
14 | }
15 |
16 | // InitialMinter returns an initial Minter object.
17 | func InitialMinter() Minter {
18 | return NewMinter(sdk.NewDec(0), 0)
19 | }
20 |
21 | // DefaultInitialMinter returns a default initial Minter object for a new chain.
22 | func DefaultInitialMinter() Minter {
23 | return InitialMinter()
24 | }
25 |
26 | // Validate validates minter. Returns nil on success, error otherewise.
27 | func (m Minter) Validate() error {
28 | return nil
29 | }
30 |
31 | // BlockProvision returns the provisions for a block based on the block
32 | // provisions rate.
33 | func (m Minter) BlockProvision(time int64, params Params) sdk.Coin {
34 | provisionAmt := m.DailyProvisions.Mul(sdk.NewDec(time - m.LastMintTime)).Quo(sdk.NewDec(86400))
35 | return sdk.NewCoin(params.MintDenom, provisionAmt.TruncateInt())
36 | }
37 |
--------------------------------------------------------------------------------