Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 6c17589

Browse files
committed
Merge remote-tracking branch 'origin/master' into dp-jsonrpsee-integration-2
2 parents 8a6ba85 + 50c84cb commit 6c17589

File tree

18 files changed

+298
-31
lines changed

18 files changed

+298
-31
lines changed

.gitlab-ci.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ test-wasmer-sandbox:
516516
variables:
517517
<<: *default-vars
518518
script:
519-
- time cargo test --release --features runtime-benchmarks,wasmer-sandbox
519+
- time cargo test --release --features runtime-benchmarks,wasmer-sandbox,disable-ui-tests
520520
- sccache -s
521521

522522
cargo-check-macos:
@@ -618,6 +618,7 @@ build-rustdoc:
618618
variables:
619619
<<: *default-vars
620620
SKIP_WASM_BUILD: 1
621+
DOC_INDEX_PAGE: "sc_service/index.html" # default redirected page
621622
artifacts:
622623
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}-doc"
623624
when: on_success
@@ -632,7 +633,7 @@ build-rustdoc:
632633
- mv ./target/doc ./crate-docs
633634
# FIXME: remove me after CI image gets nonroot
634635
- chown -R nonroot:nonroot ./crate-docs
635-
- echo "<meta http-equiv=refresh content=0;url=sc_service/index.html>" > ./crate-docs/index.html
636+
- echo "<meta http-equiv=refresh content=0;url=${DOC_INDEX_PAGE}>" > ./crate-docs/index.html
636637
- sccache -s
637638

