Skip to content

Commit

Permalink
Merge branch 'main' into refactor/pro-1160/remove-side-side-map
Browse files Browse the repository at this point in the history
  • Loading branch information
Janislav committed Feb 13, 2024
2 parents 5aa4e57 + 27d37c0 commit 27f29dc
Show file tree
Hide file tree
Showing 24 changed files with 295 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_02_retrieve-bins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
./ci/scripts/check_binary_version.sh ./chainflip-cli ${{ github.ref_name }}
- name: Re-upload binary artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-backend-bin-ubuntu-${{ matrix.ubuntu_version }}
path: |
Expand All @@ -64,7 +64,7 @@ jobs:
generate-genesis-keys
- name: Re-upload runtime artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-node-runtime-production
path: |
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/_20_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
sccache --show-stats
- name: Upload binary artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: ${{ inputs.upload-name }}-ubuntu-${{ matrix.ubuntu_version }}
path: |
Expand All @@ -59,8 +59,9 @@ jobs:
./target/${{ inputs.binary-subdir }}/chainflip-ingress-egress-tracker
- name: Upload runtime artifacts
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
if: ${{ matrix.ubuntu_version == '22.04' }} # Only upload runtime once as it is the same for both versions
with:
name: chainflip-node-runtime-${{ inputs.profile }}-ubuntu-${{ matrix.ubuntu_version }}
name: chainflip-node-runtime-${{ inputs.profile }}
path: |
./target/${{ inputs.binary-subdir }}/wbuild/state-chain-runtime/state_chain_runtime*.wasm
8 changes: 4 additions & 4 deletions .github/workflows/_24_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download binaries 📥
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-22.04

Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
- name: Upload image 📤
if: inputs.save_tags != ''
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-backend-private-images
path: private
Expand All @@ -176,7 +176,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download binaries 📥
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-22.04

Expand Down Expand Up @@ -234,7 +234,7 @@ jobs:
- name: Upload image 📤
if: inputs.save_tags != ''
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-backend-public-images
path: public
4 changes: 2 additions & 2 deletions .github/workflows/_25_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download binaries from same run
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-${{ matrix.ubuntu_version }}
path: ./target/release
Expand All @@ -45,7 +45,7 @@ jobs:
cargo deb -v --no-build --no-strip -p chainflip-lp-api --deb-revision "${{ steps.get-date.outputs.date }}"
- name: Upload packages
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-backend-packages-ubuntu-${{ matrix.ubuntu_version }}
path: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/_30_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download packages
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-packages-ubuntu-${{ matrix.ubuntu_version }}
path: packages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_40_post_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
npm install -g wscat
- name: Download binaries 📥
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-22.04

Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- name: Upload Localnet Logs 💾
if: always()
continue-on-error: true
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: localnet-logs
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/_50_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
echo "RELEASE_DIR=chainflip_${{ github.ref_name }}_ubuntu_${{ matrix.ubuntu_version }}_amd64" >> $GITHUB_ENV
- name: Download binaries
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-${{ matrix.ubuntu_version }}
path: ${{ env.RELEASE_DIR }}
Expand All @@ -33,7 +33,7 @@ jobs:
run: tar -czf ${{ env.RELEASE_DIR }}.tar.gz ${{ env.RELEASE_DIR }}

- name: Upload binaries
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-backend-bin
path: ${{ env.RELEASE_DIR }}.tar.gz
Expand All @@ -47,7 +47,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download binaries
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/_60_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download binaries
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-bin-ubuntu-22.04
path: assets/bin
Expand All @@ -33,25 +33,25 @@ jobs:
rm -f assets/bin/generate-genesis-keys
- name: Download packages
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-packages-ubuntu-22.04
path: assets/debian

- name: Download runtime
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-node-runtime-production
path: assets/runtime

- name: Download public images
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-public-images
path: assets/docker/public

- name: Download private images
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-backend-private-images
path: assets/docker/private
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
sccache --show-stats
- name: Upload chainflip-node binary artifact with benchmarks
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
with:
name: chainflip-node-ubuntu-${{ matrix.ubuntu_version }}-benchmarks-${{ matrix.profile }}
path: |
Expand All @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

