Skip to content

Commit

Permalink
Merge branch 'master' into skunert/overhead-benchmark-again
Browse files Browse the repository at this point in the history
  • Loading branch information
skunert authored Oct 30, 2024
2 parents 52458b8 + 6f96f72 commit 1858d9a
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 49 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/build-publish-eth-rpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build and push ETH-RPC image

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
IMAGE_NAME: "docker.io/paritypr/eth-rpc"

jobs:
set-variables:
# This workaround sets the container image for each job using 'set-variables' job output.
# env variables don't work for PR from forks, so we need to use outputs.
runs-on: ubuntu-latest
outputs:
VERSION: ${{ steps.version.outputs.VERSION }}
steps:
- name: Define version
id: version
run: |
export COMMIT_SHA=${{ github.sha }}
export COMMIT_SHA_SHORT=${COMMIT_SHA:0:8}
export REF_NAME=${{ github.ref_name }}
export REF_SLUG=${REF_NAME//\//_}
VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}
echo "VERSION=${REF_SLUG}-${COMMIT_SHA_SHORT}" >> $GITHUB_OUTPUT
echo "set VERSION=${VERSION}"
build_docker:
name: Build docker image
runs-on: parity-large
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./substrate/frame/revive/rpc/Dockerfile
push: false
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
build_push_docker:
name: Build and push docker image
runs-on: parity-large
if: github.ref == 'refs/heads/master'
needs: [set-variables]
env:
VERSION: ${{ needs.set-variables.outputs.VERSION }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.PARITYPR_DOCKERHUB_USERNAME }}
password: ${{ secrets.PARITYPR_DOCKERHUB_PASSWORD }}

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./substrate/frame/revive/rpc/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:${{ env.VERSION }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ coretime-collator: is up
alice: js-script ./0004-configure-relay.js with "" return is 0 within 600 secs

# Coretime chain should be producing blocks when the extrinsic is sent
alice: parachain 1005 block height is at least 10 within 120 seconds
alice: parachain 1005 block height is at least 10 within 180 seconds

# configure broker chain
coretime-collator: js-script ./0004-configure-broker.js with "" return is 0 within 600 secs
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_6268.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Bump a timeout in zombienet coretime smoke test
doc:
- audience: Node Dev
description: |-
polkadot/zombienet_tests/smoke/0004-coretime-smoke-test.zndsl still timeouts on CI from time to time. Bumping the timeout a bit more.

Related to https://github.com/paritytech/polkadot-sdk/issues/6226
crates:
- name: polkadot
bump: none
14 changes: 14 additions & 0 deletions prdoc/pr_6278.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
title: '[pallet-revive] rpc server add docker file'
doc:
- audience: Runtime Dev
description: |-
Add a docker for pallet-revive eth-rpc

Tested with
```
sudo docker build . -t eth-rpc -f substrate/frame/revive/rpc/Dockerfile
sudo docker run --network="host" -e RUST_LOG="info,eth-rpc=debug" eth-rpc
```
crates:
- name: pallet-revive-eth-rpc
bump: minor
7 changes: 7 additions & 0 deletions substrate/frame/revive/rpc/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
doc
**target*
.idea/
Dockerfile
.dockerignore
.local
.env*
23 changes: 23 additions & 0 deletions substrate/frame/revive/rpc/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM rust AS builder

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y \
protobuf-compiler

WORKDIR /polkadot
COPY . /polkadot
RUN cargo build --locked --profile production -p pallet-revive-eth-rpc --bin eth-rpc

FROM docker.io/parity/base-bin:latest
COPY --from=builder /polkadot/target/production/eth-rpc /usr/local/bin

USER root
RUN useradd -m -u 1001 -U -s /bin/sh -d /polkadot polkadot && \
# unclutter and minimize the attack surface
rm -rf /usr/bin /usr/sbin && \
# check if executable works in this container
/usr/local/bin/eth-rpc --help

USER polkadot
EXPOSE 8545
ENTRYPOINT ["/usr/local/bin/eth-rpc"]
101 changes: 55 additions & 46 deletions substrate/frame/utility/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,73 +19,82 @@

#![cfg(feature = "runtime-benchmarks")]

use super::*;
use alloc::{vec, vec::Vec};
use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller};
use alloc::vec;
use frame_benchmarking::{benchmarking::add_to_whitelist, v2::*};
use frame_system::RawOrigin;

