Skip to content

Commit

Permalink
feat(bungee): add skeleton for bungee
Browse files Browse the repository at this point in the history
Signed-off-by: André Augusto <[email protected]>

refactor(plugin-satp-hermes): update messages formats SATP core version 2.0.0 OpenAPI

* created new messages in openAPI definition

feat(bungee): fix bungee dependencies

Signed-off-by: André Augusto <[email protected]>

feat(SATP-Hermes): gateway coordinator

feat(SATP-Hermes): gateway coordinator

feat(SATP-Hermes): gateway coordinator WIP

Signed-off-by: Rafael Belchior <[email protected]>

test(SATP-Hermes): enable decorators needed for gateway coordinator checks

Signed-off-by: Rafael Belchior <[email protected]>

docs(SATP-Hermes): update package.json

Signed-off-by: Rafael Belchior <[email protected]>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <[email protected]>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <[email protected]>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <[email protected]>

refactor(SATP-Hermes): remove kotlin sdk, add protobuffer

Signed-off-by: Rafael Belchior <[email protected]>

feat(SATP-Hermes): protobuf structure

Signed-off-by: Rafael Belchior <[email protected]>

feat(SATP-Hermes): protobuf structure

Signed-off-by: Rafael Belchior <[email protected]>

refactor(SATP-Hermes): refactor naming

Signed-off-by: Rafael Belchior <[email protected]>

feat(SATP-Hermes): protobuf structure improvements

Signed-off-by: Rafael Belchior <[email protected]>

feat(SATP-Hermes): update yarn.lock and clean up

Signed-off-by: André Augusto <[email protected]>

refactor(test-tooling): fix types of streams: use NodeJS.ReadableStream

1. The container management library that we use in the test infrastructure
(called dockerode) is expecting streams that are defined in the global
namespace of the `@types/node` library, e.g. the standard library of NodeJS
itself.
2. Previously we were using the "streams" package to provide type information
to the streams that we were passing around to dockerode and it was working
fine, but after some changes that seem unrelated this has broken the
compilation process.
3. The mentioned changes are not yet on the main branch, but we expect
them to be there soon and so this change is laying the groundwork for that
by pre-emptively fixing the broken build's root cause which is that the
test-tooling package does not declare it's typings related dependencies
correctly: It implicitly uses the NodeJS standard library's types but
so far had not declared them on the package level.
4. This change is therefore to rectify the issue of the `@types/node`
dependency missing from the test-tooling package and also the refactoring
of some of the test ledger classes which were relying on the `streams`
builtin package instead of correctly using the NodeJS.ReadableStream global.
5. Earlier the reasoning for this was that we try to avoid pulling in
types from the global scope because we try to avoid any sort of dependency
on the global scope in general. Once we have proof though that this is
causing issues with the build, then we must give up the principle for
practical reasons (and only in the minimum viable scope, e.g. this does
not change the fact that everywhere else in the codebase we should still
do our best to avoid using the global scoped classes, types, functions,
etc..).

Thank you to @AndreAugusto11 and @RafaelAPB for pointing out this issue
through the pull request of his that is currently being worked on at the
time of this writing:
RafaelAPB#72

Related to but does not address hyperledger-cacti#2811

Signed-off-by: Peter Somogyvari <[email protected]>

refactor(SATP-Hermes): remove unused packages

* updated openapi version
* updated bungee plugin version to 2.0.0-alpha.2

Co-authored-by: Peter Somogyvari <[email protected]>

Signed-off-by: André Augusto <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
AndreAugusto11 authored and petermetz committed Mar 4, 2024
1 parent e21073b commit 80b0803
Show file tree
Hide file tree
Showing 188 changed files with 3,284 additions and 5,606 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ site/
tools/docker/geth-testnet/data-geth1/

