-
Notifications
You must be signed in to change notification settings - Fork 27
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: gateway #252
base: main
Are you sure you want to change the base?
feat: gateway #252
Conversation
ba05390
to
4220b60
Compare
Coverage reportThe coverage rate is
Diff Coverage details (click to unfold)crates/primitives/gateway/src/receipt.rs
crates/client/gateway/src/client/builder.rs
crates/primitives/receipt/src/into_starknet_core.rs
crates/primitives/receipt/src/lib.rs
crates/primitives/gateway/src/state_update.rs
crates/client/gateway/src/client/request_builder.rs
crates/primitives/receipt/src/from_blockifier.rs
crates/node/src/cli/gateway.rs
crates/client/gateway/src/server/worker.rs
crates/client/gateway/src/client/methods.rs
crates/primitives/gateway/src/transaction.rs
crates/client/gateway/src/server/handler.rs
crates/client/gateway/src/error.rs
crates/primitives/transactions/src/lib.rs
crates/node/src/main.rs
crates/primitives/gateway/src/block.rs
crates/primitives/receipt/src/from_starknet_provider.rs
crates/primitives/utils/src/lib.rs
crates/client/gateway/src/server/helpers.rs
crates/primitives/convert/src/hex_serde.rs
crates/client/gateway/src/server/router.rs
crates/node/src/service/gateway.rs
|
b9b65a8
to
38256b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool!
I think we should move the client to another crate
|
||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] | ||
#[serde(deny_unknown_fields)] | ||
pub struct BlockProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why block provider name
#[serde(deny_unknown_fields)] | ||
pub enum BlockStatus { | ||
Pending, | ||
Aborted, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add todo: what does that mean,,??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should:
- check if RPC has those / equivalents
- if so, ask #starknet-json-rpc slack
otherwise i think we should ask starkware what it is supposed to mean?
crates/tests/src/lib.rs
Outdated
@@ -185,6 +185,7 @@ impl MadaraCmdBuilder { | |||
format!("{}", self.tempdir.as_ref().display()), | |||
"--rpc-port".into(), | |||
format!("{}", self.port.0), | |||
"--".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
let state_diff = match backend.get_block_state_diff(&resolved_block_id) { | ||
Ok(Some(state_diff)) => state_diff, | ||
Ok(None) => { | ||
return StarknetError::block_not_found().into(); | ||
} | ||
Err(e) => { | ||
log::error!("Error getting contract class hash at: {}", e); | ||
return storage_error_to_response(e); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
example of how to refactor these functions
backend.get_block_state_diff(&resolved_block_id)
.or_internal_server_error("Error getting contract class hash")?
.ok_or(StarknetError::block_not_found())?
|
||
/// The gateway port to listen at. | ||
#[arg(long, value_name = "GATEWAY PORT", default_value = "8080")] | ||
pub gateway_port: u16, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we want CORS at least here, i don't really know
@@ -262,15 +262,15 @@ fn block_hash( | |||
parent_block_hash, | |||
block_number, | |||
global_state_root, | |||
sequencer_address, | |||
sequencer_address: Some(sequencer_address), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't have an opinion on whether we should have that as an option (same for the other 3 fields)
} | ||
}); | ||
|
||
log::info!("🌐 Gateway endpoint started at {}", listener.local_addr()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we add cors, match the message from rpc
log::info!(
"📱 Running JSON-RPC server at {} (allowed origins={})",
local_addr.map_or_else(|| "unknown".to_string(), |a| a.to_string()),
format_cors(cors.as_ref())
);
b31f96d
to
bbbf378
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nitpicks, otherwise all seems good 👍
use super::*; | ||
|
||
#[tokio::test] | ||
async fn test_get_block() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no assert
? It seems you are testing for block 0, maybe we could check the contents of the block too, or at the very least asserts its block number?
} | ||
|
||
#[tokio::test] | ||
async fn test_get_state_update() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
fn or_internal_server_error<C: fmt::Display>(self, context: C) -> Result<T, GatewayError>; | ||
} | ||
|
||
impl<T, E: Into<GatewayError>> ResultExt<T, E> for Result<T, E> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noice 👌
} | ||
} | ||
|
||
// append_pair("includeBlock", "true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider deleting this comment (nitpick)
Pull Request type
What is the current behavior?
Resolves: #186
What is the new behavior?
Does this introduce a breaking change?
No
Other information