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

starknet_getClass #110

Merged
merged 9 commits into from
Feb 6, 2024
Merged

starknet_getClass #110

merged 9 commits into from
Feb 6, 2024

Conversation

Trantorian1
Copy link
Member

@Trantorian1 Trantorian1 commented Feb 1, 2024

Class & ABI storage for starknet_getClass

  • RPC

What is the current behavior?

  • Contract classes as well as contract ABIs are not stored in the Susbtrate db.
  • RPC calls to starknet_getClass have an invalid return

Resolves: #32

What is the new behavior?

Changes pertaining to #32:

  • Classes which are not yet stored in the local Substrate db are downloaded during l2 sync.
  • New runtime storage has been added to store contract ABIs separately from Blockifier contract classes. This has been done to avoid impacting too much the existing logic around accessing contract classes from the db, but might change in the future. A cleaner solution would be to stop using Blockifier types for db storage and instead define new storage-exclusive types.
  • Implemented starknet_getClass RPC call.

Quality of life changes:

  • New wrapper types have been added for Encoding/Decoding contract classes and contract ABIs
  • Easier converting logic has been added to pass from starknet blockifier to starknet core types (From & Into) via the new wrapper types.
  • Existing madara primitive conversion logic from rpc/util has been moved to a dedicated crate convert. Please add any further conversion logic that does not use wrapper types there.
  • devcontainer.json now works and will initialize the database on attach.

Does this introduce a breaking change?

Any node with an existing database will need to re-synchronize from block 0 to be able to download all contract class data. I recommend the usage of @jbcaron's feeder cache for that purpose.

New classes now have their class hash syncked from request to the sequencer during l2 sync. These hashes are then bundled into a `StarknetClassUpdate` and sent by thread bus to be added to pre-runtime digest.
@Trantorian1 Trantorian1 added the RPC RPC implementation related issues label Feb 1, 2024
@Trantorian1 Trantorian1 requested a review from antiyro February 1, 2024 16:06
@Trantorian1
Copy link
Member Author

⚠️ There remains JSON deserialization issues due to invalid JSON format specified for Cairo 0 contract in cairo-rs, DO NOT merge before this is resolved !

This comment will be updated once this problem has been resolved

Trantorian added 3 commits February 3, 2024 13:35
Devcontainer now works again (**remember to set your UID** in Dockerfile though) and will automatically set up deoxys dp and run cargo fmt upon container startup.

Developpers already using their own devcontainer will have to rebuild their conainter the next time they lauch it.
@Trantorian1 Trantorian1 self-assigned this Feb 4, 2024
@@ -0,0 +1,32 @@
FROM rust:1.75.0-bookworm
Copy link
Member

Choose a reason for hiding this comment

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

what does this docker do? And why is it necessary for Deoxys?

Copy link
Member Author

Choose a reason for hiding this comment

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

This uses the official rust docker image as base for the devcontainer used to launch Deoxys.

To answer your question, this allows to set up a dev environment with all the required dependencies and vscode plugins for building, running and debugging Deoxys. The idea behind this is to simply the onboard process of new devs by reducing the amount of friction required in setting up a dev environment, but also standardize the tools between contributors working on Deoxys.

To learn more about vscode dev containers, check out the offial documentation.

"storage": "128gb"
}
}
"build": {
Copy link
Member

Choose a reason for hiding this comment

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

what are those changes on the devcontainer? are they needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Very much so.

The previous dev container did not work and took up several GB on disk, just for the image. The new dev container is much lighter and allows the following:

  • Support for rust nightly.
  • Bundled with all the required libraries, such as liabsound2 and alsalib for building.
  • Essential vscode extensions, such as Rust will be automatically installed in the dev container.
  • Since the db is already stored in /tmp, it will be shared between the container and the host.
  • postAttachCommand: ensures that the Deoxys db is initialized each time the container is started (no need to run madara setup anymore).

There's also a bit more setup under the hood to make it so the container user is the same as the host user, meaning new files are not created as root but with the scope and permissions of the host user. This is mostly to allow the host to retain file access rights when outside the container, but it also is a nice added security benefit :)

@@ -0,0 +1,21 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

This script is just being used to do some setup each time the dev container is started, namely setting up the Deoxys db so we no longer have to call madara setup :)

.vscode/settings.json Outdated Show resolved Hide resolved
members = [
"crates/client/commitment-state-diff",
Copy link
Member

Choose a reason for hiding this comment

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

what happened to those members previously they disapeared?

Copy link
Member Author

Choose a reason for hiding this comment

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

I beleive they were just reorganised

Trantorian added 2 commits February 6, 2024 09:18
@Trantorian1 Trantorian1 closed this Feb 6, 2024
@Trantorian1 Trantorian1 reopened this Feb 6, 2024
@Trantorian1 Trantorian1 marked this pull request as ready for review February 6, 2024 09:24
@antiyro antiyro merged commit 954e2ba into KasarLabs:main Feb 6, 2024
4 of 7 checks passed
@Trantorian1 Trantorian1 deleted the feat/store_class_in_db branch February 6, 2024 10:37
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
RPC RPC implementation related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat/starknet_getClass
2 participants