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 old cc pkg upload API #583

Merged
merged 4 commits into from
Dec 2, 2023

Conversation

xichen1
Copy link
Member

@xichen1 xichen1 commented Nov 8, 2023

Refactor old chaincode package upload API according to the new design doc.

Signed-off-by: xichen1 xichen.pan@gmail.com

Refactor old chaincode package upload API according to the new design
doc.

Signed-off-by: xichen1 <xichen.pan@gmail.com>
@xichen1
Copy link
Member Author

xichen1 commented Nov 8, 2023

The original API implementation requires the user to upload a zipped chaincode file, then the backend will package the the cc file using peer command line.

According to our new API design, now we need the user to package the cc package by themselves and upload the cc package directly. Therefore adjust the current implementation to allow the requirement.

The PR also updated the cc Django model, the current db columns include uuid, package_id, name, label, version, creator, language, description and create_ts.

@xichen1
Copy link
Member Author

xichen1 commented Nov 8, 2023

One issue still exists is it's impossible to get cc version from the metadata.json file (it doesn't contain the version info).

Do we update the version in the backend automatically? (if a duplicate cc package id is received we increase the version?)

Update: It seems cc name and version can only be created in Approve step (to create a new running instance), which needs to be confirmed.

@xichen1
Copy link
Member Author

xichen1 commented Nov 18, 2023

Need to simplify the extraction and verification steps. Only need to extract metadata.json file and check and store its information. It can be done using the library tarfile:

    with tarfile.open(tar_file_path, "r:gz") as tar:
        try:
            # Retrieve the member information for the specified file
            member = tar.getmember("metadata.json")
            # Extract the file
            tar.extract(member, path=output_path)
        except KeyError:
            print(f"File '{file_name}' not found in the archive.")

@xichen1
Copy link
Member Author

xichen1 commented Nov 18, 2023

One issue still exists is it's impossible to get cc version from the metadata.json file (it doesn't contain the version info).

Do we update the version in the backend automatically? (if a duplicate cc package id is received we increase the version?)

Update: It seems cc name and version can only be created in Approve step (to create a new running instance), which needs to be confirmed.

Confirmed: cc names and versions are decided at Approve step. They are tied with the cc and one channel specified at Approve step.

Extract only necessary info from cc package. Optimize performance.

Add postman testcase for cc upload.

Signed-off-by: xichen1 <xichen.pan@gmail.com>
@xichen1 xichen1 marked this pull request as ready for review November 28, 2023 03:33
@xichen1 xichen1 requested a review from a team November 28, 2023 03:33
Signed-off-by: xichen1 <xichen.pan@gmail.com>
Signed-off-by: xichen1 <xichen.pan@gmail.com>
@yeasy yeasy merged commit 5c8def2 into hyperledger:main Dec 2, 2023
3 checks passed
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