Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/779-build-arm-binaries-and-con…
Browse files Browse the repository at this point in the history
…tainers-for-linux-and-macos' into 779-build-arm-binaries-and-containers-for-linux-and-macos
  • Loading branch information
mattheworris committed Mar 12, 2024
2 parents 05760de + 27e2bc2 commit b01255f
Show file tree
Hide file tree
Showing 44 changed files with 1,451 additions and 1,080 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/common/rust-cross/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ runs:
- name: Determine whether we need to cross-compile
id: determine-cross-compile
shell: bash
run: set-cross-compile.sh ${{ inputs.target }}
run: |
./.github/workflows/common/rust-cross/set-cross-compile.sh ${{ inputs.target }}
- name: Install toolchain
shell: bash
# uses: dtolnay/rust-toolchain@master
Expand All @@ -56,10 +57,12 @@ runs:
rustup toolchain install ${{ inputs.toolchain }}
rustup target add ${{ inputs.target }}
rustup default ${{ inputs.toolchain }}
rustup target add wasm32-unknown-unknown --toolchain ${{ inputs.toolchain }}
rustup show
- name: Determine cross version
id: determine-cross-version
shell: bash
run: determine-cross-version.sh "${{ inputs.cross-version }}"
run: ./.github/workflows/common/rust-cross/determine-cross-version.sh "${{ inputs.cross-version }}"
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
Expand All @@ -68,7 +71,7 @@ runs:
- name: Set directory for installing cross
id: set-cross-dir
shell: bash
run: set-cross-dir.sh
run: ./.github/workflows/common/rust-cross/set-cross-dir.sh
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
- name: Cache cross
id: cache-cross
Expand All @@ -79,14 +82,14 @@ runs:
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
- name: Install cross if cross-compiling (*nix)
shell: bash
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
run: ./.github/workflows/common/rust-cross/install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true' }}
env:
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
- name: Set build command
id: set-build-command
shell: bash
run: set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
run: ./.github/workflows/common/rust-cross/set-build-command.sh ${{ steps.set-cross-dir.outputs.cross-dir }}
- name: Run tests (*nix)
working-directory: ${{ inputs.working-directory }}
shell: bash
Expand Down Expand Up @@ -118,6 +121,6 @@ runs:
- name: Strip binary
working-directory: ${{ inputs.working-directory }}
shell: bash
run: strip-binary.sh ${{ inputs.target }}
run: ./.github/workflows/common/rust-cross/strip-binary.sh ${{ inputs.target }}
# strip doesn't work with cross-arch binaries on Linux or Windows.
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env:
RELEASE_BRANCH_NAME: release-${{github.event.inputs.release-version || github.ref_name}}
LATEST_FULL_RELEASE_TAG: _LATEST-FULL-RELEASE
TEST_RUN: ${{startsWith(github.event.inputs.release-version || github.ref_name, 'v0.0.1')}}
RUST_TOOLCHAIN: "stable" # Match to /rust-toolchain.toml
RUST_TOOLCHAIN: "1.76.0" # Match to /rust-toolchain.toml

