Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(connector-fabric): deployContractGoSourceV1 uses Fabric v2.5.6 #3058

Conversation

petermetz
Copy link
Contributor

The deployContractGoSourceV1() method now assumes that the underlying
test ledger is Fabric 2.5 (current LTS).

This will allow us to upgrade the contracts that are being used by the
Supply chain app to Fabric 2.x from Fabric 1.x which will then implicitly
fix a large number of other issues at the same time.

This change is part of laying the foundation for that follow-up work.

Primary changes:

  1. Added a new, standalone utility function to deploy go source contracts
    with the name of deployContractGoSourceImplFabricV256().
  2. The code of this function was derived from the original Fabric v1
    compatible deployContractGoSourceV1 method of the Fabric connector.
  3. 2 organizations are supported for deployment via the endpoint.
  4. The endpoint is only used by the supply chain app example at the moment
    and there is no test coverage of it due to dependencies that will be
    resolved in a follow-up pull request that is coming soon.

Secondary changes:

  1. Also extracted the SSH execution function from the fabric connector
    into a standalone function that can be used without having to have a
    Fabric connector instance created first.
  2. Also extracted/abstracted some logic into a utility function for
    similar reasons that is used to replace logging configuration environment
    variables in shell commands that we use to perform contract deployment
    onto the Fabric test ledgers.

Depends on #3054

Signed-off-by: Peter Somogyvari [email protected]

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

petermetz added a commit to petermetz/cacti that referenced this pull request Mar 5, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

Depends on hyperledger-cacti#3058
Depends on hyperledger-cacti#3054

Fixes hyperledger-cacti#2945
Fixes hyperledger-cacti#2969
Fixes hyperledger-cacti#1899
Fixes hyperledger-cacti#1521
Fixes hyperledger-cacti#1518

Signed-off-by: Peter Somogyvari <[email protected]>
petermetz added a commit to petermetz/cacti that referenced this pull request Mar 5, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

Depends on hyperledger-cacti#3058
Depends on hyperledger-cacti#3054

Fixes hyperledger-cacti#2945
Fixes hyperledger-cacti#2969
Fixes hyperledger-cacti#1899
Fixes hyperledger-cacti#1521
Fixes hyperledger-cacti#1518

Signed-off-by: Peter Somogyvari <[email protected]>
Copy link
Contributor

@jagpreetsinghsasan jagpreetsinghsasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@outSH outSH self-requested a review March 7, 2024 11:54
@outSH outSH disabled auto-merge March 7, 2024 11:55
Copy link
Contributor

