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(fgw): addition of a gateway + removal of starknet-provider #252

Merged
merged 37 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
36c1dd6
gateway
jbcaron Sep 6, 2024
372dc80
add add_transaction endpoint
jbcaron Sep 19, 2024
9834851
fix: disable_root
jbcaron Sep 20, 2024
582f189
fix fmt
jbcaron Sep 20, 2024
da1bb7d
fix(comments)
Trantorian1 Sep 23, 2024
cc87b39
refactor(error): updated `handler.rs` error handling
Trantorian1 Sep 23, 2024
ae92369
fix(comments)
Trantorian1 Sep 23, 2024
57bfe5d
fix(comments)
Trantorian1 Sep 23, 2024
57c1b50
fix(casing): `L1DataAvailabilityMode` casing causing deserialization …
Trantorian1 Sep 24, 2024
52eb380
fix(clippy)
Trantorian1 Sep 24, 2024
f0a9080
fix(deserialize): L1 DA mode can be deserialized independant of casing
Trantorian1 Sep 24, 2024
b14f3c1
feat(feeder): added `get_state_update_with_block` fgw method
Trantorian1 Sep 25, 2024
aa704a7
feat(feeder): added method `get_class_by_hash`
Trantorian1 Sep 26, 2024
51fb782
CHECKPOINT
Trantorian1 Sep 26, 2024
d09b49c
CHECKPOINT
Trantorian1 Sep 27, 2024
68aefb1
feat(mocks): replaced json mocks with compressed gz mocks
Trantorian1 Sep 28, 2024
b9b9625
fix(clippy)
Trantorian1 Sep 28, 2024
cd5bc4b
refactor(rstest): removed redundant `rstest` in certain tests
Trantorian1 Oct 1, 2024
63df3e2
fix(test): updated e2e tests to use fgw
Trantorian1 Oct 1, 2024
f603a93
fix(test): repaired mc-e2e-tests
Trantorian1 Oct 1, 2024
f016bdc
fix(test): repaired mc-sync tests
Trantorian1 Oct 1, 2024
4d24cad
feat(fetch): added CLI option to set fgw url
Trantorian1 Oct 1, 2024
d5757a2
fix(lint)
Trantorian1 Oct 1, 2024
4ec67b8
Merge branch 'main' into gateway
Trantorian1 Oct 1, 2024
fe6775b
fix(json): removed some test files
Trantorian1 Oct 1, 2024
639ed14
fix(prettier)
Trantorian1 Oct 1, 2024
75de1c4
fix(rate_limit): reverted `MAX_RETRY` to 15
Trantorian1 Oct 2, 2024
9339dcd
fix(disable_root)
Trantorian1 Oct 2, 2024
6bf5bae
fix(feedback)
Trantorian1 Oct 2, 2024
d0a4f86
fix(feedback)
Trantorian1 Oct 2, 2024
521d8fe
Merge branch 'main' into gateway
Trantorian1 Oct 2, 2024
ac2d7d2
fix(ci): fixed out-of-order state update storage diffs
Trantorian1 Oct 2, 2024
e719007
Merge branch 'main' into gateway
Trantorian1 Oct 2, 2024
20cf3e7
Merge branch 'main' into gateway
antiyro Oct 2, 2024
4ad0ffa
Merge branch 'main' into gateway
Trantorian1 Oct 3, 2024
2adb31d
fix(lint)
Trantorian1 Oct 3, 2024
f898e9a
Merge branch 'main' into gateway
antiyro Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(comments)
  • Loading branch information
Trantorian1 authored and jbcaron committed Oct 1, 2024
commit ae92369fcba84400e2256e73e52fb61f72923485
1 change: 0 additions & 1 deletion crates/client/gateway/src/client/request_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,5 @@ where
return Err(error);
}

