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

feat: active_deals table #9

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

feat: active_deals table #9

wants to merge 6 commits into from

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented Jan 16, 2025

Create a table to store active deals. Add a dummy test to show client code
writing and reading data from this new table.

Links:

Signed-off-by: Miroslav Bajtoš <[email protected]>
Copy link

@pyropy pyropy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

sector_id INT NOT NULL,
payload_cid TEXT,

UNIQUE (miner_id, client_id, sector_id, piece_cid, piece_size)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my current understanding of what must be unique about every deal.

We can also leave out this index until we start writing to this table and then create the index based on what we see in the claim events.

Note that there is no primary key constraint in this table. We can change the UNIQUE constraint to become the primary key.

@NikolasHaimerl What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it only possible to store a piece cid inside the same sector once?

Copy link
Member Author

@bajtos bajtos Jan 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure, TBH.

The docs say that one sector can contain multiple pieces.

I can imagine that it's possible to accept two deals from two different clients that want to store the same data, and pack that data into a single sector. The current UNIQUE index supports that. I have no idea whether this can ever happen.

Also, IIRC, the current practice is only one piece per sector.

I see two paths forward - we can reach out to core FIL developers (maybe in #fil-lotus-dev and ask for clarification, but that can delay our effort. Alternatively, or until we get the answer, let's design the constraint in such a way that it can support the data (even payload/deals) we see now.

Maybe it's best to drop the constraint entirely until we get a better understanding.

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the same client wants to store the same piece of data in the same sector then this would invalidate our assumption about uniqueness.
I think we can move forward without this constraint. I don't think we have much to gain by keeping it.
Depending on how we want to query the data later on it might also be favourable to use a Document based database instead of a relational database for this kind of task.
It does not block us from bringing out a first version that supports DDOs though. It is merely a performance and efficieny matter IMHO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the constraint in 49c69d4

db/index.js Show resolved Hide resolved
@bajtos bajtos enabled auto-merge (squash) January 20, 2025 15:59
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.

4 participants