diff --git a/.github/workflows/crates.yml b/.github/workflows/crates.yml index a1dae96cf5..3b536709c6 100644 --- a/.github/workflows/crates.yml +++ b/.github/workflows/crates.yml @@ -10,7 +10,7 @@ jobs: steps: - uses: hecrj/setup-rust-action@v1 with: - rust-version: 'nightly-2020-02-02' + rust-version: 'nightly-2020-07-01' targets: 'wasm32-unknown-unknown' - name: Checkout the source code uses: actions/checkout@master diff --git a/.github/workflows/dockerpush.yml b/.github/workflows/dockerpush.yml index 4a76e40b53..f465f88910 100644 --- a/.github/workflows/dockerpush.yml +++ b/.github/workflows/dockerpush.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: hecrj/setup-rust-action@v1 with: - rust-version: 'nightly-2020-02-02' + rust-version: 'nightly-2020-07-01' targets: 'wasm32-unknown-unknown' - name: Checkout the source code uses: actions/checkout@master diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 07628d7928..7995115de5 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -14,7 +14,7 @@ jobs: run: choco install llvm - uses: hecrj/setup-rust-action@v1 with: - rust-version: 'nightly-2020-04-04' + rust-version: 'nightly-2020-07-01' targets: 'wasm32-unknown-unknown' - name: Checkout the source coder uses: actions/checkout@master diff --git a/Cargo.lock b/Cargo.lock index 182d985269..f45613b1b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4215,7 +4215,7 @@ checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" [[package]] name = "plasm-cli" -version = "1.2.0" +version = "1.2.1" dependencies = [ "bs58", "frame-benchmarking-cli", @@ -4265,7 +4265,7 @@ dependencies = [ [[package]] name = "plasm-primitives" -version = "1.2.0" +version = "1.2.1" dependencies = [ "frame-system", "parity-scale-codec", @@ -4276,7 +4276,7 @@ dependencies = [ [[package]] name = "plasm-rpc" -version = "1.2.0" +version = "1.2.1" dependencies = [ "jsonrpc-core", "pallet-contracts-rpc", @@ -4303,7 +4303,7 @@ dependencies = [ [[package]] name = "plasm-runtime" -version = "1.2.0" +version = "1.2.1" dependencies = [ "frame-executive", "frame-support", diff --git a/bin/node/cli/Cargo.toml b/bin/node/cli/Cargo.toml index f3c1ab5768..47bd2aed32 100644 --- a/bin/node/cli/Cargo.toml +++ b/bin/node/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plasm-cli" -version = "1.2.0" +version = "1.2.1" authors = ["Stake Technologies "] description = "Plasm node implementation in Rust." build = "build.rs" diff --git a/bin/node/cli/src/chain_spec.rs b/bin/node/cli/src/chain_spec.rs index 5ec657bf8c..e08acefe77 100644 --- a/bin/node/cli/src/chain_spec.rs +++ b/bin/node/cli/src/chain_spec.rs @@ -151,8 +151,8 @@ fn make_genesis( dollar_rate: (9_000, 200), vote_threshold: 1, positive_votes: 1, - // Max time bounds for testing purposes - time_bounds: (0, 2_594_459_790_000u64), + // Start from launch for testing purposes + lockdrop_bounds: (0, 1_000_000), }), pallet_session: Some(SessionConfig { keys: keys diff --git a/bin/node/primitives/Cargo.toml b/bin/node/primitives/Cargo.toml index e7d07476f6..94578748a6 100644 --- a/bin/node/primitives/Cargo.toml +++ b/bin/node/primitives/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plasm-primitives" -version = "1.2.0" +version = "1.2.1" authors = ["Stake Technologies "] edition = "2018" diff --git a/bin/node/rpc/Cargo.toml b/bin/node/rpc/Cargo.toml index cecc31e664..7451dfbc58 100644 --- a/bin/node/rpc/Cargo.toml +++ b/bin/node/rpc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plasm-rpc" -version = "1.2.0" +version = "1.2.1" authors = ["Stake Technologies "] edition = "2018" diff --git a/bin/node/runtime/Cargo.toml b/bin/node/runtime/Cargo.toml index 636c26d207..ef74116182 100644 --- a/bin/node/runtime/Cargo.toml +++ b/bin/node/runtime/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plasm-runtime" -version = "1.2.0" +version = "1.2.1" authors = ["Stake Technologies "] edition = "2018" build = "build.rs" diff --git a/bin/node/runtime/src/lib.rs b/bin/node/runtime/src/lib.rs index f73d9496c5..f770bbc6e0 100644 --- a/bin/node/runtime/src/lib.rs +++ b/bin/node/runtime/src/lib.rs @@ -67,8 +67,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // and set impl_version to equal spec_version. If only runtime // implementation changes and behavior does not, then leave spec_version as // is and increment impl_version. - spec_version: 3, - impl_version: 3, + spec_version: 4, + impl_version: 4, apis: RUNTIME_API_VERSIONS, transaction_version: 1, }; diff --git a/frame/plasm-lockdrop/src/lib.rs b/frame/plasm-lockdrop/src/lib.rs index 4d759a5d9c..f3c693f032 100644 --- a/frame/plasm-lockdrop/src/lib.rs +++ b/frame/plasm-lockdrop/src/lib.rs @@ -254,7 +254,7 @@ decl_error! { /// Authorities reject this claim request. NotApproved, /// Lockdrop isn't run now, request could not be processed. - OutOfTime, + OutOfBounds, } } @@ -286,7 +286,7 @@ decl_storage! { /// Positive votes = approve votes - decline votes. PositiveVotes get(fn positive_votes) config(): AuthorityVote; /// Timestamp bounds of lockdrop held period. - TimeBounds get(fn time_bounds) config(): (T::Moment, T::Moment); + LockdropBounds get(fn lockdrop_bounds) config(): (T::BlockNumber, T::BlockNumber); } } @@ -324,7 +324,8 @@ decl_module! { ); if !>::contains_key(claim_id) { - ensure!(Self::time_guard(), Error::::OutOfTime); + let now = >::block_number(); + ensure!(Self::is_active(now), Error::::OutOfBounds); let amount = match params { Lockdrop::Bitcoin { value, duration, .. } => { @@ -472,10 +473,10 @@ decl_module! { /// Set lockdrop held time. #[weight = 50_000] - fn set_time_bounds(origin, from: T::Moment, to: T::Moment) { + fn set_bounds(origin, from: T::BlockNumber, to: T::BlockNumber) { ensure_root(origin)?; ensure!(from < to, "wrong arguments"); - >::put((from, to)); + >::put((from, to)); } /// Set minimum of positive votes required for lock approve. @@ -493,10 +494,11 @@ decl_module! { } // Runs after every block within the context and current state of said block. - fn offchain_worker(_now: T::BlockNumber) { - debug::RuntimeLogger::init(); + fn offchain_worker(now: T::BlockNumber) { + // Launch if validator and lockdrop is active + if sp_io::offchain::is_validator() && Self::is_active(now) { + debug::RuntimeLogger::init(); - if sp_io::offchain::is_validator() { match Self::offchain() { Err(_) => debug::error!( target: "lockdrop-offchain-worker", @@ -646,10 +648,9 @@ impl Module { None } - /// Check that current time suits lockdrop time bounds. - fn time_guard() -> bool { - let now = T::Time::now(); - let bounds = >::get(); + /// Check that block suits lockdrop bounds. + fn is_active(now: T::BlockNumber) -> bool { + let bounds = >::get(); now >= bounds.0 && now < bounds.1 } } diff --git a/frame/plasm-lockdrop/src/mock.rs b/frame/plasm-lockdrop/src/mock.rs index 9bd5e40af1..760cdc1472 100644 --- a/frame/plasm-lockdrop/src/mock.rs +++ b/frame/plasm-lockdrop/src/mock.rs @@ -219,7 +219,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities { dollar_rate: (9_000, 200), vote_threshold: 3, positive_votes: 2, - time_bounds: (0, 100_000_000), + lockdrop_bounds: (0, 1_000_000), } .assimilate_storage(&mut storage);