Conversation
4a3123e to
583629c
Compare
PhilosophyOne key principle behind this PR is that unused code should be removed from the codebase. If a piece of code becomes relevant again in the future, it can always be recovered from Git history. That’s precisely what version control is for — preserving past implementations without cluttering the present codebase. API EngineThis is where most of the refactoring takes place, so let’s start here. "Agents Are Actually Redundant"This may sound controversial at first, but I genuinely believe that once we decided to adopt Docker Swarm (which we must, given blockchain's network accessibility requirements), the concept of "agents" in the Hyperledger Cello architecture became unnecessary. The Hyperledger Fabric binaries we rely on are already well-equipped to operate nodes (peers and orderers) remotely — for example, using the familiar This leads to a simple conclusion: since both the infrastructure layer (Docker/Kubernetes) and the application layer (Fabric) already provide remote control capabilities, there's no need to implement another redundant remote-control layer ourselves. We can directly leverage the built-in functionality of these tools. As a result, the StructureAnother major improvement is the API Engine structure. Views-Serializers-Services-ModelsIf a module needs some logic implementations, the module should be divided into 4 files (at least).
Previous, most logic was tightly packed inside Code StyleAs mentioned in the Philosophy section, all legacy code unrelated to current functionality has been removed. Additionally, redundant or incorrect implementations have been cleaned up. Here are a few examples:
|
Delivery
Side Effect
|
|
@YoungHypo suggest we create a new branch for this refactor work. |
I just realized that I myself can also create a new branch in this repo. Therefore, I created a new branch called Feel free to suggest another branch name. |
|
With the first interaction with a chaincode via Hyperledger Cello done on my PC, I hereby proudly announce that now Hyperledger Cello API Engine has the very basic ability to interact with chaincodes after a1f9e92 🥳! This definitely took a lot longer than expected, and the functionality is definitely not mature enough now ---- it is currently inaccessible via dashboard.
|
|
Update for this PR: After several meetings and discussions, I officially retract some of my comments in #735 (comment) and acknowledge that agents do indeed have their necessity. However, I also raised my concerns during the meetings — namely, that the logic for interacting with blockchain nodes on the Subsequently, @yeasy proposed moving all current blockchain interaction logic into the agent, allowing the agent to handle all operations. This also aligns with the original intention of Hyperledger Cello: to move blockchain-specific operations into agents, enabling users to support various blockchain projects simply by swapping agents. Fortunately, after this refactoring, user request handling is decoupled from business logic to the maximum extent (i.e., a view-service layered design). This makes it relatively easier to extract service logic and insert it into a standalone agent project compared to the In any case, reintegrating the decoupled agent will be the next and final stage of this refactoring. Hopefully, this process will go more smoothly this time. |
edeabb0 to
eb936ad
Compare
|
And as we discussed, the new model can be pushed a a new branch such as |
Yeah. So I did. |
|
@yeasy Here is the latest update. I've reintroduced the agents as discussed, and all Hyperledger Fabric operations have now been consolidated within them. This change inevitably increased the scope of the PR. Ideally, some of this restructuring could have been split into a follow-up PR, but given the current context, I've consolidated everything here to keep the refactor coherent. At this stage, I believe the branch is in a mergeable state. While there is still room for improvement, those refinements can be addressed incrementally in subsequent PRs. Since this branch is already significantly ahead of main (118 commits), I think it would be healthier for the project to bring main up to date with the refactor, rather than continuing to extend a long-running branch. Keeping branches aligned will make future development and review cycles much smoother. If reviewing the full diff is challenging due to its size, I suggest focusing on the resulting architecture and overall behavior. I'm of course happy to clarify any specific concerns. Given the above, I've updated the target branch to main. If you feel there's a strong reason to follow a different merge strategy, I'm open to discussing it. Overall, I believe this PR is ready to move forward. |
|
It will be better to have stable code before merging into main. |
I can try, but I’d like to point out that doing so within this PR will further increase its scope and complexity. |
|
Another approach is that checkout a new v1-stable branch and merge your refactor into main. |
That's actaully a good idea! We can check out a |
@YoungHypo how do you think? |
LGTM. |
Signed-off-by: dodo920306 <dodo920306@gmail.com>
These values can be retrieved from files dynamically whenever they're wanted. They shouldn't be stored as DB columns. Signed-off-by: dodo920306 <dodo920306@gmail.com>
They're not necessary. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Node types are parsed as strings rather than enums. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Use 'w' instead of 'r+' to overwrite files instead of just appending contents. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Package MSP and TLS crypto materials into their own directories respectively. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Save TLS certificates in the DB so that they can be accessed by other organizations in the future. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
1. Remove Chaincode peers input from the form 2. Sync Node status with status returned by the Docker Python API 3. Remove Channel peers/orders input from the form Signed-off-by: dodo920306 <dodo920306@gmail.com>
Response chaincode status (CREATED, INSTALLED, APPROVED, COMMITTED) for the chaincode page. Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Signed-off-by: dodo920306 <dodo920306@gmail.com>
Replace `make` with `docker compose` commands with `docker-compose.dev.yaml` as the config file. Signed-off-by: dodo920306 <dodo920306@gmail.com>
In the Hyperledger Fabric docker agent, I want to igore files starting with '.' like `.venv` for the python virtual environment for personal development. Thus, I added `.*` in the `.dockerignore`. However, this causes a warning when building the docker image because for `COPY . .` because the current path `.` is also included in `.*`. Therefore, `!.` is added to the dockerfile to suppress the warning. Signed-off-by: dodo920306 <dodo920306@gmail.com>
The Hyperledger Fabric agent in the CI pipeline aren't assigned with the network and the docker socket volume, so it becomes inaccessible. Signed-off-by: dodo920306 <dodo920306@gmail.com>
efe7764 to
1dfba83
Compare
|
@yeasy I believe the commits are verified now. |
Done, thanks! |

Let's face it: the current state of this project’s code is not so good.
Contributions over time have lacked consistency, leading to duplicated implementations and a fragmented structure that makes maintenance and development difficult.
The combination of Python, Django, and object-oriented design has introduced unnecessary complexity, and without long-term technical stewardship, the project has become hard to extend.
Another pressing issue is the number of long-standing bugs. For a project that has been in existence for over six years, there remain issues that ideally should have been addressed very early on. Many of these are not superficial problems that tools or automated testing could easily detect, but deeper logical flaws that only become evident when the affected code paths are used.
Additionally, it seems that the project has not fully embraced the design principles of Django REST Framework (DRF). For example, serializers are often used only for traffic handling, while much of the core business logic resides in views.py, which goes against DRF’s intended design practices.
To summary, a refactor is inevitable, and to make sure I’m not just another person who criticizes without acting, I’ll do it myself.