Skip to content

Commit

Permalink
Merge branch 'master' into vs/rpc-call-gas
Browse files Browse the repository at this point in the history
  • Loading branch information
ukint-vs committed Sep 19, 2023
2 parents 83c3ccc + 5166948 commit 14e1c5b
Show file tree
Hide file tree
Showing 105 changed files with 2,723 additions and 1,502 deletions.
1 change: 0 additions & 1 deletion .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ jobs:
-p "pallet-*"
-p gear-lazy-pages
-p gear-runtime-interface
--features=lazy-pages
--release
upload:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ jobs:
run: curl -LsSf https://get.nexte.st/latest/mac | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin

- name: "Build: Node"
run: >-
cargo build
-p gear-cli --features=lazy-pages
run: cargo build -p gear-cli

- name: "Test: Lazy pages"
run: >-
cargo nextest run
-p "pallet-*"
-p gear-lazy-pages
-p gear-runtime-interface
--features=lazy-pages
8 changes: 2 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,8 @@ jobs:
- name: "Check: Vara runtime imports"
run: ./target/release/wasm-proc --check-runtime-imports target/release/wbuild/vara-runtime/vara_runtime.compact.wasm

- name: "Test: Gear pallet tests with lazy pages"
run: ./scripts/gear.sh test pallet --features lazy-pages --release --locked

- name: "Test: Gear workspace"
run: ./scripts/gear.sh test gear --exclude gclient --exclude gcli --exclude gsdk --features pallet-gear-debug/lazy-pages --release --locked
run: ./scripts/gear.sh test gear --exclude gclient --exclude gcli --exclude gsdk --release --locked

- name: "Test: gsdk tests"
run: ./scripts/gear.sh test gsdk --release
Expand Down Expand Up @@ -158,7 +155,7 @@ jobs:

- name: "Build: Production binaries"
if: github.event_name == 'push'
run: cargo build -p gear-cli -F cli --profile production
run: cargo build -p gear-cli -F dev,cli --profile production

- name: Prepare artifacts
if: github.event_name == 'push'
Expand Down Expand Up @@ -252,7 +249,6 @@ jobs:
-p "pallet-*"
-p gear-lazy-pages
-p gear-runtime-interface
--features=lazy-pages
--release
env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-measurements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ jobs:
tar -xf /cache/check_cargo_registry_${{ github.ref_name }}.tar -C /
- name: "Build: Gear"
run: ./scripts/gear.sh build gear --release --locked --features=dev,runtime-benchmarks,lazy-pages
run: ./scripts/gear.sh build gear --release --locked --features=dev,runtime-benchmarks

