Git Product home page Git Product logo

plug-blockchain's People

Contributors

andresilva avatar arkpar avatar athei avatar bkchr avatar cecton avatar cheme avatar chevdor avatar demi-marie avatar expenses avatar gabreal avatar gavofyork avatar gnunicorn avatar jordy25519 avatar joshorndorff avatar kianenigma avatar ltfschoen avatar marcio-diaz avatar mxinden avatar nikvolf avatar pepyakin avatar rphmeier avatar shawntabrizi avatar sorpaas avatar stanislav-tkach avatar svyatonik avatar thiolliere avatar tomaka avatar tomusdrw avatar tripleight avatar xlc avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

plug-blockchain's Issues

Stability Testing Script

The script should should send continual extrinsics to a plug network under test.

It should add random variance to:

  • the type of extrinsic (balance transfer, attestation, etc.)
  • sender account
  • transaction rate (TPS)

It should stop after significant non-responsiveness by the network which would indicate a failure or a target block height is reached by majority of the nodes.

A/C - script demonstrated working on local plug development network running 1.0.0-rc.1

Should make use of https://github.com/plugblockchain/plug-sdk-types

Create / refactor Dockerfile

To make the docker image work with our deployment pipeline (k8s), we need ENTRYPOINT instead of COMMAND. There are also two conflicting Dockerfiles:

Task list:

  • Refactor dockerfile
  • Update changelog

Rust nightly can't see WASM toolchain

There's an issue with the latest rust nightly, this appears to affect substrate as well. This results in the following error when trying to build the node-template:
Rust WASM toolchain not installed, please install it!

Sort term solution provided by @Holygits to use an older rust build:

rustup toolchain uninstall nightly
rustup toolchain install nightly-2020-08-23
rustup target add wasm32-unknown-unknown --toolchain nightly-2020-08-23

Revisit generic asset locks

Currently if there are different locks on an asset for different reasons, when withdrawing from that asset we check if the widthraw reason overlaps with the locks reason and if so we apply the lock amount as a limit. The logic for this behaviour is not quite clear and intuitive. We need to review why we need locks and how they should behave according to the latest requirements of a lockable currency and improve or correct this behaviour.

generic asset 'free' balance

Due to historic reasons the notion of 'free balance' in GA is a misnomer for the staking currency.
We should alter this API / naming to ensure it is fool-proof

Background

expectation:
"free balance": the freely spendable balance of an account
reality:
"free balance": the maybe spendable balance, need to check locks also

This is extremely misleading for dapps which have to be aware of this difference and internal modules
when dealing with the staked currency must be aware of this also.

The currency locks API is made especially for staking, so this misnomer is only true for the staked asset.
No other asset can have locks, so the 'free balance' really is the freely spendable balance.

Goals

Make the generic asset balance API clear and fool-proof
Maintain backwards compatibility with the current API

Proposal

internal module API changes: free_balance

  1. StakingAssetCurrency and MultiCurrency when asset is the staking asset must return the truely free balance (free balance - locked amount)

  2. cennznet/api.js
    Provide a new freeBalance rpc which will always return the truely free balance e.g.: api.rpc.genericAsset.freeBalance and encourage dapps to swtich.
    Maybe place warnings in cennznet/api.js code against using api.query.genericAsset.freeBalance directly

Purge generic asset accounts with balances less than existential deposit

Asset info for each asset should feature the existential deposit for that asset. Generic Asset, post any operations that would potentially leave dust asset for an account should update the account data in the account store and purge the insignificant asset if the policy of that operation allows it. The account would be removed from the account store as well when there is no significant assets left.
A migration logic would be needed so the current storage of the accounts is searched for dust balances.
Endowed accounts defined in the genesis will be exempt from the dust balance check. Or in other worlds they should persist anyway.

Release failure for refs/tags/v2.0.1

Pipeline for release refs/tags/v2.0.1 failed. Please investigate.

If the pipeline has failed before pushing to crates.io, delete the release tag
and fix the release as necessary, retagging after complete. If the pipeline has
failed after pushing to crates.io, create a new tag incrementing the version.

Use decl_error macro for doughnut error codes

Refactor error codes in PlugDoughnut with the decl_error! macro

Here:

