Skip to content

Commit

Permalink
Update tessera container name to have stack name
Browse files Browse the repository at this point in the history
Signed-off-by: rodion <rodion.lim@partior.com>
  • Loading branch information
rodion-lim-partior committed Jun 28, 2024
1 parent 1589b82 commit 55a8385
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions internal/blockchain/ethereum/quorum/geth_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ func CreateTesseraKeys(ctx context.Context, image, outputDirectory, prefix, name
return privateKeyData.Data.Bytes, string(pubKeyBytes[:]), path, nil

Check failure on line 76 in internal/blockchain/ethereum/quorum/private_transaction_manager.go

View workflow job for this annotation

GitHub Actions / build

unslice: could simplify pubKeyBytes[:] to pubKeyBytes (gocritic)
}

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"
Expand Down
12 changes: 6 additions & 6 deletions internal/blockchain/ethereum/quorum/quorum.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Check failure on line 28 in internal/blockchain/ethereum/quorum/quorum.go

View workflow job for this annotation

GitHub Actions / build

ST1003: func parameter chainId should be chainID (stylecheck)
discoveryCmd := "BOOTNODE_CMD=\"\""
connectTimeout := 15
if memberIndex != "0" {
Expand All @@ -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
Expand Down

0 comments on commit 55a8385

Please sign in to comment.