{"id":25412300,"url":"https://github.com/datachainlab/fabric-batch-chaincode","last_synced_at":"2025-04-14T16:45:45.475Z","repository":{"id":57694185,"uuid":"418765850","full_name":"datachainlab/fabric-batch-chaincode","owner":"datachainlab","description":"This library enables batch transactions in chaincode without additional trusted systems.","archived":false,"fork":false,"pushed_at":"2021-11-02T14:30:07.000Z","size":46,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-13T03:33:21.872Z","etag":null,"topics":["chaincode","chaincode-go","hyperledger-fabric"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datachainlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-19T04:10:10.000Z","updated_at":"2022-11-09T18:14:06.000Z","dependencies_parsed_at":"2022-09-26T21:01:26.695Z","dependency_job_id":null,"html_url":"https://github.com/datachainlab/fabric-batch-chaincode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datachainlab%2Ffabric-batch-chaincode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datachainlab%2Ffabric-batch-chaincode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datachainlab%2Ffabric-batch-chaincode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datachainlab%2Ffabric-batch-chaincode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datachainlab","download_url":"https://codeload.github.com/datachainlab/fabric-batch-chaincode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248918714,"owners_count":21183241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chaincode","chaincode-go","hyperledger-fabric"],"created_at":"2025-02-16T11:18:39.410Z","updated_at":"2025-04-14T16:45:45.452Z","avatar_url":"https://github.com/datachainlab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fabric-Batch-Chaincode\n\n![Test](https://github.com/datachainlab/fabric-batch-chaincode/workflows/Test/badge.svg)\n[![GoDoc](https://godoc.org/github.com/datachainlab/fabric-batch-chaincode?status.svg)](https://pkg.go.dev/github.com/datachainlab/fabric-batch-chaincode?tab=doc)\n\nFabric-Batch-Chaincode (FBC) is a library that enables batch transactions in chaincode without additional trusted systems.\n\n## Overview\n\nIn FBC, one unit of processing is called `Msg`, and it provides SubmitMsg function to submit it to the ledger, and Commit function to execute the submitted `Msg`s.\n\nEach function performs the following operations:\n\n- SubmitMsg(msg: Msg, current_time: int64)\n  - SubmitMsg is a function that takes a `Msg` and timestamp `current_time` arguments\n  - The validity of `current_time` is explained in [Validation for Current Time](#validation-for-current-time).\n  - Validate that there is no commit after `current_time`.\n  - Msg is stored in association with a key that contains `current_time` as prefix.\n\n- Commit(commit_time: int64)\n  - Commit is a function that takes a timestamp `commit_time` argument.\n  - The `commit_time` should be less than the \"Current Time Window\" described later.\n  - Get `Msg`s between the last committed time and `commit_time`.\n  - Execute these Msgs, and save a commit log with `commit_time` as key prefix.\n\nIt also keeps the following states:\n\n- last committed time: \"lct\" =\u003e {timestamp}\n- msg: \"msg/{timestamp}{TxID}\"\n- commit log: \"commit/{timestamp}\"\n\n## Validation for Current Time\n\nIn fabric, no timestamp indicates the current time that is agreed between peers. Of course, it can get a current time in the chaincode, but this is based on the local clock and will be a different value for each peer.\n\nFBC defines \"Current Time\" as a range defined by a parameter `TimeGapAllowance` based on the local clock of endorser peers.\n\n## Correctness\n\nFBC satisfies the following three properties:\n\n(1) All Msgs will eventually be submitted\n  - Insert Msg with `current_time` as key prefix in `SubmitMsg`\n  - `Commit` can only be performed at a time older than `Current Time`\n\nThe above points guarantee that a Msg will eventually be submitted if a submitter can get a valid current time.\n\n(2) There is no commit log newer than the time of the uncommitted Msg\n  - Verify that there is no commit log newer than the current time with `GetStateByRange(current_time, ∞)`\n\nThis will recheck for the existence of the commit logs during the validation phase, and if there is a commit log with a time newer than `current_time`, the tx that contains the `SubmitMsg` will fail. Therefore, (2) is guaranteed.\n\n(3) All submitted Msgs will eventually be committed\n  - `commit_time` is always newer than previous `commit_time`\n  - Timestamp of a Msg to be committed is within the range between the previous time and `commit_time`.\n\nThe above points and (2) guarantees (3) under the assumption that an actor performs `Commit`.\n\n## TODO\n\n- [ ] Implement ChaincodeStubInterface for BatchState\n- [ ] Design for Msg authentication\n- [ ] Enhance integration with fabric-contract-api-go\n  - It should be possible to integrate it into an existing chaincode implementation with a few modifications\n\n## Maintainers\n\n- [Jun Kimura](https://github.com/bluele)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatachainlab%2Ffabric-batch-chaincode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatachainlab%2Ffabric-batch-chaincode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatachainlab%2Ffabric-batch-chaincode/lists"}