Skip to content

Commit

Permalink
feat(satp-Hermes): gateway refactor WIP
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

feat(bungee): add skeleton for bungee

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>

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 <andre.augusto@tecnico.ulisboa.pt>

feat(SATP-Hermes): gateway coordinator

feat(SATP-Hermes): gateway coordinator

feat(SATP-Hermes): gateway coordinator WIP

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

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

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

docs(SATP-Hermes): update package.json

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

refactor(SATP-Hermes): re-estructure project

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

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

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

feat(SATP-Hermes): protobuf structure

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

feat(SATP-Hermes): protobuf structure

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

refactor(SATP-Hermes): refactor naming

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

feat(SATP-Hermes): protobuf structure improvements

Signed-off-by: Rafael Belchior <rafael.belchior@tecnico.ulisboa.pt>

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

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>

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 #2811

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>

refactor(SATP-Hermes): remove unused packages

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

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
RafaelAPB committed Aug 9, 2024
1 parent d0e4539 commit 2b20a8b
Show file tree
Hide file tree
Showing 169 changed files with 2,699 additions and 5,065 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ tools/docker/geth-testnet/data-geth1/
.history/
.manual-geth-artillery-config.yaml
packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/fixtures/go/asset-transfer-private-data/chaincode-go/chaincode-go
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 @@ -105,11 +105,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 @@ -134,10 +135,10 @@ export class CbdcBridgingApp {
});

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

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

const crpcOptionsServer1 = {
host: this.options.apiCrpcHost,
Expand Down Expand Up @@ -190,8 +191,8 @@ export class CbdcBridgingApp {
),
fabricApiClient,
besuApiClient,
fabricSatpGateway,
besuSatpGateway,
FabricSATPGateway,
BesuSATPGateway,
};
}

Expand Down Expand Up @@ -254,6 +255,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 @@ -39,8 +39,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 @@ -248,9 +248,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 @@ -275,9 +275,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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module.exports = {
maxConcurrency: 1,
setupFilesAfterEnv: ["jest-extended/all", "./jest.setup.console.logs.js"],
testTimeout: 60 * 60 * 1000,
moduleNameMapper: {
"^(.+)/(.+)_pb\\.js$": "$1/$2_pb"
},
testMatch: [
`**/cactus-*/src/test/typescript/{unit,integration,benchmark}/**/*.test.ts`,
`**/cacti-*/src/test/typescript/{unit,integration,benchmark}/**/*.test.ts`,
Expand Down
Loading

0 comments on commit 2b20a8b

Please sign in to comment.