- name: "Collect: Gear workspace tests"
run: |
mkdir -p ./target/analysis/tests/
mkdir -p ./target/analysis/output/
for i in `seq 1 $COUNT`; do echo $i; ./scripts/gear.sh test gear --exclude gclient --exclude gcli --features pallet-gear-debug/lazy-pages --release -j1 > ./target/analysis/output/$i 2>&1 ; mv ./target/nextest/ci/junit.xml ./target/analysis/tests/$i; done
for i in `seq 1 $COUNT`; do echo $i; ./scripts/gear.sh test gear --exclude gclient --exclude gcli --release -j1 > ./target/analysis/output/$i 2>&1 ; mv ./target/nextest/ci/junit.xml ./target/analysis/tests/$i; done
./target/release/regression-analysis collect-data --data-folder-path ./target/analysis/tests/ --output-path ./target/pallet-tests.json
- name: "Generate report: Gear workspace tests"
Expand Down
34 changes: 33 additions & 1 deletion Cargo.lock

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

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ pallet-gear-rpc = { path = "pallets/gear/rpc" }
pallet-gear-rpc-runtime-api = { path = "pallets/gear/rpc/runtime-api", default-features = false }
pallet-gear-scheduler = { path = "pallets/gear-scheduler", default-features = false }
pallet-gear-staking-rewards = { path = "pallets/staking-rewards", default-features = false }
pallet-gear-staking-rewards-rpc = { path = "pallets/staking-rewards/rpc" }
pallet-gear-staking-rewards-rpc-runtime-api = { path = "pallets/staking-rewards/rpc/runtime-api", default-features = false }
pallet-gear-voucher = { path = "pallets/gear-voucher", default-features = false }
pallet-gear-bank = { path = "pallets/gear-bank", default-features = false }
runtime-common = { package = "gear-runtime-common", path = "runtime/common", default-features = false }
Expand Down Expand Up @@ -371,15 +373,15 @@ demo-calc-hash-in-one-block = { path = "examples/calc-hash/in-one-block" }
demo-calc-hash-over-blocks = { path = "examples/calc-hash/over-blocks" }
demo-custom = { path = "examples/custom" }
demo-compose = { path = "examples/compose" }
demo-constructor = { path = "examples/constructor" }
demo-constructor = { path = "examples/constructor", default-features = false }
demo-delayed-sender = { path = "examples/delayed-sender" }
demo-distributor = { path = "examples/distributor" }
demo-futures-unordered = { path = "examples/futures-unordered", features = ["debug"] }
demo-gas-burned = { path = "examples/gas-burned" }
demo-fungible-token = { path = "examples/fungible-token" }
demo-incomplete-async-payloads = { path = "examples/incomplete-async-payloads" }
demo-init-fail-sender = { path = "examples/init-fail-sender" }
demo-init-wait = { path = "examples/init-wait" }
demo-init-wait = { path = "examples/init-wait", default-features = false }
demo-init-wait-reply-exit = { path = "examples/init-wait-reply-exit" }
demo-messager = { path = "examples/messager" }
demo-meta-io = { path = "examples/new-meta/io" }
Expand All @@ -396,15 +398,15 @@ demo-proxy-relay = { path = "examples/proxy-relay" }
demo-proxy-reservation-with-gas = { path = "examples/proxy-reservation-with-gas" }
demo-read-big-state = { path = "examples/read-big-state", default-features = false }
demo-reservation-manager = { path = "examples/reservation-manager" }
demo-reserve-gas = { path = "examples/reserve-gas" }
demo-reserve-gas = { path = "examples/reserve-gas", default-features = false }
demo-rwlock = { path = "examples/rwlock" }
demo-send-from-reservation = { path = "examples/send-from-reservation" }
demo-signal-entry = { path = "examples/signal-entry" }
demo-state-rollback = { path = "examples/state-rollback" }
demo-sync-duplicate = { path = "examples/sync-duplicate" }
demo-vec = { path = "examples/vec" }
demo-wait = { path = "examples/wait" }
demo-waiter = { path = "examples/waiter" }
demo-waiter = { path = "examples/waiter", default-features = false }
demo-wait-timeout = { path = "examples/wait-timeout" }
demo-wait-wake = { path = "examples/wait_wake" }
demo-waiting-proxy = { path = "examples/waiting-proxy" }
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ node-release:

.PHONY: vara
vara:
@ ./scripts/gear.sh build node --no-default-features --features=vara-native,lazy-pages
@ ./scripts/gear.sh build node --no-default-features --features=vara-native

.PHONY: vara-release
vara-release:
@ ./scripts/gear.sh build node --release --no-default-features --features=vara-native,lazy-pages
@ ./scripts/gear.sh build node --release --no-default-features --features=vara-native

.PHONY: gear-replay
gear-replay:
Expand Down Expand Up @@ -175,11 +175,11 @@ purge-chain-release:

.PHONY: purge-dev-chain
purge-dev-chain:
@ ./scripts/gear.sh run purge-dev-chain
@ ./scripts/gear.sh run purge-dev-chain -F dev

.PHONY: purge-dev-chain-release
purge-dev-chain-release:
@ ./scripts/gear.sh run purge-dev-chain --release
@ ./scripts/gear.sh run purge-dev-chain --release -F dev

# Test section
.PHONY: test # \
Expand All @@ -197,13 +197,13 @@ test-doc:
test-gear: #\
We use lazy-pages feature for pallet-gear-debug due to cargo building issue \
and fact that pallet-gear default is lazy-pages.
@ ./scripts/gear.sh test gear --exclude gclient --exclude gcli --exclude gsdk --features pallet-gear-debug/lazy-pages
@ ./scripts/gear.sh test gear --exclude gclient --exclude gcli --exclude gsdk

