Giter Club home page Giter Club logo

archethic-node's Introduction

Archethic

Welcome to the Archethic Node source repository ! This software enables you to build the first transaction chain and next generation of blockchain focused on scalability and human oriented.

Archethic features:

  • Fast transaction processing (> 1M tps)
  • Lower energy consumption than other blockchain
  • Designed with a high level of security (ARCH consensus supporting 90% of maliciousness)
  • Adaptive cryptographic algorithms (quantum resistant)
  • Decentralized Identity and Self Sovereign Identity
  • Smart contract platform powered by a built-in interpreter
  • Strong scalability with geo secured sharding
  • Soft-Real-Time P2P view with supervised networking

Development

Our codebase aims to reach the guidelines of Elixir projects. We are focusing on the best quality.

The source code can change to respect the best quality of reading and regarding best practices.

Current implemented features:

  • Adaptive cryptography: different elliptic curves and software implementation
  • Hybrid root of trust: mix of hardware and software cryptographic key to maintain trust and security
  • TransactionChain: Transaction structure and transaction generation
  • Smart Contract: interpreter coded with Elixir DSL through Meta-programming and AST
  • Node election: heuristic validation and storage node selection
  • P2P: Inter-node communication, supervised connection to detect the P2P view of nodes in almost real-time
  • Transaction mining: ARCH consensus
  • Beacon chain: Maintains a global view of the network (transactions, P2P view)
  • Self-Repair: Self-healing mechanism allowing to resynchronize missing transactions
  • Embedded explorer leveraging sharding to retrieve information
  • Custom Binary protocol for data transmission
  • Token minting
  • Internal oracles (UCO Price Feed)
  • Tailored embedded database

Running a node for development purpose

Using Elixir

Requirements:

Platforms supported:

  • Linux (Ubuntu 18.04)
  • Mac OS X

At first, clone the repository:

git clone https://github.com/archethic-foundation/archethic-node.git
cd archethic-node

Get dependencies:

mix deps.get

Install the static assets

cd assets ; npm install; cd -

To start a single node:

iex -S mix

To clean the data

make clean

To start mutiple node, you need to update some environment variables:

# Start the first node
iex -S mix

# Start second node
ARCHETHIC_CRYPTO_SEED=node2 ARCHETHIC_P2P_PORT=3003 ARCHETHIC_HTTP_PORT=4001 ARCHETHIC_HTTPS_PORT=5001 iex -S mix

# To start other node, increment the environment variables

Using docker

Requires docker compose plugin

At first, clone the repository:

git clone https://github.com/archethic-foundation/archethic-node.git
cd archethic-node

Build the image:

docker build -t archethic-node .

To start a single node:

# You can run node up to node3
docker compose up node1
docker compose up node2
docker compose up node3

To start all nodes at the same time:

docker compose up

To run benchmarks:

docker compose up bench

To run the playbooks to validate non regression:

docker compose up validate

Using snap

Work in progress ..

Running a node for testnet / mainnet

Will be opened regarding roadmap advancement

Contribution

Thank you for considering to help out with the source code. We welcome contributions from anyone and are grateful for even the smallest of improvement.

Please to follow this workflow:

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Licence

AGPL

archethic-node's People

Contributors

88maomao avatar ambareesha7 avatar apoorv-2204 avatar ba3aww avatar bchamagne avatar blackode avatar cluster avatar dependabot[bot] avatar dmytronasyrov avatar dr-chain avatar gdaguin avatar herissondev avatar imnik11 avatar kevin-btc avatar manujuniris avatar netboz avatar neylix avatar prix-uniris avatar pvmart avatar reddwarf03 avatar roychowdhuryrohit-dev avatar samantatarun avatar samuelmanzanera avatar snyk-bot avatar tenmoves avatar wicliff avatar zedalaye 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

archethic-node's Issues

Create scheduler to manage origin keys renewal

Origin keys must be renewed and authorized by a certain device public keys.
It can be software, hardware device, etc..

A scheduler must run this renewal of keys.

This issue can involve:

  • Implement the scheduling (like once a day / week -> this should be configurable)

Create more performant P2P client

