Skip to content

Commit db3475f

Browse files
eduv09petermetz
authored andcommitted
feat(consortium-static): new consortium plugin
* New plugin consortium-static, based on consortium-manual. Long story short, the plugin allows for the addition of Cacti Nodes to consortium at runtime. New node entities must belong to one of the consortium entities (organizations) that were specified on consortium creation. So it allows to add new nodes 'CactusNode', but not new 'ConsortiumMember' entities. * New feature: add CactusNode to consortium at runtime The code is based on the plugin-consortium-manual, with the new features built on top of it. The process of adding a new node is conducted as follows: 1. The new node forges a request with information about itself and sends it to any Node in the consortium 2. The receiver verifies the request, and if it is approved, broadcasts it to the rest of the consortium Nodes. 3. Each node verifies the same request, and adds the new node to the consortium database. At the same time, the receiver node from point 2 sends the consortium data to the new node, who updates it's database. * Includes a new policy model The package includes a policy model, which was developed based on the ideas of the Policy Core Information Model [RFC3060](https://www.rfc-editor.org/rfc/rfc3060) . The idea was to introduce the idea of a multi-purpose policy framework that can be leveraged by other packages in cacti. Signed-off-by: eduv09 <[email protected]>
1 parent bf35762 commit db3475f

File tree

86 files changed

+7730
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+7730
-1
lines changed

.github/workflows/ci.yaml