.PHONY: test-gear-release
test-gear-release: # \
We use lazy-pages feature for pallet-gear-debug due to cargo building issue \
and fact that pallet-gear default is lazy-pages.
@ ./scripts/gear.sh test gear --release --exclude gclient --exclude gcli --exclude gsdk --features pallet-gear-debug/lazy-pages
@ ./scripts/gear.sh test gear --release --exclude gclient --exclude gcli --exclude gsdk

.PHONY: test-gsdk
test-gsdk: node-release
Expand Down
15 changes: 3 additions & 12 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub use gas_provider::{
LockId, LockableTree, Provider as GasProvider, ReservableTree, Tree as GasTree,
};

/// Type alias for gas entity.
pub type Gas = u64;

pub trait Origin: Sized {
fn into_origin(self) -> H256;
fn from_origin(val: H256) -> Self;
Expand Down Expand Up @@ -228,18 +231,6 @@ impl<BlockNumber: Copy + Saturating> Program<BlockNumber> {
})
)
}

pub fn is_uninitialized(&self) -> Option<MessageId> {
if let Program::Active(ActiveProgram {
state: ProgramState::Uninitialized { message_id },
..
}) = self
{
Some(*message_id)
} else {
None
}
}
}

#[derive(Clone, Debug, derive_more::Display)]
Expand Down
28 changes: 16 additions & 12 deletions common/src/scheduler/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::paused_program_storage::SessionId;
use crate::{paused_program_storage::SessionId, Gas};
use frame_support::{
codec::{self, Decode, Encode, MaxEncodedLen},
scale_info::{self, TypeInfo},
Expand Down Expand Up @@ -85,7 +85,7 @@ pub enum ScheduledTask<AccountId> {
}

impl<AccountId> ScheduledTask<AccountId> {
pub fn process_with(self, handler: &mut impl TaskHandler<AccountId>) {
pub fn process_with(self, handler: &mut impl TaskHandler<AccountId>) -> Gas {
use ScheduledTask::*;

match self {
Expand Down Expand Up @@ -117,32 +117,36 @@ pub trait TaskHandler<AccountId> {
// Rent charging section.
// -----
/// Pause program action.
fn pause_program(&mut self, program_id: ProgramId);
fn pause_program(&mut self, program_id: ProgramId) -> Gas;
/// Remove code action.
fn remove_code(&mut self, code_id: CodeId);
fn remove_code(&mut self, code_id: CodeId) -> Gas;
/// Remove from mailbox action.
fn remove_from_mailbox(&mut self, user_id: AccountId, message_id: MessageId);
fn remove_from_mailbox(&mut self, user_id: AccountId, message_id: MessageId) -> Gas;
/// Remove from waitlist action.
fn remove_from_waitlist(&mut self, program_id: ProgramId, message_id: MessageId);
fn remove_from_waitlist(&mut self, program_id: ProgramId, message_id: MessageId) -> Gas;
/// Remove paused program action.
fn remove_paused_program(&mut self, program_id: ProgramId);
fn remove_paused_program(&mut self, program_id: ProgramId) -> Gas;

// Time chained section.
// -----
/// Wake message action.
fn wake_message(&mut self, program_id: ProgramId, message_id: MessageId);
fn wake_message(&mut self, program_id: ProgramId, message_id: MessageId) -> Gas;

// Send delayed message to program action.
fn send_dispatch(&mut self, stashed_message_id: MessageId);
fn send_dispatch(&mut self, stashed_message_id: MessageId) -> Gas;

// Send delayed message to user action.
fn send_user_message(&mut self, stashed_message_id: MessageId, to_mailbox: bool);
fn send_user_message(&mut self, stashed_message_id: MessageId, to_mailbox: bool) -> Gas;

/// Remove gas reservation action.
fn remove_gas_reservation(&mut self, program_id: ProgramId, reservation_id: ReservationId);
fn remove_gas_reservation(
&mut self,
program_id: ProgramId,
reservation_id: ReservationId,
) -> Gas;

/// Remove data created by resume program session.
fn remove_resume_session(&mut self, session_id: SessionId);
fn remove_resume_session(&mut self, session_id: SessionId) -> Gas;
}

#[test]
Expand Down
Loading

0 comments on commit 14e1c5b

Please sign in to comment.