The current implementation of the P2P client is using GenServer but GenServer come with some unbounded message queue.
However, this can be dangerous as the number of process entering inside the process is not limited, and no back pressure mechanism is provided.

We should change the P2P client to more efficient in terms of performance with some back pressure and avoid system limits.

By still keeping the GenServer to manage the connection, we can use ETS to perform some verification before sending the message, like a semaphore.

"invalid smart contract" error

Via JS, when try to push a SC, with last version of SDK, the server return "invalid smart contract" error

Type of transaction is hosting and the code is define like this

const code = actions triggered by: transaction do set_type hosting set_content "Test SC" end

Add live feed for oracle transaction into the OracleChain explorer

The current OracleChain's explorer only support updates of transactions listing for Oracle's summary transaction.

In the context to have a real feed for the explorer, we need to add the insertion of new transaction once they are received.

Because all the nodes will receive the oracle transactions, we can dispatch as soon as they arrived.

Compilation Error Float-16

With the last version, we have the following error when we launch the application

== Compilation error in file lib/archethic/beacon_chain/summary.ex ==
** (CompileError) lib/archethic/beacon_chain/summary.ex:255: float requires size*unit to be 32 or 64 (default), got: 16
(elixir 1.11.2) src/elixir_bitstring.erl:165: :elixir_bitstring.expand_specs/6
(elixir 1.11.2) src/elixir_bitstring.erl:38: :elixir_bitstring.expand/7
(elixir 1.11.2) src/elixir_bitstring.erl:26: :elixir_bitstring.expand/4
(elixir 1.11.2) src/elixir_fn.erl:15: anonymous fn/4 in :elixir_fn.expand/3
(stdlib 3.14.1) lists.erl:1358: :lists.mapfoldl/3
(elixir 1.11.2) src/elixir_fn.erl:20: :elixir_fn.expand/3
(stdlib 3.14.1) lists.erl:1358: :lists.mapfoldl/3
(stdlib 3.14.1) lists.erl:1359: :lists.mapfoldl/3
(stdlib 3.14.1) lists.erl:1358: :lists.mapfoldl/3
(elixir 1.11.2) expanding macro: Kernel.|>/2
lib/archethic/beacon_chain/summary.ex:256: ArchEthic.BeaconChain.Summary.serialize/1