+33-1
Original file line numberDiff line numberDiff line change
@@ -2205,7 +2205,6 @@ jobs:
22052205
with:
22062206
name: coverage-reports-37
22072207
path: ./code-coverage-ts/**/
2208-
22092208
ct-cmd-api-server:
22102209
continue-on-error: false
22112210
needs:
@@ -2528,6 +2527,39 @@ jobs:
25282527
with:
25292528
name: coverage-reports-46
25302529
path: ./code-coverage-ts/**/
2530+
cp-consortium-static:
2531+
continue-on-error: false
2532+
env:
2533+
FULL_BUILD_DISABLED: true
2534+
JEST_TEST_RUNNER_DISABLED: false
2535+
JEST_TEST_PATTERN: packages/cacti-plugin-consortium-static/src/test/typescript/(unit|integration|benchmark)/.*/*.test.ts
2536+
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/cp-consortium-static
2537+
JEST_TEST_CODE_COVERAGE_ENABLED: true
2538+
TAPE_TEST_RUNNER_DISABLED: true
2539+
needs: build-dev
2540+
runs-on: ubuntu-22.04
2541+
steps:
2542+
- name: Use Node.js ${{ env.NODEJS_VERSION }}
2543+
uses: actions/[email protected]
2544+
with:
2545+
node-version: ${{ env.NODEJS_VERSION }}
2546+
- uses: actions/[email protected]
2547+
2548+
- id: yarn-cache
2549+
name: Restore Yarn Cache
2550+
uses: actions/[email protected]
2551+
with:
2552+
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
2553+
path: ./.yarn/
2554+
restore-keys: |
2555+
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
2556+
- run: ./tools/ci.sh
2557+
if: ${{ env.RUN_CODE_COVERAGE == 'true' }}
2558+
- name: Upload coverage reports as artifacts
2559+
uses: actions/[email protected]
2560+
with:
2561+
name: coverage-reports-47
2562+
path: ./code-coverage-ts/**/
25312563
ghcr-besu-all-in-one:
25322564
runs-on: ubuntu-22.04
25332565
steps:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cactus-openapi-spec-plugin-consortium-manual.json
2+
src/main/typescript/generated/openapi/typescript-axios/.npmignore
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# `@hyperledger/cacti-plugin-consortium-static`
2+
3+
## Cacti Consortium Static
4+
5+
This plugin is an improvement of the package /cactus-plugin-consortium-manual ,bringing some new features to the table while conserving the possibility to be used as the old one (not allowing runtime changes)
6+
7+
### Add Nodes to Consortium
8+
9+
It is possible to add a new node to the consortium using the api of the plugin.
10+
11+
New nodes need to belong/be certified by one of the organizations that are part of the consortium. On creating the consortium, it is required to specify the public keys of the organizations that are part of the consortium. When a new node requests to join, the request carries a jwt token signed by the organization it is tied to, which serves as proof that the organization reccognises the new node identity.
12+
13+
When a new node submits a request to join, the receiving node verifies the request and broadcasts it (or not, depending on the verification) to the remaining nodes in the consortium. There is no consensus or reliable broadcast implemented. All the other nodes submit the request to the same verification process. If, for some reason, there are disparities in the consortiumDatabases of each node, either it is due to a network issue (broadcast did not reach destination) or due to malfunction of some node.
14+
15+
16+
### Consortium Repository
17+
18+
In addition to the default consortium repository (in cactus-core), the new repository includes data about the Node the repository belongs to:
19+
```typescript
20+
//data about self
21+
private readonly node: CactusNode;
22+
private readonly ledgers: Ledger[];
23+
private readonly pluginInstances: PluginInstance[];
24+
private readonly memberId: string;
25+
```
26+
It also includes the root PolicyGroup of the consortium (explained in next section), and the common configurations of the packages deployed by nodes within the consortium.
27+
28+
We do not verify if the nodes actually apply these configurations and policies, the information so far is used just to check that nodes have knowledge of this settings. Compliance or not is at the responsibility of each node, and to be verified if necessary by other means.
29+
30+
To verify new nodes have the same policies and package configs as the others already in the consortium, we deterministically build two merkle trees (one with each info), concat both roots, and each node verifies the result against their own policies and package common configs.
31+
32+
As a result of this proccess, nodes with divergent policies and configs are not accepted in the consortium (we assume all nodes are correctly configured when the network is created).
33+
34+
### Policy Model
35+
36+
We introduce in this package a proposal of a general-purpose policy model based in work done by the IETF: Core Policy Framework [RFC3060](https://www.rfc-editor.org/rfc/rfc3060).
37+
38+
The model (simplified version) can be viewed in the policy-model directory.
39+
40+
As a brief description, we group PolicyRules in PolicyGroups. PolicyGroups contain PolicyRules and possibly other PolicyGroups. A PolicyRule is composed by a PolicyCondition (constraint to be verified prior to applying the policy) and a PolicyAction (action to be applied).
41+
42+
Below a simplified UML with the relationships between the classes:
43+
44+
![policy model uml](https://github.com/eduv09/images/blob/main/policy-model-uml.jpg)
45+
46+
The consortium information needs to hold only the root policyGroup (others are reached going down in the hierarchy). Each PolicyGroup has a Role. Roles identify the scope of the policy, so a PolicyRule has a set of Roles (role of the group it belongs to, and groups higher in the hierarchy).
47+
48+
The model is in an early stage, and serves only as a POC for now. The goal is to refine it, and possibly move it to cactus-core once if it is accepted by the community as a advantageous feature. It is possible to create consortium without any policy rule or group defined.
49+
50+
51+
52+
## Notes
53+
54+
Please reffer to package "@hyperledger/cactus-plugin-consortium-manual" as the documentation there applies to this one, namely information about the Prometheus Exporter.
55+
56+
For usage, check the tests in the /integration folder
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
3+
"spaces": 2,
4+
"generator-cli": {
5+
"version": "6.6.0"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
{
2+
"name": "@hyperledger/cacti-plugin-consortium-static",
3+
"version": "2.0.0-rc.3",
4+
"description": "A web service plugin that provides management capabilities on a Cactus consortium as a whole for administrative purposes.",
5+
"keywords": [
6+
"Hyperledger",
7+
"Cactus",
8+
"Integration",
9+
"Blockchain",
10+
"Distributed Ledger Technology"
11+
],
12+
"homepage": "https://github.com/hyperledger/cacti#readme",
13+
"bugs": {
14+
"url": "https://github.com/hyperledger/cacti/issues"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/hyperledger/cacti.git"
19+
},
20+
"license": "Apache-2.0",
21+
"author": {
22+
"name": "Hyperledger Cactus Contributors",
23+
"email": "[email protected]",
24+
"url": "https://www.hyperledger.org/use/cacti"
25+
},
26+
"contributors": [
27+
{
28+
"name": "Eduardo Vasques",
29+
"email": "[email protected]",
30+
"url": "https://example.com"
31+
},
32+
{
33+
"name": "Peter Somogyvari",
34+
"email": "[email protected]",
35+
"url": "https://accenture.com"
36+
}
37+
],
38+
"main": "dist/lib/main/typescript/index.js",
39+
"module": "dist/lib/main/typescript/index.js",
40+
"browser": "dist/cacti-plugin-consortium-static.web.umd.js",
41+
"types": "dist/lib/main/typescript/index.d.ts",
42+
"files": [
43+
"dist/*"
44+
],
45+
"scripts": {
46+
"codegen": "run-p 'codegen:*'",
47+
"codegen:openapi": "npm run generate-sdk",
48+
"generate-sdk": "run-p 'generate-sdk:*'",
49+
"generate-sdk:kotlin": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g kotlin -o ./src/main/kotlin/generated/openapi/kotlin-client/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
50+
"generate-sdk:typescript-axios": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected --ignore-file-override ../../openapi-generator-ignore",
51+
"watch": "npm-watch",
52+
"webpack": "npm-run-all webpack:dev",
53+
"webpack:dev": "npm-run-all webpack:dev:node webpack:dev:web",
54+
"webpack:dev:node": "webpack --env=dev --target=node --config ../../webpack.config.js",
55+
"webpack:dev:web": "webpack --env=dev --target=web --config ../../webpack.config.js"
56+
},
57+
"dependencies": {
58+
"@hyperledger/cactus-common": "2.0.0-rc.3",
59+
"@hyperledger/cactus-core": "2.0.0-rc.3",
60+
"@hyperledger/cactus-core-api": "2.0.0-rc.3",
61+
"axios": "1.6.0",
62+
"body-parser": "1.20.2",
63+
"express": "4.19.2",
64+
"http-errors-enhanced-cjs": "2.0.1",
65+
"jose": "4.15.5",
66+
"merkletreejs": "0.4.0",
67+
"prom-client": "15.1.3",
68+
"safe-stable-stringify": "2.4.3",
69+
"typescript-optional": "2.0.1",
70+
"uuid": "10.0.0"
71+
},
72+
"devDependencies": {
73+
"@hyperledger/cactus-api-client": "2.0.0-rc.3",
74+
"@hyperledger/cactus-cmd-api-server": "2.0.0-rc.3",
75+
"@hyperledger/cactus-plugin-ledger-connector-besu": "2.0.0-rc.3",
76+
"@hyperledger/cactus-test-tooling": "2.0.0-rc.3",
77+
"@types/express": "4.17.21",
78+
"@types/json-stable-stringify": "1.0.33",
79+
"@types/uuid": "10.0.0",
80+
"web3": "1.6.1"
81+
},
82+
"engines": {
83+
"node": ">=18",
84+
"npm": ">=8"
85+
},
86+
"publishConfig": {
87+
"access": "public"
88+
},
89+
"browserMinified": "dist/cacti-plugin-consortium-static.web.umd.min.js",
90+
"mainMinified": "dist/cacti-plugin-consortium-static.node.umd.min.js",
91+
"watch": {
92+
"codegen:openapi": {
93+
"patterns": [
94+
"./src/main/json/openapi.json"
95+
]
96+
}
97+
}
98+
}

0 commit comments

Comments
 (0)