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

Commit

Permalink
Patched finality proof for testnet_v3 (#538)
Browse files Browse the repository at this point in the history
Added bootstrap-start-testnet

Co-authored-by: fernando <[email protected]>
  • Loading branch information
rg911 and fboucquez authored Dec 2, 2020
1 parent 998c75d commit 03add73
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 24 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ yarn test
yarn bootstrap-stop
```

## Testnet

Another alternative, is having bootstrap creating a Testnet node without rest that you can run from code:

```
yarn bootstrap-start-testnet
```

In another terminal

```
yarn start:dev
```


## Usage

Please refer to the [documentation](https://nemtech.github.io/api.html) for more information.
Expand Down
2 changes: 1 addition & 1 deletion catapult-sdk/src/model/ModelSchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ class ModelSchemaBuilder {
messageGroups: { type: ModelType.array, schemaName: 'messageGroup' }
},
messageGroup: {
signatureSchema: ModelType.uint16,
stage: ModelType.uint32,
height: ModelType.uint64,
hashes: { type: ModelType.array, schemaName: ModelType.binary },
signatures: { type: ModelType.array, schemaName: 'bmTreeSignature' }
},
bmTreeSignature: {
root: { type: ModelType.object, schemaName: 'parentPublicKeySignaturePair' },
top: { type: ModelType.object, schemaName: 'parentPublicKeySignaturePair' },
bottom: { type: ModelType.object, schemaName: 'parentPublicKeySignaturePair' }
},
parentPublicKeySignaturePair: {
Expand Down
1 change: 0 additions & 1 deletion catapult-sdk/test/model/ModelSchemaBuilder_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ describe('model schema builder', () => {
'blockHeaderWithMetadata.block',

'bmTreeSignature.root',
'bmTreeSignature.top',
'bmTreeSignature.bottom',

'transactionWithMetadata.meta',
Expand Down
20 changes: 20 additions & 0 deletions rest/bootstrap-preset-testnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#nodeEqualityStrategy: public-key
logLevel: 'Debug'
throttlingBurst: 35
throttlingRate: 1000
databases:
- name: db
openPort: true
nodes:
- trustedHosts: '127.0.0.1, 172.20.0.25, 172.20.0.1'
localNetworks: '127.0.0.1, 172.20.0.25, 172.20.0.1'
openPort: true
brokerOpenPort: 7902
gateways:
- excludeDockerService: true
name: rest
apiNodeConfigPath: target/gateways/rest/api-node-config
restLoggingFilename: target/rest.log
databaseHost: localhost
apiNodeHost: localhost

3 changes: 3 additions & 0 deletions rest/bootstrap-preset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
logLevel: 'Debug'
throttlingBurst: 35
throttlingRate: 1000
#votingKeyLinkV2: 360000
#importanceBlock: 360000
#accountRestrictionsV2: 360000
nodes:
- repeat: 0
- trustedHosts: '127.0.0.1, 172.20.0.25, 172.20.0.1'
Expand Down
3 changes: 2 additions & 1 deletion rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lint:jenkins": "eslint -o tests.catapult.lint.xml -f junit src test || exit 0",
"bootstrap-clean": "symbol-bootstrap clean",
"bootstrap-start": "symbol-bootstrap start -a light -c bootstrap-preset.yml --healthCheck",
"bootstrap-start-testnet": "symbol-bootstrap start -p testnet -a dual -c bootstrap-preset-testnet.yml --healthCheck",
"bootstrap-start-detached": "symbol-bootstrap start -a light -c bootstrap-preset.yml --detached --healthCheck",
"bootstrap-stop": "symbol-bootstrap stop",
"bootstrap-run": "symbol-bootstrap run",
Expand Down Expand Up @@ -46,7 +47,7 @@
"nodemon": "^2.0.6",
"rimraf": "^2.6.3",
"sinon": "^7.3.2",
"symbol-bootstrap": "0.3.0-alpha-202011301515"
"symbol-bootstrap": "0.3.0-alpha-202012011317"
},
"dependencies": {
"catapult-sdk": "link:../catapult-sdk",
Expand Down
9 changes: 2 additions & 7 deletions rest/src/sockets/finalizationProofCodec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ const finalizationProofCodec = {
while (0 !== sizeLeft) {
const messageGroupSize = parser.uint32();
const hashCount = parser.uint32();
const signatureCount = parser.uint32();
const signatureCount = parser.uint16();
const messageGroup = {
signatureSchema: parser.uint16(),
stage: parser.uint32(),
height: parser.uint64(),
hashes: [],
Expand All @@ -62,25 +63,19 @@ const finalizationProofCodec = {

for (let i = 0; i < hashCount; i++)
messageGroup.hashes.push(parser.buffer(sizes.hash256));

for (let i = 0; i < signatureCount; i++) {
const signature = {
root: {
parentPublicKey: parser.buffer(sizes.signerPublicKey),
signature: parser.buffer(sizes.signature)
},
top: {
parentPublicKey: parser.buffer(sizes.signerPublicKey),
signature: parser.buffer(sizes.signature)
},
bottom: {
parentPublicKey: parser.buffer(sizes.signerPublicKey),
signature: parser.buffer(sizes.signature)
}
};
messageGroup.signatures.push(signature);
}

proof.messageGroups.push(messageGroup);
sizeLeft -= messageGroupSize;
}
Expand Down
16 changes: 6 additions & 10 deletions rest/test/sockets/finalizationProofCodec_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ describe('deserialize', () => {
const createSignature = () => {
const rootParentPublicKey = testPublicKey;
const rootSignature = testInnerSignature;
const topParentPublicKey = testPublicKey;
const topSignature = testInnerSignature;
const bottomParentPublicKey = testPublicKey;
const bottomSignature = testInnerSignature;

const signature = [
rootParentPublicKey, rootSignature,
topParentPublicKey, topSignature,
bottomParentPublicKey, bottomSignature
];

Expand All @@ -66,12 +63,14 @@ describe('deserialize', () => {
const createMessageGroup = (hashCount, signatureCount) => {
const messageGroupSize = Buffer.from([0x00, 0x00, 0x00, 0x00]); // 4b
const messageGrouphashCount = Buffer.from([0x00, 0x00, 0x00, 0x00]); // 4b
const messageGroupsignatureCount = Buffer.from([0x00, 0x00, 0x00, 0x00]); // 4b
const messageGroupsignatureCount = Buffer.from([0x00, 0x00]); // 2b
const messageGroupsignatureSchema = Buffer.from([0x01, 0x00]); // 2b
const messageGroupStage = Buffer.from([0x01, 0x00, 0x00, 0x00]); // 4b
const messageGroupHeight = Buffer.from([0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]); // 8b

const messageGroup = [
messageGroupSize, messageGrouphashCount, messageGroupsignatureCount, messageGroupStage, messageGroupHeight
messageGroupSize, messageGrouphashCount, messageGroupsignatureCount,
messageGroupsignatureSchema, messageGroupStage, messageGroupHeight
];

for (let i = 0; i < hashCount; ++i)
Expand All @@ -83,7 +82,7 @@ describe('deserialize', () => {
const messageGroupBuffer = Buffer.concat(messageGroup);
messageGroupBuffer.writeInt32LE(messageGroupBuffer.length, 0);
messageGroupBuffer.writeInt32LE(hashCount, 4);
messageGroupBuffer.writeInt32LE(signatureCount, 8);
messageGroupBuffer.writeInt16LE(signatureCount, 8);

return messageGroupBuffer;
};
Expand All @@ -102,10 +101,6 @@ describe('deserialize', () => {
parentPublicKey: testPublicKey,
signature: testInnerSignature
},
top: {
parentPublicKey: testPublicKey,
signature: testInnerSignature
},
bottom: {
parentPublicKey: testPublicKey,
signature: testInnerSignature
Expand All @@ -121,6 +116,7 @@ describe('deserialize', () => {
for (let i = 0; i < messageGroupsCount; ++i) {
finalizationProof.push(createMessageGroup(hashCount, signatureCount));
expectedMessageGroups.push({
signatureSchema: 1,
stage: 1,
height: [1, 0],
hashes: expectedHashes,
Expand Down
8 changes: 4 additions & 4 deletions rest/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5900,10 +5900,10 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"

[email protected]202011301515:
version "0.3.0-alpha-202011301515"
resolved "https://registry.yarnpkg.com/symbol-bootstrap/-/symbol-bootstrap-0.3.0-alpha-202011301515.tgz#737c6b9556afba4f087d6ac5ba6bbabbd4922a0f"
integrity sha512-FBWXSrMrQE3BOUmIYMgVCI+RLlwVg6eh5aJ+HHhKNuuts+Glpid9xE12J+MxDLEzFEx9N/qvUVT/tLx2fO9+vQ==
[email protected]202012011317:
version "0.3.0-alpha-202012011317"
resolved "https://registry.yarnpkg.com/symbol-bootstrap/-/symbol-bootstrap-0.3.0-alpha-202012011317.tgz#3a04060cf09b78a3b31818f8e44761c252ef1c41"
integrity sha512-nLYQy+3VpyTi6wgq7Hrtg1JXXD+olZ4u+/tlYHwnjq/mpTyfVQAeWKJWq9z5buyPvuZQdUgcxG5IRytWx/uaSg==
dependencies:
"@oclif/command" "^1.7.0"
"@oclif/config" "^1.16.0"
Expand Down

0 comments on commit 03add73

Please sign in to comment.