Skip to content

Replace Proxy with Object API#86

Merged
sanderpick merged 12 commits intodevelopfrom
avichalp/object-head
Jun 11, 2024
Merged

Replace Proxy with Object API#86
sanderpick merged 12 commits intodevelopfrom
avichalp/object-head

Conversation

@avichalp
Copy link
Copy Markdown
Collaborator

@avichalp avichalp commented Jun 6, 2024

This PR deals with the following:

  1. Removes the obsolete HTTP endpoints, which should not be since we have SDK now. The exception here is the os-get and os-list endpoints. These are still in use. The SDK uses these endpoints to download the file. In this PR, I have added a new GET endpoint for SDK to download files. First, the SDK needs to move over to the new endpoint, and then these two could be deleted in an upcoming PR. Due to these two endpoints, the proxy wallet and sequence have not been removed yet. But it will be removed in a subsequent PR.

  2. Renames all "proxy" references in provisioning scripts etc except for the proxy-wallet which will be handled in the next PR.

Fixes #78

}
// If it is a HEAD request, we don't need to send the body
// but we still need to send the Content-Length header
if method == "HEAD" {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a new HEAD /objects method to get the size of file. It will help with adding a progress bar in the sdk: recallnet/rust-recall#38

@avichalp avichalp requested a review from sanderpick June 6, 2024 10:36
@avichalp avichalp marked this pull request as ready for review June 6, 2024 10:36
use serde_json::{json, Value};

/// A trait to convert a type to a JSON value.
#[allow(dead_code)]
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@sanderpick: This code is coming from upstream but it is not used anywhere anymore. Not sure if we should ignore the warning or remove it?

@avichalp avichalp force-pushed the avichalp/object-head branch from bf4c07b to 0c8304e Compare June 6, 2024 18:28
[object_api]

[proxy.listen]
[object_api.listen]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

how about just objects?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and everywhere is where "object api" is used... i think it could just be "objects". easier to read

[object_api.listen]
# Only accept local connections by default.
host = "127.0.0.1"
host = "0.0.0.0"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's a good idea to keep this local in the default config. Env vars can open it up.

gas_limit: Option<u64>,
broadcast_mode: Option<BroadcastMode>,
async fn handle_object_download(
cid: Cid,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

does this method just download by cid? is there a way for the api to reject downloading an object if it is not resolved?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i think, we would need to call GetObject here to know if it is resolved or not. the SDK already knows if the object is resolved and it only makes the download request if it is resolved. but that means that users can potentially download unresolved objects which we should not allow?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

right, because otherwise a user could submit to the object API and then just not send the txn to comet, and still be able to download the file from this node.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but you can do that by embedding the SDK into this api right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yeah we can use the SDK to make the GetObject call again to check the resolved status.

I am wondering now weather SDK and CLI should have a separate method for downloading detached objects. because with one get method currently, we call GetObject on the actor and if it is a detached object we call the objects API which will again call the GetObject to get the resolve status.

not sure if it would be bad dev UX to have two methods and leaking the details about attached and detached objects.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i think one method in the SDK is pretty nice. do we need to call get from the SDK if the object API is doing it for the resolved check?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think, this is will sorted now that we are make all objects detached.

@sanderpick
Copy link
Copy Markdown
Contributor

I forgot to mention, in a draft PR (now superseded by #90), I added a change to skip the "only hash" step in the object api when adding a file. It cuts in half the time it takes to upload an object: db4f160#diff-678770e4084ddb1a610b9550c305bfa4364ab9c43251de3e194dbef200c09cd9

Mentioned in an issue here #84. Can you add that to this PR?

@avichalp avichalp force-pushed the avichalp/object-head branch 3 times, most recently from 1064add to f2de6d9 Compare June 11, 2024 09:52
@avichalp
Copy link
Copy Markdown
Collaborator Author

@sanderpick: should be merge this with objects GET call still in there? This PR migrates the SDK to use objects GET call for now. Once we have the required functionality in S3-API service, I will remove this endpoint and the remaining proxy endpoints (get and list) from here.

@sanderpick
Copy link
Copy Markdown
Contributor

Sounds good to me.

Looks like I caused some conflicts here with the newer PRs that got merged.

@avichalp avichalp force-pushed the avichalp/object-head branch from f2de6d9 to e6a57e7 Compare June 11, 2024 15:45
Comment on lines 12 to 15
--env FM_PROXY_SECRET_KEY=/data/${NODE_NAME}/${PROXY_PRIV_KEY_PATH} \
--env FM_PROXY_ACCOUNT_KIND=ethereum \
--env FM_PROXY_BROADCAST_MODE=sync \
--env FM_PROXY_SEQUENCE=0 \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should these also be removed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I left these because they were being used while creating a TransClient that we still use that in the objects GET endpoint. We can remove after SDK starts using the s3 service.

https://github.com/amazingdatamachine/ipc/blob/0e62386400550cdc901af2ba44ae26869cb45d5a/fendermint/app/src/cmd/rpc.rs#L329-L341


#[derive(Subcommand, Debug, Clone)]
pub enum ProxyCommands {
pub enum ObjectsCommands {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need still need the args: super::rpc::TransArgs in here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hrm, looks like we do as long as we're using the TransClient from cmd::rpc. Once we move to the SDK we can use VoidSigner, ie, no private key, sequence, etc. required.

.and(warp::header::optional::<u64>("X-ADM-GasLimit"))
.and(warp::header::optional::<BroadcastMode>("X-ADM-BroadcastMode"))
.and_then(handle_os_upload);
let objects_download = warp::path!("v1" / "objects" / Address / String)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you need to handle the full path here like in the original download method: warp::path!("v1" / "objects" / Address / ..), and then handle tail: Tail in the handler.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It looks like that the tail is being used for list in the original API? But SDK already does list/query call directly. In this new API I added a String param to get the key. Using the objectstore's Address and the key it finds out the object to download.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's used for listing when tail is empty or it end in slash, e.g., foo/, foo/bar/. But it's used to get the object otherwise, e.g., foo, foo/bar. You need to match on "v1" / "objects" / Address / .. to access recursive paths like foo/bar. IIRC otherwise you'll get a 404 not found HTTP error.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh! that makes sense. Changing and testing with nested paths now.

avichalp added 2 commits June 12, 2024 01:23
Signed-off-by: avichalp <[email protected]>
Signed-off-by: avichalp <[email protected]>
Copy link
Copy Markdown
Contributor

@sanderpick sanderpick left a comment

Choose a reason for hiding this comment

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

lgtm!

@sanderpick
Copy link
Copy Markdown
Contributor

Merging so we can get started on new deployment.

@sanderpick sanderpick merged commit d6dcc55 into develop Jun 11, 2024
@sanderpick sanderpick deleted the avichalp/object-head branch June 11, 2024 23:30
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.

Migrate proxy codebase to ObjectAPI. Remove custom RPC logic (use SDK).

2 participants