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

fix(fgw): sync from other nodes and block signature #307

Merged
merged 63 commits into from
Oct 11, 2024
Merged

Conversation

Trantorian1
Copy link
Collaborator

@Trantorian1 Trantorian1 commented Oct 4, 2024

Pull Request type

  • Bugfix

What is the current behavior?

The current Madara feeder gateway presents several issues and does not currently work when synchronizing from another node. This is due to invalid JSON response formats and missing fgw methods which other nodes like Pathfinder or Juno use. This pr aims to fix that.

What is the new behavior?

  • Performs manual serialization of legacy contract ABI into json as part of serialize_to_json. This has to be done manually since bincode, which is used to store contract ABI in db, does not support the #[serde(tag = "type")] container attribute.

  • Missing fgw methods get_signature get_compiled_class_by_class_hash, get_contract_addresses and get_public_key have been added. This does not currently include all possible fgw methods. However, in the absence of a clear spec, this will at least work for the current versions of Juno and Pathfinder.

  • Calls to the madara fgw now have their url normalized so partially invalid request such as /foo///abc will be evaluated correctly.

  • Changes to how certain types are serialized to JSON by the fgw has been updated to more closely match the behavior of the official starknet.io fgw. In the future it would be nice to have this based on specs instead.

  • Proper block signing has has been implemented in the fgw: Madara now has a private key it uses to sign the hash of blocks it provides through the fgw. This is still not very secure and we are looking into ways to zeroize the private key and load it from env on use to limit its availabiltiy. Note that this fixes feat(sync): Utilize Signature Verification Methods to Secure L2-only Blocks #72

Does this introduce a breaking change?

Yes. Due to changes in some storage structure, existing dbs will need to be re-synchronized from genesis.

@Trantorian1 Trantorian1 marked this pull request as ready for review October 7, 2024 18:00
@Trantorian1 Trantorian1 changed the title fix(fgw): invalid JSON format when acting as provider fix(fgw): fgw now works with Juno and Pathfinder Oct 7, 2024
crates/client/gateway/src/error.rs Show resolved Hide resolved
crates/client/gateway/src/server/router.rs Outdated Show resolved Hide resolved
crates/client/gateway/src/server/router.rs Outdated Show resolved Hide resolved
crates/client/gateway/src/server/router.rs Outdated Show resolved Hide resolved
crates/client/gateway/src/server/service.rs Outdated Show resolved Hide resolved
crates/primitives/gateway/src/receipt.rs Show resolved Hide resolved
crates/client/gateway/src/server/handler.rs Outdated Show resolved Hide resolved
@jbcaron
Copy link
Member

jbcaron commented Oct 8, 2024

this PR finally solves #72 🥳

Trantorian1 and others added 6 commits October 8, 2024 09:56
Blocks are no longer stored in db with their signature. Instead, Madara
is able to sign block it authors through the feeder gateway. Note that
the private key is still exposed and needs to be zeroed. This will be
address in a pr to the primitive libs being used.
@Trantorian1 Trantorian1 changed the title fix(fgw): fgw now works with Juno and Pathfinder fix(fgw): fgw now works with Juno and Pathfinder and block signature Oct 9, 2024
@Trantorian1 Trantorian1 changed the title fix(fgw): fgw now works with Juno and Pathfinder and block signature fix(fgw): sync from other nodes and block signature Oct 9, 2024
@Trantorian1 Trantorian1 merged commit 7751329 into main Oct 11, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

feat(sync): Utilize Signature Verification Methods to Secure L2-only Blocks
4 participants