Coder Social home page Coder Social logo

crytic / etheno Goto Github PK

View Code? Open in Web Editor NEW
329.0 22.0 31.0 751 KB

Simplify Ethereum security analysis and testing

License: GNU Affero General Public License v3.0

Python 95.72% Dockerfile 1.67% Solidity 1.99% JavaScript 0.62%
ethereum solidity truffle ganache symbolic-execution differential-testing

etheno's Introduction

Etheno

Slack Status PyPI version


Etheno is the Ethereum testing Swiss Army knife. It’s a JSON RPC multiplexer, analysis tool wrapper, and test integration tool. It eliminates the complexity of setting up analysis tools like Echidna on large, multi-contract projects.

If you are a smart contract developer, you should use Etheno to test your contracts. If you are an Ethereum client developer, you should use Etheno to perform differential testing on your implementation.

Etheno is named after the Greek goddess Stheno, sister of Medusa, and mother of Echidna—which also happens to be the name of our EVM property-based fuzz tester.

Features

  • JSON RPC Multiplexing: Etheno runs a JSON RPC server that can multiplex calls to one or more clients
    • API for filtering and modifying JSON RPC calls
    • Enables differential testing by sending JSON RPC sequences to multiple Ethereum clients
    • Deploy to and interact with multiple networks at the same time
  • Integration with Test Frameworks like Ganache and Truffle
    • Run a local test network with a single command

Quickstart

Use our prebuilt Docker container to quickly install and try Etheno:

docker pull trailofbits/etheno
docker run -it trailofbits/etheno

NOTE: Many of Etheno's capabilities will require publishing one or more ports and persisting data using volumes as part of the docker run command.

  • To learn about publishing ports, click here
  • To learn more about persisting data using volumes, click here

Alternatively, natively install Etheno in a few shell commands:

# Install system dependencies
sudo apt-get update && sudo apt-get install python3 python3-pip -y

# Install Etheno
pip3 install --user etheno

# Use the Etheno CLI
cd /path/to/a/truffle/project
etheno --ganache --truffle

Usage

Etheno can be used in many different ways and therefore has numerous command-line argument combinations.

Ganache Integration

A Ganache instance can automatically be run within Etheno:

etheno --ganache
  • --ganache-port will set the port on which Ganache is run; if omitted, Etheno will choose the lowest port higher than the port on which Etheno’s JSON RPC server is running
  • --ganache-args lets you pass additional arguments to Ganache
  • --accounts or -a sets the number of accounts to create in Ganache (default is 10)
  • --balance or -b sets the default balance (in Ether) to seed to each Ganache account (default is 1000.0)
  • --gas-price or -c sets the default gas price in wei for Ganache (default is 20_000_000_000)

Running a Ganache instance via Etheno can be used to deploy large, multi-contract projects in tandem with Echidna. To learn more on how to use Echidna and Ganache together, click here.

NOTE: We recommend using the latest version of Ganache (v7.3.2) and Node 16.x. After the upstream bug (see below) is fixed, the Ganache package should be upgraded.

