Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Bootstrap mainchain and sidechain registration command - Closes #7032 #7112

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions framework/src/modules/interoperability/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@ export const MODULE_NAME_INTEROPERABILITY = 'interoperability';

// General constants
export const MAINCHAIN_ID = 1;
export const MAINCHAIN_NAME = 'lisk-mainchain';
export const TAG_CHAIN_REG_MESSAGE = 'LSK_CHAIN_REGISTRATION';
export const LIVENESS_LIMIT = 2592000; // 30*24*3600
export const MAX_CCM_SIZE = 10240;
export const EMPTY_FEE_ADDRESS = Buffer.alloc(0);
export const EMPTY_BYTES = Buffer.alloc(0);
export const REGISTRATION_FEE = BigInt(1000000000);
export const MAX_NUM_VALIDATORS = 199;
export const MAX_LENGTH_NAME = 40;
export const MAX_UINT32 = 4294967295;
export const MAX_UINT64 = BigInt('18446744073709551615'); // BigInt((2 ** 64) - 1) - 1
mitsuaki-u marked this conversation as resolved.
Show resolved Hide resolved
export const THRESHOLD_MAINCHAIN = 68;

// Store prefixes
export const STORE_PREFIX_OUTBOX_ROOT = 0x0000;
Expand Down Expand Up @@ -48,3 +56,7 @@ export const CCM_STATUS_CROSS_CHAIN_COMMAND_NOT_SUPPORTED = 2;
export const CCM_STATUS_CHANNEL_UNAVAILABLE = 3;
export const CCM_STATUS_RECOVERED = 4;
export const MIN_RETURN_FEE = BigInt(1000);

// Commands
export const COMMAND_ID_SIDECHAIN_REG = 0;
export const COMMAND_ID_MAINCHAIN_REG = 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright © 2022 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseCommand } from '../../../base_command';
import { COMMAND_ID_SIDECHAIN_REG } from '../../constants';
import { sidechainRegParams } from '../../schema';
import { VerificationResult } from '../../../../node/state_machine';

export class SidechainRegistrationCommand extends BaseCommand {
public id = COMMAND_ID_SIDECHAIN_REG;
public name = 'sidechainRegistration';
public schema = sidechainRegParams;

// TODO
// eslint-disable-next-line @typescript-eslint/require-await
public async verify(): Promise<VerificationResult> {
throw new Error('Method not implemented.');
}

// TODO
// eslint-disable-next-line @typescript-eslint/require-await
public async execute(): Promise<void> {
throw new Error('Method not implemented.');
}
}
80 changes: 80 additions & 0 deletions framework/src/modules/interoperability/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,86 @@ export const terminatedOutboxSchema = {
},
};

export const sidechainRegParams = {
$id: '/modules/interoperability/mainchain/sidechain_registration',
type: 'object',
required: ['name', 'genesisBlockID', 'initValidators', 'certificateThreshold'],
properties: {
name: {
dataType: 'string',
fieldNumber: 1,
},
genesisBlockID: {
dataType: 'bytes',
fieldNumber: 2,
},
initValidators: {
type: 'array',
fieldNumber: 3,
items: {
type: 'object',
required: ['blsKey', 'bftWeight'],
properties: {
blsKey: {
dataType: 'bytes',
fieldNumber: 1,
},
bftWeight: {
dataType: 'uint64',
fieldNumber: 2,
},
},
},
},
certificateThreshold: {
dataType: 'uint64',
fieldNumber: 4,
},
},
};

export const mainchainRegParams = {
$id: '/modules/interoperability/sidechain/mainchain_registration',
type: 'object',
required: ['ownChainID', 'ownName', 'mainchainValidators', 'signature', 'aggregationBits'],
properties: {
ownChainID: {
dataType: 'uint32',
fieldNumber: 1,
},
ownName: {
dataType: 'string',
fieldNumber: 2,
},
mainchainValidators: {
type: 'array',
fieldNumber: 3,
items: {
type: 'object',
required: ['blsKey', 'bftWeight'],
properties: {
blsKey: {
dataType: 'bytes',
fieldNumber: 1,
},
bftWeight: {
dataType: 'uint64',
fieldNumber: 2,
},
},
},
},
signature: {
dataType: 'bytes',
fieldNumber: 4,
},
aggregationBits: {
dataType: 'bytes',
fieldNumber: 5,
},
},
};

// Cross chain commands schemas
export const registrationCCMParamsSchema = {
$id: 'modules/interoperability/ccCommand/registration',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright © 2022 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*/

import { BaseCommand } from '../../../base_command';
import { COMMAND_ID_MAINCHAIN_REG } from '../../constants';
import { mainchainRegParams } from '../../schema';
import { VerificationResult } from '../../../../node/state_machine';

export class MainRegistrationCommand extends BaseCommand {
public id = COMMAND_ID_MAINCHAIN_REG;
mehmetegemen marked this conversation as resolved.
Show resolved Hide resolved
public name = 'mainchainRegistration';
public schema = mainchainRegParams;

// TODO
// eslint-disable-next-line @typescript-eslint/require-await
public async verify(): Promise<VerificationResult> {
throw new Error('Method not implemented.');
}

// TODO
// eslint-disable-next-line @typescript-eslint/require-await
public async execute(): Promise<void> {
throw new Error('Method not implemented.');
}
}