if self.verify().is_err() {
// 170 == invalid signature on doughnut
return Err(InvalidTransaction::Custom(170).into())
}
if let Err(_) = self.0.validate(who, Runtime::TimestampProvider::now()) {
// 171 == use of doughnut by who at the current timestamp is invalid
return Err(InvalidTransaction::Custom(171).into())
}

Reference usage in srml/system:

decl_error! {
/// Error for the System module
pub enum Error {
BadSignature,
BlockFull,
RequireSignedOrigin,
RequireRootOrigin,
RequireNoOrigin,
}
}

Improve CI pipeline

Pipeline often fails with timeouts ~2 hours on the test step.

For comparison a clean local build takes around 35mins and a test ~40mins (requires building and executing tests)

Running the test suite in 1 hour seems like a reasonable target

Some options to improve this:

- Upgrade circleci plan with more CPU allocation
- Switch CI altogether to get more CPU (parity uses gitlab)
- Optimize caching with sccache
- Chunk tests by crates. we run them all in one step cargo test --all at the moment

Make GA asset info queryable from the chain

Update GA module with a new storage map key: asset ID โ†’ value: {symbol, ID, dp}

Required fields:

  • symbol (characters: A-Z, length: 8) *ignore uniqueness for now, assets are created by governance, unlikely to allow duplicates
  • ID
  • decimal places (hardcode to 4dp for now, as customising this has other implications)

GA create call should take this metadata also

Update Plug Node information

Update node info and binary name for Plug

See: cennznet/plug-blockchain#55 (comment)

Also:

  • Update the binary and package name to plug

    name = "substrate"

    name = "substrate"

  • Update Dockerfile

    useradd -m -u 1000 -U -s /bin/sh -d /substrate substrate
    COPY --from=builder /substrate/target/$PROFILE/substrate /usr/local/bin
    # checks
    RUN ldd /usr/local/bin/substrate && \
    /usr/local/bin/substrate --version
    # Shrinking
    RUN rm -rf /usr/lib/python* && \
    rm -rf /usr/bin /usr/sbin /usr/share/man
    USER substrate
    EXPOSE 30333 9933 9944
    VOLUME ["/data"]
    CMD ["/usr/local/bin/substrate"]

  • "plug-node"

    impl_name: create_runtime_str!("substrate-node"),

Maybe add some sweet ascii art too?

________________/\\\\\\_______/\\\________________        
 _______________\////\\\______/\\/\\_______________       
  ___/\\\\\\\\\_____\/\\\_____/\\\//\\___/\\\\\\\\__      
   __/\\\/////\\\____\/\\\____\//__\//___/\\\////\\\_     
    _\/\\\\\\\\\\_____\/\\\______________\//\\\\\\\\\_    
     _\/\\\//////______\/\\\_______________\///////\\\_   
      _\/\\\____________\/\\\_______________/\\_____\\\_  
       _\/\\\__________/\\\\\\\\\___________\//\\\\\\\\__ 
        _\///__________\/////////_____________\////////___

Keep extrinsic sender through contract call stack

Provide the means to query the extrinsic sender address during nested contract execution.
So that the extrinsic origin is known throughout nested contract calls.

For reference, caller() gives the address of the calling account (extrinsic sender at the top level, changes to calling contract for nested calls)

/// Returns a reference to the account id of the caller.
fn caller(&self) -> &AccountIdOf<Self::T>;

unblocks: #32

Implement hook for contract to contract calls

Implement the hook from #32 for contract to contract calls.

Remove accounts purged in GA from the account store

With the current implementation of providing accounts in generic asset, even when an account is removed from the generic asset storage, generic asset keeps to be providing that account from the frame system's point of view. That's because reaping an account and thus its nonce from the account store would incur some complexity for the case the account is again created. As this may be a potential storage bloating to keep the dead accounts in the frame system, we should consider to remove them in a safe way later.
Trace the todo comments in the code with this issue number 191 as an initial step.

Generic asset does not allow system account reaping

When used to provide AccountData to system pallet generic asset will always act as a "provider" for the account, even after all it's balance related storage has been reclaimed.

This prevents the system module from reclaiming the account storage e.g. current nonce.
For now this is the safest behaviour as removing an account's nonce has it's own set of challenges.

Issue opened here to track the behaviour.

Fix compilation warnings