@outSH outSH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, squash the commits before the merge (I've disabled an auto-merge)

@petermetz
Copy link
Contributor Author

LGTM, squash the commits before the merge (I've disabled an auto-merge)

@outSH Oops, sorry and thank you very much for being on the lookout! I should be more careful with the auto-merge feature for pull requests that have parents!

The deployContractGoSourceV1() method now assumes that the underlying
test ledger is Fabric 2.5 (current LTS).

This will allow us to upgrade the contracts that are being used by the
Supply chain app to Fabric 2.x from Fabric 1.x which will then implicitly
fix a large number of other issues at the same time.

This change is part of laying the foundation for that follow-up work.

Primary changes:
-----------------

1. Added a new, standalone utility function to deploy go source contracts
with the name of `deployContractGoSourceImplFabricV256()`.
2. The code of this function was derived from the original Fabric v1
compatible deployContractGoSourceV1 method of the Fabric connector.
3. 2 organizations are supported for deployment via the endpoint.
4. The endpoint is only used by the supply chain app example at the moment
and there is no test coverage of it due to dependencies that will be
resolved in a follow-up pull request that is coming soon.

Secondary changes:
1. Also extracted the SSH execution function from the fabric connector
into a standalone function that can be used without having to have a
Fabric connector instance created first.
2. Also extracted/abstracted some logic into a utility function for
similar reasons that is used to replace logging configuration environment
variables in shell commands that we use to perform contract deployment
onto the Fabric test ledgers.

Depends on hyperledger-cacti#3054

Signed-off-by: Peter Somogyvari <[email protected]>
@petermetz petermetz force-pushed the test-connector-fabric-deploy-golang-source-fabric-v2-5-6 branch from bdfc683 to ffbcf31 Compare March 7, 2024 18:15
@github-actions github-actions bot removed the dependent label Mar 7, 2024
Copy link

github-actions bot commented Mar 7, 2024

This PR/issue depends on:

@petermetz petermetz enabled auto-merge (rebase) March 7, 2024 18:15
@petermetz petermetz merged commit 21fd747 into hyperledger-cacti:main Mar 7, 2024
123 of 147 checks passed
petermetz added a commit to petermetz/cacti that referenced this pull request Mar 7, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

Depends on hyperledger-cacti#3058
Depends on hyperledger-cacti#3054

Fixes hyperledger-cacti#2945
Fixes hyperledger-cacti#2969
Fixes hyperledger-cacti#1899
Fixes hyperledger-cacti#1521
Fixes hyperledger-cacti#1518

Signed-off-by: Peter Somogyvari <[email protected]>
@petermetz petermetz deleted the test-connector-fabric-deploy-golang-source-fabric-v2-5-6 branch March 7, 2024 22:49
petermetz added a commit to petermetz/cacti that referenced this pull request Mar 8, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

The container image is now published as:

`ghcr.io/hyperledger/cactus-example-supply-chain-app:2024-03-08--pr-3059-1`

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

The supply chain app container image was built with this command:
```sh
DOCKER_BUILDKIT=1 docker build \
  --build-arg="NPM_PKG_VERSION=2.0.0-2945-supply-chain-app-build-failed.241+b2c306ea0" \
  -f ./examples/cactus-example-supply-chain-backend/Dockerfile \
  . \
  -t scaeb
```

The NPM_PKG_VERSION build arg is important because the image defaults to
"latest" which at the moment is packages that do not contain the fixes
made by this commit, so re-building the image without that extra arg
will not work until we issue the next official non-canary release.

Depends on hyperledger-cacti#3058
Depends on hyperledger-cacti#3054

Fixes hyperledger-cacti#2945
Fixes hyperledger-cacti#2969
Fixes hyperledger-cacti#1899
Fixes hyperledger-cacti#1521
Fixes hyperledger-cacti#1518

Signed-off-by: Peter Somogyvari <[email protected]>
petermetz added a commit that referenced this pull request Mar 9, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

The container image is now published as:

`ghcr.io/hyperledger/cactus-example-supply-chain-app:2024-03-08--pr-3059-1`

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

The supply chain app container image was built with this command:
```sh
DOCKER_BUILDKIT=1 docker build \
  --build-arg="NPM_PKG_VERSION=2.0.0-2945-supply-chain-app-build-failed.241+b2c306ea0" \
  -f ./examples/cactus-example-supply-chain-backend/Dockerfile \
  . \
  -t scaeb
```

The NPM_PKG_VERSION build arg is important because the image defaults to
"latest" which at the moment is packages that do not contain the fixes
made by this commit, so re-building the image without that extra arg
will not work until we issue the next official non-canary release.

Depends on #3058
Depends on #3054

Fixes #2945
Fixes #2969
Fixes #1899
Fixes #1521
Fixes #1518

Signed-off-by: Peter Somogyvari <[email protected]>
petermetz added a commit to petermetz/cacti that referenced this pull request Mar 10, 2024
The supply chain app's build and execution scripts should finally be
working after this and also be much more stable than before due to the
flakiness of the Fabric V1 test ledger not being an issue anymore.

The container image is now published as:

`ghcr.io/hyperledger/cactus-example-supply-chain-app:2024-03-08--pr-3059-1`

1.The new contract is compiled with go v1.20 and therefore has to have
the contract method names capitalized insted of camelCase, otherwise
the methods are not possible to be exported and the contract deployment
fails even if everything else is correct.
2. The supply chain app now uses the newest edition of the Fabric v2 AIO
test ledger container image which uses Fabric v2.5.6 (current LTS at the
time of this writing).
3. The shipment contract's source code has been migrated to Fabric v2
meaning that instead of a stub object we get a context object for each
method's first parameter and then the stub can be acquired from that
context object.
4. The method arguments no longer need to be passed around as an array
of strings and instead the contract method's input arguments are first-class
go method parameters.
5. Re-enabled a test case that was being skipped until now due to flakiness:
...`src/test/typescript/integration/supply-chain-backend-api-calls.test.ts`

The supply chain app container image was built with this command:
```sh
DOCKER_BUILDKIT=1 docker build \
  --build-arg="NPM_PKG_VERSION=2.0.0-2945-supply-chain-app-build-failed.241+b2c306ea0" \
  -f ./examples/cactus-example-supply-chain-backend/Dockerfile \
  . \
  -t scaeb
```

The NPM_PKG_VERSION build arg is important because the image defaults to
"latest" which at the moment is packages that do not contain the fixes
made by this commit, so re-building the image without that extra arg
will not work until we issue the next official non-canary release.

Depends on hyperledger-cacti#3058
Depends on hyperledger-cacti#3054

Fixes hyperledger-cacti#2945
Fixes hyperledger-cacti#2969
Fixes hyperledger-cacti#1899
Fixes hyperledger-cacti#1521
Fixes hyperledger-cacti#1518

Signed-off-by: Peter Somogyvari <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants