Skip to content

Commit

Permalink
0.5.0 spec (#230)
Browse files Browse the repository at this point in the history
* modified contract error in ApiError

* remove pending transactions endpoint

* add spec_version

* added config file where the version of the rpc_spec is specified

* add get_transaction_execution_and_finality_status, make TransactionFinalityStatus non optional, remove create_rejected method

* added starknet_version and l1_gas_price to block header and entry to config file

* added constants for builtins names

* execution resources struct

* map transaction execution info to execution resources

* use builtins constants in vm_resource_fee_cost setting

* use txn execution info when generating a receipt

* add check for empty string passed as abi when deserializing sierra class

* removed empty file

* test functionality for reading json-rpc spec and testing it against existing in/out structures

* remove not needed test files

* anotate request inputs with deny_unknown_fields so if there are any additions to the requests in the spec, the deserialization will fail

* move models/state to types/rpc/state

* improve algorithm for generating request responses of spec

* extract ThinStateDiff logic generation into converter

* replace PatriciaKeyHex with PatriciaKey

* add state diff to transaction trace

* add instructions to modify the spec

* modify tests for simulated transactions

* remove println

* generate only required fields

* tests for generated requests/responses from the spec

* edit the spec

* comments about extra fields not present in 0.5.0 spec

* add execution info to get_receipt params

* add StarknetResponse - enum for covering all return values from json rpc methods

* return StarknetResponse from each method of json-rpc

* changes to match 0.5.0 spec

* dependencies

* clippy + fmt

* lock file

* clippy fix

* marked spec 0.5.0

* Update crates/starknet-server/tests/test_simulate_transactions.rs

Co-authored-by: FabijanC <[email protected]>

* remove comment

* fmt

* edit starknet_version

* update starknet_version in config

* added ordered event and ordered message to l1

* use thread_rng().gen_bool in do_for_boolean_primitive

* improved generated_combined_schema readability

* not needed serde attribute

* fmt

* added comment

* added forgotten method mentioned in issue  #248

* fix test

* clippy

* fmt

---------

Co-authored-by: FabijanC <[email protected]>
  • Loading branch information
marioiordanov and FabijanC committed Nov 21, 2023
1 parent 2aca236 commit 2c984aa
Show file tree
Hide file tree
Showing 59 changed files with 5,887 additions and 450 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[env]
RPC_SPEC_VERSION = "0.5.0"
STARKNET_VERSION = "0.12.3"
97 changes: 93 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ clap = { version = "4.3.2", features = ["derive"] }
flate2 = { version = "1.0.26" }
serde = { version = "1.0.171", features = ["derive"] }
serde_json = { version = "1.0.81" }
serde_yaml = { version = "0.9.27" }
thiserror = { version = "1.0.32" }
anyhow = "1"
tokio-graceful-shutdown = "0.13.0"
indexmap = "2.0.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
regex_generate = "0.2.3"

# Starknet dependencies
starknet_api = { version = "0.6.0-rc0", features = ["testing"] }
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This repository is work in progress, please be patient. Please check below the s

### TODO

- [ ] RPC v0.5.0
- [x] RPC v0.5.0

### TODO to reach feature parity with the Pythonic Devnet

Expand Down
4 changes: 4 additions & 0 deletions crates/starknet-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ starknet-rs-accounts = { workspace = true }
starknet-rs-contract = { workspace = true }
starknet-rs-signers = { workspace = true }
starknet-core = { workspace = true, features = ["test_utils"] }
rand = { workspace = true }
rand_chacha = { workspace = true }
regex_generate = { workspace = true }
serde_yaml = { workspace = true }
5 changes: 4 additions & 1 deletion crates/starknet-server/src/api/http/endpoints/mint_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ fn get_balance(starknet: &Starknet, address: ContractAddress) -> Result<BigUint,
if new_balance_raw.len() != 2 {
let msg =
format!("Fee token contract expected to return 2 values; got: {:?}", new_balance_raw);
return Err(ApiError::ContractError { msg });

return Err(ApiError::ContractError {
error: starknet_core::error::Error::UnexpectedInternalError { msg },
});
}
let new_balance_low: BigUint = (*new_balance_raw.get(0).unwrap()).into();
let new_balance_high: BigUint = (*new_balance_raw.get(1).unwrap()).into();
Expand Down
Loading

0 comments on commit 2c984aa

Please sign in to comment.