From 4f683808371ff07b7fbbf7548cd94e2e55b38b4a Mon Sep 17 00:00:00 2001 From: Antonio Date: Tue, 19 Dec 2023 14:30:20 +0100 Subject: [PATCH] fix: configure DIP templates BlockNumber to u64 (#599) DIP consumers are specific to a given provider. Right now, the template provider uses `u32` as block numbers, while `Peregrine` uses `u64`. This means that it is not possible to use a single consumer runtime (hence Docker image) to test both providers. The issue is fixed by making the provider template use the same block number type as Peregrine, so we can "stretch" it to be used in integration tests against the template consumer without having to have two different consumer runtimes and Docker images. To keep it consistent (although it is not required), I also changed the consumer runtime to use `u64`s. Integration tests with the DIP-SDK are finally passing. You can run them yourself following the instructions below. ## Checklist - [x] Apply change - [x] Build and push temp Docker images - [x] Verify integration tests for same template consumer work with both template provider and Peregrine - [ ] Review PR ## How to test * Clone the [DIP-SDK repo at this branch for PR #3](https://github.com/KILTprotocol/dip-sdk/pull/3) * Set the env variables in `tests/peregrine-dip-consumer-template/.env.develop.test` for `CONSUMER_IMAGE` to `kiltprotocol/dip-consumer-node-template:dev-release-48c2c610d7c6a91f9c1579c8a93d12c59b35b6cc` and in `tests/dip-provider-template-dip-consumer-template/.env.develop.test` for `PROVIDER_IMAGE` to `kiltprotocol/dip-provider-node-template:dev-release-48c2c610d7c6a91f9c1579c8a93d12c59b35b6cc` and for `CONSUMER_IMAGE` to `kiltprotocol/dip-consumer-node-template:dev-release-48c2c610d7c6a91f9c1579c8a93d12c59b35b6cc`. * Run `yarn test:e2e:start-network:peregrine-provider:develop` to spin up the Zombienet network for Peregrine <-> DIP consumer * In a different bash, run `yarn test:e2e:peregrine-provider` to run the integration tests * Same thing with `yarn test:e2e:start-network:dip-template-provider:develop` and `yarn test:e2e:dip-template-provider`. --- dip-template/runtimes/dip-consumer/src/lib.rs | 14 +++++++------- dip-template/runtimes/dip-provider/src/lib.rs | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/dip-template/runtimes/dip-consumer/src/lib.rs b/dip-template/runtimes/dip-consumer/src/lib.rs index 06e031d2d..cbbcb2dc2 100644 --- a/dip-template/runtimes/dip-consumer/src/lib.rs +++ b/dip-template/runtimes/dip-consumer/src/lib.rs @@ -89,12 +89,12 @@ pub type AccountId = AccountId32; pub type Address = MultiAddress; pub type Balance = u128; pub type Block = generic::Block; -pub type BlockNumber = u32; +pub type BlockNumber = u64; pub type DidIdentifier = AccountId; pub type Hasher = BlakeTwo256; pub type Hash = sp_core::H256; pub type Header = generic::Header; -pub type Nonce = u32; +pub type Nonce = u64; pub type Signature = MultiSignature; pub type SignedExtra = ( @@ -228,7 +228,7 @@ impl frame_system::Config for Runtime { type AccountData = AccountData; type AccountId = AccountId; type BaseCallFilter = Everything; - type BlockHashCount = ConstU32<256>; + type BlockHashCount = ConstU64<256>; type BlockLength = RuntimeBlockLength; type Block = Block; type BlockWeights = RuntimeBlockWeights; @@ -237,7 +237,7 @@ impl frame_system::Config for Runtime { type Hashing = BlakeTwo256; type Lookup = AccountIdLookup; type MaxConsumers = ConstU32<16>; - type Nonce = u32; + type Nonce = u64; type OnKilledAccount = (); type OnNewAccount = (); type OnSetCode = ParachainSetCode; @@ -323,7 +323,7 @@ parameter_types! { impl pallet_collator_selection::Config for Runtime { type Currency = Balances; type PotId = PotId; - type KickThreshold = ConstU32<{ 6 * HOURS }>; + type KickThreshold = ConstU64<{ 6 * HOURS }>; type MaxCandidates = ConstU32<1_000>; type MaxInvulnerables = ConstU32<100>; type MinEligibleCollators = ConstU32<5>; @@ -343,11 +343,11 @@ impl_opaque_keys! { impl pallet_session::Config for Runtime { type Keys = SessionKeys; - type NextSessionRotation = PeriodicSessions, ConstU32<0>>; + type NextSessionRotation = PeriodicSessions, ConstU64<0>>; type RuntimeEvent = RuntimeEvent; type SessionHandler = ::KeyTypeIdProviders; type SessionManager = CollatorSelection; - type ShouldEndSession = PeriodicSessions, ConstU32<0>>; + type ShouldEndSession = PeriodicSessions, ConstU64<0>>; type ValidatorId = AccountId; type ValidatorIdOf = IdentityCollator; type WeightInfo = (); diff --git a/dip-template/runtimes/dip-provider/src/lib.rs b/dip-template/runtimes/dip-provider/src/lib.rs index 8a083b92b..7d6e1581a 100644 --- a/dip-template/runtimes/dip-provider/src/lib.rs +++ b/dip-template/runtimes/dip-provider/src/lib.rs @@ -89,11 +89,11 @@ pub type AccountId = AccountId32; pub type Address = MultiAddress; pub type Balance = u128; pub type Block = generic::Block; -pub type BlockNumber = u32; +pub type BlockNumber = u64; pub type DidIdentifier = AccountId; pub type Hash = sp_core::H256; pub type Header = generic::Header; -pub type Nonce = u32; +pub type Nonce = u64; pub type Signature = MultiSignature; pub type SignedExtra = ( @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime { type AccountData = AccountData; type AccountId = AccountId; type BaseCallFilter = Everything; - type BlockHashCount = ConstU32<256>; + type BlockHashCount = ConstU64<256>; type BlockLength = RuntimeBlockLength; type Block = Block; type BlockWeights = RuntimeBlockWeights; @@ -238,7 +238,7 @@ impl frame_system::Config for Runtime { type Hashing = BlakeTwo256; type Lookup = AccountIdLookup; type MaxConsumers = ConstU32<16>; - type Nonce = u32; + type Nonce = u64; type OnKilledAccount = (); type OnNewAccount = (); type OnSetCode = ParachainSetCode; @@ -324,7 +324,7 @@ parameter_types! { impl pallet_collator_selection::Config for Runtime { type Currency = Balances; type PotId = PotId; - type KickThreshold = ConstU32<{ 6 * HOURS }>; + type KickThreshold = ConstU64<{ 6 * HOURS }>; type MaxCandidates = ConstU32<1_000>; type MaxInvulnerables = ConstU32<100>; type MinEligibleCollators = ConstU32<5>; @@ -344,11 +344,11 @@ impl_opaque_keys! { impl pallet_session::Config for Runtime { type Keys = SessionKeys; - type NextSessionRotation = PeriodicSessions, ConstU32<0>>; + type NextSessionRotation = PeriodicSessions, ConstU64<0>>; type RuntimeEvent = RuntimeEvent; type SessionHandler = ::KeyTypeIdProviders; type SessionManager = CollatorSelection; - type ShouldEndSession = PeriodicSessions, ConstU32<0>>; + type ShouldEndSession = PeriodicSessions, ConstU64<0>>; type ValidatorId = AccountId; type ValidatorIdOf = IdentityCollator; type WeightInfo = (); @@ -392,7 +392,7 @@ impl did::Config for Runtime { type Fee = ConstU128; type FeeCollector = (); type KeyDeposit = ConstU128; - type MaxBlocksTxValidity = ConstU32; + type MaxBlocksTxValidity = ConstU64; type MaxNewKeyAgreementKeys = MaxNewKeyAgreementKeys; type MaxNumberOfServicesPerDid = ConstU32<1>; type MaxNumberOfTypesPerService = ConstU32<1>;