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

0.5.0 spec #230

Merged
merged 56 commits into from
Nov 21, 2023
Merged

0.5.0 spec #230

merged 56 commits into from
Nov 21, 2023

Conversation

marioiordanov
Copy link
Contributor

@marioiordanov marioiordanov commented Oct 27, 2023

Changes

Test module spec_reader

For generating JSON requests and responses from JSON-RPC specification.
edit_spec_instructions.yaml file is used for correcting some errors in the spec and removing some PENDING structs, because we dont support pending feature yet
NOTE: If for some reason there are unwraps in this module, keep in mind that its only used in tests.
NOTE: the specs in test_data are not 100% similar to the the spec in starkware repo, due to limitation of modifying the spec some irrelevant data to devnet was removed manually

  • ApiError::ContractError receives an Error as parameter. Serializing ContractError to RpcResult populates the data object.
  • Added .cargo/config.toml with entries - RPC_SPEC_VERSION, STARKNET_VERSION
  • Removed starknet_pendingTransactions
  • Added starknet_specVersion
  • Removed method StarknetTransaction::create_rejected
  • Made StarknetTransaction::finality_status member field non-optional
  • Added starknet_getTransactionStatus RPC method
  • Added starknet_version and l1_gas_price
  • Added execution_resources to receipt
  • Decorate most of the input/output structs with deny_unknown_fields, so we can be maximally compliant with the specification.
  • Removed PatriciaKeyHex and moved its serialization/deserialization to Starknet-types
  • Removed data.rs file
  • Adapted test_simulate_transactions.rs
  • Extracted resource fee costs names into constants.rs
  • Added conversion from StateDiff to ThinStateDiff
  • Refactor StateUpdate to hold StateDiff, instead of its flattened properties
  • Added some TODOs which should be handled by this issue: JSON-RPC methods returning extra properties not in the spec #248
  • Added Deserialize or Serialize to some structs in so they can be tested with the spec_reader.
  • All endpoints read/write now return StarknetResponse enum, which has an entry for every method. It is used for being able to match if generated response from spec_generator can be deserialised to the implemented one.
  • Refactor api_error_to_rpc_error
  • Wrap write_endpoints.rs methods input params into enums in the form BroadcastedDeclareTransactionEnumWrapper for specifying the type, because before only accepting BroadcastedDeclareTransaction doesn't accept a type field, but in the spec a type field is specified for all input objects for the methods addDeclareTransaction, addInvokeTransaction, addDeployAccountTransaction
  • Implemented logic for calculating ExecutionResources in transaction receipt
  • Remove abi field when deserializing to Sierra contract class, If the field is empty.
  • Removed some irrelevant for 0.5.0 test_data files - declare_accepted.json and invoke_accepted.json
  • Refactored message_available_if_estimation_panics to send custom rpc request, instead of using starknet-rs, because with 0.5.0 the data field of the error result is populated with information and in this test we need to check the revert reason returned from the rpc request

Checklist:

  • Created git tag json-rpc-0.4.0 on main just before this PR is merged
  • Applied formatting - ./scripts/format.sh
  • No linter errors - ./scripts/clippy_check.sh
  • Performed code self-review
  • Rebased to the last commit of the target branch (or merged it into my branch)
  • Documented the changes
  • Linked the issues which this PR resolves
  • Checked the TODO section in README.md if this PR resolves it
  • Updated the tests
  • All tests are passing - cargo test

…nalityStatus non optional, remove create_rejected method
…dditions to the requests in the spec, the deserialization will fail
@marioiordanov marioiordanov linked an issue Nov 14, 2023 that may be closed by this pull request
@FabijanC FabijanC self-requested a review November 15, 2023 09:24
Copy link
Contributor

@FabijanC FabijanC left a comment

Choose a reason for hiding this comment

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

I've reviewed everything except the spec_reader testing module, I would like to consult with you about that.

crates/starknet-server/src/api/json_rpc/endpoints.rs Outdated Show resolved Hide resolved
.cargo/config.toml Outdated Show resolved Hide resolved
crates/starknet-server/tests/test_simulate_transactions.rs Outdated Show resolved Hide resolved
crates/starknet/src/state/state_diff.rs Show resolved Hide resolved
crates/types/src/rpc/transaction_receipt.rs Show resolved Hide resolved
crates/types/src/serde_helpers.rs Show resolved Hide resolved
@marioiordanov marioiordanov merged commit 2c984aa into main Nov 21, 2023
1 check passed
@marioiordanov marioiordanov deleted the 0.5.0-spec branch November 21, 2023 10:37
@marioiordanov marioiordanov restored the 0.5.0-spec branch November 21, 2023 14:52
@marioiordanov marioiordanov deleted the 0.5.0-spec branch March 28, 2024 07:48
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.

Update RPC logic to v0.5.0
3 participants