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: remove effective_canister_id from fn fetch_api_boundary_nodes() signature #543

Conversation

nikolay-komarevskiy
Copy link
Contributor

@nikolay-komarevskiy nikolay-komarevskiy commented Mar 26, 2024

Description

Following the spec, it would make sense to split fn fetch_api_boundary_nodes(effective_canister_id) into two functions:

pub async fn fetch_api_boundary_nodes_by_canister_id(canister_id)
pub async fn fetch_api_boundary_nodes_by_subnet_id(subnet_id)

How Has This Been Tested?

  1. Testing against mainnent is not yet possible, this MR needs to be released.
  2. Functions were tested in system-tests with respective canister_id/subnet_id.

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@nikolay-komarevskiy nikolay-komarevskiy changed the title feat: remove effective_canister_id fn fetch_api_boundary_nodes() signature feat: remove effective_canister_id from fn fetch_api_boundary_nodes() signature Mar 26, 2024
@nikolay-komarevskiy nikolay-komarevskiy force-pushed the fetch-api-boundary-nodes-via-subnet-read branch from 74398d9 to d747b21 Compare March 26, 2024 15:18
@mraszyk
Copy link
Contributor

mraszyk commented Mar 26, 2024

I think the new function should complement, not replace the old one. There are use cases when you might want to fetch the API boundary nodes based on a canister you want to talk to.

@nikolay-komarevskiy
Copy link
Contributor Author

I think the new function should complement, not replace the old one. There are use cases when you might want to fetch the API boundary nodes based on a canister you want to talk to.

fn fetch_api_boundary_nodes_via(effective_canister_id)
fn fetch_api_boundary_nodes()

Like this?

@mraszyk
Copy link
Contributor

mraszyk commented Mar 26, 2024

I'd go for fetch_api_boundary_nodes_via -> fetch_api_boundary_nodes_for_canister but that's the idea, indeed.

@nikolay-komarevskiy nikolay-komarevskiy force-pushed the fetch-api-boundary-nodes-via-subnet-read branch from 2ee341e to 92971fa Compare March 26, 2024 15:48
@nikolay-komarevskiy
Copy link
Contributor Author

fetch_api_boundary_nodes

@mraszyk Once the support for getting API Boundary Nodes via subnet/subnet_id/read_state is done, we could use it in the fn fetch_api_boundary_nodes(). Or would it make sense to introduce yet another function fn fetch_api_boundary_nodes_via_subnet()?

@chenyan-dfinity
Copy link
Contributor

This default canister id probably only works when talking with the mainnet. For local replica or testnet, r7inp-6aaaa-aaaaa-aaabq-cai may not exist?

@nikolay-komarevskiy
Copy link
Contributor Author

This default canister id probably only works when talking with the mainnet. For local replica or testnet, r7inp-6aaaa-aaaaa-aaabq-cai may not exist?

Correct. To rectify this we could give a more precise name to the function: fn fetch_api_boundary_nodes_mainnet()

@nikolay-komarevskiy
Copy link
Contributor Author

This default canister id probably only works when talking with the mainnet. For local replica or testnet, r7inp-6aaaa-aaaaa-aaabq-cai may not exist?

Correct. To rectify this we could give a more precise name to the function: fn fetch_api_boundary_nodes_mainnet()

What do You think @chenyan-dfinity and @adamspofford-dfinity?

@chenyan-dfinity
Copy link
Contributor

chenyan-dfinity commented Mar 27, 2024

Yeah, that's a more precise name, and we don't need to rename the original function then.

@nikolay-komarevskiy
Copy link
Contributor Author

Yeah, that's a more precise name, and we don't need to rename the original function then.

In fact as @mraszyk has implemented api_boundary_nodes for subnet read_state, we could have these three function flavours:

 1. pub async fn fetch_api_boundary_nodes_by_subnet_id(subnet_id: Principal)
 2. pub async fn fetch_api_boundary_nodes_mainnet() // uses hard-coded root subnet_id internally
 3. pub async fn fetch_api_boundary_nodes_by_canister_id(effective_canister_id: Principal)

But it feels that the 3rd one is not necessary, I suggest to have 1 and 2.

@chenyan-dfinity
Copy link
Contributor

I don't know how boundary node works, so I don't know what's the best API here. I think it depends on the following questions:

  1. Do boundary nodes exist only in the mainnet? If so, it makes sense to have a hard-coded subnet/canister id.
  2. With different subnet/canister id, do we expect to get a different list of boundary nodes? If so, we will need both 1 and 3. Currently on the mainnet, it seems the list is always empty?

@nikolay-komarevskiy
Copy link
Contributor Author

I don't know how boundary node works, so I don't know what's the best API here. I think it depends on the following questions:

  1. Do boundary nodes exist only in the mainnet? If so, it makes sense to have a hard-coded subnet/canister id.
  2. With different subnet/canister id, do we expect to get a different list of boundary nodes? If so, we will need both 1 and 3. Currently on the mainnet, it seems the list is always empty?
  1. API BNs will exist in three environments:
  • Mainnet (now it's an empty array to be populated soon)
  • system-tests
  • Dynamic testnets
  1. Provided the responding nodes have identical state the response for both subnet_id/canister_id should be identical.

I updated the current PR with a suggestion to have just two functions, which cover all our needs, see description.

@nikolay-komarevskiy nikolay-komarevskiy marked this pull request as ready for review April 2, 2024 08:07
@nikolay-komarevskiy nikolay-komarevskiy requested a review from a team as a code owner April 2, 2024 08:07
@adamspofford-dfinity adamspofford-dfinity merged commit 140bd77 into dfinity:main Apr 2, 2024
26 checks passed
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