Skip to content

Commit b207004

Browse files
committed
Add docs
1 parent 324e68f commit b207004

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

framework/components/blockchain/canton.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,70 +10,75 @@ import (
1010
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain/canton"
1111
)
1212

13+
// newCanton sets up a Canton blockchain network with the specified number of validators.
14+
// It creates a Docker network and starts the necessary containers for Postgres, Canton, Splice, and an Nginx reverse proxy.
15+
//
16+
// The reverse proxy is used to allow access to all validator participants through a single HTTP endpoint.
17+
// The following routes are configured for each participant and the Super Validator (SV):
18+
// - http://[PARTICIPANT].json-ledger-api.localhost:[PORT] -> JSON Ledger API
19+
// - grpc://[PARTICIPANT].grpc-ledger-api.localhost:[PORT] -> gRPC Ledger API
20+
// - http://[PARTICIPANT].admin-api.localhost:[PORT] -> Admin API
21+
// - http://[PARTICIPANT].wallet.localhost:[PORT] -> Wallet API
22+
// - http://[PARTICIPANT].http-health-check.localhost:[PORT] -> HTTP Health Check
23+
// - grpc://[PARTICIPANT].grpc-health-check.localhost:[PORT] -> gRPC Health Check
24+
// To access a participant's endpoints, replace [PARTICIPANT] with the participant's identifier, i.e. `sv`, `participant01`, `participant02`, ...
25+
//
26+
// Additionally, the global Scan service is accessible via:
27+
// - http://scan.localhost:[PORT]/api/scan -> Scan API
28+
// - http://scan.localhost:[PORT]/registry -> Scan Registry
29+
// The PORT is the same for all routes and is specified in the input parameters.
30+
//
31+
// Note: The maximum number of validators supported is 99, participants are numbered starting from `participant01` through `participant99`.
1332
func newCanton(ctx context.Context, in *Input) (*Output, error) {
1433
if in.NumberOfCantonValidators >= 100 {
1534
return nil, fmt.Errorf("number of validators too high: %d, max is 99", in.NumberOfCantonValidators)
1635
}
1736

18-
// TODO - remove debug prints
19-
fmt.Println("Starting Canton blockchain node...")
20-
fmt.Println("Creating network...")
37+
// Create separate Docker network for Canton stack
2138
dockerNetwork, err := network.New(ctx, network.WithAttachable())
2239
if err != nil {
2340
return nil, err
2441
}
25-
fmt.Println("Network created:", dockerNetwork.Name)
2642

2743
// Set up Postgres container
2844
postgresReq := canton.PostgresContainerRequest(in.NumberOfCantonValidators, dockerNetwork.Name)
29-
fmt.Printf("Starting postgres container %s...\n", postgresReq.Name)
30-
c, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
45+
_, err = testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
3146
ContainerRequest: postgresReq,
3247
Started: true,
3348
})
3449
if err != nil {
3550
return nil, err
3651
}
37-
_ = c
38-
fmt.Println("Postgres container started")
3952

4053
// Set up Canton container
4154
cantonReq := canton.CantonContainerRequest(dockerNetwork.Name, in.NumberOfCantonValidators, in.Image)
42-
fmt.Printf("Starting canton container %s...\n", cantonReq.Name)
43-
cantonContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
55+
_, err = testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
4456
ContainerRequest: cantonReq,
4557
Started: true,
4658
})
4759
if err != nil {
4860
return nil, err
4961
}
50-
_ = cantonContainer
51-
fmt.Println("Canton container started")
5262

5363
// Set up Splice container
5464
spliceReq := canton.SpliceContainerRequest(dockerNetwork.Name, in.NumberOfCantonValidators, in.Image)
55-
fmt.Printf("Starting splice container %s...\n", spliceReq.Name)
56-
spliceContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
65+
_, err = testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
5766
ContainerRequest: spliceReq,
5867
Started: true,
5968
})
6069
if err != nil {
6170
return nil, err
6271
}
63-
_ = spliceContainer
64-
fmt.Println("Splice container started")
6572

6673
// Set up Nginx container
6774
nginxReq := canton.NginxContainerRequest(dockerNetwork.Name, in.NumberOfCantonValidators, in.Port)
68-
fmt.Printf("Starting nginx container %s...\n", nginxReq.Name)
6975
nginxContainer, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
7076
ContainerRequest: nginxReq,
7177
Started: true,
7278
})
7379
if err != nil {
7480
return nil, err
7581
}
76-
fmt.Println("Nginx container started")
7782

7883
host, err := nginxContainer.Host(ctx)
7984
if err != nil {
@@ -88,7 +93,6 @@ func newCanton(ctx context.Context, in *Input) (*Output, error) {
8893
Nodes: []*Node{
8994
{
9095
ExternalHTTPUrl: fmt.Sprintf("http://%s:%s", host, in.Port),
91-
InternalHTTPUrl: fmt.Sprintf("http://%s:%s", nginxReq.Name, in.Port), // TODO - should be docker-internal port instead?
9296
},
9397
},
9498
}, nil

0 commit comments

Comments
 (0)