- name: Download previously built binaries
uses: actions/download-artifact@7a1cd3216ca9260cd8022db641d960b1db4d1be4
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a
with:
name: chainflip-node-ubuntu-${{ matrix.ubuntu_version }}-benchmarks-${{ matrix.profile }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ inputs.upgrade-to-workflow-name }}
name: chainflip-node-runtime-try-runtime-ubuntu-22.04
name: chainflip-node-runtime-try-runtime
path: main-runtime
commit: ${{ inputs.upgrade-to-commit }}

Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion engine/src/dot/retry_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ impl DotRetryRpcApi for DotRetryRpcClient {
) -> anyhow::Result<PolkadotHash> {
let log = RequestLog::new(
"submit_raw_encoded_extrinsic".to_string(),
Some(format!("{encoded_bytes:?}")),
Some(format!("0x{}", hex::encode(&encoded_bytes[..]))),
);
self.rpc_retry_client
.request_with_limit(
Expand Down
2 changes: 1 addition & 1 deletion engine/src/witness/dot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn proxy_addeds(
continue
}

tracing::info!("Witnessing ProxyAdded. new delegatee: {delegatee:?} at block number {block_number} and extrinsic_index; {extrinsic_index}");
tracing::info!("Witnessing ProxyAdded. new delegatee: {delegatee} at block number {block_number} and extrinsic_index; {extrinsic_index}");

extrinsic_indices.insert(extrinsic_index);
}
Expand Down
2 changes: 1 addition & 1 deletion state-chain/pallets/cf-threshold-signature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ pub enum KeyRotationStatus<T: Config<I>, I: 'static = ()> {
},
}

pub const PALLET_VERSION: StorageVersion = StorageVersion::new(4);
pub const PALLET_VERSION: StorageVersion = StorageVersion::new(5);

const THRESHOLD_SIGNATURE_RESPONSE_TIMEOUT_DEFAULT: u32 = 10;
const KEYGEN_CEREMONY_RESPONSE_TIMEOUT_BLOCKS_DEFAULT: u32 = 90;
Expand Down
8 changes: 6 additions & 2 deletions state-chain/pallets/cf-threshold-signature/src/migrations.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use crate::Pallet;
use cf_runtime_upgrade_utilities::{migration_template, VersionedMigration};

use cf_runtime_upgrade_utilities::{migration_template::Migration, VersionedMigration};
mod v4;

pub type PalletMigration<T> = VersionedMigration<Pallet<T>, Migration<T>, 3, 4>;
pub type PalletMigration<T, I> = (
VersionedMigration<Pallet<T, I>, v4::Migration<T, I>, 4, 5>,
VersionedMigration<Pallet<T, I>, migration_template::Migration<T>, 5, 6>,
);
101 changes: 101 additions & 0 deletions state-chain/pallets/cf-threshold-signature/src/migrations/v4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
use cf_traits::{Chainflip, EpochInfo};
use frame_support::traits::OnRuntimeUpgrade;
use sp_std::marker::PhantomData;

#[cfg(feature = "try-runtime")]
mod try_runtime_includes {
pub use codec::{Decode, DecodeLength, Encode};
pub use frame_support::{
ensure, pallet_prelude::DispatchError, storage, traits::PalletInfoAccess,
};
pub use sp_std::prelude::*;
}
#[cfg(feature = "try-runtime")]
use try_runtime_includes::*;

use crate::{CurrentKeyEpoch, KeyRotationStatus, PendingKeyRotation};

mod old {
use cf_primitives::EpochIndex;
use frame_support::{storage_alias, Blake2_128Concat};

use crate::{AggKeyFor, Config, Pallet};

#[storage_alias]
pub type Vaults<T: Config<I>, I: 'static> =
StorageMap<Pallet<T, I>, Blake2_128Concat, EpochIndex, AggKeyFor<T, I>>;
}