638639
#### stage: publish
@@ -728,42 +729,73 @@ publish-rustdoc:
728729
stage: publish
729730
<<: *kubernetes-env
730731
<<: *vault-secrets
731-
image: paritytech/tools:latest
732+
image: node:16
732733
variables:
733734
GIT_DEPTH: 100
735+
# --- Following variables are for rustdocs deployment ---
736+
# Space separated values of branches and tags to generate rustdocs
737+
RUSTDOCS_DEPLOY_REFS: "master monthly-2021-09+1 monthly-2021-08 v3.0.0"
738+
# Location of the docs index template
739+
INDEX_TPL: ".maintain/docs-index-tpl.ejs"
740+
# Where the `/latest` symbolic link links to. One of the $RUSTDOCS_DEPLOY_REFS value.
741+
LATEST: "monthly-2021-09+1"
734742
rules:
735743
- if: $CI_PIPELINE_SOURCE == "pipeline"
736744
when: never
737745
- if: $CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master"
738746
- if: $CI_COMMIT_REF_NAME == "master"
747+
- if: $CI_COMMIT_REF_NAME =~ /^monthly-20[0-9]{2}-[0-9]{2}.*$/ # to support: monthly-2021-09+1
748+
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
739749
# `needs:` can be removed after CI image gets nonroot. In this case `needs:` stops other
740750
# artifacts from being dowloaded by this job.
741751
needs:
742752
- job: build-rustdoc
743753
artifacts: true
744754
script:
755+
# If $CI_COMMIT_REF_NAME doesn't match one of $RUSTDOCS_DEPLOY_REFS space-separated values, we
756+
# exit immediately.
757+
# Putting spaces at the front and back to ensure we are not matching just any substring, but the
758+
# whole space-separated value.
759+
- '[[ " ${RUSTDOCS_DEPLOY_REFS} " =~ " ${CI_COMMIT_REF_NAME} " ]] || exit 0'
745760
- rm -rf /tmp/*
746761
# Set git config
747762
- rm -rf .git/config
748763
- git config user.email "devops-team@parity.io"
749764
- git config user.name "${GITHUB_USER}"
750-
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/substrate.git"
765+
- git config remote.origin.url "https://${GITHUB_TOKEN}@github.com/paritytech/${CI_PROJECT_NAME}.git"
751766
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
752767
- git fetch origin gh-pages
768+
# Install `ejs` and generate index.html based on RUSTDOCS_DEPLOY_REFS
769+
- yarn global add ejs
770+
- 'ejs ${INDEX_TPL} -i "{\"deploy_refs\":\"${RUSTDOCS_DEPLOY_REFS}\",\"repo_name\":\"${CI_PROJECT_NAME}\",\"latest\":\"${LATEST}\"}" > /tmp/index.html'
753771
# Save README and docs
754772
- cp -r ./crate-docs/ /tmp/doc/
755773
- cp README.md /tmp/doc/
756774
- git checkout gh-pages
757-
# Remove everything and restore generated docs and README
758-
- rm -rf ./*
759-
- mv /tmp/doc/* .
775+
# Remove directories no longer necessary, as specified in $RUSTDOCS_DEPLOY_REFS.
776+
# Also ensure $RUSTDOCS_DEPLOY_REFS is non-space
777+
- if [[ ! -z ${RUSTDOCS_DEPLOY_REFS// } ]]; then
778+
for FILE in *; do
779+
if [[ ! " $RUSTDOCS_DEPLOY_REFS " =~ " $FILE " ]]; then
780+
echo "Removing ${FILE}..."
781+
rm -rf $FILE
782+
fi
783+
done
784+
fi
785+
# Move the index page & built back
786+
- mv -f /tmp/index.html .
787+
# Ensure the destination dir doesn't exist.
788+
- rm -rf ${CI_COMMIT_REF_NAME}
789+
- mv -f /tmp/doc ${CI_COMMIT_REF_NAME}
790+
# Add the symlink
791+
- '[[ -e "$LATEST" ]] && ln -sf "${LATEST}" latest'
760792
# Upload files
761793
- git add --all --force
762794
# `git commit` has an exit code of > 0 if there is nothing to commit.
763795
# This causes GitLab to exit immediately and marks this job failed.
764796
# We don't want to mark the entire job failed if there's nothing to
765797
# publish though, hence the `|| true`.
766-
- git commit -m "Updated docs for ${CI_COMMIT_REF_NAME}" ||
798+
- git commit -m "___Updated docs for ${CI_COMMIT_REF_NAME}___" ||
767799
echo "___Nothing to commit___"
768800
- git push origin gh-pages --force
769801
after_script:

.maintain/docs-index-tpl.ejs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<%
2+
const capFirst = s => (s && s[0].toUpperCase() + s.slice(1)) || "";
3+
%>
4+
5+
<!DOCTYPE html>
6+
<html lang="en">
7+
8+
<head>
9+
<meta charset="UTF-8">
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
11+
<title><%= capFirst(repo_name) %> Rustdocs</title>
12+
<meta name="description" content="Nothing here." />
13+
<meta name="robots" content="noindex">
14+
<style>
15+
body {
16+
font-family: Helvetica, Arial, Sans Serif;
17+
margin: 0;
18+
}
19+
.center-me {
20+
display: flex;
21+
justify-content: center;
22+
align-items: center;
23+
height: 100vh;
24+
}
25+
.content {
26+
display: block;
27+
}
28+
.content li {
29+
font-size: 1em;
30+
line-height: .4em;
31+
padding: .8em 0;
32+
}
33+
</style>
34+
</head>
35+
36+
<body>
37+
<div class="center-me">
38+
<div class="content">
39+
<h1><%= capFirst(repo_name) %> Rustdocs</h1>
40+
<section>
41+
<ul>
42+
<%_ deploy_refs.split(/\s+/).forEach(ref => { _%>
43+
<li>
44+
<a href="/<%= repo_name _%>/<%= ref _%>"><%- ref -%></a>
45+
<%_ if (latest && latest.trim() !== '' && latest === ref) { _%>
46+
(<a href="/<%= repo_name _%>/latest">latest</a>)
47+
<%_ } _%>
48+
</li>
49+
<%_ }) _%>
50+
</ul>
51+
</section>
52+
</div>
53+
</div>
54+
</body>
55+
</html>

bin/node/runtime/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,9 @@ parameter_types! {
932932
/// We prioritize im-online heartbeats over election solution submission.
933933
pub const StakingUnsignedPriority: TransactionPriority = TransactionPriority::max_value() / 2;
934934
pub const MaxAuthorities: u32 = 100;
935+
pub const MaxKeys: u32 = 10_000;
936+
pub const MaxPeerInHeartbeats: u32 = 10_000;
937+
pub const MaxPeerDataEncodingSize: u32 = 1_000;
935938
}
936939

937940
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
@@ -996,6 +999,9 @@ impl pallet_im_online::Config for Runtime {
996999
type ReportUnresponsiveness = Offences;
9971000
type UnsignedPriority = ImOnlineUnsignedPriority;
9981001
type WeightInfo = pallet_im_online::weights::SubstrateWeight<Runtime>;
1002+
type MaxKeys = MaxKeys;
1003+
type MaxPeerInHeartbeats = MaxPeerInHeartbeats;
1004+
type MaxPeerDataEncodingSize = MaxPeerDataEncodingSize;
9991005
}
10001006

10011007
impl pallet_offences::Config for Runtime {

frame/im-online/src/benchmarking.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use super::*;
2323

2424
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite};
25-
use frame_support::traits::UnfilteredDispatchable;
25+
use frame_support::{traits::UnfilteredDispatchable, WeakBoundedVec};
2626
use frame_system::RawOrigin;
2727
use sp_core::{offchain::OpaqueMultiaddr, OpaquePeerId};
2828
use sp_runtime::{
@@ -46,7 +46,9 @@ pub fn create_heartbeat<T: Config>(
4646
for _ in 0..k {
4747
keys.push(T::AuthorityId::generate_pair(None));
4848
}
49-
Keys::<T>::put(keys.clone());
49+
let bounded_keys = WeakBoundedVec::<_, T::MaxKeys>::try_from(keys.clone())
50+
.map_err(|()| "More than the maximum number of keys provided")?;
51+
Keys::<T>::put(bounded_keys);
5052

5153
let network_state = OpaqueNetworkState {
5254
peer_id: OpaquePeerId::default(),

0 commit comments

Comments
 (0)