My version of Elixir
iex -v
Erlang/OTP 23 [erts-11.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

IEx 1.11.2 (compiled with Erlang/OTP 23)

Debian 9 et 10: Impossible d'exécuter install.sh

Le programme s'arrête rapidement, a priori causé par NodePM (incompatibilité entre NPM et NODEJS)

./scripts/install_system_deps.sh: 6: ./scripts/install_system_deps.sh: function: not found
0000000000
./scripts/install_system_deps.sh: 8: ./scripts/install_system_deps.sh: Syntax er ror: "}" unexpected
./scripts/release.sh: 36: ./scripts/release.sh: mix: not found
./scripts/release.sh: 37: ./scripts/release.sh: mix: not found
./scripts/release.sh: 42: ./scripts/release.sh: mix: not found
./scripts/release.sh: 45: ./scripts/release.sh: npm: not found
grep: mix.exs: No such file or directory

Version:
Installation dir: INSTALL_DIR
./scripts/release.sh: 55: [: 0: unexpected operator
Generate release
./scripts/release.sh: 74: ./scripts/release.sh: mix: not found
Install MainNet release
Copy release into INSTALL_DIR/mainnet
cp: cannot stat '_build/prod/rel/uniris_node/releases//uniris_node.tar.gz': No s uch file or directory
tar (child): INSTALL_DIR/uniris_node.tar.gz: Cannot open: No such file or direct ory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Install TestNet release
Copy release into INSTALL_DIR/testnet
tar (child): INSTALL_DIR/uniris_node.tar.gz: Cannot open: No such file or direct ory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
cp: cannot stat 'rel/test_runtime_config.exs': No such file or directory

Validate smart contract calls

Rationale

When a transaction is targeting a smart contract through the recipients field in the transaction data, we should provide a way to check if the transaction would be valid before to send.
Hence, clients can call this endpoint to be sure the transaction will pass.

Why not doing it during transaction validation ?

Because if the transaction calls are invalid, we don't want a user to spam the network making DDOS attack for nothing and do not pay the fee as the transaction would be not valid.
So by letting the transaction be validated and refused on the smart contract side, we are using the fee as a security mechanism for malicious attacks towards smart contracts.

How to do it

We should provide an API to check the validity of the smart contract call.
This API should:

  • Download transaction's code of the smart contract targeted
  • Interpret the transaction conditions with the pending transaction as input
  • Return errors or success

Self-Repair cannot fetch transaction summary

During the self repair, when a node restart, the self repair cannot fetch the transaction summary from an empty list of nodes.
The node list should not be empty

Log:

transaction_type=summary [error] Cannot fetch during self repair from []

Epic: #321

"gmp.h" header file not found

Description

Running iex -S mix phx.server fails when "gmp.h" dependency in /usr/bin/gcc src/c/hypergeometric_distribution.c is not found.

Expected Behaviour

Uniris node accessible via localhost:$PORT.

Actual Behaviour

src/c/hypergeometric_distribution.c:3:10: fatal error: 'gmp.h' file not found
#include <gmp.h>
         ^~~~~~~
1 error generated.
make: *** [hypergeometric_distribution] Error 1
** (Mix) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.

Steps To Reproduce

iex -S mix phx.server

Platform

macOS Big Sur 11.2.3

Possible Solution

A simple brew install gmp is one of the easiest way to solve this issue. Please add gmp under installation requirements.

Fix OracleChain pagination "Next Page" button

When the node starts up, and if we go to the OracleChain explorer page.
When there are 2 pages, from the page 1, if you click on the “Next page” button, the page in the URL is updated but not the list.

This bug is not present once you have 3 pages.

Enforce the authorization of origin of node public key

We should add configuration to say in prod, we only accept node public key coming from hardware and on dev, and test we accept software keys (like authorized list of origin)

This would avoid spamming of new joiners using software keys in production


Epic: #306

Add BeaconChain Explorer

Provide an interface like the OracleChain to get the list of transaction in the network using the BeaconChain

Using AlpineJS

Add AlpineJS for the web view, to simplify UI avoiding backend interaction (for LiveView) for just UI rendering.

Fetch other beacon summary to build network coordinates map

BeaconChain must implement the consolidation of the network coordinates by fetching other beacon summaries to get the whole map of the network and determine the network coordinates patch.

This feature should also add a new entry in the beacon summary data to hold the network patch of the nodes involved in the beacon chain's subset.


Epic: #155

Add a P2P message to get a BeaconChain Summary

This feature should reduce latency during self repair.

Instead of loading the full beacon summary transaction it will only load the the denormalized data

However we may still need to download the transaction if the node doesn't have it and if it needs to store it.

Using list instead of map in the API

We should use a list instead of map in the API to be more expressive and to leverage a well known schema.

For example:

Instead of

authorizedKeys: {
   "mypublickey": "mysecretkey"
}

we should have

authorizedKeys: [
  { 
    "publicKey": "mypublickey",
    "encryptedSecretKey": "mysecretkey"
  }
]

This requires changes from

  • lib/archethic_web/controllers/api/types/authorized_keys.ex
  • lib/archethic_web/controllers/api/transaction_payload.ex

[Feature]: Support live transaction streaming of beacon chain summary

The BeaconChain's explorer should support a feature to stream the transactions submitted to the beacon summary in near real time.

The idea would be to create processes responsible for creating asynchronous communication with the pool of storage node for the next summary. Those nodes will notify clients about new transaction arrived (note: this approach will be less intensive than a polling mechanism).

Each Beacon's subset can have a list of subscribers for summary updates

The feature should support the switch of pool when there is a new summary timer event. (pools may change for every interval).

When those processes received a notification of new transaction, they will submit a message through PubSub to update the UI elements.

:crypto.hmac/3 is undefined or private

Description

Running iex -S mix phx.server fails because of deprecated function in crypto library

Expected Behaviour

Running node

Actual Behaviour

warning: :crypto.hmac/3 is undefined or private. Did you mean one of:

      * mac/3
      * mac/4
      * macN/4
      * macN/5

Steps To Reproduce

iex -S mix phx.server

Platform

Ubuntu 18.04 LTS

Possible Solution

I tried replacing all hmac by mac (suggested by erlang), but I got an other error (full error: )

Generated uniris app
2021-05-18 14:27:13.705 [info] Try to open the port 3002
2021-05-18 14:27:13.707 [info] Port forwarding is skipped - reason: IP lookup provider is not NAT
2021-05-18 14:27:13.707 [info] Port must be open manually
2021-05-18 14:27:13.716 [info] Initialize InMemory Chain Lookup...
2021-05-18 14:27:13.717 [info] Initialize InMemory Pending Ledger...
2021-05-18 14:27:13.717 [info] Initialize InMemory KO Ledger...
2021-05-18 14:27:13.739 [error] GenServer Uniris.Crypto.SoftwareKeystore terminating
** (FunctionClauseError) no function clause matching in :crypto.mac/3
    (crypto 5.0) crypto.erl:588: :crypto.mac(:sha512, "", "node1")
    (uniris 0.10.0) lib/uniris/crypto.ex:238: Uniris.Crypto.get_extended_seed/2
    (uniris 0.10.0) lib/uniris/crypto.ex:114: Uniris.Crypto.derive_keypair/3
    (uniris 0.10.0) lib/uniris/crypto/keystore/software_impl.ex:66: Uniris.Crypto.SoftwareKeystore.handle_call/3
    (stdlib 3.15) gen_server.erl:721: :gen_server.try_handle_call/4
    (stdlib 3.15) gen_server.erl:750: :gen_server.handle_msg/6
    (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message (from Uniris.Crypto.KeystoreLoader): {:node_public_key, 0}
State: %{node_key_counter: 0, node_seed: "node1", node_shared_key_counter: 0}
Client Uniris.Crypto.KeystoreLoader is alive

    (stdlib 3.15) gen.erl:233: :gen.do_call/4
    (elixir 1.11.2) lib/gen_server.ex:1024: GenServer.call/3
    (uniris 0.10.0) lib/uniris/crypto/keystore/loader.ex:21: Uniris.Crypto.KeystoreLoader.init/1
    (stdlib 3.15) gen_server.erl:423: :gen_server.init_it/2
    (stdlib 3.15) gen_server.erl:390: :gen_server.init_it/6
    (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
2021-05-18 14:27:13.764 [info] Application uniris exited: Uniris.Application.start(:normal, []) returned an error: shutdown: failed to start child: Uniris.Crypto.Supervisor
    ** (EXIT) shutdown: failed to start child: Uniris.Crypto.KeystoreLoader
        ** (EXIT) exited in: GenServer.call(Uniris.Crypto.SoftwareKeystore, {:node_public_key, 0}, 5000)
            ** (EXIT) an exception was raised:
                ** (FunctionClauseError) no function clause matching in :crypto.mac/3
                    (crypto 5.0) crypto.erl:588: :crypto.mac(:sha512, "", "node1")
                    (uniris 0.10.0) lib/uniris/crypto.ex:238: Uniris.Crypto.get_extended_seed/2
                    (uniris 0.10.0) lib/uniris/crypto.ex:114: Uniris.Crypto.derive_keypair/3
                    (uniris 0.10.0) lib/uniris/crypto/keystore/software_impl.ex:66: Uniris.Crypto.SoftwareKeystore.handle_call/3
                    (stdlib 3.15) gen_server.erl:721: :gen_server.try_handle_call/4
                    (stdlib 3.15) gen_server.erl:750: :gen_server.handle_msg/6
                    (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application uniris: Uniris.Application.start(:normal, []) returned an error: shutdown: failed to start child: Uniris.Crypto.Supervisor
    ** (EXIT) shutdown: failed to start child: Uniris.Crypto.KeystoreLoader
        ** (EXIT) exited in: GenServer.call(Uniris.Crypto.SoftwareKeystore, {:node_public_key, 0}, 5000)
            ** (EXIT) an exception was raised:
                ** (FunctionClauseError) no function clause matching in :crypto.mac/3
                    (crypto 5.0) crypto.erl:588: :crypto.mac(:sha512, "", "node1")
                    (uniris 0.10.0) lib/uniris/crypto.ex:238: Uniris.Crypto.get_extended_seed/2
                    (uniris 0.10.0) lib/uniris/crypto.ex:114: Uniris.Crypto.derive_keypair/3
                    (uniris 0.10.0) lib/uniris/crypto/keystore/software_impl.ex:66: Uniris.Crypto.SoftwareKeystore.handle_call/3
                    (stdlib 3.15) gen_server.erl:721: :gen_server.try_handle_call/4
                    (stdlib 3.15) gen_server.erl:750: :gen_server.handle_msg/6
                    (stdlib 3.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
[os_mon] memory supervisor port (memsup): Erlang has closed

Thanks for the help

Support multiple secrets

It can be good to be able to have multiple secrets and to specify authorized keys for each.

We can define like this:

  • Secrets: [ ...., ....., ....]
  • Authorized Keys: [ [ key => encrypted_secret_key, key => encrypted_secret_key], [ key => encrypted_key, key => encrypted_secret_key], ....]

Epic: #306

Add faucet rate limiter

We should add a rate limiter for the faucet to avoid someone to drain the pool of UCO dedicated to the faucet.
So we could imagine something like: X amount of UCO for a given address or given IP during a given time.
This will mean we need to timestamp all the faucet transfers in particular process and clear them after the given timespan elapsed.

Knowledge:

  • Checking out Existing Modules Registry related
  • Finding the Module Entry points where to place code and testing

We should:

  • Implement a GenServer which manages the registry of addresses and timestamps
  • Implement a clean up based on timespan
  • Prevent faucet transaction if the address is listed in the registry
  • Add Relevant Test Cases
  • Testing on multiple nodes

Error message on http://localhost:4000/explorer/transactions

With a fresh installation based on the version available on 29/1/21

On the explorer via http://localhost:4000/explorer/transactions
I received a debug page with the follwing page

unhandled exit at GET /explorer/transactions
exited in: GenServer.call(#PID<0.670.0>, {:select, [pipe: [filter: #Function<11.114912407/1 in Uniris.DB.KeyValueImpl.list_transactions/1>, map: #Function<12.114912407/1 in Uniris.DB.KeyValueImpl.list_transactions/1>]]}, 5000) ** (EXIT) time out

[Feature]: Metric Dashboard

It should be good to have a view where we can see the metrics for the local node or globally.

We can use the endpoints /metrics to get the exported metrics, but also for the local one use telemetry.attach.

Another idea, can be to use circular buffer to have some history from those metrics

Later we could leverage beacon chain to get some metrics

GraphQL query: Support of Nested Query

It seems that the current implementation of GraphQL didn't support nested query like this

lastTransaction(address:"xxxxxx") { chainLength transactionChain { address } }

It will be nice to support this.

Reduce replications call by avoiding notifying node movements chains

In the current scheme, during the transaction validation, we are building a node movements list to specify the rewards of the validation nodes and the involved storage nodes. However, this leads to send them the transaction to update their UTXO table and their balance.

The thing is, while this scheme is acceptable, we will end up to a lot of P2P messages and replications of the transaction which will alter the performance and the throughput of the network.
For example, if you are taking a network with 50 nodes, and if each shard is composed of 20 nodes, we will have to make 100 Replication messages just to reward the nodes, without counting the recipient and emitter storage pools.

So the idea is to drop this node_movements so you can reward nodes later from their availability using the BeaconChain aggregation from the list of summaries for all the subsets.

More details here: archethic-foundation/archethic-docs#3

This will involve:

  • Change the transaction structure and database field
  • Change the validation processing to avoid P2P communication
  • Remove the field from the UI and Graphql API
  • Remove node_movements UTXO mem table entries
  • Remove the UTXO type reward

Epic: #306

Flow dependency error

since last PR, we need some errors about Flow.

warning: Flow.flat_map/2 is undefined (module Flow is not available or is yet to be defined)
Found at 2 locations:
  lib/archethic/beacon_chain.ex:75: ArchEthic.BeaconChain.get_summary_pools/2
  lib/archethic/beacon_chain.ex:114: ArchEthic.BeaconChain.get_slot_pools/2

warning: Flow.from_enumerable/1 is undefined (module Flow is not available or is yet to be defined)
Found at 2 locations:
  lib/archethic/beacon_chain.ex:74: ArchEthic.BeaconChain.get_summary_pools/2
  lib/archethic/beacon_chain.ex:113: ArchEthic.BeaconChain.get_slot_pools/2

warning: Flow.partition/2 is undefined (module Flow is not available or is yet to be defined)
Found at 2 locations:
  lib/archethic/beacon_chain.ex:78: ArchEthic.BeaconChain.get_summary_pools/2
  lib/archethic/beacon_chain.ex:117: ArchEthic.BeaconChain.get_slot_pools/2

warning: Flow.reduce/3 is undefined (module Flow is not available or is yet to be defined)
Found at 2 locations:
  lib/archethic/beacon_chain.ex:79: ArchEthic.BeaconChain.get_summary_pools/2
  lib/archethic/beacon_chain.ex:118: ArchEthic.BeaconChain.get_slot_pools/2

Could you (if it is the good way) add in mix.exs the declaration:

 {:flow, "~> 1.0"}

Send NFT / Crash Error 500

For a NFT transfer, when the amount is a string, the node return an 500 error & invalid JSON.

Should return an appropriate error

Timeout for TPM signing during beacon summary transaction creation

I found out some issues regarding the TPM calls, as there was no beacon summary transaction and therefore not self repair.
The logs reported this:

GenServer.call(ArchEthic.Crypto.NodeKeystore.TPMImpl, {:sign_with_first_key, ...
** (EXIT) time out
(elixir 1.12.0) lib/gen_server.ex:1024: GenServer.call/3
(archethic 0.11.1) lib/archethic/transaction_chain/transaction.ex:244: ArchEthic.TransactionChain.Transaction.origin_sign_transaction/1
(archethic 0.11.1) lib/archethic/beacon_chain/subset.ex:310: ArchEthic.BeaconChain.Subset.create_summary_transaction/3
** (stop) exited in: GenServer.call(ArchEthic.Crypto.NodeKeystore.TPMImpl, :get_first_public_key, 5000)
 ** (EXIT) time out
(elixir 1.12.0) lib/gen_server.ex:1024: GenServer.call/3
(archethic 0.11.1) lib/archethic/crypto/keystore/node/tpm_impl.ex:48: ArchEthic.Crypto.NodeKeystore.TPMImpl.first_public_key/0
(archethic 0.11.1) lib/archethic/beacon_chain/subset.ex:326: ArchEthic.BeaconChain.Subset.create_validation_stamp/3
(archethic 0.11.1) lib/archethic/beacon_chain/subset.ex:318: ArchEthic.BeaconChain.Subset.create_summary_transaction/3

It seems there are some bottlenecks while calling the TPM.
We should probably leverage ETS for non-blocking calls.

Oracle Summary transactions submitted twice

After a long run, the scheduler spawn two oracle summary transactions at 1 second of interval, causing the rejection of the last one because of the violation of the inherit constraints.

Missing transaction during self-repair

I got this error during a local testnet with 3 nodes.

The self repair is not capable to fetch transaction because there is no transaction from the remote nodes responsible
to store it

2021-09-16 01:20:06.251 transaction_address=00871BA0A7CF932056F42C13A3187B45090960470C33C09FF9CB7C48202C13309C transaction_type=oracle_summary [error] Transaction not found from remote nodes during self repair

Epic: #321

Support inheritance exception based on proof of ownership

Smart contract need a way to be able to escape inherit constraints by proving you are the owner of the contract or being authorized in a specific list of owners.

Because the smart contract's keys must be shared with the nodes to allow self-triggers of transactions, we cannot rely afterward on the chain's private keys to prove the ownership.

However, a new scheme must be created to support bypass and ownership identification.

To do so, we have to rely on knowledge capability of the owner to determine the eligibility.
A genesis identification scheme can be used to split the knowledge of the chain's owning and the transaction delegation to have a separation of duties within the same chain.

In this scheme, a different key derivation is used for the genesis and the child private keys.

Key derivation

The genesis private key is used to delegate a seed for the node to derive the next transactions, while keeping the original seed for the owner.
The address of the transaction will use the delegate keypair while the 1st previous public key (genesis public key of the chain) will use the origin keypair.

Use transaction seed genesis private key to be immuable.
Allow the new authorized node should have this access

flowchart TB
    GenSeed[Genesis seed] --> GenPv[Genesis Private Key]
    GenSeed[Genesis seed] --> GenPub[Genesis Public Key]
    GenPub --> FirstPreviousPub(1st Previous public key)
    GenPv --> GenSign(Sign)
    GenSign --> FirstPreviousSignature(1st previous signature)

    GenPv --> DerExtSeed(Derive)
    StorageNoncePubKey[Storage nonce public key] --> DerExtSeed
    DerExtSeed --> DelegatedSeed[Delegated Seed]
    DelegatedSeed --> DerKey(Derive Keypair)
    Index --> DerKey
    DerKey --> DelPub(Delegated Public key)

    DerKey --> DelPv(Delegated Private key)
    DelPub --> Hash
    Hash --> Address

    DelPub --> NextPreviousPub(nth previous public key)
    DelPv --> DelSign(Sign)
    DelSign --> NextPreviousSignature(nth previous signature)

Verification

Later, when the owner of the contract would like to bypass inherit constraints to update the code, it will generate a new transaction with the new code and including a signature of the new code using the Genesis Private Key.
The node will then be able to check if this signature matches with the chain's genesis public key.

Extensibility

However, sometimes we want to extend the way to assert something by having multiple owners or the ownership evolution.
Hence, the smart contract should include a new inherit constraints property: exception.
This property will allow defining custom instruction where the inherit conditions will be escaped.

Also, to share the real ownership of the contract, the genesis seed or private key can be encoded in the ownership section of the transaction to be encrypted for multiple authorized public keys.
This allows to keep the same scheme of verification while having multiple owners.

Improve the latency to compute beacon chain pools

During self-repair, depending on the interval for the summary timer, the latency to compute the list of summary pools can be huge.

Proposal is to flat summary pools to reduce nested iterations and to use concurrency to split the processing among time windows.


Epic: #321

./uniris_node start

Impossible de lancer le noeud, voiçi le verbose:

init terminating in do_boot ({,[{Elixir.System,fetch_env!,1,[{},{}]},{erl_eval,do_apply,6,[{},{}]},{erl_eval,expr_list,6,[{},{}]},{erl_eval,expr,5,[{},{}]},{erl_eval,expr,5,[{},{}]},{erl_eva

Crash dump is being written to: erl_crash.dump...done
=INFO REPORT==== 24-Nov-2020::15:34:27.556057 ===
application: mix
exited: stopped
type: temporary

could not fetch environment variable "UNIRIS_CRYPTO_SEED" because it is not set
(elixir 1.10.3) lib/system.ex:520: System.fetch_env!/1
(stdlib 3.13.2) erl_eval.erl:680: :erl_eval.do_apply/6
(stdlib 3.13.2) erl_eval.erl:888: :erl_eval.expr_list/6
(stdlib 3.13.2) erl_eval.erl:240: :erl_eval.expr/5
(stdlib 3.13.2) erl_eval.erl:232: :erl_eval.expr/5
(stdlib 3.13.2) erl_eval.erl:888: :erl_eval.expr_list/6
(stdlib 3.13.2) erl_eval.erl:411: :erl_eval.expr/5
(elixir 1.10.3) src/elixir.erl:278: :elixir.recur_eval/3

{"init terminating in do_boot",{#{'exception'=>true,'struct'=>'Elixir.ArgumentError',message=><<"could not fetch environment variable "UNIRIS_CRYPTO_SEED" because it is not set">>},[{'Elixir.System','fetch_env!',1,[{file,"lib/system.ex"},{line,520}]},{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]},{erl_eval,expr_list,6,[{file,"erl_eval.erl"},{line,888}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,240}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,232}]},{erl_eval,expr_list,6,[{file,"erl_eval.erl"},{line,888}]},{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,411}]},{elixir,recur_eval,3,[{file,"src/elixir.erl"},{line,278}]}]}}
Unable to configure release!

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.