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

Chaincode Information #641

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

mbwhite
Copy link
Collaborator

@mbwhite mbwhite commented Jan 26, 2023

Add in new modules to get access to chaincode information from the peer.

{
        "changed": false,
        "committed_chaincodes": [
            {
                "collections": {},
                "endorsement_plugin": "escc",
                "name": "asset-transfer",
                "sequence": 3,
                "validation_parameter": "EiAvQ2hhbm5lbC9BcHBsaWNhdGlvbi9FbmRvcnNlbWVudA==",
                "validation_plugin": "vscc",
                "version": "3.0.0"
            }
        ],
        "failed": false,
        "installed_chaincodes": [
            {
                "label": "asset-transfer",
                "package_id": "asset-transfer:8b4c3e8fde8b4d96264aeb2d9b9e22ace299086f41215f74fc844d1e32b1a5fb",
                "references": {
                    "cashchannel": {
                        "chaincodes": [
                            {
                                "name": "asset-transfer",
                                "version": "3.0.0"
                            }
                        ]
                    }
                }
            }
        ]
    }

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
@mbwhite mbwhite force-pushed the relmain/chaincode-sequence branch 2 times, most recently from 0c7a59f to 1fe60e7 Compare January 27, 2023 14:33
@mbwhite
Copy link
Collaborator Author

mbwhite commented Jan 27, 2023

Updated the ApprovedChaincode sequence number semantics. If and only if this is set to 0 the next sequence number of chaincode will be calculated. This uses the 'name' as the key to check existing committed chaincodes. If one exists, the highest sequence + 1 is used. Otherwise 1 is used. Make sure to check the return value for the new sequence number


    - name: Approve the chaincode on the channel
      ibm.blockchain_platform.approved_chaincode:
        api_endpoint: "{{ api_endpoint }}"
        api_authtype: "{{ api_authtype }}"
        api_key: "{{ api_key }}"
        api_secret: "{{ api_secret | default(omit) }}"
        api_token_endpoint: "{{ api_token_endpoint | default(omit) }}"
        peer: "{{ org2_peer_name }}"
        identity: "{{ wallet }}/{{ org2_name }} Admin.json"
        msp_id: "{{ org2_msp_id }}"
        channel: "{{ channel_name }}"
        name: "{{ smart_contract_name }}"
        version: "{{ smart_contract_version }}_"
        package_id: "assettxts:8d74d5220dad81e0b5c09eed66d42cca463dfc59fe22650e8115f43376a57afe"
        # set to zero for auto increment
        sequence: "0"
        endorsement_policy: "{{ smart_contract_endorsement_policy | default(omit) }}"
        collections_config: "{{ smart_contract_collections_file | default(omit) }}"
      register: ccresult

    - name: Post approve information
      debug:
        msg: "{{ccresult.approved_chaincode}}"

    - name: Commit the chaincode on the channel
      ibm.blockchain_platform.committed_chaincode:
        api_endpoint: "{{ api_endpoint }}"
        api_authtype: "{{ api_authtype }}"
        api_key: "{{ api_key }}"
        api_secret: "{{ api_secret | default(omit) }}"
        api_token_endpoint: "{{ api_token_endpoint | default(omit) }}"
        peer: "{{ org1_peer_name }}"
        identity: "{{ wallet }}/{{ org1_name }} Admin.json"
        msp_id: "{{ org1_msp_id }}"
        channel: "{{ channel_name }}"
        organizations:
          - "{{ org1_name }}"
          - "{{ org2_name }}"
        name: "{{ccresult.approved_chaincode.name}}"
        version: "{{ccresult.approved_chaincode.version}}"
        sequence: "{{ccresult.approved_chaincode.sequence}}"
        endorsement_policy: "{{ smart_contract_endorsement_policy | default(omit) }}"
        collections_config: "{{ smart_contract_collections_file | default(omit) }}"

```

@mbwhite mbwhite force-pushed the relmain/chaincode-sequence branch 4 times, most recently from 7fbcf0b to ad12916 Compare January 31, 2023 16:24
- chaincode-list-info will get info on installed packages and
committed definitions of the peer. This includes sequence numbers that can
be used to increment sequence numbers

- if the sequence on teh ApprovedChaincode is set to 0, then sequence will be calculated

Signed-off-by: Matthew B White <whitemat@uk.ibm.com>
@mbwhite mbwhite merged commit 826e86e into IBM-Blockchain:main Feb 2, 2023
@mbwhite mbwhite deleted the relmain/chaincode-sequence branch February 2, 2023 10:09
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.

None yet

1 participant