centrifuge / centrifuge-chain Goto Github PK
View Code? Open in Web Editor NEWCentrifuge Chain: the layer-1 blockchain for real-world assets, built on Substrate.
Home Page: https://centrifuge.io
License: GNU Lesser General Public License v3.0
Centrifuge Chain: the layer-1 blockchain for real-world assets, built on Substrate.
Home Page: https://centrifuge.io
License: GNU Lesser General Public License v3.0
Setup Amber validator libp2p private keys in storage + setup our own accounts for validation instead of Alice and Bob
GetByAnchorID
Make sure that the βgetByAnchorIdβ does not return anchor data after evict date has been reached.
This solves the issue that the bucket might be evicted already and the index is still existing. -> Then the evict has to assure that it clears the index one after another.
given anchor id = π΄πΌπ·
π‘ππ£πππ‘=π΄ππβπππΈπ£πππ‘π·ππ‘ππ .πππ‘(π΄πΌπ·) => O(1)
πππβπππ·ππ‘π=ππππ_πβπππ_π π‘πππππ(π‘ππ£πππ‘,π΄πΌπ·) => π(πππ(ππππππ‘(π‘ππ£πππ‘,π΄πΌπ·))) => π(1)
- How to upgrade storage(partial)
In addition we might be able to use light client protocol for extracting proofs?
As the upgrade to Substrate 2.0 (master branch) is done, we can now add the worker to evict expired pre-commits.
Additional reading:
// child storage for anchor data represented as a double map
AnchorStorage: Map EvictDate => AnchorID => AnchorData
#### Commit
Anchor data = $AnchorData$
Anchor ID = $AID$
Commit date = $t_{commit}$
User defined evict Date = $t_p$
Calculate User defined anchor period = $p_u$ = $t_p$ - $t_{commit}$
System defined minimum anchor period = $p_s$
Calculate actual anchor period = $p_{actual}$ = {$p_u$ < $p_s$ ? $p_s$ : $p_u$} (properly define case stmt :)
Calculate actual evict date = $t_{evict}$ = $t_{commit}$ + $p_{actual}$
**Store in child storage** -> $set\_child\_storage(t_{evict}, AID, AnchorData)$
**Store evict date index** -> $AnchorEvictDates.put(AID, t_{evict})$
**Calculate anchor index** = $AIDX = CurrentAnchorIndex + 1$
**Store anchor index** -> $AnchorIndexes.put(AIDX, AID)$
**Store current anchor index** -> $CurrentAnchorIndex = AIDX$
Total storage per anchor = $S_{anchor} = 2 * storage(AID) + storage(AnchorData) + storage(AIDX)$
Cost per storage unit per time unit = $c_{unit}$
Calculate anchor storage cost = $c_{storage} = S_{anchor} * c_{unit} * p_{actual}$
Const gas cost (gas) = $c_{insert}$
Total tx cost = $c_{tx} = c_{storage} + c_{insert}$
complexity = $O(1)$ since trie inserts costs at most length of the anchor id string and its a fixed length hash.
This is to investigate how the current default validation logic work for cent-chain + substrate
Currently validator nodes are set to find eachother as bootnodes, which seem to cause some issues. Need to investigate the issue and fix.
cc @pstehlik
Currently on docker hub: https://cloud.docker.com/u/centrifugeio/repository/registry-1.docker.io/centrifugeio/centrifuge-chain/builds/1b4993a4-866c-481f-a4d9-01b65400c082
erroring out.
could either move into travis - or keep in dockerhub.
evaluate which one is faster to build.
we'd want to avoid hogging a travis slot for 2hrs and blocking other builds.
this is a future research topic.
Once we have the implementation for storage of anchors we need to implement the actual rent for state using the fee module.
Total storage per anchor = ππππβππ=2βπ π‘πππππ(π΄πΌπ·)+π π‘πππππ(π΄ππβπππ·ππ‘π)+π π‘πππππ(π΄πΌπ·π)
Cost per storage unit per time unit = ππ’πππ‘
Calculate anchor storage cost = ππ π‘πππππ=ππππβππβππ’πππ‘βππππ‘π’ππ
Migrations are not concern atleast for a while for new features.
Use workers
Instead of taking the pre-defined testnet with Alice/bob/... the deployment should have a more realistic genesis file:
When running fulvous, node panics with,
====================
stack backtrace:
0: substrate_panic_handler::set::{{closure}}::h22f0f1d19b29e46d (0x5570318b0ec0)
1: std::panicking::rust_panic_with_hook::h057ff03eb4c8000f (0x5570319e9a59)
at src/libstd/panicking.rs:478
2: std::panicking::begin_panic::h01337335381120d3 (0x557031539645)
3: srml_executive::Executive<System,Block,Context,UnsignedValidator,AllModules>::execute_block::h46420a4b51db8b11 (0x55703153d8ac)
4: centrifuge_chain_runtime::api::dispatch::h63face78c359dd4d (0x557031514a8d)
5: std::panicking::try::do_call::h62e7477d6f4b75b4 (0x557030f33692)
6: __rust_maybe_catch_panic (0x5570319eedea)
at src/libpanic_unwind/lib.rs:85
7: substrate_executor::native_executor::safe_call::h3cbd82ffde27a0a3 (0x557030cc9728)
8: std::thread::local::LocalKey<T>::with::h8e36660e2af3b325 (0x557030a53127)
9: <centrifuge_chain::service::Executor as substrate_executor::native_executor::NativeExecutionDispatch>::dispatch::h0913301dcc5bbd02 (0x557030891792)
10: std::thread::local::LocalKey<T>::with::hada49c4683f7f063 (0x557030a5be3e)
11: substrate_state_machine::StateMachine<H,N,B,T,O,Exec>::execute_aux::h4c4976f3f2d5fbc8 (0x557030e0ca66)
12: substrate_state_machine::StateMachine<H,N,B,T,O,Exec>::execute_call_with_native_else_wasm_strategy::h7a70dacfe7719c17 (0x557030e12122)
13: <substrate_client::call_executor::LocalCallExecutor<B,E> as substrate_client::call_executor::CallExecutor<Block,substrate_primitives::hasher::blake2::Blake2Hasher>>::call_at_state::hf54a9cd0e8c0c6eb (0x557030d9af96)
14: <&substrate_client::client::Client<B,E,Block,RA> as substrate_consensus_common::block_import::BlockImport<Block>>::import_block::h3b2cc48f55fe45c5 (0x557030a024b8)
15: <substrate_finality_grandpa::import::GrandpaBlockImport<B,E,Block,RA,PRA,SC> as substrate_consensus_common::block_import::BlockImport<Block>>::import_block::hfa4176c6ffcdc91b (0x557030f173d6)
16: <substrate_consensus_babe::BabeBlockImport<B,E,Block,I,RA,PRA> as substrate_consensus_common::block_import::BlockImport<Block>>::import_block::hf4b1416a1336ff4f (0x557030e56cce)
17: core::task::poll::Poll<T>::map::h2800644b173cd077 (0x557030b0bd38)
18: <futures_util::try_future::map_ok::MapOk<Fut,F> as core::future::future::Future>::poll::h44e75c53666d861d (0x5570307e100c)
19: futures_util::try_future::try_chain::TryChain<Fut1,Fut2,Data>::poll::hf94a03e42d347958 (0x557030e3a9ad)
20: <futures_util::try_stream::try_for_each::TryForEach<St,Fut,F> as core::future::future::Future>::poll::h1e4058bc162f42bf (0x557030b1ca59)
21: futures_util::future::chain::Chain<Fut1,Fut2,Data>::poll::h7e04c1afbe139a43 (0x5570307eacda)
22: <futures_util::compat::compat03as01::Compat<Fut> as futures::future::Future>::poll::h8dbc10bf30d58049 (0x557030ef3776)
23: <futures::future::select::Select<A,B> as futures::future::Future>::poll::h61fa2b5b8f541b6a (0x557030c31b2a)
24: futures::future::chain::Chain<A,B,C>::poll::h6107eb89c39c9da2 (0x557030ea93ec)
25: <futures::future::map_err::MapErr<A,F> as futures::future::Future>::poll::hf2217414ed5ab382 (0x557030d2bf3e)
26: futures::task_impl::std::set::h1d6c7394509821f8 (0x55703173b292)
27: std::panicking::try::do_call::h4da7ee154caa89f2 (0x55703173adf2)
28: __rust_maybe_catch_panic (0x5570319eedea)
at src/libpanic_unwind/lib.rs:85
29: tokio_threadpool::task::Task::run::h0116a589554a280b (0x5570317384b9)
30: tokio_threadpool::worker::Worker::run_task::h59c5abb9988e7e20 (0x557031731e55)
31: tokio_threadpool::worker::Worker::run::h818f5066b41d5b52 (0x55703173132e)
32: std::thread::local::LocalKey<T>::with::h1fcd9efb210f2dd2 (0x55703171bcde)
33: std::thread::local::LocalKey<T>::with::h5fbd4053ce8d547c (0x55703171be9f)
34: std::thread::local::LocalKey<T>::with::h16eaac48bb88b444 (0x55703171bb2b)
35: tokio::runtime::threadpool::builder::Builder::build::{{closure}}::h5c979caac29cea17 (0x5570317208de)
36: std::thread::local::LocalKey<T>::with::h01b9617282c3e29b (0x55703173ba63)
37: std::thread::local::LocalKey<T>::with::h076aff392ca7ff3f (0x55703173bb9e)
38: std::sys_common::backtrace::__rust_begin_short_backtrace::hd8e94618c1c47325 (0x557031733991)
39: std::panicking::try::do_call::h9f90deaf148b6ba7 (0x55703173ae3c)
40: __rust_maybe_catch_panic (0x5570319eedea)
at src/libpanic_unwind/lib.rs:85
41: core::ops::function::FnOnce::call_once{{vtable.shim}}::he5b73f6ee3ce78f5 (0x557031734610)
42: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h805c3cc89d534c05 (0x5570319d71ff)
at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/liballoc/boxed.rs:704
43: <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h9ebda9db5f03daf3 (0x5570319ee100)
at /rustc/a53f9df32fbb0b5f4382caaad8f1a46f36ea887c/src/liballoc/boxed.rs:704
std::sys_common::thread::start_thread::ha32838ccbb8a8179
at src/libstd/sys_common/thread.rs:13
std::sys::unix::thread::Thread::new::thread_start::h6f10b78f26c98dc6
at src/libstd/sys/unix/thread.rs:79
44: start_thread (0x7f52c66166ba)
45: clone (0x7f52c613641d)
46: <unknown> (0x0)
Thread 'tokio-runtime-worker-1' panicked at 'Storage root must match that calculated.', /root/.cargo/git/checkouts/substrate-7e08433d4c370a21/4e1d637/srml/executive/src/lib.rs:319
This started happening after implementing child storage anchor state rent.
Centralized way to create Cent Chain test accounts
All the functional tests and apps will require pre-funded test accounts.
Possible solution:
Exactly like commit except
Anchor data is to be retrieved using GetByAnchorID
Cost calculation should take into account difference between new and last evictedate
(Probably no need to delete the previous storage as it would get evicted)
Some kind of blank document structure that can be used to simulate pre-commit/commit with real precise proofs etc
To be able to test out state growing - there should be a permanent deployment to test with.
Following things needs to be researched/investigated
cc @pstehlik
Research into state tree design
How different actors in the system would benefit/lose out with different designs
Evict
On a certain evict date = πππ£πππ‘
Get the root of the evicted child tree = π
ππ£πππ‘ππ=πβπππ_π π‘πππππ_ππππ‘(πππ£πππ‘)
Delete all anchors for the date -> πππππ_πβπππ_π π‘πππππ(πππ£πππ‘)
Set the root for the evict date -> πΈπ£πππ‘ππΆβπππππ‘ππππππ
πππ‘π .ππ’π‘(πππ£πππ‘,π
ππ£πππ‘ππ)
Delete indexes:
π=πΏππ‘ππ π‘πΈπ£πππ‘πΌππππ₯=>ππ=π΄ππβπππΌππππ₯ππ .πππ‘(π)=>π΄ππβπππΈπ£πππ‘π·ππ‘ππ .πππππ£π(ππ)=>π΄ππβπππΌππππ₯ππ .πππππ£π(π)
until a evict date is found that is more than π‘ππ£πππ‘
set πΏππ‘ππ π‘πΈπ£πππ‘πΌππππ₯ to last removed index
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.