Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(drive)!: verify instant lock signatures with Drive #1875

Merged
merged 51 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
85f2233
refactor: encapsulate chain lock validation quorum logic to be reused
shumkov May 31, 2024
731673a
feat: introduce `CoreQuorumSet`
shumkov Jun 5, 2024
6289886
feat: verify recent instant lock signatures locally
shumkov Jun 5, 2024
10b982f
feat: update instant lock quorums
shumkov Jun 5, 2024
ec321d3
test: mock instant lock verification
shumkov Jun 5, 2024
a3423f9
test: implement instant lock signing
shumkov Jun 6, 2024
dd3165e
fix: return error if signature is not valid
shumkov Jun 6, 2024
0c3425d
docs: add todo for non-determinism issue
shumkov Jun 6, 2024
98a9e60
fix: non-deterministic quorum index is used
shumkov Jun 6, 2024
eb43aa7
chore: log state transition validation result for asset lock based STs
shumkov Jun 6, 2024
9102d0f
docs: add todo to have more verbose error
shumkov Jun 6, 2024
0c6b1c6
refactor: cleanup quorum set
shumkov Jun 6, 2024
ef8a001
fix: invalid selection logic for rotating quorums
shumkov Jun 6, 2024
e14f9b7
test: fix instant lock signing logic in strategy tests
shumkov Jun 6, 2024
8842a22
chore(dashmate): update with new configuration
shumkov Jun 6, 2024
3260d80
chore(dashmate): add missing rotation option and correct llmq type
shumkov Jun 7, 2024
3462a77
docs: add todo for a bug
shumkov Jun 7, 2024
d88fda3
chore: enhance logging for IS lock signature verification
shumkov Jun 7, 2024
29b2642
chore: kick off CI
shumkov Jun 7, 2024
fc39b72
chore: kick off CI
shumkov Jun 7, 2024
dc27176
style: remove unused import
shumkov Jun 7, 2024
7ddb81c
chore: rephrase invalid signature error
shumkov Jun 7, 2024
fd1f994
chore: remove unused trait implementation
shumkov Jun 7, 2024
96360ff
chore: versioning for CoreQuorumSet
shumkov Jun 7, 2024
93a604c
chore: bump version to 1.0.0-pr.1875.1
shumkov Jun 7, 2024
617c0a2
revert: bump version to 1.0.0-pr.1875.1
shumkov Jun 7, 2024
d262cca
refactor: simplify/decompose quorum set iterator
shumkov Jun 7, 2024
7355234
refactor: renaming from Sam
shumkov Jun 14, 2024
1084649
Merge branch 'refs/heads/v1.0-dev' into perf/drve/validate-is-locks
shumkov Jun 14, 2024
a2e26f7
revert: variable name
shumkov Jun 14, 2024
998b963
fix: non-deterministic quorum index
shumkov Jun 14, 2024
016afc3
style: unused import
shumkov Jun 18, 2024
3c71b37
revert: remove non-determinism fix
shumkov Jun 18, 2024
fc51742
refactor: rename `select_quorums`
shumkov Jun 18, 2024
7b1c6e7
refactor: `core_instant_lock` -> core_instant_send_lock
shumkov Jun 18, 2024
b9f765a
chore: exclude the testing config for production
shumkov Jun 18, 2024
2a47154
refactor: `CoreQuorumSet` to `VerificationQuorumSet`
shumkov Jun 18, 2024
e2b551f
refactoring: more renamings
shumkov Jun 18, 2024
654b67e
fix: outdated name
shumkov Jun 19, 2024
e5a1114
fix: commit signature verification is disabled by default
shumkov Jun 19, 2024
828bf7e
revert: quorum index update
shumkov Jun 19, 2024
0684d6c
fix: block is not signing by default
shumkov Jun 19, 2024
53e84c6
chore: kick off CI
shumkov Jun 22, 2024
5856674
ci: show Rust formatting output
shumkov Jun 22, 2024
7dc94a6
ci: improve formatting output
shumkov Jun 22, 2024
496eda5
Merge branch 'v1.0-dev' into perf/drve/validate-is-locks
shumkov Jun 22, 2024
7378e31
ci: fix formatting task
shumkov Jun 22, 2024
93eb706
Merge remote-tracking branch 'origin/perf/drve/validate-is-locks' int…
shumkov Jun 22, 2024
a328355
style: fix formatting
shumkov Jun 22, 2024
4f8f94a
perf: reuse chain lock quorums for instant lock if they are the same …
shumkov Jun 23, 2024
29fb68b
ci: install Rust 1.76 as default toolchain
shumkov Jun 23, 2024
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
2 changes: 1 addition & 1 deletion .github/actions/rust/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
toolchain:
description: Rust toolchain to use, stable / nightly / beta, or exact version
# The same as in /README.md
default: "stable"
default: "1.76"
target:
description: Target Rust platform
required: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-rs-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
cache: false

