Skip to content

Commit 32090e3

Browse files
committed
chore(satp-hermes): document bridge configuration
Signed-off-by: Rafael Belchior <[email protected]> Co-signed-by: Rafael Belchior <[email protected]>
1 parent fb214cb commit 32090e3

File tree

5 files changed

+136
-10
lines changed

5 files changed

+136
-10
lines changed

packages/cactus-plugin-satp-hermes/README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,57 @@ const gatewayConfig: {
163163

164164
### Bridge Configuration
165165

166+
#### Reusing Deployed Wrapper Contracts
167+
168+
When you already have bridge wrapper contracts on-chain, provide their identifiers in the leaf configuration so the deployment step skips redeployment. The CLI entrypoint loads the configuration, `validateCCConfig` verifies the schema, and the bridge manager attaches each leaf to the supplied contract details.
169+
170+
##### Fabric Leaf Wrapper Example
171+
```typescript
172+
const fabricWrapperConfig = {
173+
networkIdentification: {
174+
id: "FabricLedgerTestNetwork",
175+
ledgerType: "FABRIC_2",
176+
},
177+
channelName: "mychannel",
178+
signingCredential: {/* Fabric signing credential */},
179+
connectorOptions: {/* Fabric connector options */},
180+
wrapperContractName: "satp-wrapper-fabric", // Existing chaincode package name
181+
claimFormats: [1],
182+
};
183+
```
184+
185+
##### Besu Leaf Wrapper Example
186+
```typescript
187+
const besuWrapperConfig = {
188+
networkIdentification: {
189+
id: "BesuLedgerTestNetwork",
190+
ledgerType: "BESU_2X",
191+
},
192+
signingCredential: {/* Besu signing credential */},
193+
connectorOptions: {/* Besu connector options */},
194+
wrapperContractName: "BesuWrapper",
195+
wrapperContractAddress: "0x1234...cdef",
196+
claimFormats: [1],
197+
};
198+
```
199+
200+
##### Ethereum Leaf Wrapper Example
201+
```typescript
202+
const ethereumWrapperConfig = {
203+
networkIdentification: {
204+
id: "EthereumLedgerTestNetwork",
205+
ledgerType: "ETHEREUM",
206+
},
207+
signingCredential: {/* Ethereum signing credential */},
208+
connectorOptions: {/* Ethereum connector options */},
209+
wrapperContractName: "EthereumWrapper",
210+
wrapperContractAddress: "0x9876...abcd",
211+
claimFormats: [1],
212+
};
213+
```
214+
215+
If both `wrapperContractName` and `wrapperContractAddress` are present (Fabric only requires the name), leaf deployment logs that contracts already exist and continues without redeploying them.
216+
166217
#### Fabric Configuration Example:
167218
```typescript
168219
const leafConfig = {
@@ -264,6 +315,49 @@ const leafConfig = {
264315
claimFormats: [1] // Claim format identifiers (application-specific)
265316
}
266317
```
318+
319+
### Gateway Example (One Leaf Using Existing Wrapper)
320+
```typescript
321+
const gatewayConfig = {
322+
gid: {
323+
id: "gatewayId",
324+
name: "GatewayWithBesuConnection",
325+
version: [{ Core: "v02", Architecture: "v02", Crash: "v02" }],
326+
proofID: "mockProofID10",
327+
address: "http://gateway1.satp-hermes",
328+
},
329+
logLevel: "TRACE",
330+
counterPartyGateways: [],
331+
localRepository: localDbKnexConfig,
332+
remoteRepository: remoteDbKnexConfig,
333+
environment: "development",
334+
ontologyPath: "/opt/cacti/satp-hermes/ontologies",
335+
enableCrashRecovery: true,
336+
ccConfig: {
337+
bridgeConfig: [
338+
{
339+
networkIdentification: {
340+
id: "BesuLedgerTestNetwork",
341+
ledgerType: "BESU_2X",
342+
},
343+
signingCredential: {
344+
ethAccount: "0x736dC9B8258Ec5ab2419DDdffA9e1fa5C201D0b4",
345+
secret: "0xc31e76f70d6416337d3a7b7a8711a43e30a14963b5ba622fa6c9dbb5b4555986",
346+
type: "PRIVATE_KEY_HEX",
347+
},
348+
gas: 999999999999999,
349+
connectorOptions: {
350+
rpcApiHttpHost: "http://172.20.0.6:8545",
351+
rpcApiWsHost: "ws://172.20.0.6:8546",
352+
},
353+
wrapperContractName: "BesuWrapper",
354+
wrapperContractAddress: "0x09D16c22216BC873e53c8D93A38420f48A81dF1B",
355+
claimFormats: [1],
356+
},
357+
],
358+
},
359+
};
360+
```
267361
#### Notes:
268362
- **Field values:** Replace placeholders (such as file paths, endpoint addresses, credentials, etc.) with values appropriate for your environment.
269363
- **Security**: Credentials and secret material (certificates, private keys, etc.) must be handled securely, never checked into version control, and managed via secure secrets management.

packages/cactus-plugin-satp-hermes/src/main/typescript/cross-chain-mechanisms/bridge/leafs/besu-leaf.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,15 @@ export class BesuLeaf
357357
try {
358358
await Promise.all([this.deployWrapperContract()]);
359359
} catch (err) {
360-
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
361-
span.recordException(err);
360+
if (err instanceof WrapperContractAlreadyCreatedError) {
361+
this.log.debug(
362+
`${fnTag}, Wrapper contracts already exist, skipping deployment`,
363+
);
364+
span.setStatus({ code: SpanStatusCode.OK });
365+
} else {
366+
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
367+
span.recordException(err);
368+
}
362369
throw err;
363370
} finally {
364371
span.end();

packages/cactus-plugin-satp-hermes/src/main/typescript/cross-chain-mechanisms/bridge/leafs/ethereum-leaf.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,15 @@ export class EthereumLeaf
341341
try {
342342
await Promise.all([this.deployWrapperContract()]);
343343
} catch (err) {
344-
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
345-
span.recordException(err);
344+
if (err instanceof WrapperContractAlreadyCreatedError) {
345+
this.log.debug(
346+
`${fnTag}, Wrapper contracts already exist, skipping deployment`,
347+
);
348+
span.setStatus({ code: SpanStatusCode.OK });
349+
} else {
350+
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
351+
span.recordException(err);
352+
}
346353
throw err;
347354
} finally {
348355
span.end();
@@ -368,8 +375,15 @@ export class EthereumLeaf
368375
}
369376
return this.wrapperDeployReceipt;
370377
} catch (err) {
371-
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
372-
span.recordException(err);
378+
if (err instanceof WrapperContractAlreadyCreatedError) {
379+
this.log.debug(
380+
`${fnTag}, Wrapper contracts already exist, skipping deployment`,
381+
);
382+
span.setStatus({ code: SpanStatusCode.OK });
383+
} else {
384+
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
385+
span.recordException(err);
386+
}
373387
throw err;
374388
} finally {
375389
span.end();

packages/cactus-plugin-satp-hermes/src/main/typescript/cross-chain-mechanisms/bridge/leafs/fabric-leaf.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,15 @@ export class FabricLeaf
397397
// this.deployNonFungibleWrapperContract(),
398398
]);
399399
} catch (err) {
400-
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
401-
span.recordException(err);
400+
if (err instanceof WrapperContractAlreadyCreatedError) {
401+
this.log.debug(
402+
`${fnTag}, Wrapper contracts already exist, skipping deployment`,
403+
);
404+
span.setStatus({ code: SpanStatusCode.OK });
405+
} else {
406+
span.setStatus({ code: SpanStatusCode.ERROR, message: String(err) });
407+
span.recordException(err);
408+
}
402409
throw err;
403410
} finally {
404411
span.end();

packages/cactus-plugin-satp-hermes/src/main/typescript/cross-chain-mechanisms/bridge/satp-bridge-execution-layer-implementation.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,19 @@ export class SATPBridgeExecutionLayerImpl implements SATPBridgeExecutionLayer {
610610
* @throws {Error} If the method is not implemented.
611611
*/
612612
public async verifyAssetExistence(
613-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
614613
assetId: string,
615-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
616614
invocationType: unknown,
617615
): Promise<boolean | undefined> {
618616
const fnTag = `${SATPBridgeExecutionLayerImpl.CLASS_NAME}#verifyAssetExistence()`;
619617
const { span, context: ctx } = this.monitorService.startSpan(fnTag);
620618
return context.with(ctx, () => {
621619
try {
620+
this.log.debug(
621+
`${fnTag}, Verifying asset existence for assetId: ${assetId}`,
622+
);
623+
this.log.debug(
624+
`${fnTag}, invocationType: ${JSON.stringify(invocationType)}`,
625+
);
622626
//todo: implement this
623627
throw new Error("Not implemented");
624628
} catch (err) {

0 commit comments

Comments
 (0)