jobs:
validate-release-version:
Expand Down
37 changes: 31 additions & 6 deletions .github/workflows/verify-pr-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,17 @@ jobs:
# needs: changes
# if: needs.changes.outputs.rust == 'true'
name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
# runs-on: ${{ matrix.platform.os }}
runs-on: self-hosted
runs-on: [self-hosted, Linux, X64, build, v2]
container: ghcr.io/libertydsnp/frequency/ci-base-image:latest
env:
CROSS_CONTAINER_IN_CONTAINER: true
strategy:
fail-fast: false
matrix:
platform:
- os_name: Linux-aarch64
os: ubuntu-22.04
target: aarch64-unknown-linux-musl
target: aarch64-unknown-linux-gnu
binary: frequency
- os_name: Linux-x86_64
os: ubuntu-22.04
Expand All @@ -135,15 +137,38 @@ jobs:
toolchain:
- stable
steps:
- run: echo "Cross Build ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}"
- name: Cross Build Worrkflow
run: echo "Cross Build ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}"
# TODO: Don't need this if we use ci-base-image
# - name: Install Required Packages for Linux
# if: matrix.platform.os_name == 'Linux-x86_64' || matrix.platform.os_name == 'Linux-aarch64'
# run: |
# sudo apt-get update
# sudo apt install -y protobuf-compiler libclang-dev clang cmake
# export PROTOC=/usr/bin/protoc
# echo "PROTOC=$PROTOC" >> $GITHUB_ENV
# echo '********************************************************'
# echo $PROTOC
# protoc --version
# echo '********************************************************'
# - name: Install Required Packages for macOS
# if: matrix.platform.os_name == 'macOS-x86_64' || matrix.platform.os_name == 'macOS-aarch64'
# run: |
# brew install protobuf
# export PROTOC=/opt/homebrew/bin/protoc
# echo "PROTOC=$PROTOC" >> $GITHUB_ENV
# echo '********************************************************'
# echo $PROTOC
# protoc --version
# echo '********************************************************'
- uses: actions/checkout@v4
- name: Build Binary
uses: ./.github/workflows/common/rust-cross
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--release --features frequency-no-relay"
args: "--features frequency-no-relay"
strip: true
# - name: Rename Binary (linux and macos)
# run: mv target/${{ matrix.platform.target }}/release/frequency ${{ matrix.platform.binary }}
Expand Down Expand Up @@ -786,7 +811,7 @@ jobs:
steps:
- name: Set Env Vars
run: |
echo "EXPECTED_GENESIS_STATE_PASEO=0x000000000000000000000000000000000000000000000000000000000000000000d1912c5cd40e89fe2f4e1391801d17f6905cf84d961cbf4abb49139f03c2d85503170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "EXPECTED_GENESIS_STATE_PASEO=0x000000000000000000000000000000000000000000000000000000000000000000805f6ddb6879aa31316a38c149e52ffe4e9f2a193e966ddcf3b6a2cb5846e96903170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "EXPECTED_GENESIS_STATE_ROCOCO=0x000000000000000000000000000000000000000000000000000000000000000000e3495742b019f5ad49dff7de4040bc965b75eaf46769c24db1027d4ff86fc92703170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "EXPECTED_GENESIS_STATE_MAINNET=0x000000000000000000000000000000000000000000000000000000000000000000393a2a0f7778716d006206c5a4787cbf2ea3b26a67379b7a38ee54519d7fd4be03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c11131400" >> $GITHUB_ENV
echo "BIN_FILENAME_TESTNET=frequency.testnet.frequency-testnet.pr" >> $GITHUB_ENV
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions Cross.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[build]
dockerfile = "./tools/ci/docker/aarch64-unknown-linux-gnu.dockerfile"

# [target.aarch64-unknown-linux-gnu]
# pre-build = [
# "apt-get update && apt-get install -y protobuf-compiler",
# "rm -rf /var/lib/apt/lists/*",
# ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ format:
lint:
cargo +nightly-2024-03-01 fmt --check
SKIP_WASM_BUILD=1 env -u RUSTFLAGS cargo clippy --features runtime-benchmarks,frequency-lint-check -- -D warnings
RUSTDOCFLAGS="--enable-index-page --check -Zunstable-options" cargo +nightly-2024-03-01 doc --no-deps --features frequency
RUSTC_BOOTSTRAP=1 RUSTDOCFLAGS="--enable-index-page --check -Zunstable-options" cargo doc --no-deps --features frequency

