Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/LibertyDSNP/frequency into …
Browse files Browse the repository at this point in the history
…942-capacity-replace-currency-trait-with-fungible-trait
  • Loading branch information
Matthew Orris committed Dec 5, 2023
2 parents 9384ed3 + bd32d04 commit 57cd323
Show file tree
Hide file tree
Showing 26 changed files with 2,807 additions and 617 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/common/codecov/action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
name: Run Generation of Code Coverage
description: Runs cargo llvm-cov
description: Runs cargo grcov
inputs:
code-cov-token:
description: "codecov token"
required: true
runs:
using: "composite"
steps:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install grcov
shell: bash
run: cargo +nightly-2023-07-13 install grcov
- name: Build
shell: bash # Limited to 12 threads max
run: cargo +nightly-2023-07-13 build -j 12 --features frequency-lint-check
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
- name: Test
shell: bash # Limited to 12 threads max
run: cargo +nightly-2023-07-13 test -j 12 --features frequency-lint-check
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
# There are a lot of things ignored here to make it all work
# See the grcov docs for more information
# excl rpc traits, and error enums
# Only one of excl start and stop are allowed.
- name: Generate code coverage
shell: bash
run: |
cargo llvm-cov -v --no-fail-fast --workspace --lcov --output-path lcov.info \
--ignore-filename-regex "^.*\/(node\/|runtime\/|mock\.rs|weights(\.rs)?|benchmarking\.rs|runtime-api/src/lib\.rs).*$" \
--exclude "frequency,frequency-cli,frequency-runtime,frequency-service" \
--features frequency-lint-check
grcov . -s . --binary-path ./target/debug/ -t lcov \
--ignore-not-existing \
--excl-start '(pub enum Error<T> \{|#\[rpc\()' \
--excl-stop '\s*}$' \
--ignore "target/*" \
--ignore "node/*" \
--ignore "runtime/*" \
--ignore "**/*weights.rs" \
--ignore "**/benchmark*.rs" \
--ignore "**/*tests.rs" \
--ignore "**/tests/*.rs" \
--ignore "**/*mock.rs" \
--ignore "**/*runtime-api/src/lib.rs" \
--ignore "*github.com*" \
--ignore "*libcore*" \
--ignore "*rustc*" \
--ignore "*liballoc*" \
--ignore "*cargo*" \
-o ./target/debug/lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4.0.0-beta.3
with:
files: lcov.info
token: ${{inputs.code-cov-token}}
files: ./target/debug/lcov.info
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
6 changes: 3 additions & 3 deletions .github/workflows/merge-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ jobs:

calc-code-coverage:
name: Merge - Calculate Code Coverage
# This job currently fails on EKS runners and must be run on standalone until
# https://www.pivotaltracker.com/story/show/185045668 is resolved.
runs-on: [self-hosted, Linux, X64, build, v1]
runs-on: [self-hosted, Linux, X64, build, v2]
container: ghcr.io/libertydsnp/frequency/ci-base-image:1.0.0
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Generate and Upload Code Coverage
id: codecov
uses: ./.github/workflows/common/codecov
with:
code-cov-token: ${{ secrets.CODECOV_TOKEN }}

publish-ci-base-image:
needs: changes
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/verify-pr-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ jobs:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Calculate Code Coverage
# This job currently fails on EKS runners and must be run on standalone until
# https://www.pivotaltracker.com/story/show/185045668 is resolved.
runs-on: [self-hosted, Linux, X64, build, v1]
runs-on: [self-hosted, Linux, X64, build, v2]
container: ghcr.io/libertydsnp/frequency/ci-base-image:1.0.0
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Generate and Upload Code Coverage
id: codecov
uses: ./.github/workflows/common/codecov
with:
code-cov-token: ${{ secrets.CODECOV_TOKEN }}

