Skip to content

Commit

Permalink
rip(gear-runtime): Remove PoA runtime (#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx authored Oct 17, 2023
1 parent 4d332e7 commit 05339e2
Show file tree
Hide file tree
Showing 77 changed files with 187 additions and 6,943 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@ jobs:
- name: Run all benchmarks
run: |
./scripts/benchmarking/run_all_benchmarks.sh -c gear-dev -m
cp ./scripts/benchmarking/weights-output/* runtime/gear/src/weights
./scripts/benchmarking/run_all_benchmarks.sh -b -c vara-dev -m # -b to skip build
./scripts/benchmarking/run_all_benchmarks.sh -c vara-dev -m
cp ./scripts/benchmarking/weights-output/* runtime/vara/src/weights
# apply some patches for `pallets/gear/src/weights.rs`
cp runtime/gear/src/weights/pallet_gear.rs pallets/gear/src/weights.rs
cp runtime/vara/src/weights/pallet_gear.rs pallets/gear/src/weights.rs
sed -i -E 's/\w+::WeightInfo for SubstrateWeight/WeightInfo for SubstrateWeight/' pallets/gear/src/weights.rs
# clear the target directory because our benchmarking machine is not ephemeral
cargo clean
Expand All @@ -57,12 +55,6 @@ jobs:
path: scripts/benchmarking/benchmarking_errors.txt
if-no-files-found: ignore

- name: "ACTIONS: Upload artifact with updated weights (gear)"
uses: actions/upload-artifact@v3
with:
name: weights-gear
path: runtime/gear/src/weights/

- name: "ACTIONS: Upload artifact with updated weights (vara)"
uses: actions/upload-artifact@v3
with:
Expand All @@ -79,15 +71,14 @@ jobs:
with:
commit_message: >-
chore(runtime): update weights
file_pattern: "pallets/gear/src/ runtime/gear/src/weights/ runtime/vara/src/weights/"
file_pattern: "pallets/gear/src/ runtime/vara/src/weights/"

- name: Create Pull Request
if: ${{ inputs.change-type == 'pull_request' }}
uses: peter-evans/create-pull-request@v5
with:
add-paths: |
pallets/gear/src/
runtime/gear/src/weights/
runtime/vara/src/weights/
commit-message: update weights
branch: weights/patch
Expand All @@ -96,4 +87,4 @@ jobs:
chore(runtime): update weights
body: |
`run_all_benchmarks.sh` script is applied to update weights (branch: `${{ github.ref_name }}`, commit ${{ github.sha }})
**Note:** If CI fails, try manually updating the heuristic tests: `runtime/{gear, vara}/src/tests.rs`
**Note:** If CI fails, try manually updating the heuristic tests: `runtime/vara/src/tests.rs`
6 changes: 0 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ jobs:
- name: "Build fuzzer"
run: ./scripts/gear.sh build fuzz --locked --release

- name: "Check: Gear runtime imports"
run: ./target/release/wasm-proc --check-runtime-imports target/release/wbuild/gear-runtime/gear_runtime.compact.wasm

- name: "Check: Vara runtime imports"
run: ./target/release/wasm-proc --check-runtime-imports target/release/wbuild/vara-runtime/vara_runtime.compact.wasm

Expand Down Expand Up @@ -164,9 +161,6 @@ jobs:
cd target/wasm32-unknown-unknown/release
tar czvf ../../../artifact/examples.tar.gz *.wasm
cd ../../..
cp target/production/wbuild/gear-runtime/gear_runtime.compact.compressed.wasm artifact/
cp target/production/wbuild/gear-runtime/gear_runtime.compact.wasm artifact/
cp target/production/wbuild/gear-runtime/gear_runtime.wasm artifact/
cp target/production/wbuild/vara-runtime/vara_runtime.compact.compressed.wasm artifact/
cp target/production/wbuild/vara-runtime/vara_runtime.compact.wasm artifact/
cp target/production/wbuild/vara-runtime/vara_runtime.wasm artifact/
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ jobs:
- name: "Environment: Export versions"
run: |
echo "GEAR_SPEC=$(cat runtime/gear/src/lib.rs | grep "spec_version: " | awk -F " " '{print substr($2, 1, length($2)-1)}')" >> $GITHUB_ENV
echo "VARA_SPEC=$(cat runtime/vara/src/lib.rs | grep "spec_version: " | awk -F " " '{print substr($2, 1, length($2)-1)}')" >> $GITHUB_ENV
- name: "Environment: Make `artifact` directory"
Expand All @@ -79,27 +78,23 @@ jobs:
- name: "Build: Production `vara-runtime`"
run: cargo build -p vara-runtime --profile production --no-default-features --features std

- name: "Test: Production `vara-runtime`"
run: ./wasm-proc --check-runtime-imports target/production/wbuild/vara-runtime/vara_runtime.wasm

- name: "Artifact: Production `vara-runtime`"
run: cp target/production/wbuild/vara-runtime/vara_runtime.compact.compressed.wasm "artifact/vara_runtime_v$VARA_SPEC.wasm"

- name: "Build: Production node with development runtimes"
run: cargo build -p gear-cli --profile production

- name: "Test: Development runtimes"
run: |
./wasm-proc --check-runtime-imports target/production/wbuild/gear-runtime/gear_runtime.wasm
./wasm-proc --check-runtime-imports target/production/wbuild/vara-runtime/vara_runtime.wasm
- name: "Artifact: Production node and development runtimes"
- name: "Artifact: Production node client and development `vara-runtime`"
run: |
cp target/production/wbuild/gear-runtime/gear_runtime.compact.compressed.wasm "artifact/gear_devruntime_v$GEAR_SPEC.wasm"
cp target/production/wbuild/vara-runtime/vara_runtime.compact.compressed.wasm "artifact/vara_devruntime_v$VARA_SPEC.wasm"
cp target/production/gear artifact/gear
strip artifact/gear || true
- name: "Test: Runtimes"
run: |
./wasm-proc --check-runtime-imports --check-runtime-is-dev false "artifact/vara_runtime_v$VARA_SPEC.wasm"
./wasm-proc --check-runtime-imports --check-runtime-is-dev true "artifact/vara_devruntime_v$VARA_SPEC.wasm"
- name: Publish
uses: softprops/action-gh-release@v1
with:
Expand Down
73 changes: 4 additions & 69 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ gear-lazy-pages = { path = "lazy-pages" }
gear-lazy-pages-common = { path = "lazy-pages/common", default-features = false }
gear-lazy-pages-interface = { path = "lazy-pages/interface", default-features = false }
gear-node-testing = { path = "node/testing" }
gear-runtime = { path = "runtime/gear", default-features = false }
gear-runtime-common = { path = "runtime/common", default-features = false }
gear-runtime-interface = { path = "runtime-interface", default-features = false }
gear-sandbox = { path = "sandbox/sandbox", default-features = false }
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@ gear-replay:
gear-replay-vara-native:
@ ./scripts/gear.sh build gear-replay --release --no-default-features --features=std,vara-native

.PHONY: gear-replay-gear-native
gear-replay-gear-native:
@ ./scripts/gear.sh build gear-replay --release --no-default-features --features=std,gear-native

# Check section
.PHONY: check
check:
Expand Down
1 change: 0 additions & 1 deletion gcli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ which.workspace = true

[features]
node-key = [ "libp2p" ]
vara-testing = [ ]

[package.metadata.docs.rs]
all-features = true
49 changes: 33 additions & 16 deletions gcli/tests/cmd/claim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,40 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

//! Integration tests for command `send`
#![cfg(not(feature = "vara-testing"))]
use crate::common::{
self, traits::NodeExec, Args, Result, ALICE_SS58_ADDRESS as ADDRESS, MESSAGER_SENT_VALUE,
};
use crate::common::{self, logs, traits::NodeExec, Args, Result, ALICE_SS58_ADDRESS as ADDRESS};
use gsdk::Api;

const REWARD_PER_BLOCK: u128 = 75_000; // 3_000 gas * 25 value per gas

#[tokio::test]
async fn test_command_claim_works() -> Result<()> {
// hack to check initial alice balance
let (initial_balance, initial_stash) = {
let mut node = common::dev()?;

node.wait_for_log_record(logs::gear_node::IMPORTING_BLOCKS)?;

// Get balance of the testing address
let signer = Api::new(Some(&node.ws()))
.await?
.signer("//Alice//stash", None)?;
(
signer.api().get_balance(ADDRESS).await.unwrap_or(0),
signer
.api()
.get_balance(&signer.address())
.await
.unwrap_or(0),
)
};

let node = common::create_messager().await?;

// Check the mailbox of the testing account
let signer = Api::new(Some(&node.ws())).await?.signer("//Alice", None)?;
let signer = Api::new(Some(&node.ws()))
.await?
.signer("//Alice//stash", None)?;
let mailbox = signer
.api()
.mailbox(Some(common::alice_account_id()), 10)
Expand All @@ -39,21 +59,18 @@ async fn test_command_claim_works() -> Result<()> {
assert_eq!(mailbox.len(), 1);
let id = hex::encode(mailbox[0].0.id.0);

// Claim value from message id
let burned_before = signer.api().get_balance(&signer.address()).await? - initial_stash;
let before = signer.api().get_balance(ADDRESS).await?;

// Claim value from message id
let _ = node.run(Args::new("claim").message_id(id))?;

let burned_after = signer.api().get_balance(&signer.address()).await? - initial_stash;
let after = signer.api().get_balance(ADDRESS).await?;

// # TODO
//
// not using `//Alice` or estimating the reward
// before this checking.
let expected = MESSAGER_SENT_VALUE + REWARD_PER_BLOCK;
assert_eq!(
after.saturating_sub(before),
expected,
"Alice should have received the value of the message plus the reward ({expected})"
);
assert_eq!(initial_balance - before - burned_before, REWARD_PER_BLOCK,);

assert_eq!(initial_balance - burned_after, after);

Ok(())
}
Loading

0 comments on commit 05339e2

Please sign in to comment.