Git Product home page Git Product logo

aeplugin_dev_mode's Introduction

Aeternity node

CircleCI License Build Tool

A new blockchain for รฆpps.

Optimized for scalability via smart contracts inside state-channels.

Has a built-in oracle for integration with real-world data.

Comes with a naming system, for developerability.

Written in Erlang.

To install and run the Aeternity node, see the instructions below or just follow the progress of the project via GitHub Issues.

If you have discovered a bug or security vulnerability please get in touch. The Aeternity Crypto Foundation pays bug bounties up to 100.000 AE Tokens for critical vulnerabilities. Please get in touch via [email protected].

Documentation

For an overview of the installation process for different platforms, building the package from source, configuration and operation of the Aeternity node please refer to Aeternity node documentation.

We keep our protocol, APIs and research spec in separate protocol repository.

How to start

We publish packages for major platforms on GitHub. Each release comes with release notes describing the changes of the Aeternity node in each particular version.

Please use the latest published stable release rather than the master branch. The master branch tracks the ongoing efforts towards the next stable release to be published though it is not guaranteed to be stable.

Quick Install

Linux / Mac

By using the installer to install the latest stable version:

bash <(curl -s https://install.aeternity.io/install.sh)

See the documentation for starting and configuring the node.

Docker

Alternatively, you can run the node client as a docker container:

Linux / Mac

Or running a docker container (latest tag):

mkdir -p ~/.aeternity/maindb
docker pull aeternity/aeternity
docker run -p 3013:3013 -p 3015:3015 \
    -v ~/.aeternity/maindb:/home/aeternity/node/data/mnesia \
    aeternity/aeternity

Windows

mkdir %APPDATA%\aeternity\maindb
docker pull aeternity/aeternity
docker run -p 3013:3013 -p 3015:3015 -v %APPDATA%/aeternity/maindb:/home/aeternity/node/data/mnesia aeternity/aeternity

Restore from snapshot

To speed up the initial blockchain synchronization the node database can be restored from a snapshot following the below steps:

  • delete the contents of the database if the node has been started already
  • download the database snapshot
  • verify if the snapshot checksum matches the downloaded file
  • unarchive the database snapshot

Note that the docker container must be stopped before replacing the database

The following snippet can be used to replace the current database with the latest mainnet snapshot assuming the database path is ~/.aeternity/maindb:

rm -rf ~/.aeternity/maindb/ && mkdir -p ~/.aeternity/maindb/
curl -o ~/.aeternity/mnesia_main_v-1_latest.tar.zst https://aeternity-database-backups.s3.eu-central-1.amazonaws.com/main_backup_v1_full_latest.tar.zst
CHECKSUM=$(curl https://aeternity-database-backups.s3.eu-central-1.amazonaws.com/main_backup_v1_full_latest.tar.zst.md5)
diff -qs <(echo $CHECKSUM) <(openssl md5 -r ~/.aeternity/mnesia_main_v-1_latest.tar.zst | awk '{ print $1; }')
test $? -eq 0 && tar --use-compress-program=unzstd -xf ~/.aeternity/mnesia_main_v-1_latest.tar.zst -C ~/.aeternity/maindb/

Additional resources

aeplugin_dev_mode's People

Contributors

davidyuk avatar dincho avatar nikita-fuchs avatar uwiger avatar

Stargazers

 avatar

Watchers

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

aeplugin_dev_mode's Issues

Change prefunded accounts key to use hard fork configuration

At the moment, the plugin uses the configuration key custom_prefunded_accs_file to set the prefunded accounts file.

The newly added hard_forks configuration can instead be used to set the prefunded accounts file, in which case, the key custom_prefunded_accs_file can be removed from aeternity.

failing to add dependencies

I deactivated the rebar.config.script in order to take dependencies directly from the rebar.config and added this:

        {ebip39,           
                {git, "https://github.com/aeternity/ebip39.git"}}

It fetches ebip39 and compiles properly, however in runtime:

[error] CRASH REPORT Process <0.1657.0> with 0 neighbours exited with reason: call to undefined function ebip39:generate_mnemonic(128)

In my test app I can import and use it without an issue, what is different here @uwiger ?

Add an option to reduce entropy (set time to a constant)

Currently, if reset chain to height 1 and do some transactions in sequence their hashes will be the same as before resetting. Because they produced from the same nonce and so. The only thing that changes is block/microblock hashes, due to they include a current time.

Having block hashes the same from run to run is useful in testing. I can reset the chain, run some script, record its output, and just compare it with a previous run. Also, it would help to avoid fluctuations in visual testing (when two screenshots are compared).

So, I propose adding an option to freeze the blocks' time to some constant value. If there are any other sources of randomness (a block nonce?) then freeze them as well.

Looks like it is also doable by modifying the node environment, but preferable to have it integrated, to simplify the setup
https://stackoverflow.com/a/41548434/6176994

introduce devmode for development

Devmode

Marginal conditions

  • Devtools need to be able to re-use existing APIs to submit transactions, etc.
  • 1 node only setup (no peer connections expected)
    • no sync required, can be deactivated!
  • Resource requirements should be decreased as much as possible. At least mining mustn't be required anymore for testing.

Configuration

These params can be included in a new section simulator of the YAML or provided in the command line when executing the binary:

Required

  • active Used to activate the devmode with a custom consensus algorithm. Exposes the devmode management API if activated.
    • default: false
  • block_interval Can be used to define a specific "mining interval" in seconds. By default blocks should be mined immediately.
    • default: 0 (immediately)
  • protocol_version Define the protocol version to run the node with (hard_forks section should be omitted)
    • default: 5 (always the latest hardfork)
  • start_time The unix timestamp to start with the first (or ongoing) block
    • default: the current unix timestamp
  • derive_from_mnemonic Use a specific HD wallet mnemonic to generate initial accounts.
    • default: generated on-startup
  • default_balance The default account balance to fund the generated accounts with, specified in AE.
    • default: 500
  • total_accounts Number of accounts to generate at startup.
    • default: 10

Optional (to be discussed)

  • db_path Some users prefer to set a custom db-path
  • block_height_start The height to start the creation of blocks at. Only relevant if the node is started using a snapshot.
    • default: the following block based on the latest block of the snapshot
  • impersonated_accounts An array of accounts addresses to be "impersonated". We probably need to investigate how to achieve that combined with tooling (e.g. SDK).
    • default: []

YAML example for the configuration:

- simulator:
  - active: true
  - chain:
    - db_path: '/opt/custom_dev_snapshot' # optional
    - protocol_version: 5
    - block_interval: 0
    - start_time: 15299999292
    - fork_from: 'https://mainnet.aeternity.io' # optional
    - block_height_start: 444450 # optional
  - accounts:
    - derive_from_mnemonic: <mnemonic_here>
    - default_balance: 500
    - total_accounts: 10
    - impersonated_accounts: ['ak_...', 'ak_...', 'ak_...'] # optional 

Comments

Protocol version

Here the question is how the node should behave if it is started with a snapshot of the chain. I think it should use the latest version of the snapshot and then immediately mine a new the protocol version defined in the config. If the protocol version provided is lower than the latest version in the snapshot the startup must fail.

Account funding

Regarding the account generation the question is if we want to keep the standard way like it is right now where we provide a genesis file that contains a JSON file with addresses and the corresponding amount to fund it. The above mentioned configuration options would be a bit more convenient for developers. In every case the "genesis" accounts and balances should be printed/logged. Maybe this doesn't matter at all if we decide to manage this via management API of the devmode. This way the tooling could call the API after startup and provide the addresses and respective amounts.

Block Height Start

Not sure if this is relevant. Does anybody see a reason to introduce this?

Database path

Not sure if this can currently already be set. But independent from that I think the devmode should - for simplicity - only support 1 specific db backend.

Fork from & impersonated accounts

This can be a very important feature if somebody want's to test functionality e.g. based on the current state of the mainnet. In best case we would be able to only fetch the top height from the remote node and be able continue the chain in the simulator.

On Ethereum there exist a lot of DeFi protocols like Compound or Aave which new projects might want to integrate into their decentralized applications. In some cases it is also required to impersonate other accounts - meaning that you need to be able to perform transactions on behalf of these accounts while not knowing the private key. I am currently not sure how tools & frameworks like Ganache or Hardhat are managing this. But they allow to broadcast transactions on behalf of these "impersonated" or "unlocked" accounts. We should definitely take a look into that.

See:

Start using environment variables

According to recent discussions the config options can also be provided via env-variables when executing the node's binary. So e.g. running ./aeternity start AE__DEVMODE__ACTIVE=true would start the devmode with default values. Basically there are different options to run the node with the desired configuration, see https://docs.aeternity.io/en/stable/configuration/#user-provided-configuration. @nikita-fuchs Raise your voice if we need sth. else here. But I think we already have enough options and just need to make sure it can easily be used with out tooling that wraps around it ๐Ÿ˜›

Devmode management API

This API should be active by default if node runs in devmode and can be a simple http API provided in a new group/tag.

Required

Update protocol version (trigger hardfork)

We need an endpoint that can be used to trigger a hardfork on-demand.

  • PUT /devmode/protocol-version
    • Request payload example: {"value": 2}

Should fail if the protocol version doesn't exist and if the protocol version is equal or lower than the current version.

Jump into the future by block or time

We need an endpoint to be able to jump into the future to test block-height or time-based dependent logic.

By block

  • PUT /devmode/block-height
    • Request payload example: {"type": "delta", "value": 20} (here we can distinguish between delta and actual block as already done for TTL)

Should fail if an actual block is provided which is lower than the current height.

By time

  • PUT /devmode/time
    • Request payload example {"value": 86400} (amount of seconds to move forward)

Optional (to be discussed)

Fund accounts

It might be necessary to fund certain accounts on-demand where one would not want to rely on performing a SpendTx on behalf of an existing account. Not sure if it makes sense as we are able to fund accounts on startup already. Can probably be omitted.

Snapshot the chain state & revert to a specific chain state

This is a feature that Ganache provides. Currently wondering about the usecase. When would we need to make a snapshot during tests where we could revert back to at any point of time?

Probably the easiest way is just to allow the dev to jump back to a certain block height of the current chain by invoking the management API of the simulator.

References

For Ethereum there exists Ganache where we can take a look at and pick what we need:

more devmode features

Current State

  • Config
    • chain
      • keyblock interval
      • microblock interval
      • auto-emission of microblocks
      • start_time - unix timestamp to start with the first (or ongoing) block
        • default: current unix timestamp
      • protocol_version - protocol version to run the node with (hard_forks section should be omitted)
        • default: always the latest hardfork
      • block_height_start - height to start the creation of blocks at
        • only relevant if the node is started using a snapshot.
        • default: following block based on the latest block of the snapshot
    • accounts
      • derive_from_mnemonic - mnemonic seed phrase to derive accounts from (@nikita-fuchs working on that afaik)
        • default: some seed phrase we always use OR a generated one (not sure what's better @nikita-fuchs)
      • default_balance - the default balance of all generated accounts
        • default: 500 ร†
      • total_accounts - the total amount of accounts to derive from mnemonic
        • default: 10
  • API
    • chain
      • /emit_mb - Emit a microblock
      • /emit_kb?n=<N> - Emit N keyblocks
      • /kb_interval?secs=<S> - Set a keyblock interval of S seconds (secs=0 turns off)
      • /mb_interval?secs=<S> - Set a microblock interval of S seconds (secs=0 turns off)
      • /auto_emit_mb?auto_emit=on - Turn on auto-emission of microblocks on tx push
      • /auto_emit_mb?auto_emit=off - Turn off auto-emission of microblocks on tx push
      • time?secs=<S> - Jump S seconds into the future
      • protocol_version=<V> Jump to the (future) protocol version V

Other considerations

  • did somebody ever test running devmode based on a mainnet/testnet snapshot? @nikita-fuchs @thepiwo
  • we recently also discussed if we can fund a new account after we run in devmode based on a mainnet/testnet snapshop. it should already be doable but somebody needs to test @nikita-fuchs @thepiwo
  • impersonating accounts when running devmode based on a mainnet/testnet snapshot -> how can we get control over an account where we do not know the private key? @uwiger @velzevur @hanssv

Originally posted by @marc0olo in #19 (comment)

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.