Skip to content

Commit

Permalink
fix: configure DIP templates BlockNumber to u64 (#599)
Browse files Browse the repository at this point in the history
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](KILTprotocol/dip-sdk#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`.
  • Loading branch information
ntn-x2 authored Dec 19, 2023
1 parent 072955f commit 4f68380
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions dip-template/runtimes/dip-consumer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ pub type AccountId = AccountId32;
pub type Address = MultiAddress<AccountId, ()>;
pub type Balance = u128;
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
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<BlockNumber, Hasher>;
pub type Nonce = u32;
pub type Nonce = u64;
pub type Signature = MultiSignature;

pub type SignedExtra = (
Expand Down Expand Up @@ -228,7 +228,7 @@ impl frame_system::Config for Runtime {
type AccountData = AccountData<Balance>;
type AccountId = AccountId;
type BaseCallFilter = Everything;
type BlockHashCount = ConstU32<256>;
type BlockHashCount = ConstU64<256>;
type BlockLength = RuntimeBlockLength;
type Block = Block;
type BlockWeights = RuntimeBlockWeights;
Expand All @@ -237,7 +237,7 @@ impl frame_system::Config for Runtime {
type Hashing = BlakeTwo256;
type Lookup = AccountIdLookup<AccountId, ()>;
type MaxConsumers = ConstU32<16>;
type Nonce = u32;
type Nonce = u64;
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ParachainSetCode<Self>;
Expand Down Expand Up @@ -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>;
Expand All @@ -343,11 +343,11 @@ impl_opaque_keys! {

impl pallet_session::Config for Runtime {
type Keys = SessionKeys;
type NextSessionRotation = PeriodicSessions<ConstU32<HOURS>, ConstU32<0>>;
type NextSessionRotation = PeriodicSessions<ConstU64<HOURS>, ConstU64<0>>;
type RuntimeEvent = RuntimeEvent;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type SessionManager = CollatorSelection;
type ShouldEndSession = PeriodicSessions<ConstU32<HOURS>, ConstU32<0>>;
type ShouldEndSession = PeriodicSessions<ConstU64<HOURS>, ConstU64<0>>;
type ValidatorId = AccountId;
type ValidatorIdOf = IdentityCollator;
type WeightInfo = ();
Expand Down
16 changes: 8 additions & 8 deletions dip-template/runtimes/dip-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ pub type AccountId = AccountId32;
pub type Address = MultiAddress<AccountId, ()>;
pub type Balance = u128;
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
pub type BlockNumber = u32;
pub type BlockNumber = u64;
pub type DidIdentifier = AccountId;
pub type Hash = sp_core::H256;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub type Nonce = u32;
pub type Nonce = u64;
pub type Signature = MultiSignature;

pub type SignedExtra = (
Expand Down Expand Up @@ -229,7 +229,7 @@ impl frame_system::Config for Runtime {
type AccountData = AccountData<Balance>;
type AccountId = AccountId;
type BaseCallFilter = Everything;
type BlockHashCount = ConstU32<256>;
type BlockHashCount = ConstU64<256>;
type BlockLength = RuntimeBlockLength;
type Block = Block;
type BlockWeights = RuntimeBlockWeights;
Expand All @@ -238,7 +238,7 @@ impl frame_system::Config for Runtime {
type Hashing = BlakeTwo256;
type Lookup = AccountIdLookup<AccountId, ()>;
type MaxConsumers = ConstU32<16>;
type Nonce = u32;
type Nonce = u64;
type OnKilledAccount = ();
type OnNewAccount = ();
type OnSetCode = ParachainSetCode<Self>;
Expand Down Expand Up @@ -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>;
Expand All @@ -344,11 +344,11 @@ impl_opaque_keys! {

impl pallet_session::Config for Runtime {
type Keys = SessionKeys;
type NextSessionRotation = PeriodicSessions<ConstU32<HOURS>, ConstU32<0>>;
type NextSessionRotation = PeriodicSessions<ConstU64<HOURS>, ConstU64<0>>;
type RuntimeEvent = RuntimeEvent;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type SessionManager = CollatorSelection;
type ShouldEndSession = PeriodicSessions<ConstU32<HOURS>, ConstU32<0>>;
type ShouldEndSession = PeriodicSessions<ConstU64<HOURS>, ConstU64<0>>;
type ValidatorId = AccountId;
type ValidatorIdOf = IdentityCollator;
type WeightInfo = ();
Expand Down Expand Up @@ -392,7 +392,7 @@ impl did::Config for Runtime {
type Fee = ConstU128<MILLIUNIT>;
type FeeCollector = ();
type KeyDeposit = ConstU128<UNIT>;
type MaxBlocksTxValidity = ConstU32<HOURS>;
type MaxBlocksTxValidity = ConstU64<HOURS>;
type MaxNewKeyAgreementKeys = MaxNewKeyAgreementKeys;
type MaxNumberOfServicesPerDid = ConstU32<1>;
type MaxNumberOfTypesPerService = ConstU32<1>;
Expand Down

0 comments on commit 4f68380

Please sign in to comment.