Skip to content

Conversation

Kubuxu
Copy link
Collaborator

@Kubuxu Kubuxu commented Oct 9, 2025

No description provided.

@Kubuxu Kubuxu requested a review from a team as a code owner October 9, 2025 15:32
@Kubuxu Kubuxu force-pushed the pdp/create-and-upload branch from 64afc4a to 726cf4d Compare October 9, 2025 15:53
return fmt.Errorf("expeted to find dataSetId in receipt but failed to extract: %w", err)
}
// XXX: I considered here chekcing if dataset exists already in DB, but not sure if it is needed
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The majority of my questions are around this file. I'm yet to test it, but I'm using dataset=0 as a sentinel value.

It might be better if it were maybe NULL. Also, I don't know about any possible table relations that this might affect.
@LexLuthr

Copy link
Member

Choose a reason for hiding this comment

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

I think you should look at handleGetPieceAdditionStatus, that's the only place I can see where it might matter - client can ask for piece addition status and it selects by data set id; what should the client ask for in the case of the combined flow and what do we expect them to get, because I think maybe none of it works currently. We call that with getPieceAdditionStatus in the SDK.

The only other place where we have functionality outside of this PR that impacts that table is the trigger we add for transaction resolving and it doesn't care about data set id:

CREATE OR REPLACE FUNCTION update_pdp_data_set_piece_adds()
RETURNS TRIGGER AS $$
BEGIN
IF OLD.tx_status = 'pending' AND (NEW.tx_status = 'confirmed' OR NEW.tx_status = 'failed') THEN
-- Update the add_message_ok field in pdp_data_set_piece_adds if a matching entry exists
UPDATE pdp_data_set_piece_adds
SET add_message_ok = CASE
WHEN NEW.tx_status = 'failed' OR NEW.tx_success = FALSE THEN FALSE
WHEN NEW.tx_status = 'confirmed' AND NEW.tx_success = TRUE THEN TRUE
ELSE add_message_ok
END
WHERE add_message_hash = NEW.signed_tx_hash;
END IF;
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could special-case dataset=0 in handleGetPieceAdditionStatus

@Kubuxu Kubuxu changed the title feat(pdp): support create and upload [WIP] feat(pdp): support create and upload Oct 9, 2025
@Kubuxu
Copy link
Collaborator Author

Kubuxu commented Oct 10, 2025

@rvagg would appriciate you taking a look as well.

// POST /pdp/data-sets - Create a new data set
r.Post("/", p.handleCreateDataSet)

// POST /pdp/data-sets/create-and-add - Create a new data set and add pices at the same time
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// POST /pdp/data-sets/create-and-add - Create a new data set and add pices at the same time
// POST /pdp/data-sets/create-and-add - Create a new data set and add pieces at the same time


type RequestBody struct {
RecordKeeper string `json:"recordKeeper"`
Pieces []AddPieceRequest `json:"pieces"`
Copy link
Member

Choose a reason for hiding this comment

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

oh yeah, nicely typed

return false, err
}
// XXX: The zero (0) here is a hack, it would be better if this was nullable. Not sure if this will work
err = p.insertPieceAdds(tx, 0, txHashLower, reqBody.Pieces, subPieceInfoMap)
Copy link
Member

Choose a reason for hiding this comment

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

important lint failure

if err != nil {
return false, err
}
// XXX: The zero (0) here is a hack, it would be better if this was nullable. Not sure if this will work
Copy link
Member

Choose a reason for hiding this comment

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

you could just make it nullable then, it's not hard to put in a migration for the table

Copy link
Member

Choose a reason for hiding this comment

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

but I don't mind 0 here

Copy link
Member

Choose a reason for hiding this comment

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

I'm realising this file should have been renamed long ago, you could rename it if you're inclined as long as you're in here s/root/pieces

@rvagg
Copy link
Member

rvagg commented Oct 10, 2025

Looks good, my only concern is the impact on handleGetPieceAdditionStatus

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.

2 participants