Skip to content

Commit

Permalink
Merge branch 'master' into dn-unstabilize-hold-bound
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx committed Aug 18, 2022
2 parents 99850da + 10bf72d commit cb32577
Show file tree
Hide file tree
Showing 34 changed files with 714 additions and 289 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CD-vara.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CD
name: Vara CD

on:
workflow_dispatch:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ jobs:
- name: "Test: Process node runtime testsuite"
run: ./scripts/gear.sh test rtest

# TODO: make also rtest run for node without lazy-pages feature (issue #1023)
- name: "Test: runtime spec tests no lazy pages"
run: |
cargo build -p gear-node --release --no-default-features --features=gear-native --out-dir target-no-lazy -Z unstable-options
./target-no-lazy/gear-node runtime-spec-tests ./gear-test/spec/*
- name: "Test (performance): node runtime testsuite"
if: ${{ github.ref != 'refs/heads/master' }}
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/vara-deploy-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Vara-deploy-only

on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
jobs:
deploy:
runs-on: ubuntu-latest
needs: docker
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Info
run: |
ls -l .
ls -l ../..
pwd
- name: Send telegram notify before run playbook
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
token: ${{ secrets.TELEGRAM_BOT_TOKEN }}
message: |
Attention! Instances will be temporarily unavailable!
${{ github.actor }} run build with commit: "${{ github.event.commits[0].message }}"
Build number: ${{ github.run_number }}
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
with:
# Required, playbook filepath
directory: ./ansible/
playbook: vara.yaml
# Optional, SSH private key
key: ${{secrets.SSH_PRIVATE_KEY}}
# Optional, literal inventory file contents
inventory: |
[gearNodes:children]
bootnode
nodes
[bootnode]
${{secrets.VARA_NODE}} name=vara-gear01 loki=yes loki_url=${{secrets.LOKI_URL}}
[nodes]
${{secrets.VARA_NODE_2}} name=vara-gear02 validator=yes loki=yes loki_url=${{secrets.LOKI_URL}}
${{secrets.VARA_NODE_3}} name=vara-rpc-node rpc=yes unsafe=yes loki=yes loki_url=${{secrets.LOKI_URL}}
${{secrets.VARA_NODE_4}} name=vara-gear04 validator=yes loki=yes loki_url=${{secrets.LOKI_URL}}
${{secrets.VARA_NODE_5}} name=vara-gear05 validator=yes loki=yes loki_url=${{secrets.LOKI_URL}}
${{secrets.VARA_NODE_6}} name=vara-gear06 validator=yes loki=yes loki_url=${{secrets.LOKI_URL}}
${{secrets.VARA_NODE_7}} name=vara-gear07 validator=yes loki=yes loki_url=${{secrets.LOKI_URL}}
53 changes: 47 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ codec = { package = "parity-scale-codec", version = "3.1.2", default-features =
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
primitive-types = { version = "0.11.1", default-features = false, features = ["scale-info"] }
log = "0.4.17"
gear-common-codegen = { path = "./codegen" }
derive_more = "0.99.17"
parity-wasm = { version = "0.45.0", default-features = false, optional = true }

# Internal deps
gear-core = { path = "../core" }
gear-common-codegen = { path = "./codegen" }

# Substrate deps

sp-core = { version = "6.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false }
sp-io = { version = "6.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false }
sp-runtime = { version = "6.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false }
Expand All @@ -25,9 +26,6 @@ sp-arithmetic = { version = "5.0.0", git = "https://github.com/gear-tech/substra
frame-support = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false }
frame-system = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false, optional = true }
frame-benchmarking = { version = "4.0.0-dev", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false, optional = true }
gear-runtime-interface = { path = "../runtime-interface", default-features = false }
parity-wasm = { version = "0.45.0", default-features = false, optional = true }
derive_more = "0.99.17"

[dev-dependencies]
hex-literal = "0.3.3"
Expand All @@ -46,7 +44,6 @@ std = [
"sp-arithmetic/std",
"frame-support/std",
"primitive-types/std",
"gear-runtime-interface/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
25 changes: 25 additions & 0 deletions common/lazy-pages/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "gear-lazy-pages-common"
version = "0.1.0"
authors = ["Gear Technologies"]
edition = "2018"
license = "GPL-3.0"

[dependencies]
derive_more = "0.99.17"
log = { version = "0.4.17", default-features = false }

gear-core = { path = "../../core", default-features = false }
gear-common = { path = "..", default-features = false }
gear-runtime-interface = { path = "../../runtime-interface", default-features = false }

sp-std = { version = "4.0.0", git = "https://github.com/gear-tech/substrate.git", branch = "gear-stable", default-features = false }

[features]
default = ["std"]
std = [
"gear-common/std",
"gear-runtime-interface/std",
"sp-std/std",
"log/std",
]
36 changes: 11 additions & 25 deletions common/src/lazy_pages.rs → common/lazy-pages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,30 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Lazy pages support runtime functions
//! Lazy pages support for runtime.
#![cfg_attr(not(feature = "std"), no_std)]

use crate::Origin;
use alloc::string::ToString;
use core::fmt;
use gear_common::{pages_prefix, Origin};
use gear_core::{
ids::ProgramId,
memory::{HostPointer, Memory, PageNumber, WasmPageNumber},
};
use gear_runtime_interface::{gear_ri, RIError};
use sp_std::vec::Vec;

#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display)]
extern crate alloc;
use alloc::string::ToString;

#[derive(Debug, Clone, PartialEq, Eq, derive_more::Display, derive_more::From)]
pub enum Error {
#[display(fmt = "{}", _0)]
#[from]
RIError(RIError),
#[display(fmt = "Wasm memory buffer is undefined after wasm memory relocation")]
WasmMemBufferIsUndefined,
}

impl From<RIError> for Error {
fn from(err: RIError) -> Self {
Self::RIError(err)
}
}

fn mprotect_lazy_pages(mem: &impl Memory, protect: bool) -> Result<(), Error> {
if mem.get_buffer_host_addr().is_none() {
return Ok(());
Expand All @@ -55,19 +53,7 @@ fn mprotect_lazy_pages(mem: &impl Memory, protect: bool) -> Result<(), Error> {

/// Try to enable and initialize lazy pages env
pub fn try_to_enable_lazy_pages() -> bool {
if !gear_ri::init_lazy_pages() {
// TODO: lazy-pages must be disabled in validators in relay-chain.
log::debug!("lazy-pages: disabled or unsupported");
false
} else {
log::debug!("lazy-pages: enabled");
true
}
}

/// Returns whether lazy pages environment is enabled
pub fn is_lazy_pages_enabled() -> bool {
gear_ri::is_lazy_pages_enabled()
gear_ri::init_lazy_pages()
}

/// Protect and save storage keys for pages which has no data
Expand Down Expand Up @@ -126,7 +112,7 @@ pub fn update_lazy_pages_and_protect_again(

// Cannot panic, unless OS allocates wasm mem buffer
// in not aligned by native page addr.
gear_ri::set_wasm_mem_begin_addr(new_mem_addr).expect("Cannot not set new wasm mem addr");
gear_ri::set_wasm_mem_begin_addr(new_mem_addr).expect("Cannot set new wasm mem addr");
}

let new_mem_size = mem.size();
Expand Down
10 changes: 9 additions & 1 deletion common/src/gas_provider/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub trait Tree {
type ExternalOrigin;

/// Type that identifies a particular value item.
type Key;
type Key: Clone;

/// Type representing a quantity of value.
type Balance;
Expand Down Expand Up @@ -192,6 +192,14 @@ pub trait Tree {
/// This can't create imbalance as no value is burned or created.
fn unlock(key: Self::Key, amount: Self::Balance) -> Result<(), Self::Error>;

/// Unlocking all value from node's locked balance.
///
/// See [`unlock`](Self::unlock) for details.
fn unlock_all(key: Self::Key) -> Result<(), Self::Error> {
let amount = Self::get_lock(key.clone())?;
Self::unlock(key, amount)
}

/// Get locked value associated with given id.
///
/// Returns errors in cases of absence associated with given key node,
Expand Down
1 change: 0 additions & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
extern crate gear_common_codegen;

pub mod event;
pub mod lazy_pages;
pub mod scheduler;
pub mod storage;

Expand Down
Loading

0 comments on commit cb32577

Please sign in to comment.