# Workaround to handle skipped required check inside matrix
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ Please check out [the information here](./CONTRIBUTING.md).
# Security Issue Reporting
Do you know of an on-chain vulnerability (or possible one) that can lead to economic loss, privacy loss, or instability of the network?
Please report it to [[email protected]](mailto:[email protected])
Please report it by following the steps mentioned in [here](./SECURITY.md).
# Additional Resources
Expand Down
91 changes: 91 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Security Policy

We appreciate the efforts of security researchers and the broader community in helping us maintain a
secure environment for our users. If you discover a security vulnerability, we kindly request that
you report it to us privately before disclosing it publicly. This allows us to address the issue
promptly and protect our users.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Instead, please report the vulnerability via [https://github.com/LibertyDSNP/frequency/security/advisories/new](https://github.com/LibertyDSNP/frequency/security/advisories/new).

Alternatively, you can send email to [[email protected]](mailto:[email protected]). If
possible, encrypt your message with our PGP key; you can download it from [OpenGPG key server](https://keys.openpgp.org/vks/v1/by-fingerprint/0E50AE7CFD8195999CF45370B766E94411B9B734)
or copy from below.

You should receive a response within 48 hours. If for some reason you do not, please follow up via
email to ensure we received your original message.

## Report details
Please include the requested information listed below (as much as you can provide) to help us better
understand the nature and scope of the possible issue:

- Your name and contact information
- Description of the vulnerability
- Attack scenario (if any)
- Step-by-step instructions to reproduce the issue
- Any other details

**Reminder: This process is only for security related vulnerabilities and if this is a generic issue
(no security implications) with Frequency or Polkadot-sdk or any other dependencies please open a
regular GitHub issue.**


## Plaintext PGP Key

```
-----BE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VBvGhbRX6j/+J0CH0Ya9lGJmhVyb9My/YmusjjPRiEngyjcXN0lv
G9rrqFVwQLoGanF/YZE8VOPrC33NreocuF7ClK8Kkvwow71254inUYIw6VJVrwMW
97QYvDAJ8iRLh6fY2W1JaLNbJS89OcDfq8yaHhQlheT2moFONcx+IxrFQu/HEqGn
6DLCoYnNrHtVH2ZfRvE3T0dzJ/NtTr4QrQARAQABiQI8BBgBCAAmFiEEDlCufP2B
lZmc9FNwt2bpRBG5tzQFAmVt5AsCGwwFCQfSlgwACgkQt2bpRBG5tzQpWRAAirJZ
I1CQzk4+tYdFzPx9dWgvsO/J+y+tM3HJdeLKzBIeQGGJKvAmQC6RyMhhXwapznm8
qS+KUj3/riBLuGRni1OJLABR0W+zilsVA9RMkAHdK8jGCCRjB7+HSAXKcN1k297j
mJwZstQuWlWOU315v2ebLSLW+SwBvHQVFnWRQZqu8oNm0uVWQBzZ0jAzoMXi/KDm
156L9CFowcHVwCHzkdgyQ6h5XxJfTwGlX5Kwed8SQD1eavRHiFstl6S4bqG9+xlB
YGFIKCMOSNO5DO+76NiqcgZb2huZ+9WHdcYB911j766uRHqPIAinWOARPYmtaLoT
kl96hi50EmtmFa0Roa5otbnw4TAXvlSsXXLqc30XoI3gKhnMLY846HVsU/PjCvgq
5WFDxT+fovLfd2IUfmSri8zGFdlAPSyRa1jPp9vtEeelKeMTTElRiz2e6LYMkhmF
YAfw4o1Gy+Io+Eu/Gu+CXfQuGRBU/sbIBwfe/mlk1e0NOO7u4sx5Q0QaRvl/XZ/P
oyjZstz48mfnFOTGbWRaX45rs/eBLYTggAFiNZXUrA0vH4iAxN1o+IsEzmnGFfRb
hVu9J6odTCsucHDKzqhPxbJdPP4rS9yKHwoYmilZq9NzwkX88raA7pWRX4tp6KPe
GK223m2Hg28/Y6p6JVrKZ/3w/Q8QFMkHFOeOSMs=
=oBQV
-----END PGP PUBLIC KEY BLOCK-----
```
16 changes: 16 additions & 0 deletions common/primitives/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ use utils::*;
/// Schema Id is the unique identifier for a Schema
pub type SchemaId = u16;

/// Schema version number
pub type SchemaVersion = u8;

/// Types of modeling in which a message payload may be defined
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Copy, Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq, MaxEncodedLen)]
Expand Down Expand Up @@ -130,6 +133,19 @@ impl SchemaSettings {
}
impl_codec_bitflags!(SchemaSettings, u16, SchemaSetting);