warning: unused import: contracts_rpc_runtime_api::ContractExecResult
--> node/runtime/src/lib.rs:52:5
|
52 | use contracts_rpc_runtime_api::ContractExecResult;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: unused import: StorageMap
--> core/test-runtime/src/system.rs:22:38
|
22 | use runtime_support::storage::{self, StorageMap};
| ^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

Setup circleci integration

Setup the circleci integration for this repo and plugblockchain org
The circleci config already exists

Update to 2.0 [Tracker]

Substrate 2.0 is close here
It is a good chance to update larger components of this codebase now that the development cadence is slower upstream and hopefully more commitment to API stability.

In general the plug runtime has diverged from substrate and it does not need to follow the runtime changes upstream as they're mostly fed by different network or business requirements.
We do however want to follow the core framework where possible:

Things to pull in (in order of least difficulty):

Take everything in client/ metric reporting, db backend updates, refactors the lot

  • [general client/ update]

It's not clear if this change was backwards compatible.
e.g. new message types added, will need some careful testing to support current networks.

  • [networking/lib-p2p update]

[Tracker] 2.0 release

The spike/2.0 branch is basically ready, still needs:

TODO:

  • update prml/validator-manager
  • update prml/consortium-permission
  • update wiki/docs including doughnut architecture + Option signed extension type

Place the locks for a specifed asset

Currently when a lock is placed for an account, it will be used against all the assets (different asset ids) of that account which is wrong. The locks should be keyed by the asset ids and checked against the same asset id for which they are placed.
We may then need to implement lockable currency not for the whole generic asset module, but for a currency that is maintained by generic asset. Currencies like spending asset or staking asset and so on.

Uncouple handling block gas spent from emptying gas meter

Updating block gas spent should be done independently from emptying gas meter, so if the latter function is overridden, there would be no need to deal with block gas spent too. This will also eliminate the need for exposing the block gas handling function.

Better Peerset logs

As a node operator I want better logging from peer networking so that I can diagnose network issues easily

Tasks:

  • Add logs for reputational changes and causes to peerset / other relevant modules (e.g. networking)
  • PR made to <hotfix> branch also

Note: develop and hotfix are quite different. May need replicate the changes

Invulnerables (HotFix)

As a node operator I want some network peers to be invulnerable to the reputation system so that my network is less volatile.

Tasks:

Update Plug with Versioned Doughnut

  • Refactor Plug to use the new versioned Doughnut enum type
  • May require creating and tagging a new release branch for doughnut-rs (includes Cargo.toml version bump)

This should be part of the Plug and CENNZnet 1.0.0-rc2 releases

Initial smart contract permissioning

Provide initial trait and hooks for smart contract permissioning

  • Augment the DelegatedDispatchVerifier trait
    It should provide functions to handle the following call scenarios:

  • runtime calls contract
    verify_runtime_to_contract_dispatch(caller, doughnut, contract address) -> Result

  • contract calls contract
    verify_contract_to_contract_dispatch(caller, doughnut, contract address) -> Result

  • Implement the hook for runtime to contract dispatch (<T as system::Trait>::DelegatedDispatchVerifier>::verify_runtime_to_contract_call)

    pub fn call(
    origin,
    dest: <T::Lookup as StaticLookup>::Source,
    #[compact] value: BalanceOf<T>,
    #[compact] gas_limit: Gas,
    data: Vec<u8>
    ) -> Result {
    let origin = ensure_signed(origin)?;
    let dest = T::Lookup::lookup(dest)?;

Release failure for refs/tags/v2.0.0

Pipeline for release refs/tags/v2.0.0 failed. Please investigate.

If the pipeline has failed before pushing to crates.io, delete the release tag
and fix the release as necessary, retagging after complete. If the pipeline has
failed after pushing to crates.io, create a new tag incrementing the version.

Leave account storage handling in Generic Asset to an account store

The study of recent upstream changes suggests to me that our generic asset module which is replacing the balances pallet should use an account store when dealing with creating or removing accounts. An account store will be bound to StoredMap and its functionalities is already implemented by frame_system::Module. The generic asset should only call functions like insert or try_mutate_exists when appropriate.

GA create total supply use decimal places

When creating a GA, initial issuance should be the whole number of tokens to create and the total supply should handle the decimal places i.e

total_supply = initial_issuance x 10.pow(decimal_places)

this will be a much simpler API to use client side

while we're here, limit decimal places to <= 18 seems sensible

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.