@@ -31,6 +31,7 @@ import (
31
31
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector"
32
32
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector/ethconnect"
33
33
"github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/connector/evmconnect"
34
+ "github.com/hyperledger/firefly-cli/internal/blockchain/ethereum/tessera"
34
35
"github.com/hyperledger/firefly-cli/internal/docker"
35
36
"github.com/hyperledger/firefly-cli/internal/log"
36
37
"github.com/hyperledger/firefly-cli/pkg/types"
@@ -78,10 +79,10 @@ func (p *QuorumProvider) WriteConfig(options *types.InitOptions) error {
78
79
}
79
80
80
81
// Generate tessera docker-entrypoint for each member
81
- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
82
+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
82
83
l .Info (fmt .Sprintf ("generating tessera docker-entrypoint file for member %d" , i ))
83
84
tesseraEntrypointOutputDirectory := filepath .Join (initDir , "tessera" , fmt .Sprintf ("tessera_%d" , i ))
84
- if err := CreateTesseraEntrypoint (p .ctx , tesseraEntrypointOutputDirectory , p .stack .Name , len (p .stack .Members )); err != nil {
85
+ if err := tessera . CreateTesseraEntrypoint (p .ctx , tesseraEntrypointOutputDirectory , p .stack .Name , len (p .stack .Members )); err != nil {
85
86
return err
86
87
}
87
88
}
@@ -143,7 +144,7 @@ func (p *QuorumProvider) FirstTimeSetup() error {
143
144
return err
144
145
}
145
146
146
- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
147
+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
147
148
// Copy member specific tessera key files
148
149
if err := p .dockerMgr .MkdirInVolume (p .ctx , tesseraVolumeNameMember , rootDir ); err != nil {
149
150
return err
@@ -153,14 +154,14 @@ func (p *QuorumProvider) FirstTimeSetup() error {
153
154
return err
154
155
}
155
156
// Copy tessera docker-entrypoint file
156
- tmEntrypointPath := filepath .Join (tesseraDir , fmt .Sprintf ("tessera_%d" , i ), DockerEntrypoint )
157
+ tmEntrypointPath := filepath .Join (tesseraDir , fmt .Sprintf ("tessera_%d" , i ), tessera . DockerEntrypoint )
157
158
if err := p .dockerMgr .CopyFileToVolume (p .ctx , tesseraVolumeNameMember , tmEntrypointPath , rootDir ); err != nil {
158
159
return err
159
160
}
160
161
}
161
162
162
163
// Copy quorum docker-entrypoint file
163
- quorumEntrypointPath := filepath .Join (blockchainDir , fmt .Sprintf ("quorum_%d" , i ), DockerEntrypoint )
164
+ quorumEntrypointPath := filepath .Join (blockchainDir , fmt .Sprintf ("quorum_%d" , i ), tessera . DockerEntrypoint )
164
165
if err := p .dockerMgr .CopyFileToVolume (p .ctx , quorumVolumeNameMember , quorumEntrypointPath , rootDir ); err != nil {
165
166
return err
166
167
}
@@ -236,43 +237,46 @@ func (p *QuorumProvider) DeployFireFlyContract() (*types.ContractDeploymentResul
236
237
return p .connector .DeployContract (contract , "FireFly" , p .stack .Members [0 ], nil )
237
238
}
238
239
240
+ func (p * QuorumProvider ) buildTesseraServiceDefinition (memberIdx int ) * docker.ServiceDefinition {
241
+ return & docker.ServiceDefinition {
242
+ ServiceName : fmt .Sprintf ("tessera_%d" , memberIdx ),
243
+ Service : & docker.Service {
244
+ Image : tesseraImage ,
245
+ ContainerName : fmt .Sprintf ("%s_member%dtessera" , p .stack .Name , memberIdx ),
246
+ Volumes : []string {fmt .Sprintf ("tessera_%d:/data" , memberIdx )},
247
+ Logging : docker .StandardLogOptions ,
248
+ Ports : []string {fmt .Sprintf ("%d:%s" , p .stack .ExposedPtmPort + (memberIdx * ExposedBlockchainPortMultiplier ), tessera .TmTpPort )}, // defaults 4100, 4110, 4120, 4130
249
+ Environment : p .stack .EnvironmentVars ,
250
+ EntryPoint : []string {"/bin/sh" , "-c" , "/data/docker-entrypoint.sh" },
251
+ Deploy : map [string ]interface {}{"restart_policy" : map [string ]interface {}{"condition" : "on-failure" , "max_attempts" : int64 (3 )}},
252
+ HealthCheck : & docker.HealthCheck {
253
+ Test : []string {
254
+ "CMD" ,
255
+ "curl" ,
256
+ "--fail" ,
257
+ fmt .Sprintf ("http://localhost:%s/upcheck" , tessera .TmTpPort ),
258
+ },
259
+ Interval : "15s" , // 6000 requests in a day
260
+ Retries : 30 ,
261
+ },
262
+ },
263
+ VolumeNames : []string {fmt .Sprintf ("tessera_%d" , memberIdx )},
264
+ }
265
+ }
266
+
239
267
func (p * QuorumProvider ) GetDockerServiceDefinitions () []* docker.ServiceDefinition {
240
268
memberCount := len (p .stack .Members )
241
269
serviceDefinitionsCount := memberCount
242
- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
270
+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
243
271
serviceDefinitionsCount *= 2
244
272
}
245
273
serviceDefinitions := make ([]* docker.ServiceDefinition , serviceDefinitionsCount )
246
274
connectorDependents := map [string ]string {}
247
275
for i := 0 ; i < memberCount ; i ++ {
248
276
var quorumDependsOn map [string ]map [string ]string
249
- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
277
+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
250
278
quorumDependsOn = map [string ]map [string ]string {fmt .Sprintf ("tessera_%d" , i ): {"condition" : "service_healthy" }}
251
- serviceDefinitions [i + memberCount ] = & docker.ServiceDefinition {
252
- ServiceName : fmt .Sprintf ("tessera_%d" , i ),
253
- Service : & docker.Service {
254
- Image : tesseraImage ,
255
- ContainerName : fmt .Sprintf ("%s_member%dtessera" , p .stack .Name , i ),
256
- Volumes : []string {fmt .Sprintf ("tessera_%d:/data" , i )},
257
- Logging : docker .StandardLogOptions ,
258
- Ports : []string {fmt .Sprintf ("%d:%s" , p .stack .ExposedPtmPort + (i * ExposedBlockchainPortMultiplier ), TmTpPort )}, // defaults 4100, 4110, 4120, 4130
259
- Environment : p .stack .EnvironmentVars ,
260
- EntryPoint : []string {"/bin/sh" , "-c" , "/data/docker-entrypoint.sh" },
261
- Deploy : map [string ]interface {}{"restart_policy" : map [string ]interface {}{"condition" : "on-failure" , "max_attempts" : int64 (3 )}},
262
- HealthCheck : & docker.HealthCheck {
263
- Test : []string {
264
- "CMD" ,
265
- "curl" ,
266
- "--fail" ,
267
- fmt .Sprintf ("http://localhost:%s/upcheck" , TmTpPort ),
268
- },
269
- Interval : "15s" , // 6000 requests in a day
270
- Retries : 30 ,
271
- },
272
- },
273
- VolumeNames : []string {fmt .Sprintf ("tessera_%d" , i )},
274
- }
275
-
279
+ serviceDefinitions [i + memberCount ] = p .buildTesseraServiceDefinition (i )
276
280
// No arm64 images for Tessera
277
281
if runtime .GOARCH == "arm64" {
278
282
serviceDefinitions [i + memberCount ].Service .Platform = "linux/amd64"
@@ -377,9 +381,9 @@ func (p *QuorumProvider) CreateAccount(args []string) (interface{}, error) {
377
381
378
382
// Tessera is an optional add-on to the quorum blockchain node provider
379
383
var tesseraPubKey , tesseraKeysPath string
380
- if ! p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerNone ) {
384
+ if p .stack .PrivateTransactionManager .Equals (types .PrivateTransactionManagerTessera ) {
381
385
tesseraKeysOutputDirectory := filepath .Join (directory , "tessera" , fmt .Sprintf ("tessera_%s" , memberIndex ), "keystore" )
382
- _ , tesseraPubKey , tesseraKeysPath , err = CreateTesseraKeys (p .ctx , tesseraImage , tesseraKeysOutputDirectory , "" , "tm" )
386
+ _ , tesseraPubKey , tesseraKeysPath , err = tessera . CreateTesseraKeys (p .ctx , tesseraImage , tesseraKeysOutputDirectory , "" , "tm" )
383
387
if err != nil {
384
388
return nil , err
385
389
}
0 commit comments