/// RPC Response from a schema name query
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[derive(Clone, Encode, Decode, PartialEq, Debug, TypeInfo, Eq)]
pub struct SchemaVersionResponse {
/// Schema name in following format: namespace.descriptor
#[cfg_attr(feature = "std", serde(with = "as_string"))]
pub schema_name: Vec<u8>,
/// The version for this schema
pub schema_version: SchemaVersion,
/// The unique identifier for this Schema
pub schema_id: SchemaId,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
47 changes: 47 additions & 0 deletions e2e/scaffolding/extrinsicHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,29 @@ export class ExtrinsicHelper {
);
}

/** Schema v3 Extrinsics */
public static createSchemaV3(
keys: KeyringPair,
model: any,
modelType: 'AvroBinary' | 'Parquet',
payloadLocation: 'OnChain' | 'IPFS' | 'Itemized' | 'Paginated',
grant: ('AppendOnly' | 'SignatureRequired')[],
schemaNme: string | null
) {
return new Extrinsic(
() =>
ExtrinsicHelper.api.tx.schemas.createSchemaV3(
JSON.stringify(model),
modelType,
payloadLocation,
grant,
schemaNme
),
keys,
ExtrinsicHelper.api.events.schemas.SchemaCreated
);
}

/** Generic Schema Extrinsics */
public static createSchemaWithSettingsGov(
keys: KeyringPair,
Expand All @@ -375,6 +398,30 @@ export class ExtrinsicHelper {
);
}

/** Generic Schema Extrinsics v2 */
public static createSchemaWithSettingsGovV2(
keys: KeyringPair,
model: any,
modelType: 'AvroBinary' | 'Parquet',
payloadLocation: 'OnChain' | 'IPFS' | 'Itemized' | 'Paginated',
grant: 'AppendOnly' | 'SignatureRequired',
schemaName: string | null
) {
return new Extrinsic(
() =>
ExtrinsicHelper.api.tx.schemas.createSchemaViaGovernanceV2(
keys.publicKey,
JSON.stringify(model),
modelType,
payloadLocation,
[grant],
schemaName
),
keys,
ExtrinsicHelper.api.events.schemas.SchemaCreated
);
}

/** Get Schema RPC */
public static getSchema(schemaId: u16): Promise<Option<SchemaResponse>> {
return ExtrinsicHelper.apiPromise.rpc.schemas.getBySchemaId(schemaId);
Expand Down
17 changes: 17 additions & 0 deletions e2e/scaffolding/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,20 @@ export async function assertAddNewKey(
assertEvent(eventMap, 'system.ExtrinsicSuccess');
assertEvent(eventMap, 'msa.PublicKeyAdded');
}

export function generateSchemaPartialName(length: number): string {
let result = '';
const characters = 'abcdefghijklmnopqrstuvwxyz-';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
const randomChar = characters.charAt(Math.floor(Math.random() * charactersLength));
if ((counter == 0 || counter == length - 1) && randomChar === '-') {
// avoid creating invalid name
continue;
}
result += randomChar;
counter += 1;
}
return result;
}
Loading

0 comments on commit 57cd323

Please sign in to comment.