response.error_for_status_ref().map(|_| ())?;
Ok(response.json::<T>().await?)
}
2 changes: 1 addition & 1 deletion crates/client/gateway/src/server/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum GatewayError {

impl From<MadaraStorageError> for GatewayError {
fn from(e: MadaraStorageError) -> Self {
log::error!("Storage error: {}", e);
log::error!(target: "gateway_errors", "Storage error: {}", e);
Self::InternalServerError
}
}
Expand Down
16 changes: 12 additions & 4 deletions crates/client/gateway/src/server/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ pub(crate) async fn main_router(
// Router for requests related to feeder_gateway
async fn feeder_gateway_router(req: Request<Body>, backend: Arc<MadaraBackend>) -> Result<Response<Body>, Infallible> {
match (req.method(), req.uri().path()) {
(&Method::GET, "/feeder_gateway/get_block") => Ok(handle_get_block(req, backend).await),
(&Method::GET, "/feeder_gateway/get_state_update") => Ok(handle_get_state_update(req, backend).await),
(&Method::GET, "/feeder_gateway/get_class_by_hash") => Ok(handle_get_class_by_hash(req, backend).await),
(&Method::GET, "/feeder_gateway/get_block") => {
Ok(handle_get_block(req, backend).await.unwrap_or_else(Into::into))
}
(&Method::GET, "/feeder_gateway/get_state_update") => {
Ok(handle_get_state_update(req, backend).await.unwrap_or_else(Into::into))
}
(&Method::GET, "/feeder_gateway/get_class_by_hash") => {
Ok(handle_get_class_by_hash(req, backend).await.unwrap_or_else(Into::into))
}
_ => Ok(not_found_response()),
}
}
Expand All @@ -41,7 +47,9 @@ async fn gateway_router(
add_transaction_provider: Arc<dyn AddTransactionProvider>,
) -> Result<Response<Body>, Infallible> {
match (req.method(), req.uri().path()) {
(&Method::POST, "/feeder/add_transaction") => Ok(handle_add_transaction(req, add_transaction_provider).await),
(&Method::POST, "/feeder/add_transaction") => {
Ok(handle_add_transaction(req, add_transaction_provider).await.unwrap_or_else(Into::into))
}
_ => Ok(not_found_response()),
}
}
14 changes: 14 additions & 0 deletions crates/primitives/block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

pub mod header;

use std::fmt::Display;

pub use header::Header;
use header::PendingHeader;
use mp_chain_config::StarknetVersion;
Expand Down Expand Up @@ -126,6 +128,18 @@ impl From<BlockId> for starknet_core::types::BlockId {
}
}
}
impl Display for BlockId {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BlockId::Hash(hash) => write!(f, "0x{hash:x}"),
BlockId::Number(number) => write!(f, "{number}"),
BlockId::Tag(blocktag) => match blocktag {
BlockTag::Latest => write!(f, "latest"),
BlockTag::Pending => write!(f, "pending"),
},
}
}
}

// Light version of the block with block_hash
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
Expand Down
32 changes: 12 additions & 20 deletions crates/primitives/gateway/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@






#[cfg(test)]
mod tests {
use std::fmt::Debug;
use std::fmt::Debug;

use serde::de::DeserializeOwned;
use serde::de::DeserializeOwned;

use super::*;
use super::*;

fn test_serialize_deserialize<T>(value: T) -> T
where
T: Serialize + DeserializeOwned + Clone + Debug + PartialEq,
{
let serialized = serde_json::to_string(&value).unwrap();
let deserialized: T = serde_json::from_str(&serialized).unwrap();
assert_eq!(value, deserialized);
deserialized
}
}
fn test_serialize_deserialize<T>(value: T) -> T
where
T: Serialize + DeserializeOwned + Clone + Debug + PartialEq,
{
let serialized = serde_json::to_string(&value).unwrap();
let deserialized: T = serde_json::from_str(&serialized).unwrap();
assert_eq!(value, deserialized);
deserialized
}