use crate::*;

const SEED: u32 = 0;

fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
frame_system::Pallet::<T>::assert_last_event(generic_event.into());
}

benchmarks! {
where_clause { where <T::RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin: Clone }
batch {
let c in 0 .. 1000;
let mut calls: Vec<<T as Config>::RuntimeCall> = Vec::new();
for i in 0 .. c {
let call = frame_system::Call::remark { remark: vec![] }.into();
calls.push(call);
}
#[benchmarks]
mod benchmark {
use super::*;

#[benchmark]
fn batch(c: Linear<0, 1000>) {
let calls = vec![frame_system::Call::remark { remark: vec![] }.into(); c as usize];
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), calls)
verify {
assert_last_event::<T>(Event::BatchCompleted.into())

#[extrinsic_call]
_(RawOrigin::Signed(caller), calls);

assert_last_event::<T>(Event::BatchCompleted.into());
}

as_derivative {
#[benchmark]
fn as_derivative() {
let caller = account("caller", SEED, SEED);
let call = Box::new(frame_system::Call::remark { remark: vec![] }.into());
// Whitelist caller account from further DB operations.
let caller_key = frame_system::Account::<T>::hashed_key_for(&caller);
frame_benchmarking::benchmarking::add_to_whitelist(caller_key.into());
}: _(RawOrigin::Signed(caller), SEED as u16, call)

batch_all {
let c in 0 .. 1000;
let mut calls: Vec<<T as Config>::RuntimeCall> = Vec::new();
for i in 0 .. c {
let call = frame_system::Call::remark { remark: vec![] }.into();
calls.push(call);
}
add_to_whitelist(caller_key.into());

#[extrinsic_call]
_(RawOrigin::Signed(caller), SEED as u16, call);
}

#[benchmark]
fn batch_all(c: Linear<0, 1000>) {
let calls = vec![frame_system::Call::remark { remark: vec![] }.into(); c as usize];
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), calls)
verify {
assert_last_event::<T>(Event::BatchCompleted.into())

#[extrinsic_call]
_(RawOrigin::Signed(caller), calls);

assert_last_event::<T>(Event::BatchCompleted.into());
}

dispatch_as {
#[benchmark]
fn dispatch_as() {
let caller = account("caller", SEED, SEED);
let call = Box::new(frame_system::Call::remark { remark: vec![] }.into());
let origin: T::RuntimeOrigin = RawOrigin::Signed(caller).into();
let pallets_origin: <T::RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin = origin.caller().clone();
let pallets_origin = Into::<T::PalletsOrigin>::into(pallets_origin);
}: _(RawOrigin::Root, Box::new(pallets_origin), call)

force_batch {
let c in 0 .. 1000;
let mut calls: Vec<<T as Config>::RuntimeCall> = Vec::new();
for i in 0 .. c {
let call = frame_system::Call::remark { remark: vec![] }.into();
calls.push(call);
}
let origin = T::RuntimeOrigin::from(RawOrigin::Signed(caller));
let pallets_origin = origin.caller().clone();
let pallets_origin = T::PalletsOrigin::from(pallets_origin);

#[extrinsic_call]
_(RawOrigin::Root, Box::new(pallets_origin), call);
}

#[benchmark]
fn force_batch(c: Linear<0, 1000>) {
let calls = vec![frame_system::Call::remark { remark: vec![] }.into(); c as usize];
let caller = whitelisted_caller();
}: _(RawOrigin::Signed(caller), calls)
verify {
assert_last_event::<T>(Event::BatchCompleted.into())

#[extrinsic_call]
_(RawOrigin::Signed(caller), calls);

assert_last_event::<T>(Event::BatchCompleted.into());
}

impl_benchmark_test_suite!(Pallet, crate::tests::new_test_ext(), crate::tests::Test);
impl_benchmark_test_suite! {
Pallet,
tests::new_test_ext(),
tests::Test
}
}
4 changes: 2 additions & 2 deletions substrate/frame/vesting/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ mod benchmarks {

impl_benchmark_test_suite! {
Pallet,
crate::mock::ExtBuilder::default().existential_deposit(256).build(),
crate::mock::Test
mock::ExtBuilder::default().existential_deposit(256).build(),
mock::Test
}
}

0 comments on commit 1858d9a

Please sign in to comment.