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/rpc endpoints to fetch data from key #4997

Merged
merged 34 commits into from
Nov 26, 2024

Conversation

hugocaillard
Copy link
Collaborator

Description

Add two new endpoints:

  • /v2/clarity_marf_value/:clarity_marf_key
  • /v2/clarity_metadata/:principal/:contract_name/:clarity_metadata_key

I'm currently working on a Clarinet feature that allows to simulate running (or, said differently, to fork the mainnet state in the simnet data store). This requires the ability to fetch values from marf and metadata keys.

These new endpoints are similar to already existing endpoint (such as getdatavar, getmapentry, getcontractsrc, etc).

Applicable issues

N/A

Additional info (benefits, drawbacks, caveats)

Read more about this feature in the Clarinet issue: hirosystems/clarinet#1503

I confirmed that the 2 new endpoints allow to achieve the desired goal by running a local devnet with these changes and forking the Clarinet simnet state from it.

Checklist

  • Test coverage for new or modified code paths
  • Changelog is updated
  • Required documentation changes (e.g., docs/rpc/openapi.yaml and rpc-endpoints.md for v2 endpoints, event-dispatcher.md for new events)

@hugocaillard hugocaillard self-assigned this Jul 23, 2024
@hugocaillard hugocaillard marked this pull request as ready for review July 23, 2024 16:35
@hugocaillard hugocaillard requested review from a team as code owners July 23, 2024 16:35
@hugocaillard hugocaillard marked this pull request as draft July 29, 2024 10:27
@hugocaillard hugocaillard force-pushed the feat/rpc-endpoints-to-fetch-data-from-key branch from dca20bd to 6260c16 Compare November 5, 2024 17:55
@hugocaillard
Copy link
Collaborator Author

Thanks for the reviews @jcnelson 🙏
I marked as resolved all of the addressed comment
Re-requested Brice review as well since it was dismissed, but he already approved earlier.

obycode
obycode previously approved these changes Nov 18, 2024
Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

🎉

@hugocaillard
Copy link
Collaborator Author

@jcnelson I'm actually seeing something weird with the last test I added.

If I add a request after this call, or if I add a previous request hitting this code path (such as a request vm-metadata::9::invalid-contract-metadata-key, the following request don't work and this assertion fails.

Is it possible that this code path breaks the test runner?
It works just fine in practice when calling this endpoint

@jcnelson
Copy link
Member

@hugocaillard Can you push a test case so I can take a look?

@jcnelson jcnelson self-requested a review November 18, 2024 19:32
Copy link
Member

@jcnelson jcnelson left a comment

Choose a reason for hiding this comment

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

Placing a hold on this until we get further clarity from @hugocaillard

@hugocaillard
Copy link
Collaborator Author

@jcnelson
I added this test:

let request = StacksHttpRequest::new_getclaritymetadata(
addr.into(),
StacksAddress::from_string("ST2DS4MSWSGJ3W9FBC6BVT0Y92S345HY8N3T6AV7R").unwrap(),
"hello-world".try_into().unwrap(),
"vm-metadata::9::contract-size".to_string(),
TipRequest::UseLatestAnchoredTip,
);
requests.push(request);

Which is a copy of the first request (L217).

But any request after the last one fails

Copy link
Contributor

@obycode obycode left a comment

Choose a reason for hiding this comment

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

LGTM!

@obycode obycode added this pull request to the merge queue Nov 26, 2024
Merged via the queue into develop with commit 380a5f0 Nov 26, 2024
153 of 156 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