From 55a8385b61f384c838995cb5a94376c552234c22 Mon Sep 17 00:00:00 2001 From: rodion Date: Fri, 28 Jun 2024 06:57:55 +0000 Subject: [PATCH] Update tessera container name to have stack name Signed-off-by: rodion --- internal/blockchain/ethereum/quorum/geth_provider.go | 6 +++--- .../ethereum/quorum/private_transaction_manager.go | 4 ++-- internal/blockchain/ethereum/quorum/quorum.go | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/blockchain/ethereum/quorum/geth_provider.go b/internal/blockchain/ethereum/quorum/geth_provider.go index bcc5226..00bf4ba 100644 --- a/internal/blockchain/ethereum/quorum/geth_provider.go +++ b/internal/blockchain/ethereum/quorum/geth_provider.go @@ -241,7 +241,7 @@ func (p *GethProvider) GetDockerServiceDefinitions() []*docker.ServiceDefinition ServiceName: fmt.Sprintf("tessera_%d", i), Service: &docker.Service{ Image: tesseraImage, - ContainerName: fmt.Sprintf("member%dtessera", i), + ContainerName: fmt.Sprintf("%s_member%dtessera", p.stack.Name, i), Volumes: []string{fmt.Sprintf("tessera_%d:/data", i)}, Logging: docker.StandardLogOptions, Ports: []string{fmt.Sprintf("%d:%s", p.stack.ExposedPtmPort+(i*exposedBlockchainPortMultiplier), TmTpPort)}, // defaults 4100, 4110, 4120, 4130 @@ -347,14 +347,14 @@ func (p *GethProvider) CreateAccount(args []string) (interface{}, error) { l.Info(fmt.Sprintf("keys generated in %s", tesseraKeysPath)) l.Info(fmt.Sprintf("generating tessera docker-entrypoint file for member %s", memberIndex)) tesseraEntrypointOutputDirectory := filepath.Join(directory, "tessera", fmt.Sprintf("tessera_%s", memberIndex)) - if err := CreateTesseraEntrypoint(p.ctx, tesseraEntrypointOutputDirectory, tesseraVolumeName, memberCount); err != nil { + if err := CreateTesseraEntrypoint(p.ctx, tesseraEntrypointOutputDirectory, tesseraVolumeName, memberCount, p.stack.Name); err != nil { return nil, err } } l.Info(fmt.Sprintf("generating quorum docker-entrypoint file for member %s", memberIndex)) quorumEntrypointOutputDirectory := filepath.Join(directory, "blockchain", fmt.Sprintf("geth_%s", memberIndex)) - if err := CreateQuorumEntrypoint(p.ctx, quorumEntrypointOutputDirectory, gethVolumeName, memberIndex, p.stack.QuorumConsensus.String(), int(p.stack.ChainID()), p.stack.TesseraEnabled); err != nil { + if err := CreateQuorumEntrypoint(p.ctx, quorumEntrypointOutputDirectory, gethVolumeName, memberIndex, p.stack.QuorumConsensus.String(), p.stack.Name, int(p.stack.ChainID()), p.stack.TesseraEnabled); err != nil { return nil, err } diff --git a/internal/blockchain/ethereum/quorum/private_transaction_manager.go b/internal/blockchain/ethereum/quorum/private_transaction_manager.go index a558737..eca97a1 100644 --- a/internal/blockchain/ethereum/quorum/private_transaction_manager.go +++ b/internal/blockchain/ethereum/quorum/private_transaction_manager.go @@ -76,12 +76,12 @@ func CreateTesseraKeys(ctx context.Context, image, outputDirectory, prefix, name return privateKeyData.Data.Bytes, string(pubKeyBytes[:]), path, nil } -func CreateTesseraEntrypoint(ctx context.Context, outputDirectory, volumeName, memberCount string) error { +func CreateTesseraEntrypoint(ctx context.Context, outputDirectory, volumeName, memberCount, stackName string) error { // only tessera v09 onwards is supported var sb strings.Builder memberCountInt, _ := strconv.Atoi(memberCount) for i := 0; i < memberCountInt; i++ { - sb.WriteString(fmt.Sprintf("{\"url\":\"http://member%dtessera:%s\"},", i, TmP2pPort)) // construct peer list + sb.WriteString(fmt.Sprintf("{\"url\":\"http://%s_member%dtessera:%s\"},", stackName, i, TmP2pPort)) // construct peer list } peerList := strings.TrimSuffix(sb.String(), ",") content := fmt.Sprintf(`export JAVA_OPTS="-Xms128M -Xmx128M" diff --git a/internal/blockchain/ethereum/quorum/quorum.go b/internal/blockchain/ethereum/quorum/quorum.go index 0cbd623..e77d4ee 100644 --- a/internal/blockchain/ethereum/quorum/quorum.go +++ b/internal/blockchain/ethereum/quorum/quorum.go @@ -25,7 +25,7 @@ import ( "github.com/hyperledger/firefly-cli/internal/docker" ) -func CreateQuorumEntrypoint(ctx context.Context, outputDirectory, volumeName, memberIndex, consensus string, chainId int, tesseraEnabled bool) error { +func CreateQuorumEntrypoint(ctx context.Context, outputDirectory, volumeName, memberIndex, consensus, stackName string, chainId int, tesseraEnabled bool) error { discoveryCmd := "BOOTNODE_CMD=\"\"" connectTimeout := 15 if memberIndex != "0" { @@ -36,16 +36,16 @@ BOOTNODE_CMD=${BOOTNODE_CMD/127.0.0.1/geth_0}`, GethPort, connectTimeout) tesseraCmd := "" if tesseraEnabled { - tesseraCmd = fmt.Sprintf(`TESSERA_URL=http://member%stessera -TESSERA_TP_PORT=%s -TESSERA_Q2T_PORT=%s + tesseraCmd = fmt.Sprintf(`TESSERA_URL=http://%[5]s_member%[1]stessera +TESSERA_TP_PORT=%[2]s +TESSERA_Q2T_PORT=%[3]s TESSERA_UPCHECK_URL=$TESSERA_URL:$TESSERA_TP_PORT/upcheck ADDITIONAL_ARGS="${ADDITIONAL_ARGS:-} --ptm.timeout 5 --ptm.url ${TESSERA_URL}:${TESSERA_Q2T_PORT} --ptm.http.writebuffersize 4096 --ptm.http.readbuffersize 4096 --ptm.tls.mode off" echo -n "Checking tessera is up ... " -curl --connect-timeout %[4]d --max-time %[4]d --retry 5 --retry-connrefused --retry-delay 0 --retry-max-time 60 --silent --fail "$TESSERA_UPCHECK_URL" +curl --connect-timeout %[4]d --max-time %[4]d --retry 5 --retry-connrefused --retry-delay 0 --retry-max-time 60 --silent --fail "${TESSERA_UPCHECK_URL}" echo "" -`, memberIndex, TmTpPort, TmQ2tPort, connectTimeout) +`, memberIndex, TmTpPort, TmQ2tPort, connectTimeout, stackName) } content := fmt.Sprintf(`#!/bin/sh