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

extended CompilationFailed error(s) #2464

Merged
merged 2 commits into from
Jan 10, 2025
Merged

Conversation

vbar
Copy link
Contributor

@vbar vbar commented Jan 3, 2025

Returning Starknet compilation failure error message.

Fixes #2462 .

@vbar vbar requested a review from a team as a code owner January 3, 2025 09:35
@@ -202,7 +202,9 @@ impl ApplicationError {
ApplicationError::InsufficientResourcesForValidate => None,
ApplicationError::InsufficientAccountBalance => None,
ApplicationError::ValidationFailure => None,
ApplicationError::CompilationFailed => None,
ApplicationError::CompilationFailed { data } => Some(json!({
"data": data,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this "data": is redundant here. The JSON value returned by the .data() method is already wrapped in "data": in the JSON-RPC result.

And I'm not actually sure this is compliant with the specification: COMPILATION_FAILED doesn't have its data specified in the OpenRPC specification.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, OK, so this will eventually be valid after this PR is merged into the 0.8 specification. Then we should maybe make this change only for the 0.8 JSON-RPC API so that we don't break JSON-RPC 0.7?

Copy link
Contributor Author

@vbar vbar Jan 6, 2025

Choose a reason for hiding this comment

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

I think this "data": is redundant here. The JSON value returned by the .data() method is already wrapped in "data": in the JSON-RPC result.

Well yes, but this is implementing the .data() method... Anyway, I just went by analogy with the other cases having data (i.e. GatewayError and TransactionExecutionError)...

Also, json!({ data }) doesn't compile - "missing tokens in macro arguments"... Or do you mean serde_json::Value::String(data.to_string()) ?

Copy link
Contributor Author

@vbar vbar Jan 6, 2025

Choose a reason for hiding this comment

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

Ah, OK, so this will eventually be valid after this PR is merged into the 0.8 specification. Then we should maybe make this change only for the 0.8 JSON-RPC API so that we don't break JSON-RPC 0.7?

Like f834295 ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this "data": is redundant here. The JSON value returned by the .data() method is already wrapped in "data": in the JSON-RPC result.

Well yes, but this is implementing the .data() method... Anyway, I just went by analogy with the other cases having data (i.e. GatewayError and TransactionExecutionError)...

Also, json!({ data }) doesn't compile - "missing tokens in macro arguments"... Or do you mean serde_json::Value::String(data.to_string()) ?

Yes, I meant json!(data).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

RpcVersion::V08 => Some(json!({
"data": data,
})),
_ => None,
Copy link
Contributor

Choose a reason for hiding this comment

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

BTW: considering the introduction of the next JSON-RPC version (if ever) I think we should special-case the V07 variant instead and default to including data. That way we'd automatically get the data for the next version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@vbar vbar force-pushed the vbar/return-compilation-error branch from 23a43c2 to 26b2395 Compare January 7, 2025 07:11
@vbar vbar merged commit ca654b8 into main Jan 10, 2025
8 checks passed
@vbar vbar deleted the vbar/return-compilation-error branch January 10, 2025 13:08
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.

Return compilation error in starknet_addDeclareTransaction
3 participants