Skip to content

feat: frontend data provider #571

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

Merged
merged 21 commits into from
May 9, 2024
Merged

feat: frontend data provider #571

merged 21 commits into from
May 9, 2024

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Apr 2, 2024

I went through the Figma and tried to group the information required on one screen together into its own data type:

  • For this page, calling get_trove_assets_info(trove_id) should provide all the necessary data for each collateral, with the information for each collateral asset in a TroveAssetInfo struct. The CASH price at the top and the "Capacity" field can be obtained by calling get_yin_info(). The "Target C-ratio" can be obtained by calling get_recovery_mode_info().
  • There is also a ShrineAssetInfo struct that is a member of TroveAssetInfo, but which might be useful for landing pages that give an overview of the protocol without displaying a trove in particular. This can be obtained by calling get_shrine_assets_info().

Other changes

  • There is a mismatch in the index for yangs in Shrine (u32) and the Sentinel (u64). This is standardized to u32 which should be more than sufficient.

@milancermak
Copy link
Contributor

LGTM so far. A valuable addition 👏

I'm thinking frontend_data_provider should be upgradable, just in case. If we find a bug or sth, we won't have to update the frontend as well, just the contract itself.

Copy link
Collaborator Author

@tserg tserg left a comment

Choose a reason for hiding this comment

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

Do we want tests for (1) the Upgradeable component; and (2) the data provider contract? Since (1) is not used in core, and (2) is only preprocessing data, I was thinking that there is no need to have tests for these, which would add maintenance overhead.

@tserg tserg marked this pull request as ready for review May 3, 2024 06:41
@tserg
Copy link
Collaborator Author

tserg commented May 3, 2024

Marking this for review first. I will run the Sepolia script after review and update the state file.

@tserg tserg requested a review from milancermak May 3, 2024 08:19
Copy link
Contributor

@milancermak milancermak left a comment

Choose a reason for hiding this comment

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

Pointed out only some nits, otherwise LGTM

@tserg
Copy link
Collaborator Author

tserg commented May 8, 2024

This was how I approached the re-deployment on Sepolia:

  • First, I deleted the state file and executed the deployment script. As expected, it fails because some of the contracts have been declared.
  • Next, I restored the state file, but kept only the declare transactions and deleted everything else. I also had to delete the declare transactions for Shrine and Sentinel so that their new version can be declared. Running the deployment script now works.
  • The deployment script failed many times because of a transaction error that says invalid nonce. Re-executing the script often works. I don't know exactly why this happens but my guess is that sncast could be submitting the transactions in parallel causing some nonces to clash.

Some tips for re-deployment in the future:

  1. Retain the declare transactions in the state file for contracts that have been declared and will not be changed. For contracts that have changed, their declare transactions need to be deleted. Delete all other transactions.
  2. If the script fails because of invalid nonce, simply re-execute the script.
  3. Failed transactions can be deleted from the state file.

@milancermak
Copy link
Contributor

The deployment script failed many times because of a transaction error that says invalid nonce.

Experienced the same, see here for more details if you're curious.

First, I deleted the state file and executed the deployment script. As expected, it fails because some of the contracts have been declared.

Hmm, this could be good feedback / feature request for SN Foundry. It should be able to recover for an already declared class no? If the declare tx is not in the state file, it could just add it and continue, since a class is supposed to be declared only once. Do you mind opening an issue in the starknet-foundry repo to start the discussion? I think other teams would benefit from this as well.

Also, it's weird that there was a Shrine class clash on declare 🤔 According to the docs, a declare tx consists of a class hash which in turn is a hash of external entry points and other things. Since we added 2 new public fns to the Shrine, it should have a different hash, hence the declare tx should've succeeded.

@tserg
Copy link
Collaborator Author

tserg commented May 9, 2024

Hmm, this could be good feedback / feature request for SN Foundry. It should be able to recover for an already declared class no? If the declare tx is not in the state file, it could just add it and continue, since a class is supposed to be declared only once. Do you mind opening an issue in the starknet-foundry repo to start the discussion? I think other teams would benefit from this as well.

Sure! tracking here

Also, it's weird that there was a Shrine class clash on declare 🤔 According to the docs, a declare tx consists of a class hash which in turn is a hash of external entry points and other things. Since we added 2 new public fns to the Shrine, it should have a different hash, hence the declare tx should've succeeded.

Yea, this is odd. I may also have fumbled on this since there were a couple of issues and I was focused on having everything deployed successfully rather than figuring out the exact behaviour of sncast, so I ended up applying fixes wholesale 😅

@tserg tserg merged commit c29c1fd into main May 9, 2024
2 checks passed
@tserg tserg deleted the feat/peripheral_data branch May 9, 2024 12:49
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