lint-audit:
cargo deny check -c deny.toml
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Frequency is a [Polkadot](https://www.parity.io/technologies/polkadot) parachain

## Hardware

We run benchmarks with and recommend the same [reference hardware specified by Parity for Validators](https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware).
Benchmarks are run on an AWS `c6i.4xlarge` and recommend collators have generally the same [reference hardware specified by Parity for Validators](https://wiki.polkadot.network/docs/maintain-guides-how-to-validate-polkadot#reference-hardware).

Non-Collator nodes may have less power, but low memory configurations may lead to out of memory errors.

# Build

Expand Down
2 changes: 1 addition & 1 deletion e2e/package-lock.json

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

34 changes: 34 additions & 0 deletions e2e/scenarios/grantDelegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ describe('Delegation Scenario Tests', function () {
assert.notEqual(revokeDelegationEvent, undefined, 'should have returned DelegationRevoked event');
assert.deepEqual(revokeDelegationEvent?.data.providerId, providerId, 'provider ids should be equal');
assert.deepEqual(revokeDelegationEvent?.data.delegatorId, msaId, 'delegator ids should be equal');
const delegation = await ExtrinsicHelper.apiPromise.query.msa.delegatorAndProviderToDelegation(msaId, providerId);
assert(delegation.isSome);
assert.notEqual(delegation.unwrap().revokedAt.toNumber(), 0, 'delegation revokedAt should not be zero');
});

it('should fail to revoke a delegation that has already been revoked (InvalidDelegation)', async function () {
Expand Down Expand Up @@ -350,6 +353,37 @@ describe('Delegation Scenario Tests', function () {
});
});

it('should re-grant a previously revoked delegation', async function () {
const delegatorKeys = createKeys();
const payload = await generateDelegationPayload({ authorizedMsaId: providerId, schemaIds: [schemaId] });
const addProviderData = ExtrinsicHelper.api.registry.createType('PalletMsaAddProvider', payload);
const op = ExtrinsicHelper.createSponsoredAccountWithDelegation(
delegatorKeys,
providerKeys,
signPayloadSr25519(delegatorKeys, addProviderData),
payload
);
const { target: msaEvent } = await op.fundAndSend(fundingSource);
const newMsaId = msaEvent?.data.msaId;
assert.notEqual(newMsaId, undefined, 'should have returned an MSA');
await assert.doesNotReject(ExtrinsicHelper.revokeDelegationByProvider(newMsaId!, providerKeys).signAndSend());

await assert.doesNotReject(
ExtrinsicHelper.grantDelegation(
delegatorKeys,
providerKeys,
signPayloadSr25519(delegatorKeys, addProviderData),
payload
).signAndSend()
);
const delegation = await ExtrinsicHelper.apiPromise.query.msa.delegatorAndProviderToDelegation(
newMsaId!,
providerId
);
assert(delegation.isSome, 'delegation should exist');
assert.equal(delegation.unwrap().revokedAt.toNumber(), 0, 'delegation revokedAt should be zero');
});

it('should revoke a delegation by delegator and retire msa', async function () {
const delegatorKeys = createKeys();
const payload = await generateDelegationPayload({ authorizedMsaId: providerId, schemaIds: [schemaId] });
Expand Down
71 changes: 42 additions & 29 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,54 +73,55 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"frequency" => return Ok(Box::new(chain_spec::frequency::load_frequency_spec())),
#[cfg(feature = "frequency-no-relay")]
"dev" | "frequency-no-relay" =>
return Ok(Box::new(chain_spec::frequency_rococo::development_config())),
return Ok(Box::new(chain_spec::frequency_dev::development_config())),
#[cfg(feature = "frequency-local")]
"frequency-rococo-local" =>
return Ok(Box::new(chain_spec::frequency_rococo::local_rococo_testnet_config())),
#[cfg(feature = "frequency-local")]
"frequency-paseo-local" =>
return Ok(Box::new(chain_spec::frequency_paseo::local_paseo_testnet_config())),
#[cfg(feature = "frequency-testnet")]
"frequency-paseo" => return Ok(Box::new(chain_spec::frequency_paseo::frequency_paseo_testnet())),
"frequency-testnet" | "frequency-paseo" | "paseo" | "testnet" =>
return Ok(Box::new(chain_spec::frequency_paseo::load_frequency_paseo_spec())),
#[cfg(feature = "frequency-testnet")]
"frequency-testnet" | "frequency-rococo" | "rococo" | "testnet" =>
"frequency-rococo" | "rococo" =>
return Ok(Box::new(chain_spec::frequency_rococo::load_frequency_rococo_spec())),
path => {
if path.is_empty() {
if cfg!(feature = "frequency") {
#[cfg(feature = "frequency")]
{
return Ok(Box::new(chain_spec::frequency::load_frequency_spec()))
return Ok(Box::new(chain_spec::frequency::load_frequency_spec()));
}
#[cfg(not(feature = "frequency"))]
return Err("Frequency runtime is not available.".into())
return Err("Frequency runtime is not available.".into());
} else if cfg!(feature = "frequency-no-relay") {
#[cfg(feature = "frequency-no-relay")]
{
return Ok(Box::new(chain_spec::frequency_rococo::development_config()))
return Ok(Box::new(chain_spec::frequency_dev::development_config()));
}
#[cfg(not(feature = "frequency-no-relay"))]
return Err("Frequency Development (no relay) runtime is not available.".into())
return Err("Frequency Development (no relay) runtime is not available.".into());
} else if cfg!(feature = "frequency-local") {
#[cfg(feature = "frequency-local")]
{
return Ok(Box::new(
chain_spec::frequency_paseo::local_paseo_testnet_config(),
))
));
}
#[cfg(not(feature = "frequency-local"))]
return Err("Frequency Local runtime is not available.".into())
return Err("Frequency Local runtime is not available.".into());
} else if cfg!(feature = "frequency-testnet") {
#[cfg(feature = "frequency-testnet")]
{
return Ok(Box::new(
chain_spec::frequency_rococo::load_frequency_rococo_spec(),
))
chain_spec::frequency_paseo::load_frequency_paseo_spec(),
));
}
#[cfg(not(feature = "frequency-testnet"))]
return Err("Frequency Rococo runtime is not available.".into())
return Err("Frequency Paseo runtime is not available.".into());
} else {
return Err("No chain spec is available.".into())
return Err("No chain spec is available.".into());
}
}
let path_buf = std::path::PathBuf::from(path);
Expand All @@ -129,48 +130,50 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
if ChainIdentity::Frequency == spec.identify() {
#[cfg(feature = "frequency")]
{
return Ok(Box::new(chain_spec::frequency::ChainSpec::from_json_file(path_buf)?))
return Ok(Box::new(chain_spec::frequency::ChainSpec::from_json_file(
path_buf,
)?));
}
#[cfg(not(feature = "frequency"))]
return Err("Frequency runtime is not available.".into())
return Err("Frequency runtime is not available.".into());
} else if ChainIdentity::FrequencyRococo == spec.identify() {
#[cfg(feature = "frequency-testnet")]
{
return Ok(Box::new(chain_spec::frequency_rococo::ChainSpec::from_json_file(
path_buf,
)?))
)?));
}
#[cfg(not(feature = "frequency-testnet"))]
return Err("Frequency Rococo runtime is not available.".into())
return Err("Frequency Rococo runtime is not available.".into());
} else if ChainIdentity::FrequencyPaseo == spec.identify() {
#[cfg(feature = "frequency-testnet")]
{
return Ok(Box::new(chain_spec::frequency_rococo::ChainSpec::from_json_file(
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
path_buf,
)?))
)?));
}
#[cfg(not(feature = "frequency-testnet"))]
return Err("Frequency Paseo runtime is not available.".into())
return Err("Frequency Paseo runtime is not available.".into());
} else if ChainIdentity::FrequencyLocal == spec.identify() {
#[cfg(feature = "frequency-local")]
{
return Ok(Box::new(chain_spec::frequency_rococo::ChainSpec::from_json_file(
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
path_buf,
)?))
)?));
}
#[cfg(not(feature = "frequency-local"))]
return Err("Frequency Local runtime is not available.".into())
return Err("Frequency Local runtime is not available.".into());
} else if ChainIdentity::FrequencyDev == spec.identify() {
#[cfg(feature = "frequency-no-relay")]
{
return Ok(Box::new(chain_spec::frequency_rococo::ChainSpec::from_json_file(
return Ok(Box::new(chain_spec::frequency_paseo::ChainSpec::from_json_file(
path_buf,
)?))
)?));
}
#[cfg(not(feature = "frequency-no-relay"))]
return Err("Frequency Dev (no relay) runtime is not available.".into())
return Err("Frequency Dev (no relay) runtime is not available.".into());
} else {
return Err("Unknown chain spec.".into())
return Err("Unknown chain spec.".into());
}
},
}
Expand Down Expand Up @@ -251,7 +254,17 @@ impl SubstrateCli for RelayChainCli {
}

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter()).load_spec(id)
match id {
// TODO: Remove once on a Polkadot-SDK with Paseo-Local
#[cfg(feature = "frequency-local")]
"paseo-local" => return Ok(Box::new(chain_spec::frequency_paseo::load_paseo_local_spec())),
// TODO: Remove once on a Polkadot-SDK with Paseo
#[cfg(feature = "frequency-testnet")]
"paseo" => return Ok(Box::new(chain_spec::frequency_paseo::load_paseo_spec())),
_ =>
return polkadot_cli::Cli::from_iter([RelayChainCli::executable_name()].iter())
.load_spec(id),
}
}
}

Expand Down Expand Up @@ -347,7 +360,7 @@ pub fn run() -> Result<()> {
} else {
return Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into())
.into());
},
BenchmarkCmd::Block(cmd) => runner.sync_run(|config| {
let partials = new_partial(&config, false)?;
Expand Down
Loading

0 comments on commit b01255f

Please sign in to comment.