spacemeshos / go-spacemesh

Go Implementation of the Spacemesh protocol full node. 💾⏰💪
https://spacemesh.io
MIT License
751 stars 212 forks source link

API does not return ATXs until epoch 2 #2209

Open lrettig opened 3 years ago

lrettig commented 3 years ago

Description

In epoch 0, there are no ATXs and no blocks. In epoch 1, there are ATXs published but no blocks. From epoch 2, there are both ATXs and blocks. Right now the API returns ATXs only as part of a Layer object. Since there are no layers in epochs 0-1, there's currently no way to read ATXs from epoch 1 using the API.

Affected code

Possible fixes

This issue appears in commit hash: f76c8b99427a4a9f559da87fced6cf5aa3219266

leonanos8 commented 3 years ago

@lrettig can I work on this one? This will be my first touch with the project. I am trying to understand the problem by reading the code and the docs on the spacemesh protocol.

As I understand the problem is inside /api/grpcserver/mesh_service/LayersQuery. Am I right?

avive commented 3 years ago

I think that the most reasonable solution is to hack a layer number data-item to epoch 1 ATXs based on the time they are added. Should be most consistent with standard epochs, so an ATX will always have a layer number associated with it.

lrettig commented 3 years ago

@leonanos8 welcome and thanks for offering to contribute - sorry for the slow reply here. See @avive's suggestion. A good first step would be to post an implementation plan so we can review it and offer feedback.

avive commented 3 years ago

Listing ATX related api methods:

leonanos8 commented 3 years ago

Thanks for the welcome and the analysis. I'll start with the implementation plan and post it here when ready for review.