.history/
.manual-geth-artillery-config.yaml
.manual-geth-artillery-config.yaml
packages/cactus-plugin-satp-hermes/.config
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory
import { CbdcBridgingAppDummyInfrastructure } from "./infrastructure/cbdc-bridging-app-dummy-infrastructure";
import { DefaultApi as FabricApi } from "@hyperledger/cactus-plugin-ledger-connector-fabric";
import { DefaultApi as BesuApi } from "@hyperledger/cactus-plugin-ledger-connector-besu";
import { FabricSatpGateway } from "./satp-extension/fabric-satp-gateway";
import { BesuSatpGateway } from "./satp-extension/besu-satp-gateway";
import { FabricSATPGateway } from "./satp-extension/fabric-satp-gateway";
import { BesuSATPGateway } from "./satp-extension/besu-satp-gateway";
import CryptoMaterial from "../../crypto-material/crypto-material.json";

export interface ICbdcBridgingApp {
Expand Down Expand Up @@ -97,12 +97,12 @@ export class CbdcBridgingApp {
const addressInfoB = httpApiB.address() as AddressInfo;
const nodeApiHostB = `http://${this.options.apiHost}:${addressInfoB.port}`;

const fabricSatpGateway = await this.infrastructure.createClientGateway(
const FabricSATPGateway = await this.infrastructure.createClientGateway(
nodeApiHostA,
this.options.clientGatewayKeyPair,
);

const besuSatpGateway = await this.infrastructure.createServerGateway(
const BesuSATPGateway = await this.infrastructure.createServerGateway(
nodeApiHostB,
this.options.serverGatewayKeyPair,
);
Expand All @@ -127,10 +127,10 @@ export class CbdcBridgingApp {
});

clientPluginRegistry.add(fabricPlugin);
clientPluginRegistry.add(fabricSatpGateway);
clientPluginRegistry.add(FabricSATPGateway);

serverPluginRegistry.add(besuPlugin);
serverPluginRegistry.add(besuSatpGateway);
serverPluginRegistry.add(BesuSATPGateway);

const apiServer1 = await this.startNode(httpApiA, clientPluginRegistry);
const apiServer2 = await this.startNode(httpApiB, serverPluginRegistry);
Expand Down Expand Up @@ -166,8 +166,8 @@ export class CbdcBridgingApp {
),
fabricApiClient,
besuApiClient,
fabricSatpGateway,
besuSatpGateway,
FabricSATPGateway,
BesuSATPGateway,
};
}

Expand Down Expand Up @@ -227,6 +227,6 @@ export interface IStartInfo {
readonly besuGatewayApi: SatpApi;
readonly besuApiClient: BesuApi;
readonly fabricApiClient: FabricApi;
readonly fabricSatpGateway: FabricSatpGateway;
readonly besuSatpGateway: BesuSatpGateway;
readonly FabricSATPGateway: FabricSATPGateway;
readonly BesuSATPGateway: BesuSATPGateway;
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import { PluginRegistry } from "@hyperledger/cactus-core";
import AssetReferenceContractJson from "../../../solidity/asset-reference-contract/AssetReferenceContract.json";
import CBDCcontractJson from "../../../solidity/cbdc-erc-20/CBDCcontract.json";
import { IKeyPair } from "@hyperledger/cactus-plugin-satp-hermes";
import { FabricSatpGateway } from "../satp-extension/fabric-satp-gateway";
import { BesuSatpGateway } from "../satp-extension/besu-satp-gateway";
import { FabricSATPGateway } from "../satp-extension/fabric-satp-gateway";
import { BesuSATPGateway } from "../satp-extension/besu-satp-gateway";
import { PluginImportType } from "@hyperledger/cactus-core-api";
import CryptoMaterial from "../../../crypto-material/crypto-material.json";
import { ClientHelper } from "../satp-extension/client-helper";
Expand Down Expand Up @@ -274,9 +274,9 @@ export class CbdcBridgingAppDummyInfrastructure {
public async createClientGateway(
nodeApiHost: string,
keyPair: IKeyPair,
): Promise<FabricSatpGateway> {
): Promise<FabricSATPGateway> {
this.log.info(`Creating Source Gateway...`);
const pluginSourceGateway = new FabricSatpGateway({
const pluginSourceGateway = new FabricSATPGateway({
name: "cactus-plugin-source#satpGateway",
dltIDs: ["DLT2"],
instanceId: uuidv4(),
Expand All @@ -301,9 +301,9 @@ export class CbdcBridgingAppDummyInfrastructure {
public async createServerGateway(
nodeApiHost: string,
keyPair: IKeyPair,
): Promise<BesuSatpGateway> {
): Promise<BesuSATPGateway> {
this.log.info(`Creating Recipient Gateway...`);
const pluginRecipientGateway = new BesuSatpGateway({
const pluginRecipientGateway = new BesuSATPGateway({
name: "cactus-plugin-recipient#satpGateway",
dltIDs: ["DLT1"],
instanceId: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
} from "@hyperledger/cactus-plugin-ledger-connector-besu";
import {
IPluginSatpGatewayConstructorOptions,
PluginSatpGateway,
PluginSATPGateway,
} from "@hyperledger/cactus-plugin-satp-hermes";
import { SessionDataRollbackActionsPerformedEnum } from "@hyperledger/cactus-plugin-satp-hermes";

export interface IBesuSatpGatewayConstructorOptions
export interface IBesuSATPGatewayConstructorOptions
extends IPluginSatpGatewayConstructorOptions {
besuContractName?: string;
besuWeb3SigningCredential?: Web3SigningCredential;
Expand All @@ -21,13 +21,13 @@ export interface IBesuSatpGatewayConstructorOptions
besuPath?: string;
}

export class BesuSatpGateway extends PluginSatpGateway {
export class BesuSATPGateway extends PluginSATPGateway {
public besuApi?: BesuApi;
public besuContractName?: string;
public besuWeb3SigningCredential?: Web3SigningCredential;
public besuKeychainId?: string;

public constructor(options: IBesuSatpGatewayConstructorOptions) {
public constructor(options: IBesuSATPGatewayConstructorOptions) {
super({
name: options.name,
dltIDs: options.dltIDs,
Expand All @@ -45,7 +45,7 @@ export class BesuSatpGateway extends PluginSatpGateway {
}

private defineBesuConnection(
options: IBesuSatpGatewayConstructorOptions,
options: IBesuSATPGatewayConstructorOptions,
): void {
const fnTag = `${this.className}#defineBesuConnection()`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { SHA256 } from "crypto-js";
import {
PluginSatpGateway,
PluginSATPGateway,
TransferInitializationV1Request,
ClientGatewayHelper,
} from "@hyperledger/cactus-plugin-satp-hermes";
import { SatpMessageType } from "@hyperledger/cactus-plugin-satp-hermes";
import { FabricSatpGateway } from "./fabric-satp-gateway";
import { BesuSatpGateway } from "./besu-satp-gateway";
import { FabricSATPGateway } from "./fabric-satp-gateway";
import { BesuSATPGateway } from "./besu-satp-gateway";

export class ClientHelper extends ClientGatewayHelper {
async sendTransferInitializationRequest(
sessionID: string,
gateway: PluginSatpGateway,
gateway: PluginSATPGateway,
remote: boolean,
): Promise<void | TransferInitializationV1Request> {
const fnTag = `${this.className}#sendTransferInitializationRequest()`;
Expand Down Expand Up @@ -82,7 +82,7 @@ export class ClientHelper extends ClientGatewayHelper {
sourceLedgerAssetID: sessionData.sourceLedgerAssetID,
};

const messageSignature = PluginSatpGateway.bufArray2HexStr(
const messageSignature = PluginSATPGateway.bufArray2HexStr(
gateway.sign(JSON.stringify(initializationRequestMessage)),
);

Expand All @@ -103,7 +103,7 @@ export class ClientHelper extends ClientGatewayHelper {
data: JSON.stringify(sessionData),
});

if (gateway instanceof FabricSatpGateway) {
if (gateway instanceof FabricSATPGateway) {
await gateway
.isValidBridgeOutCBDC(
sessionData.sourceLedgerAssetID,
Expand All @@ -114,7 +114,7 @@ export class ClientHelper extends ClientGatewayHelper {
.catch((err) => {
throw new Error(`${err.response.data.error}`);
});
} else if (gateway instanceof BesuSatpGateway) {
} else if (gateway instanceof BesuSATPGateway) {
await gateway
.isValidBridgeBackCBDC(
sessionData.sourceLedgerAssetID,
Expand All @@ -134,7 +134,7 @@ export class ClientHelper extends ClientGatewayHelper {

await gateway.makeRequest(
sessionID,
PluginSatpGateway.getSatpAPI(
PluginSATPGateway.getSatpAPI(
sessionData.recipientBasePath,
).phase1TransferInitiationRequestV1(initializationRequestMessage),
"TransferInitializationRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ import {
} from "@hyperledger/cactus-plugin-ledger-connector-fabric";
import {
IPluginSatpGatewayConstructorOptions,
PluginSatpGateway,
PluginSATPGateway,
} from "@hyperledger/cactus-plugin-satp-hermes";
import { SessionDataRollbackActionsPerformedEnum } from "@hyperledger/cactus-plugin-satp-hermes";

export interface IFabricSatpGatewayConstructorOptions
export interface IFabricSATPGatewayConstructorOptions
extends IPluginSatpGatewayConstructorOptions {
fabricPath?: string;
fabricSigningCredential?: FabricSigningCredential;
fabricChannelName?: string;
fabricContractName?: string;
}

export class FabricSatpGateway extends PluginSatpGateway {
export class FabricSATPGateway extends PluginSATPGateway {
public fabricApi?: FabricApi;
public fabricSigningCredential?: FabricSigningCredential;
public fabricChannelName?: string;
public fabricContractName?: string;

public constructor(options: IFabricSatpGatewayConstructorOptions) {
public constructor(options: IFabricSATPGatewayConstructorOptions) {
super({
name: options.name,
dltIDs: options.dltIDs,
Expand All @@ -44,7 +44,7 @@ export class FabricSatpGateway extends PluginSatpGateway {
}

private defineFabricConnection(
options: IFabricSatpGatewayConstructorOptions,
options: IFabricSATPGatewayConstructorOptions,
): void {
const fnTag = `${this.className}#defineFabricConnection()`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import {
} from "@hyperledger/cactus-plugin-satp-hermes";
import {
SatpMessageType,
PluginSatpGateway,
PluginSATPGateway,
ServerGatewayHelper,
} from "@hyperledger/cactus-plugin-satp-hermes";

import { FabricSatpGateway } from "./fabric-satp-gateway";
import { FabricSATPGateway } from "./fabric-satp-gateway";
import { LogLevelDesc } from "@hyperledger/cactus-common";

export interface IServerHelperOptions {
Expand All @@ -30,7 +30,7 @@ export class ServerHelper extends ServerGatewayHelper {

async checkValidInitializationRequest(
request: TransferInitializationV1Request,
gateway: PluginSatpGateway,
gateway: PluginSATPGateway,
): Promise<void> {
const fnTag = `${gateway.className}#checkValidInitializationRequest()`;

Expand Down Expand Up @@ -124,7 +124,7 @@ export class ServerHelper extends ServerGatewayHelper {

gateway.sessions.set(request.sessionID, sessionData);

if (gateway instanceof FabricSatpGateway) {
if (gateway instanceof FabricSATPGateway) {
await gateway
.isValidBridgeBackCBDC(
request.payloadProfile.assetProfile.keyInformationLink[1].toString(), // FabricID
Expand Down
3 changes: 3 additions & 0 deletions jest.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/cactus-plugin-bungee/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperledger/cactus-plugin-bungee",
"version": "1.0.0",
"version": "2.0.0-alpha.2",
"description": "Proof of concept of bungee",
"keywords": [
"Hyperledger",
Expand Down Expand Up @@ -75,7 +75,7 @@
"@types/tape": "4.13.4",
"@types/uuid": "9.0.6",
"express": "4.18.2",
"fabric-network": "2.2.19"
"fabric-network": "2.2.20"
},
"engines": {
"node": ">=18",
Expand Down
4 changes: 2 additions & 2 deletions packages/cactus-plugin-bungee/src/main/json/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"info": {
"title": "Hyperledger Cactus Plugin - BUNGEE",
"description": "Can create blockchain views of a fabric ledger",
"version": "0.0.1",
"version": "2.0.0-alpha.2",
"license": {
"name": "Apache 2.0",
"name": "Apache-2.0",
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
}
},
Expand Down
Loading

0 comments on commit 80b0803

Please sign in to comment.