- name: Check formatting
run: exit `cargo fmt --check --package=${{ inputs.package }} | wc -l`
run: cargo fmt --check --package=${{ inputs.package }}

unused_deps:
name: Unused dependencies
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.

29 changes: 23 additions & 6 deletions packages/dashmate/configs/defaults/getBaseConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import semver from 'semver';

import fs from 'fs';
import {
NETWORK_TESTNET, PACKAGE_ROOT_DIR,
NETWORK_MAINNET,
PACKAGE_ROOT_DIR,
} from '../../src/constants.js';
import Config from '../../src/config/Config.js';

Expand Down Expand Up @@ -245,12 +246,28 @@ export default function getBaseConfigFactory(homeDir) {
retention: 60 * 3,
},
validatorSet: {
llmqType: 4,
quorum: {
llmqType: 4,
dkgInterval: 24,
activeSigners: 24,
rotation: false,
},
},
chainLock: {
llmqType: 2,
dkgInterval: 288,
llmqSize: 400,
quorum: {
llmqType: 2,
dkgInterval: 288,
activeSigners: 4,
rotation: false,
},
},
instantLock: {
quorum: {
llmqType: 5,
dkgInterval: 288,
activeSigners: 32,
rotation: true,
},
},
metrics: {
enabled: false,
Expand Down Expand Up @@ -425,7 +442,7 @@ export default function getBaseConfigFactory(homeDir) {
},
},
externalIp: null,
network: NETWORK_TESTNET,
network: NETWORK_MAINNET,
environment: 'production',
};

Expand Down
24 changes: 20 additions & 4 deletions packages/dashmate/configs/defaults/getLocalConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,28 @@ export default function getLocalConfigFactory(getBaseConfig) {
},
abci: {
validatorSet: {
llmqType: 106,
quorum: {
llmqType: 106,
dkgInterval: 24,
activeSigners: 2,
rotation: false,
},
},
chainLock: {
llmqType: 100,
dkgInterval: 24,
llmqSize: 3,
quorum: {
llmqType: 100,
dkgInterval: 24,
activeSigners: 2,
rotation: false,
},
},
instantLock: {
quorum: {
llmqType: 104,
dkgInterval: 24,
activeSigners: 2,
rotation: false,
},
},
},
},
Expand Down
24 changes: 20 additions & 4 deletions packages/dashmate/configs/defaults/getTestnetConfigFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,28 @@ export default function getTestnetConfigFactory(homeDir, getBaseConfig) {
abci: {
epochTime: 3600,
validatorSet: {
llmqType: 6,
quorum: {
llmqType: 6,
dkgInterval: 24,
activeSigners: 24,
rotation: false,
},
},
chainLock: {
llmqType: 1,
dkgInterval: 24,
llmqSize: 50,
quorum: {
llmqType: 1,
dkgInterval: 24,
activeSigners: 24,
rotation: false,
},
},
instantLock: {
quorum: {
llmqType: 5,
dkgInterval: 288,
activeSigners: 32,
rotation: true,
},
},
},
tenderdash: {
Expand Down
54 changes: 54 additions & 0 deletions packages/dashmate/configs/getConfigFileMigrationsFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)
return defaultConfigs.get(baseConfigName);
}

function getDefaultConfigByNetwork(network) {
if (network === NETWORK_MAINNET) {
return defaultConfigs.get('mainnet');
}
if (network === NETWORK_TESTNET) {
return defaultConfigs.get('testnet');
}
if (network === NETWORK_LOCAL) {
return defaultConfigs.get('local');
}

return defaultConfigs.get('base');
}

return {
'0.24.0': (configFile) => {
Object.entries(configFile.configs)
Expand Down Expand Up @@ -613,6 +627,46 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs)

return configFile;
},
'1.0.0-dev.16': (configFile) => {
Object.entries(configFile.configs)
.forEach(([name, options]) => {
if (name === 'base') {
options.network = NETWORK_MAINNET;
}

const networkConfig = getDefaultConfigByNetwork(options.network);

options.platform.drive.abci.chainLock.quorum = {
llmqType: networkConfig.get('platform.drive.abci.chainLock.quorum.llmqType'),
dkgInterval: networkConfig.get('platform.drive.abci.chainLock.quorum.dkgInterval'),
activeSigners: networkConfig.get('platform.drive.abci.chainLock.quorum.activeSigners'),
rotation: networkConfig.get('platform.drive.abci.chainLock.quorum.rotation'),
};

delete options.platform.drive.abci.chainLock.llmqType;
delete options.platform.drive.abci.chainLock.llmqSize;
delete options.platform.drive.abci.chainLock.dkgInterval;

options.platform.drive.abci.validatorSet.quorum = {
llmqType: networkConfig.get('platform.drive.abci.validatorSet.quorum.llmqType'),
dkgInterval: networkConfig.get('platform.drive.abci.validatorSet.quorum.dkgInterval'),
activeSigners: networkConfig.get('platform.drive.abci.validatorSet.quorum.activeSigners'),
rotation: networkConfig.get('platform.drive.abci.validatorSet.quorum.rotation'),
};

delete options.platform.drive.abci.validatorSet.llmqType;

options.platform.drive.abci.instantLock = {
quorum: {
llmqType: networkConfig.get('platform.drive.abci.instantLock.quorum.llmqType'),
dkgInterval: networkConfig.get('platform.drive.abci.instantLock.quorum.dkgInterval'),
activeSigners: networkConfig.get('platform.drive.abci.instantLock.quorum.activeSigners'),
rotation: networkConfig.get('platform.drive.abci.instantLock.quorum.rotation'),
},
};
});
return configFile;
},
};
}

Expand Down
16 changes: 12 additions & 4 deletions packages/dashmate/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,18 @@ services:
- MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY=${PLATFORM_MASTERNODE_REWARD_SHARES_SECOND_PUBLIC_KEY}
- WITHDRAWALS_MASTER_PUBLIC_KEY=${PLATFORM_WITHDRAWALS_MASTER_PUBLIC_KEY}
- WITHDRAWALS_SECOND_PUBLIC_KEY=${PLATFORM_WITHDRAWALS_SECOND_PUBLIC_KEY}
- VALIDATOR_SET_QUORUM_TYPE=${PLATFORM_DRIVE_ABCI_VALIDATOR_SET_LLMQ_TYPE:?err}
- CHAIN_LOCK_QUORUM_TYPE=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_LLMQ_TYPE:?err}
- CHAIN_LOCK_QUORUM_WINDOW=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_DKG_INTERVAL:?err}
- CHAIN_LOCK_QUORUM_SIZE=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_LLMQ_SIZE:?err}
- VALIDATOR_SET_QUORUM_TYPE=${PLATFORM_DRIVE_ABCI_VALIDATOR_SET_QUORUM_LLMQ_TYPE:?err}
- VALIDATOR_SET_QUORUM_WINDOW=${PLATFORM_DRIVE_ABCI_VALIDATOR_SET_QUORUM_DKG_INTERVAL:?err}
- VALIDATOR_SET_QUORUM_ACTIVE_SIGNERS=${PLATFORM_DRIVE_ABCI_VALIDATOR_SET_QUORUM_ACTIVE_SIGNERS:?err}
- VALIDATOR_SET_QUORUM_ROTATION=${PLATFORM_DRIVE_ABCI_VALIDATOR_SET_QUORUM_ROTATION:?err}
- CHAIN_LOCK_QUORUM_TYPE=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_QUORUM_LLMQ_TYPE:?err}
- CHAIN_LOCK_QUORUM_WINDOW=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_QUORUM_DKG_INTERVAL:?err}
- CHAIN_LOCK_QUORUM_ACTIVE_SIGNERS=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_QUORUM_ACTIVE_SIGNERS:?err}
- CHAIN_LOCK_QUORUM_ROTATION=${PLATFORM_DRIVE_ABCI_CHAIN_LOCK_QUORUM_ROTATION:?err}
- INSTANT_LOCK_QUORUM_TYPE=${PLATFORM_DRIVE_ABCI_INSTANT_LOCK_QUORUM_LLMQ_TYPE:?err}
- INSTANT_LOCK_QUORUM_WINDOW=${PLATFORM_DRIVE_ABCI_INSTANT_LOCK_QUORUM_DKG_INTERVAL:?err}
- INSTANT_LOCK_QUORUM_ACTIVE_SIGNERS=${PLATFORM_DRIVE_ABCI_INSTANT_LOCK_QUORUM_ACTIVE_SIGNERS:?err}
- INSTANT_LOCK_QUORUM_ROTATION=${PLATFORM_DRIVE_ABCI_INSTANT_LOCK_QUORUM_ROTATION:?err}
- DB_PATH=/var/lib/dash/rs-drive-abci/db
- ABCI_CONSENSUS_BIND_ADDRESS=tcp://0.0.0.0:26658
- GRPC_BIND_ADDRESS=0.0.0.0:26670
Expand Down
54 changes: 37 additions & 17 deletions packages/dashmate/src/config/configJsonSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ export default {
additionalProperties: false,
required: ['enabled', 'host', 'port'],
},
quorum: {
type: 'object',
properties: {
llmqType: {
type: 'integer',
enum: [1, 2, 3, 4, 5, 6, 100, 101, 102, 103, 104, 105, 106, 107],
},
dkgInterval: {
type: 'integer',
minimum: 1,
},
activeSigners: {
type: 'integer',
minimum: 1,
},
rotation: {
type: 'boolean',
},
},
required: ['llmqType', 'dkgInterval', 'activeSigners', 'rotation'],
additionalProperties: false,
},
},
properties: {
description: {
Expand Down Expand Up @@ -766,34 +788,32 @@ export default {
validatorSet: {
type: 'object',
properties: {
llmqType: {
type: 'number',
// https://github.com/dashpay/dashcore-lib/blob/843176fed9fc81feae43ccf319d99e2dd942fe1f/lib/constants/index.js#L50-L99
enum: [1, 2, 3, 4, 5, 6, 100, 101, 102, 103, 104, 105, 106, 107],
quorum: {
$ref: '#/definitions/quorum',
},
},
additionalProperties: false,
required: ['llmqType'],
required: ['quorum'],
},
chainLock: {
type: 'object',
properties: {
llmqType: {
type: 'number',
// https://github.com/dashpay/dashcore-lib/blob/843176fed9fc81feae43ccf319d99e2dd942fe1f/lib/constants/index.js#L50-L99
enum: [1, 2, 3, 4, 5, 6, 100, 101, 102, 103, 104, 105, 106, 107],
},
llmqSize: {
type: 'integer',
minimum: 0,
quorum: {
$ref: '#/definitions/quorum',
},
dkgInterval: {
type: 'integer',
minimum: 0,
},
additionalProperties: false,
required: ['quorum'],
},
instantLock: {
type: 'object',
properties: {
quorum: {
$ref: '#/definitions/quorum',
},
},
additionalProperties: false,
required: ['llmqType', 'llmqSize', 'dkgInterval'],
required: ['quorum'],
},
epochTime: {
type: 'integer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function configureTenderdashTaskFactory() {

config.set(
'platform.drive.tenderdash.genesis.validator_quorum_type',
config.get('platform.drive.abci.validatorSet.llmqType'),
config.get('platform.drive.abci.validatorSet.quorum.llmqType'),
);
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export default function enableCoreQuorumsTaskFactory(generateBlocks) {
// eslint-disable-next-line prefer-destructuring
ctx.quorumHash = quorumList[LLMQ_TYPE_TEST_PLATFORM][0];

const llmqType = ctx.masternodeCoreServices[0].getConfig().get('platform.drive.abci.validatorSet.llmqType');
const llmqType = ctx.masternodeCoreServices[0].getConfig().get('platform.drive.abci.validatorSet.quorum.llmqType');

const { result: quorumInfo } = await ctx.seedRpcClient.quorum('info', llmqType, ctx.quorumHash);

Expand Down
8 changes: 4 additions & 4 deletions packages/dashmate/test/unit/commands/config/set.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,18 @@ describe('Config set command', () => {
const command = new ConfigSetCommand();

await command.runWithDependencies({
option: 'platform.drive.abci.validatorSet.llmqType',
option: 'platform.drive.abci.validatorSet.quorum.llmqType',
value: 107,
}, flags, config);

expect(config.get('platform.drive.abci.validatorSet.llmqType')).to.equal(107);
expect(config.get('platform.drive.abci.validatorSet.quorum.llmqType')).to.equal(107);

await command.runWithDependencies({
option: 'platform.drive.abci.validatorSet.llmqType',
option: 'platform.drive.abci.validatorSet.quorum.llmqType',
value: '107',
}, flags, config);

expect(config.get('platform.drive.abci.validatorSet.llmqType')).to.equal(107);
expect(config.get('platform.drive.abci.validatorSet.quorum.llmqType')).to.equal(107);
});

it('should allow setting booleans', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use bincode::{Decode, Encode};
PlatformSerialize,
PlatformDeserialize,
)]
#[error("Invalid instant lock proof signature")]
#[error("Instant lock proof signature is invalid or wasn't created recently. Pleases try chain asset lock proof instead.")]
#[platform_serialize(unversioned)]
pub struct InvalidInstantAssetLockProofSignatureError;

Expand Down
15 changes: 13 additions & 2 deletions packages/rs-drive-abci/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@ CORE_JSON_RPC_PASSWORD=password
INITIAL_CORE_CHAINLOCKED_HEIGHT=1243

# https://github.com/dashevo/dashcore-lib/blob/286c33a9d29d33f05d874c47a9b33764a0be0cf1/lib/constants/index.js#L42-L57
VALIDATOR_SET_QUORUM_TYPE=llmq_test
VALIDATOR_SET_QUORUM_TYPE=llmq_test_platform
VALIDATOR_SET_QUORUM_SIZE=3
VALIDATOR_SET_QUORUM_WINDOW=24
VALIDATOR_SET_QUORUM_ACTIVE_SIGNERS=2
VALIDATOR_SET_QUORUM_ROTATION=false
VALIDATOR_SET_ROTATION_BLOCK_COUNT=64

CHAIN_LOCK_QUORUM_TYPE=llmq_test
CHAIN_LOCK_QUORUM_WINDOW=24
CHAIN_LOCK_QUORUM_SIZE=3
CHAIN_LOCK_QUORUM_WINDOW=24
CHAIN_LOCK_QUORUM_ACTIVE_SIGNERS=2
CHAIN_LOCK_QUORUM_ROTATION=false

INSTANT_LOCK_QUORUM_TYPE=llmq_test_instantsend
INSTANT_LOCK_QUORUM_SIZE=3
INSTANT_LOCK_QUORUM_WINDOW=24
INSTANT_LOCK_QUORUM_ACTIVE_SIGNERS=2
INSTANT_LOCK_QUORUM_ROTATION=false

# DPNS Contract

Expand Down
Loading
Loading