NOTE: Currently, there is an upstream bug in the latest version of Ganache (v7.3.2) that prevents the Etheno integration from working if the contract size that is being tested is very large (trufflesuite/ganache#3332).

JSON RPC Server and Multiplexing

This command starts a JSON RPC server and forwards all messages to the given clients:

etheno https://client1.url.com:1234/ https://client2.url.com:8545/ http://client3.url.com:8888/
  • --port or -p allows you to specify a port on which to run Etheno’s JSON RPC server (default is 8545)
  • --run-publicly allows incoming JSON RPC connections from external computers on the network
  • --debug will run a web-based interactive debugger in the event that an internal Etheno client throws an exception while processing a JSON RPC call; this should never be used in conjunction with --run-publicly
  • --master or -s will set the “master” client, which will be used for synchronizing with Etheno clients. If a master is not explicitly provided, it defaults to the first client listed.
  • --raw, when prefixed before a client URL, will cause Etheno to auto-sign all transactions and submit them to the client as raw transactions

Geth and Parity Integration

A Geth and/or Parity instance can be run as a private chain with

  • --geth or -go for Geth
  • --parity or -pa for Parity

Each will be instantiated with an autogenerated genesis block. You may provide a custom genesis.json file in Geth format using the --genesis or -j argument. The genesis used for each run will automatically be saved to the log directory (if one is provided using the --log-dir option), or it can be manually saved to a location provided with the --save-genesis option.

The network ID of each client will default to 0x657468656E6F (equal to the string etheno in ASCII). This can be overridden with the --network-id or -i option.

EIP and hard fork block numbers can be set within a custom genesis.json as usual, or they may be specified as command-line options such as --constantinople.

Differential Testing

Whenever two or more clients are run within Etheno, the differential testing plugin will automatically be loaded. This plugin checks for a variety of different discrepancies between the clients, such as gas usage differences. A report is printed when Etheno exits.

This plugin can be disabled with the --no-differential-testing option.

Truffle Integration

Truffle migrations can automatically be run within a Truffle project:

etheno --truffle

Additional arguments can be passed to Truffle using --truffle-args.

Logging

By default, Etheno only prints log messages to the console with a log level defaulting to INFO. An alternative log level can be specified with --log-level or -l. You can specify a log file with the --log-file option. In addition, you can provide the path to a logging directory with --log-dir in which the following will be saved:

  • a complete log file including log messages at all log levels;
  • separate log files for each Etheno client and plugin;
  • the genesis file used to instantiate clients;
  • a subdirectory in which each client and plugin can store additional files such as test results;
  • a script to re-run Geth and/or Parity using the same genesis and chain data that Etheno used.

Requirements

  • Python 3.7 or newer

Optional Requirements

  • Node 16.x or newer to install various integrations
  • Ganache 7.3.2 or newer for its associated integrations
  • Truffle for its associated integrations
  • Geth and/or Parity, if you would like to have Etheno run them

Getting Help

Feel free to stop by our Slack channel for help on using or extending Etheno.

License

Etheno is licensed and distributed under the AGPLv3 license. Contact us if you’re looking for an exception to the terms.

etheno's People

Contributors

anishnaik avatar dependabot[bot] avatar dguido avatar disconnect3d avatar elopez avatar esultanik avatar ggrieco-tob avatar ilya-bobyr avatar mike-myers-tob avatar montyly avatar oldsj avatar rappie avatar rmi7 avatar woodruffw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etheno's Issues

Differential testing

Enable Etheno to perform automated differential testing of clients by comparing the gas costs of transactions, execution traces, and changes to storage. Real-world use of this feature will likely depend on the features added by Issue #2.

Export contract creation/transaction summary

Create a JSON-based DSL for summarizing contract creations and transactions (e.g., for input to Echidna and Manticore) and add an option to Etheno to output it. Similar to #57, but resolve things like created contract addresses, &c.

Support exporting evm_mine events

Some contracts depend on specific conditions on the timestamp/block number, but etheno does not export that information in the JSON file. This makes the use of the JSON file unreliable to reproduce the exported transactions elsewhere.

Make Manticore an optional dependency

Move Manticore to extras_require and throw an error with installation instructions if the user tries to do something with Etheno that requires Manticore.

Add support for newer Geth

geth does no longer support the --rpc argument since v1.10.9 (Sept 29, 2021 - relevant commit ethereum/go-ethereum@9a0df80) and it should be replaced with --http.

base_args = ['/usr/bin/env', 'geth', '--nodiscover', '--rpc', '--rpcport', "%d" % self.port, '--networkid', "%d" % self.genesis['config']['chainId'], '--datadir', self.logger.to_log_path(self.datadir), '--mine', '--etherbase', format_hex_address(self.miner_account.address), f"--verbosity={verbosity}", '--minerthreads=1']

The current geth version is v1.10.14

Deprecated Manticore callback

The will_start_run callback was renamed to will_run in Manticore 0.3.0. Need to add a check for the Manticore version and dynamically set the callback name. This will partially address #62.

Release v0.2.0

To release Etheno:

  1. Merge a PR for #22 bumping the version number in setup.py, bumping the version number in __main__.py (--version), and updating the changelog with the version being released. Conventional commit message is "Etheno x.y.z". In the changelog don't forget to update the number in the "unreleased" line and check the date is correct.
  2. Check you are tagging master branch
    • git checkout master
    • git pull origin master
    • etheno --version should show expected version
  3. Tag that commit with the version number, and push tags.
    • git tag -a 0.2.xx -m "Etheno 0.2.xx"
    • git push origin 0.2.xx or git push origin --tags
  4. Make a draft release in github releases page https://github.com/trailofbits/etheno/releases. Select the right tag. The txt must be heavily based on the lastest part of the Changelog at this point: https://raw.githubusercontent.com/trailofbits/etheno/master/CHANGELOG.md
  5. Make the distribution file.
    • Make a fresh clone of the repository git clone [email protected]:trailofbits/etheno.git (If you use your normal copy the distribution file may include unexpected files)
    • Delete or manage what is in the dist/ folder so you do not accidentally upload anything else
    • python setup.py sdist # this creates the distribution file in dist/ folder

** Uploading to pypi is not reversible please try it out on test.pypi.org first **

6a. [ ] Push to test pypi and test it
- twine upload --repository-url https://test.pypi.org/legacy/ dist/*
- Check you see the correct version at https://test.pypi.org/project/etheno
- Install it from test pypi (ideally on a fresh box):
- pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple etheno
6b. Optional. If no access to test pypi. Do a fresh install in a virtualenv.
- virtualenv --python=python3.7 temp
- source temp/bin/activate
- Untar the distro file you are about to upload
- python setup.py install
- Check everything looks good

  • Uploading to pypi is not reversible please try it out on test.pypi.org first **
  1. Push to pypi
    • twine upload dist/*
  2. Update the github releases page https://github.com/trailofbits/etheno/releases

Tips

Use the Github diff links to see all the commits between the last release and now, e.g. 0.1.0...HEAD

Start with the categories of changes from keepachangelog

Types of changes

Added for new features.
Changed for changes in existing functionality.
Deprecated for soon-to-be removed features.
Removed for now removed features.
Fixed for any bug fixes.
Security in case of vulnerabilities.

and start categorizing features/commits from the diff into those

Resources

Quickstart not running

Running the quickstart steps fails with

etheno@dc0445745920:~/examples/BrokenMetaCoin$ etheno --truffle --ganache --manticore --manticore-max-depth 2 --manticore-script ExploitMetaCoinManticoreScript.py
INFO     [06-24|17:28:46][Ganache@8546] Ganache CLI v6.4.4 (ganache-core: 2.5.6)
INFO     [06-24|17:28:46][Ganache@8546]
INFO     [06-24|17:28:46][Ganache@8546] Available Accounts
INFO     [06-24|17:28:46][Ganache@8546] ==================
INFO     [06-24|17:28:46][Ganache@8546] (0) 0x85a246e29e22828237a9ea13fcb9d60041c23478 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (1) 0x2d2d139f2f3e02664ad36353eefc099d4e91fe64 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (2) 0xb1a560774f9d94be11cdedf165f9ef152a64b42a (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (3) 0xd7e277eea93a9632ca9ec299da8cd5d163028e66 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (4) 0x478de08556fa99d5be40b87bd89fcf477099a121 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (5) 0x418f723c1325cdbb073098faa72e02eb05c4412e (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (6) 0xdb2bfca2ee3744f90008c7f451f7304104179a2b (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (7) 0xa67019ae82ed7ab8a0c2903dba8471c6ba9e3841 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (8) 0xc19804764bf11d5c8ce31008ef28183b83a72341 (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546] (9) 0x422bc0d18ed94b5413a09ea89d7f5fbc807b626b (~100 ETH)
INFO     [06-24|17:28:46][Ganache@8546]
INFO     [06-24|17:28:46][Ganache@8546] Private Keys
INFO     [06-24|17:28:46][Ganache@8546] ==================
INFO     [06-24|17:28:46][Ganache@8546] (0) 0x3c0211c0fa7c402565dfb04548e00ccba9bd020a00ea6aa0ac60f1967380529c
INFO     [06-24|17:28:46][Ganache@8546] (1) 0xebf76ee055116cd4135333cc32722ee710b74d7c46612f047b7e210ac6dc19f1
INFO     [06-24|17:28:46][Ganache@8546] (2) 0xaaa3d2690c1aa663b2a825928de0096fa50cd3369d2c137e7e26754754e3b9f4
INFO     [06-24|17:28:46][Ganache@8546] (3) 0x8159ae0d52c8b3f57e92160bd80257c2b09c8bd89cd33568e7cac3b8c76c66e1
INFO     [06-24|17:28:46][Ganache@8546] (4) 0x6527b0a6fac5823810eef0d46c327313124118779cd20f6a4791a7961fc0bd10
INFO     [06-24|17:28:46][Ganache@8546] (5) 0x6d898caf9ddeb5f5a3c970067278a60eb101e687ef9d2985cbbc658267a9cb04
INFO     [06-24|17:28:46][Ganache@8546] (6) 0xaea9a5c6f4d9bfc042a05492eb576d35be611e2b9fdfe6b117397986a607e138
INFO     [06-24|17:28:46][Ganache@8546] (7) 0x26bb57c1feb9ab38a804aa47f964e38d9f892174c1865693b820d7626072aaae
INFO     [06-24|17:28:46][Ganache@8546] (8) 0xa21992695e7db0beb102bedd6a8943830338192ba574313791b456e250a39e45
INFO     [06-24|17:28:46][Ganache@8546] (9) 0x9a022d24a7985a7798f67ae41926a69a2409b3aaacff0d5fe1b5c9759fd8a278
INFO     [06-24|17:28:46][Ganache@8546]
INFO     [06-24|17:28:46][Ganache@8546] Gas Price
INFO     [06-24|17:28:46][Ganache@8546] ==================
INFO     [06-24|17:28:46][Ganache@8546] 20000000000
INFO     [06-24|17:28:46][Ganache@8546]
INFO     [06-24|17:28:46][Ganache@8546] Gas Limit
INFO     [06-24|17:28:46][Ganache@8546] ==================
INFO     [06-24|17:28:46][Ganache@8546] 6721975
INFO     [06-24|17:28:46][Ganache@8546]
INFO     [06-24|17:28:46][Ganache@8546] Listening on 127.0.0.1:8546
INFO     [06-24|17:28:46][Ganache@8546] eth_accounts
ERROR    [06-24|17:28:46][Etheno] The version of Manticore installed is 0.3.0, but the minimum required version with Etheno support is 0.2.2. We will try to proceed, but things might not work correctly! Please upgrade Manticore.
WARNING  [06-24|17:28:46][Manticore][manticore][core][manticore] There is no event named will_start_run for callback on plugin StopAtDepth
INFO     [06-24|17:28:46][Manticore][manticore][core][manticore] Deprecated!
Etheno Started! Running Truffle...
Etheno v0.2.0
 * Serving Flask app "etheno.etheno" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:8545/ (Press CTRL+C to quit)
INFO     [06-24|17:28:50][Truffle] Warning: Both truffle-config.js and truffle.js were found. Using truffle-config.js.
INFO     [06-24|17:28:50][Truffle]
INFO     [06-24|17:28:50][Truffle] Compiling your contracts...
INFO     [06-24|17:28:50][Truffle] ===========================
ERROR    [06-24|17:28:59][Etheno] Truffle exited with code 1
127.0.0.1 - - [24/Jun/2019 17:28:59] "GET /shutdown HTTP/1.1" 200 -
Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/__main__.py", line 302, in truffle_thread
    'logger': logger.EthenoLogger(os.path.basename(args.manticore_script.name), parent=manticore_client.logger)
  File "ExploitMetaCoinManticoreScript.py", line 8, in <module>
    contract_account = list(manticore.contract_accounts.values())[2]
IndexError: list index out of range

Integrate Echidna

Use Echnida's new raw transaction creation capability to fuzz clients

Etheno migration issues

I tried etheno --truffle --ganache -p 7545 -i 5777 -x export.json mentioned here.
But there is no data in export.json.

Version info:
Etheno: ToB/v0.2.3/source/Etheno
Truffle: v5.1.59 (core: 5.1.59)
Solidity: - ^0.4.18 (solc-js)
Node: v10.19.0
Web3.js: v1.2.9
Here is my truffle-config.js

const HDWalletProvider = require('truffle-hdwallet-provider');
const infuraKey = "ktSpeXTL5DRPjaJ087hh";

const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();

module.exports = {
  // See <http://truffleframework.com/docs/advanced/configuration>
  // to customize your Truffle configuration!
  compilers: {
    solc: {
      version: "^0.4.18"
    }
  },
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "5777",
    }
  }
}

Save logs to a file

Add an option to save logs to a file. Split the logs into separate files for each source. Also add an option to suppress log output for the console based on origin.

Transaction address synchronization

Enable Etheno to multiplex transactions across multiple blockchains/networks by maintaining a mapping of equivalent contract addresses and dynamically rewriting transactions to honor the correct addresses for the recipient client.

Etheno fails to run with --geth and genesis.json

Getting the following when running etheno --geth -j genesis.json

Traceback (most recent call last):
  File "/Users/nettrino/venvs/etheno/bin/etheno", line 8, in <module>
    sys.exit(main())
  File "/Users/nettrino/venvs/etheno/lib/python3.9/site-packages/etheno/__main__.py", line 204, in main
    private_key=decode_value(pkey)))
  File "/Users/nettrino/venvs/etheno/lib/python3.9/site-packages/etheno/utils.py", line 46, in decode_value
    elif v.startswith('0x') or (frozenset(['a', 'b', 'c', 'd', 'e', 'f']) & frozenset(v)):
AttributeError: 'NoneType' object has no attribute 'startswith

The genesis.json file used is

{
"config":{
   "chainId": 1337,
    "homesteadBlock": 0,
    "eip150Block": 0,
    "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
    "eip155Block": 0,
    "eip158Block": 0,
    "byzantiumBlock": 0,
    "constantinopleBlock": 0
},
 "alloc": {
        "0x72f52e17469e13b9D0D3aAA5922A597eFCdaF27e": {
            "balance": "100000000000000000000"
        }
},
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasPrice": "0xc000310480",
"gasFeeCap": "0xc000083d40",
"gasTipCap": "0xc0003c00b0",
"gasLimit" : "0x4bb14a0",
"nonce" : "0x0000000000000042",
"mixhash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" :
"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00"
}

Log human-readable transactions for Echidna

We currently just log the raw transaction data. We're already compiling the Echidna fuzz contract, so it wouldn't be too hard to extract the ABI and decode the resulting transactions.

Docker Improvements

We can reduce the Docker image size still by incorporating Echidna's new Dockerfile and applying its concepts to other installs. We also need to set up GitHub Actions to upload the image to Dockerhub rather than relying on Dockerhub to build it.

Looking for guidance with setting up a testing environment for larger smart contract projects

Hello,

I'm an aspiring bug bounty hunter, looking to get into smart contract hacking. I'm especially interested in automated fuzzing/testing, this is what led me to your awesome tools :)

So far i've been looking at:

  • Reading the "Mastering Ethereum" book
  • CTF's like Ethernaut and Damn Vulnerable DeFi
  • The slither/echidna/manticore exercises on the "Building Secure Smart Contracts" github page

While looking at real life smart contract bug bounty programs I noticed things tend to get big pretty quickly, into dozens or even more than a hundred smart contracts working together.

This led me to Etheno and here I ran into some roadblocks. While trying to get the examples working in the docker images i got adviced to explain my expectations here.

So, my plan:

I'm trying to set up a testing environment where I can run tools like Echidna/Manticore 24/7. My plan of attack would be to search for a couple of essential/sensitive parts of code in the contracts. First by looking at what at the main idea of the project, looking for ways to game the system etc. Second by looking at all the contracts manually one by one, looking for interesting pieces of code.

After this I can write tests for Echidna/Manticore and run them indefinetly, until i have another project figured out and ready to test.

The main hurdle i'm currently facing is trying to figure out how to set up all the smart contracts in such a way that i'm able to test/fuzz them as a whole. The examples I found are with 1 or 2 contracts, i'm looking for at least 10-20 (for a start).

I know there is a "multi abi" option in Echidna, but I have not been able to find any examples or further documentation about this. Etheno seems to be the most promising solution to me. It seems to have support for the Truffle migrations system, so I imagine I could set up all my smart contracts using Truffle scripts and have Etheno prepare them for testing.

Anyway, without making my post even longer than it already is, please let me know if i'm on the right track and where to go from here.

Some questions:

  • Is Etheno indeed the way to go here? I'm not stuck on Etheno at all, so let me know if there are better alternatives
  • Is my whole plan realistic? Are project of such a scale possible to fuzz/test using current technology?
  • I'm also very interested in references to more documentation about using Echidna/Manticore on non-trivial smart contracts

Thanks.

Raw transaction clients

Add support for clients that do not have any local accounts. Do this by dynamically converting calls to eth_sendTransaction to eth_sendRawTransaction by having Etheno sign the transaction.

Some truffle tests pass on ganache, but fail on etheno

In some cases, truffle tests fail in etheno, but work in ganache. To reproduce:

  1. Get the latest balancer-core revision and install all the dependencies (yarn)
  2. Install ganache and ganache-cli
  3. Start ganache in another terminal: ganache --deterministic --gasLimit 10000000
  4. Run yarn test. All the tests will pass. for instance:
    Contract: BFactory
    Factory
    ✓ BFactory is bronze release
    ✓ isBPool on non pool returns false
    ✓ isBPool on pool returns true
    ✓ fails nonAdmin calls collect (42ms)
    ✓ admin collects fees (477ms)
    ✓ nonadmin cant set blabs address
    ✓ admin changes blabs address (51ms)
    
  5. Kill ganache and start etheno in another console: etheno --ganache --ganache-args "--deterministic --gasLimit 10000000" -x out.json
  6. Run yarn test. Some of the tests will fail:
  Contract: BFactory
    Factory
      ✓ BFactory is bronze release
      ✓ isBPool on non pool returns false
      ✓ isBPool on pool returns true
      1) fails nonAdmin calls collect
    > No events were emitted
      ✓ admin collects fees (339ms)
      2) nonadmin cant set blabs address
    > No events were emitted
      ✓ admin changes blabs address (56ms)

Add support for a Bitcoin client as an Etheno client

It seems like it would be feasible to use a subset of Etheno's functionality with Bitcoin clients, but I wonder what the steps toward achieving that would be?

A Bitcoin client, like an Ethereum one, has a JSON-RPC interface for receiving commands, including commands to submit transactions embedded with scripts (in an "assembly"/bytecode form only). Like Ethereum, a Bitcoin blockchain begins with a "genesis block." Bitcoin doesn't have the concept of "gas," but the rest seems similar enough to pose this feature request.

Given that the analysis tools (Echidna, Manticore) can't do anything with Bitcoin Script yet, the first goal seems to be using Etheno's JSON-RPC multiplexing for differential testing of Bitcoin clients.

Notional CLI use:
etheno --bitcoin-core --bitcoin-core-args blabla

The next desirable feature for testing Bitcoin clients might be to extend Echidna to be able to mutate a Bitcoin script.

Web-based log viewer

Etheno already runs a webserver, so add an option to serve a webpage that dynamically loads all of the log files.

Address Synchronization in Raw Transactions

Add support for rewriting and re-signing raw transactions that contain addresses that need to be rewritten.

If Etheno does not have the necessary private key, throw an exception.

ImportError (cannot import name 'register_log_callback') when running quickstart example

First of all, thanks for developing this awesome tool 🙇🏻‍♂️

I tried running the steps on quickstart, but I got the following error when running the example:

etheno@dafa852d5dc7:~/examples/BrokenMetaCoin$ etheno --truffle --ganache --manticore  --manticore-script ExploitMetaCoinManticoreScript.py
Traceback (most recent call last):
  File "/home/etheno/.local/bin/etheno", line 33, in <module>
    sys.exit(load_entry_point('etheno==0.2.4', 'console_scripts', 'etheno')())
  File "/home/etheno/.local/bin/etheno", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/home/etheno/.local/lib/python3.6/site-packages/importlib_metadata/__init__.py", line 168, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/__main__.py", line 23, in <module>
    from .manticoreclient import ManticoreClient
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 25, in <module>
    import manticore.utils
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 20, in manticoreimport
    return oldimport(name, *args, **kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/manticore/__init__.py", line 10, in <module>
    from .ethereum.manticore import ManticoreEVM
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 20, in manticoreimport
    return oldimport(name, *args, **kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/manticore/ethereum/__init__.py", line 3, in <module>
    from .manticore import ManticoreEVM, config
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 20, in manticoreimport
    return oldimport(name, *args, **kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/manticore/ethereum/manticore.py", line 15, in <module>
    from ..core.manticore import ManticoreBase, ManticoreError
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 20, in manticoreimport
    return oldimport(name, *args, **kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/manticore/core/manticore.py", line 29, in <module>
    from .worker import (
  File "/home/etheno/.local/lib/python3.6/site-packages/etheno/manticoreclient.py", line 20, in manticoreimport
    return oldimport(name, *args, **kwargs)
  File "/home/etheno/.local/lib/python3.6/site-packages/manticore/core/worker.py", line 5, in <module>
    from ..utils.log import register_log_callback
ImportError: cannot import name 'register_log_callback'

Etheno depends on transaction receipt requests for exporting with "-x"

Hi.

I've been having problems with exporting my deployment transactions using Hardhat. It turns out this is because the etheno logging system depends on a eth_getTransactionReceipt for it's exporting plugin (EventSummaryExportPlugin). Hardhat does not request this receipt by default for function calls, so only contract deployments are being logged. Truffle does request this by default for both functions and deployments. I have not tested it in any other frameworks.

When I specifically request a receipt in the hardhat deploy script I can get it to work using the following code:

    const tx = await simple.doSomething();  // function call
    const receipt = await tx.wait(); // request receipt

Right now this is something that has to be remembered every time to keep an accurate etheno export. People new to etheno will probably not know this at all. I think it would be an nice improvement if etheno can support this out of the box. Without the need for manually requesting the receipt.

I have been tinkering with the etheno code a bit, looking for a fix. I've come up with 2 ideas for a possible fixes. Each have their own problems though, i'm hoping you guys can shed some light on this.

  1. Log function call transactions directly in eth_sendRawTransaction because you dont need to know the address of a deployed contract (which you can only know afterwards). The problem here is that currently "gas used" is also being logged. This is something you can't know in advance either, right? Is it important to keep logging this?
  2. Dont depend on the user to call eth_getTransactionReceipt at all. Etheno could just call this itself after every transaction. This would be the most robust fix in my opinion. The problem here is that we cannot do this right away, because the transaction is still being mined. So using the after_post hook for this if impossible. Correct me if i'm wrong. We'd have to have another kind of hook, or can we use evm_mine for this?

I'd be interested in putting a bit of time into this. So far i've been looking at this for about 2-4 hours. I expect one of these fixes to take another 4-8 hours (if they turn out to be possible).

Let me know what you think and if this would be elligible for a bounty. Thanks.

Etheno cannot activate Ganache-cli

May I know the suitable node version for using Etheno together with Ganache cli? According to the description in Etheno reame.md, I set the node version to node v.12.22.11. And I install ganache-cli to this node. However when I input the command "etheno --ganache" in the terminal, there would always be error as shown in the screenshot below:
Screenshot 2022-04-11 at 10 17 50 AM

I tried different version of Ganache-cli, but the same error keeps occurring. May I know what the problem is?

P.S. When I activate the Ganache-cli in node 12 by running "ganache-cli", there would also be error. So I also tried node v.16.14.0, the Ganache-cli can be activated, but when using together with Etheno, the same error occurs.

Support for Geth v1.8.17

For some reason, running Etheno with Geth v1.8.17, Geth will never mine any of Etheno's submitted transactions. Figure out why. Currently Etheno only supports Get v1.8.2.

Error: Callback was already called

If you try to use etheno with balance-core, you will get an error:

$ etheno --truffle --ganache -p 7545 -i 5777 -x export.json
INFO     [09-21|10:37:35][Ganache@7546] Ganache CLI v6.10.2 (ganache-core: 2.11.3)
INFO:Ganache@7546:Ganache CLI v6.10.2 (ganache-core: 2.11.3)
INFO     [09-21|10:37:35][Ganache@7546] Error: Callback was already called.
INFO:Ganache@7546:Error: Callback was already called.
INFO     [09-21|10:37:35][Ganache@7546]     at /home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:19:276
INFO:Ganache@7546:    at /home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:19:276
INFO     [09-21|10:37:35][Ganache@7546]     at s.<anonymous> (/home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:19:2238)
INFO:Ganache@7546:    at s.<anonymous> (/home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:19:2238)
INFO     [09-21|10:37:35][Ganache@7546]     at s.emit (events.js:314:20)
INFO:Ganache@7546:    at s.emit (events.js:314:20)
INFO     [09-21|10:37:35][Ganache@7546]     at s.destroy (/home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:39:744240)
INFO:Ganache@7546:    at s.destroy (/home/g/Code/balancer-core/node_modules/ganache-cli/build/ganache-core.node.cli.js:39:744240)
INFO     [09-21|10:37:35][Ganache@7546]     at finish (_stream_writable.js:670:14)
INFO:Ganache@7546:    at finish (_stream_writable.js:670:14)
INFO     [09-21|10:37:35][Ganache@7546]     at processTicksAndRejections (internal/process/task_queues.js:80:21)
INFO:Ganache@7546:    at processTicksAndRejections (internal/process/task_queues.js:80:21)

EVM Tracing

Add support for emitting EVM traces. Integrate this feature into the differential tester to automatically compare the traces of all transactions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.