/// The V4 migration is partly implemented in the runtime/lib.rs
/// `ThresholdSignatureRefactorMigration` struct.
pub struct Migration<T, I>(PhantomData<(T, I)>);

impl<T: crate::Config<I>, I: 'static> OnRuntimeUpgrade for Migration<T, I> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
log::info!("Running V4 threshold migration");
for (k, v) in old::Vaults::<T, I>::drain() {
crate::Keys::<T, I>::insert(k, v);
}
CurrentKeyEpoch::<T, I>::put(<T as Chainflip>::EpochInfo::epoch_index());
// Assume we don't migrate during a rotation.
PendingKeyRotation::<T, I>::put(KeyRotationStatus::Complete);
Default::default()
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
// The old vault should have been moved here from the vaults pallet.
ensure!(old::Vaults::<T, I>::iter().count() > 0, "Vaults should exist!");
ensure!(
old::Vaults::<T, I>::contains_key(<T as Chainflip>::EpochInfo::epoch_index()),
"Current Epoch Vault should exist!"
);
Ok(Default::default())
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), DispatchError> {
// NOTE Most of the below migrations are run by the vaults pallet or in the
// ThresholdSignatureRefactorMigration in the runtime.
ensure!(crate::CeremonyIdCounter::<T, I>::exists(), "CeremonyIdCounter was not migrated!");
ensure!(
crate::KeyHandoverFailureVoters::<T, I>::decode_len().is_none(),
"KeyHandoverFailureVoters should be empty!"
);
ensure!(
crate::KeyHandoverSuccessVoters::<T, I>::iter().count() == 0,
"KeyHandoverSuccessVoters should be empty!"
);
ensure!(
crate::KeygenFailureVoters::<T, I>::decode_len().is_none(),
"KeygenFailureVoters should be empty!"
);
ensure!(
crate::KeygenSuccessVoters::<T, I>::iter().count() == 0,
"KeygenSuccessVoters should be empty!"
);
ensure!(
!crate::KeygenResolutionPendingSince::<T, I>::exists(),
"KeygenResolutionPendingSince should be empty!"
);
ensure!(
crate::KeygenResponseTimeout::<T, I>::get() > 0u32.into(),
"KeygenResponseTimeout should be set!"
);
ensure!(crate::KeygenSlashAmount::<T, I>::get() > 0, "KeygenSlashAmount should be set!");
ensure!(old::Vaults::<T, I>::iter().count() == 0, "Vaults should be deleted!");
ensure!(
!old::Vaults::<T, I>::contains_key(<T as Chainflip>::EpochInfo::epoch_index()),
"Current Epoch Vault should not exist!"
);
ensure!(
CurrentKeyEpoch::<T, I>::get().unwrap() == <T as Chainflip>::EpochInfo::epoch_index(),
"CurrentKeyEpoch was not migrated!"
);
ensure!(
crate::Keys::<T, I>::contains_key(<T as Chainflip>::EpochInfo::epoch_index()),
"Keys were not migrated!"
);
Ok(())
}
}
7 changes: 0 additions & 7 deletions state-chain/pallets/cf-threshold-signature/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use crate::{
EnsureThresholdSigned, Origin, Pallet, PalletOffence, PendingCeremonies, RequestId,
};
use cf_chains::{
btc,
evm::SchnorrVerificationComponents,
mocks::{MockAggKey, MockEthereumChainCrypto, MockThresholdSignature},
ChainCrypto,
};
Expand All @@ -30,11 +28,6 @@ type Block = frame_system::mocking::MockBlock<Test>;

pub type ValidatorId = u64;

pub const ETH_DUMMY_SIG: SchnorrVerificationComponents =
SchnorrVerificationComponents { s: [0xcf; 32], k_times_g_address: [0xcf; 20] };

pub const BTC_DUMMY_SIG: btc::Signature = [0xcf; 64];

// Configure a mock runtime to test the pallet.
frame_support::construct_runtime!(
pub enum Test {
Expand Down
Loading

0 comments on commit 27f29dc

Please sign in to comment.