Skip to content

Commit b01468c

Browse files
committed
fmt
1 parent a553385 commit b01468c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+507
-488
lines changed

CONTRIBUTIONS.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ Moonbeam is following the
2323
In addition, we incorporate several tools to improve code quality. These are integrated into our CI
2424
and are expected to pass before a PR is considered mergeable. They can also be run locally.
2525

26-
* [clippy](https://github.com/rust-lang/rust-clippy) - run with `cargo clippy --release --workspace`
27-
* [rustfmt](https://github.com/rust-lang/rustfmt) - run with `cargo fmt -- --check`
28-
* [editorconfig](https://editorconfig.org/) - integrate into your text editor / IDE
29-
* [prettier](https://prettier.io/) - run with `npx prettier --check --ignore-path .gitignore '**/*.(yml|js|ts|json)'` (runs against `typescript` code)
26+
- [clippy](https://github.com/rust-lang/rust-clippy) - run with `cargo clippy --release --workspace`
27+
- [rustfmt](https://github.com/rust-lang/rustfmt) - run with `cargo fmt -- --check`
28+
- [editorconfig](https://editorconfig.org/) - integrate into your text editor / IDE
29+
- [prettier](https://prettier.io/) - run with `npx prettier --check --ignore-path .gitignore '**/*.(yml|js|ts|json)'` (runs against `typescript` code)
3030

3131
### Directory Structure
3232

3333
The following is a list of directories of interest in development.
3434

35-
|Directory |Purpose |
36-
| --------------------- | -------------------------------------------------------------------------- |
37-
|client/ | Debug & Trace related code (rust) |
38-
|docker/ | Dockerfiles for running Moonbeam |
39-
|moonbeam-types-bundle/ | PolkadotJs types definitions for Moonbeam (typescript) |
40-
|node/ | Moonbeam's main node (rust) |
41-
|pallets/ | Moonmeam's Substrate runtime pallets (rust) |
42-
|primitives/ | More Debug & Trace related code (rust) |
43-
|runtime/ | Moonbeam's runtime (on-chain) code (rust, compiled to WASM) |
44-
|scripts/ | Utilities for launching and interacting with a Moonbeam chain (typescript) |
45-
|specs/ | Spec files used to generate genesis for well-known Moonbeam networks |
46-
|tools/ | Various tools generally related to development (typescript) |
35+
| Directory | Purpose |
36+
| ---------------------- | -------------------------------------------------------------------------- |
37+
| client/ | Debug & Trace related code (rust) |
38+
| docker/ | Dockerfiles for running Moonbeam |
39+
| moonbeam-types-bundle/ | PolkadotJs types definitions for Moonbeam (typescript) |
40+
| node/ | Moonbeam's main node (rust) |
41+
| pallets/ | Moonmeam's Substrate runtime pallets (rust) |
42+
| primitives/ | More Debug & Trace related code (rust) |
43+
| runtime/ | Moonbeam's runtime (on-chain) code (rust, compiled to WASM) |
44+
| scripts/ | Utilities for launching and interacting with a Moonbeam chain (typescript) |
45+
| specs/ | Spec files used to generate genesis for well-known Moonbeam networks |
46+
| tools/ | Various tools generally related to development (typescript) |
4747

4848
### PR labels conventions
4949

PERF.md

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Introduction
22

3-
`perf` is a linux tool to profile cpu utilization within the system,
3+
`perf` is a linux tool to profile cpu utilization within the system,
44
a process, or directly a thread. It can be used in multiple ways but this documentation only describe capturing with call-graph.
55

66
`perf` simply takes a snapshot of the cpu stack at the given frequency (usually 1000hz).
@@ -13,6 +13,7 @@ In addition to `perf` itself, some tools like [speedscope](https://github.com/jl
1313

1414
Moonbeam node built with `--release`, contains enough symbols to have meanigful report for perf.
1515
However it is suggest to also combine the build with additional frame pointers in order to capture the full stack:
16+
1617
```
1718
RUSTFLAGS="-C force-frame-pointers=yes" cargo build --release
1819
```
@@ -25,38 +26,41 @@ In most cases, we want to profile a specific feature of the node (producing a bl
2526
with a command. Ex:
2627

2728
```
28-
# if you have only 1 node running
29+
# if you have only 1 node running
2930
pgrep moonbeam
3031
31-
# if you have multiple nodes, use tricks to retrieve only the given node (port, command parameters...). Ex:
32+
# if you have multiple nodes, use tricks to retrieve only the given node (port, command parameters...). Ex:
3233
ps aux | grep moonbeam | grep -e 56772 | grep db-cache | tr -s " " | cut -d' ' -f 2
3334
```
3435

35-
3636
To start perf:
37+
3738
```
3839
perf record -F 20000 -p $(pgrep moonbeam) --call-graph fp
3940
```
4041

4142
To start perf with jitdump :
43+
4244
```
4345
perf record -F 20000 -p $(pgrep moonbeam) -k mono --call-graph fp
4446
```
47+
4548
(`-k mono` allows jit injection later)
4649

4750
To stop `perf`, use **<CTRL+C>**, it will stop recording and close after few seconds.
4851

4952
- **-F** is the **frequency** (20000hz), which allows to get more precise result. If you are tracking functions taking more than 1ms, 1000hz is good enough, otherwise you need to increase it. However the more you increase, the more likely you are to miss data. If perf can't profile fast enough, it will drop some snapshot to avoid impacting the process itself.
5053
Suggested, based on function duration: 200ms: 50000, 1s: 20000, 10+s: 1000
51-
- **-p** the **\<pid\>** of the node
54+
- **-p** the **\<pid\>** of the node
5255
- **--call-graph** enables the call-graph (the function stack) using the frame-pointer that we enabled during compilation
53-
(If you can't enable frame-pointer in the compilation, use `--call-graph dwarf` instead, and limit frequency to 2000 max)
56+
(If you can't enable frame-pointer in the compilation, use `--call-graph dwarf` instead, and limit frequency to 2000 max)
5457

5558
# Generating script for speedscope
5659

5760
`perf` comes with a command `script` that allows to generate formatted data that can be used by other tools like speedscope. In order to produce a meaningful report.
5861

5962
If you want the whole report (with all the threads) simply run:
63+
6064
```
6165
perf script --no-inline > perf.script.data
6266
@@ -69,6 +73,7 @@ If you enabled the JitDump profiler at the node compilation, you need to associa
6973
```
7074
perf inject --jit --input perf.data --output perf.jit.data
7175
```
76+
7277
(verify there is a file jit before with `ls jit*`)
7378

7479
## Only specific thread (optional)
@@ -91,24 +96,25 @@ tokio-runtime-w 16503 2925245.809827: 100010 cpu-clock:pppH:
9196
5623900a6c0c sp_block_builder::runtime_d...all_api_at+0x28c (...get/release/moonbeam)
9297
56238fe47751 <moonbase_runtime::Runtim...>>::execute_in_transaction+0x201 (...get/release/moonbeam)
9398
```
94-
(The thread is `16503`, written on the first line of the block)
9599

100+
(The thread is `16503`, written on the first line of the block)
96101

97102
If your function is used in multiple threads, you should not filter by thread_id and look at `perf report` (documentation to add)
98103

99-
100-
101104
Finally, export the data (with my example):
105+
102106
```
103107
perf script --no-inline --tid 16503 > perf.script.data
104108
```
105109

106110
If you inserted jitdump, use:
111+
107112
```
108113
perf script --no-inline --input perf.jit.data --tid 16503 > perf.script.data
109114
```
110115

111116
You can also filter to remove noise generated by libc and other kernel parts:
117+
112118
```
113119
perf script --no-inline --input perf.jit.data --tid 16503 | awk '
114120
BEGIN { tokio_line = 0; }
@@ -128,19 +134,18 @@ The block production is not manual (at least in normal condition), so it require
128134

129135
Either start the node with your synced chain, or launch a new one with `yarn run launch --chain local --port-prefix 12` (this will launch the node on port ws `12102`)
130136

131-
Open 3 terminals:
132-
1. with the node logs (`tail -f 12102.log` if using local parachain)
133-
2. with the command line ready to perf record (`perf record -F 9999 -p $(ps aux | grep moonbeam | grep 12102 | grep unsafe | tr -s " " | cut -d' ' -f 2) --call-graph fp`)
134-
3. in the tools folder to generate some load
135-
137+
Open 3 terminals:
138+
139+
1. with the node logs (`tail -f 12102.log` if using local parachain)
140+
2. with the command line ready to perf record (`perf record -F 9999 -p $(ps aux | grep moonbeam | grep 12102 | grep unsafe | tr -s " " | cut -d' ' -f 2) --call-graph fp`)
141+
3. in the tools folder to generate some load
136142

137143
You can generate the load in many different way, ex: sending a bunch of request (`yarn ts-node scenarios/flood-evm-transfers.ts --url ws://localhost:12102 --eth-url http://localhost:12101 --amount 2 --count 1000`);
138144

139-
* Step 1: Generate the load
140-
* Step 2: Look at the node logs until 1 block is produced
141-
* Step 3: Start `perf record...` command very quickly after
142-
* Step 4: Wait for the node logs to produce the next block (verify it contains the expected transactions)
143-
* Step 5: Stop the `perf record...` command with \<Ctrl+C\>
145+
- Step 1: Generate the load
146+
- Step 2: Look at the node logs until 1 block is produced
147+
- Step 3: Start `perf record...` command very quickly after
148+
- Step 4: Wait for the node logs to produce the next block (verify it contains the expected transactions)
149+
- Step 5: Stop the `perf record...` command with \<Ctrl+C\>
144150

145151
At this point you should have a `perf.data` file (and a `jit-xxxx.dump` if you used jitdump), follow the `Generating script for speedscope` part.
146-

bug-bounty.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,46 @@
33
The Moonbeam bug bounty program is focused on the Moonriver and Moonbeam Parachains (deployed to Kusama and Polkadot respectively) and dapps. It is focused on preventing:
44

55
Moonbeam/Moonriver:
6-
* Thefts and freezing of principal of any amount
7-
* Thefts and freezing of unclaimed yield of any amount
8-
* Theft of governance funds
9-
* Governance activity disruption
10-
* Network shutdown
6+
7+
- Thefts and freezing of principal of any amount
8+
- Thefts and freezing of unclaimed yield of any amount
9+
- Theft of governance funds
10+
- Governance activity disruption
11+
- Network shutdown
1112

1213
Website and Apps:
13-
* Website goes down
14-
* Leak of user data
15-
* Deletion of user data
16-
* Access to sensitive pages without authorization
14+
15+
- Website goes down
16+
- Leak of user data
17+
- Deletion of user data
18+
- Access to sensitive pages without authorization
1719

1820
https://immunefi.com/bounty/moonbeamnetwork/
1921

2022
**Blockchain and EVM/Precompiles**
2123

22-
| Level | |
23-
| :--- | :--- |
24-
| Critical | up to USD $1,000,000 |
25-
| High | USD $75,000 |
26-
| Medium | USD $20,000 |
27-
| Low | USD $5,000 |
24+
| Level | |
25+
| :------- | :-------------------- |
26+
| Critical | up to USD \$1,000,000 |
27+
| High | USD \$75,000 |
28+
| Medium | USD \$20,000 |
29+
| Low | USD \$5,000 |
2830

2931
**Website and Apps**\*
3032

31-
| Level | |
32-
| :--- | :--- |
33-
| Critical\* | USD $15,000 |
34-
| High | USD $7,500 |
35-
| Medium | USD $2,500 |
36-
| Low | USD $1,000 |
33+
| Level | |
34+
| :--------- | :----------- |
35+
| Critical\* | USD \$15,000 |
36+
| High | USD \$7,500 |
37+
| Medium | USD \$2,500 |
38+
| Low | USD \$1,000 |
3739

38-
\* All web/app bug reports must come with a Proof of Concept (PoC) in order to be considered for a reward.
40+
\* All web/app bug reports must come with a Proof of Concept (PoC) in order to be considered for a reward.
3941

4042
At the discretion of the team, a PoC may be required in order to determine if the bug exists, and if necessary, to calculate the extent of the damage the bug could have if exploited.
4143

4244
Critical vulnerabilities are further capped at 10% of economic damage, with the main consideration being the funds affected in addition to PR and brand considerations, at the discretion of the team. However, there is a minimum of USD 75 000 for Critical bug reports.
4345

44-
The Moonbeam Foundation requires KYC to be done for all bug bounty hunters submitting a report and wanting a reward. The information needed is an ID scan along with a selfie to verify identity.
46+
The Moonbeam Foundation requires KYC to be done for all bug bounty hunters submitting a report and wanting a reward. The information needed is an ID scan along with a selfie to verify identity.
4547

4648
Payouts are handled by the Moonbeam Foundation team directly and are denominated in USD. However, payouts are done in USDT or USDC.

moonbeam-types-bundle/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ a **camelCase** format
1010

1111
A **new version** has been released `[email protected]`.
1212

13-
The default export `typesBundle` has **been removed** to avoid confusion.
13+
The default export `typesBundle` has **been removed** to avoid confusion.
1414

1515
**2 new typesBundles** are available:
1616

17-
* `import { typesBundlePre900 } from "moonbeam-types-bundle"` to use the new naming convention
18-
* `import { typesBundleDeprecated } from "moonbeam-types-bundle"` to keep using old naming convention that isn't camelCase (This will break at runtime 1000)
17+
- `import { typesBundlePre900 } from "moonbeam-types-bundle"` to use the new naming convention
18+
- `import { typesBundleDeprecated } from "moonbeam-types-bundle"` to keep using old naming convention that isn't camelCase (This will break at runtime 1000)
1919

2020
The following package versions have been tested:
2121

@@ -30,6 +30,7 @@ Running the latest TypeScript version will not work.
3030
### Breaking changes in typesBundlePre900
3131

3232
Those types are being changed:
33+
3334
```
3435
AssetRegistrarMetadata: {
3536
...
@@ -62,9 +63,9 @@ Those types are being changed:
6263

6364
## How to upgrade your tools/scripts using moonbeam-types-bundle
6465

65-
*(If your tool/script is not requesting past blocks, you can use the `typesBundleDeprecated`
66-
for now and fully remove it once the network has been upgraded to runtime 900,
67-
around Nov 18th 2021)*
66+
_(If your tool/script is not requesting past blocks, you can use the `typesBundleDeprecated`
67+
for now and fully remove it once the network has been upgraded to runtime 900,
68+
around Nov 18th 2021)_
6869

6970
The following package versions have been tested:
7071

@@ -79,12 +80,12 @@ Running the latest TypeScript version will not work.
7980
Ultimately it is necessary to use the new type naming as the previous one won't be supported, but
8081
you can import `typesBundleDeprecated` to buy yourself some time.
8182

82-
* moonbeam-types-bundle v1.x.x will break on runtime upgrade 900
83-
(planned Thursday 18th November 2021 on Moonriver)
84-
* moonbeam-types-bundle v2.x.x `typesBundleDeprecated` (using previous naming case)
85-
will **break on runtime 1000**
86-
* **moonbeam-types-bundle v2.x.x** `typesBundlePre900` (using new naming case)
87-
will be **maintained**.
83+
- moonbeam-types-bundle v1.x.x will break on runtime upgrade 900
84+
(planned Thursday 18th November 2021 on Moonriver)
85+
- moonbeam-types-bundle v2.x.x `typesBundleDeprecated` (using previous naming case)
86+
will **break on runtime 1000**
87+
- **moonbeam-types-bundle v2.x.x** `typesBundlePre900` (using new naming case)
88+
will be **maintained**.
8889

8990
### Step 1: Install new package
9091

pallets/author-mapping/src/benchmarks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#![cfg(feature = "runtime-benchmarks")]
1818

1919
//! Benchmarking
20-
use crate::{BalanceOf, Call, Config, Pallet};
20+
use crate::{BalanceOf, Call, Config, KeysWrapper, Pallet};
2121
use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
2222
use frame_support::{
2323
assert_ok,

tests/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Also don't forget to build `moonbeam-types-bundle` with `yarn run build` in that
9393

9494
Then run `npm run para-test-no-ci` to run the parachain tests in the para-tests-no-ci folder.
9595

96-
This script is prefixed with `DEBUG=test:substrateEvents ` to log events during the tests.
96+
This script is prefixed with `DEBUG=test:substrateEvents` to log events during the tests.
9797

9898
## Write Tests
9999

tests/para-tests-no-ci/test-xcm-para.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ describeParachain(
159159
// Sets default xcm version to relay
160160
await setDefaultVersionRelay(relayOne, aliceRelay);
161161

162-
let beforeAliceRelayBalance = (
163-
(await relayOne.query.system.account(aliceRelay.address)) as any
164-
).data.free;
162+
let beforeAliceRelayBalance = ((await relayOne.query.system.account(
163+
aliceRelay.address
164+
)) as any).data.free;
165165

166166
let reserveTrasnsferAssetsCall = relayOne.tx.xcmPallet.reserveTransferAssets(
167167
{ V1: { parents: new BN(0), interior: { X1: { Parachain: new BN(1000) } } } },
@@ -192,9 +192,9 @@ describeParachain(
192192
// Wait for parachain block to have been emited
193193
await waitOneBlock(parachainOne, 2);
194194
// about 1k should have been substracted from AliceRelay
195-
let afterAliceRelayBalance = (
196-
(await relayOne.query.system.account(aliceRelay.address)) as any
197-
).data.free;
195+
let afterAliceRelayBalance = ((await relayOne.query.system.account(
196+
aliceRelay.address
197+
)) as any).data.free;
198198

199199
expect(afterAliceRelayBalance.toString()).to.eq(expectedAfterRelayBalance.toString());
200200

@@ -367,9 +367,9 @@ describeParachain(
367367
// Sets default xcm version to relay
368368
await setDefaultVersionRelay(relayOne, aliceRelay);
369369

370-
let beforeAliceRelayBalance = (
371-
(await relayOne.query.system.account(aliceRelay.address)) as any
372-
).data.free;
370+
let beforeAliceRelayBalance = ((await relayOne.query.system.account(
371+
aliceRelay.address
372+
)) as any).data.free;
373373

374374
let reserveTrasnsferAssetsCall = relayOne.tx.xcmPallet.reserveTransferAssets(
375375
{ V1: { parents: new BN(0), interior: { X1: { Parachain: new BN(1000) } } } },
@@ -397,9 +397,9 @@ describeParachain(
397397
// Wait for parachain block to have been emited
398398
await waitOneBlock(parachainOne, 2);
399399

400-
let afterAliceRelayBalance = (
401-
(await relayOne.query.system.account(aliceRelay.address)) as any
402-
).data.free;
400+
let afterAliceRelayBalance = ((await relayOne.query.system.account(
401+
aliceRelay.address
402+
)) as any).data.free;
403403

404404
expect(afterAliceRelayBalance.toString()).to.eq(expectedAfterRelayBalance.toString());
405405

0 commit comments

Comments
 (0)