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

Improve chain connector storage #9198

Merged
merged 14 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"system": {
"dataPath": "~/.lisk/pos-mainchain-node-one",
"logLevel": "info"
"dataPath": "~/.lisk/mainchain-node-one",
"logLevel": "debug",
"keepEventsForHeights": -1,
"keepInclusionProofsForHeights": -1,
"inclusionProofKeys": [
"83ed0d250000160811fdaf692ba77eabfbfc3a6bb3c4cf6a87beafd28cfe90b5dc64cb20ab46"
]
},
"rpc": {
"modes": ["ipc"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"system": {
"dataPath": "~/.lisk/pos-mainchain-node-two",
"logLevel": "info"
"dataPath": "~/.lisk/mainchain-node-two",
"logLevel": "debug",
"keepEventsForHeights": -1,
"keepInclusionProofsForHeights": -1,
"inclusionProofKeys": [
"83ed0d250000ac894ab085f50b81fe000e99ccb27e5543de69f63d4f9105daab15dce90f81b3"
]
},
"rpc": {
"modes": ["ipc"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
{
"system": {
"dataPath": "~/.lisk/pos-mainchain-fast",
"keepEventsForHeights": -1,
"keepInclusionProofsForHeights": -1,
"inclusionProofKeys": [
"83ed0d250000160811fdaf692ba77eabfbfc3a6bb3c4cf6a87beafd28cfe90b5dc64cb20ab46"
],
"logLevel": "info"
},
"rpc": {
"modes": ["ipc"],
"port": 7881,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"system": {
"dataPath": "~/.lisk/pos-sidechain-example-one",
"keepEventsForHeights": 300,
"logLevel": "info"
"logLevel": "info",
"keepInclusionProofsForHeights": -1,
"inclusionProofKeys": [
"83ed0d250000fb5e512425fc9449316ec95969ebe71e2d576dbab833d61e2a5b9330fd70ee02"
]
},
"rpc": {
"modes": ["ipc"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"system": {
"dataPath": "~/.lisk/pos-sidechain-example-two",
"keepEventsForHeights": 300,
"logLevel": "info"
"logLevel": "info",
"keepInclusionProofsForHeights": -1,
"inclusionProofKeys": [
"83ed0d250000fb5e512425fc9449316ec95969ebe71e2d576dbab833d61e2a5b9330fd70ee02"
]
},
"rpc": {
"modes": ["ipc"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,53 +12,31 @@
* Removal or modification of this copyright notice is prohibited.
*/
/* eslint-disable no-bitwise */
import {
ActiveValidator,
Certificate,
LastCertificate,
utils,
ActiveValidatorsUpdate,
} from 'lisk-sdk';
import { ValidatorsData } from './types';
import { ActiveValidator, utils, ActiveValidatorsUpdate } from 'lisk-sdk';
import { ValidatorsDataWithHeight } from './types';

/**
* @see https://github.com/LiskHQ/lips/blob/main/proposals/lip-0053.md#computing-the-validators-update
*/

export const calculateActiveValidatorsUpdate = (
certificate: Certificate,
validatorsHashPreimage: ValidatorsData[],
lastCertificate: LastCertificate,
validatorsDataAtLastCertificate: ValidatorsDataWithHeight,
validatorsDataAtNewCertificate: ValidatorsDataWithHeight,
): { activeValidatorsUpdate: ActiveValidatorsUpdate; certificateThreshold: bigint } => {
let certificateThreshold;
const validatorDataAtCertificate = validatorsHashPreimage.find(validatorsData =>
validatorsData.validatorsHash.equals(certificate.validatorsHash),
);

if (!validatorDataAtCertificate) {
throw new Error('No validators data found for the certificate height.');
}

const validatorDataAtLastCertificate = validatorsHashPreimage.find(validatorsData =>
validatorsData.validatorsHash.equals(lastCertificate.validatorsHash),
);

if (!validatorDataAtLastCertificate) {
throw new Error('No validators data found for the given last certificate height.');
}

// If the certificate threshold is not changed from last certificate then we assign zero
if (
validatorDataAtCertificate.certificateThreshold ===
validatorDataAtLastCertificate.certificateThreshold
validatorsDataAtNewCertificate.certificateThreshold ===
validatorsDataAtLastCertificate.certificateThreshold
) {
certificateThreshold = validatorDataAtLastCertificate.certificateThreshold;
certificateThreshold = validatorsDataAtLastCertificate.certificateThreshold;
} else {
certificateThreshold = validatorDataAtCertificate.certificateThreshold;
certificateThreshold = validatorsDataAtNewCertificate.certificateThreshold;
}

const activeValidatorsUpdate = getActiveValidatorsUpdate(
validatorDataAtLastCertificate.validators,
validatorDataAtCertificate.validators,
validatorsDataAtLastCertificate.validators,
validatorsDataAtNewCertificate.validators,
);

return { activeValidatorsUpdate, certificateThreshold };
Expand Down
Loading
Loading