Skip to content

Commit e08301f

Browse files
authored
Release 0.4.3 (#803)
* skip release to crates.io due to git dependency (blockifier)
1 parent 86fb3d2 commit e08301f

File tree

29 files changed

+1548
-14
lines changed

29 files changed

+1548
-14
lines changed

.circleci/config.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,11 @@ jobs:
151151
fingerprints:
152152
- "SHA256:y2r0YUdeS8k6XSOFmgNs4wcTJFv+PIgkY0Yz+af6NSU"
153153
- run:
154-
name: Publish new versions to crates.io
155-
command: ./scripts/publish_cratesio_new_versions.sh
154+
command: echo 'Skipping publishing to crates.io. See root Cargo.toml'
155+
# TODO
156+
# - run:
157+
# name: Publish new versions to crates.io
158+
# command: ./scripts/publish_cratesio_new_versions.sh
156159
- run:
157160
name: Create tags and push joint image manifests
158161
command: ./docker/tag_images_and_create_joint_image_manifests.sh

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ enum-helper-macros = "0.0.1"
7979

8080
# Starknet dependencies
8181
starknet-types-core = "0.1.5"
82-
# Using commit hash of the latest commit, at the time of writing, of branch main-v0.13.6
82+
# Using commit hash of the latest commit, at the time of writing, of branch main-v0.13.6.
83+
# TODO Replace with a stable release once possible and address the TODO in config.yml
8384
starknet_api = { git = "https://github.com/starkware-libs/sequencer.git", rev = "3f010d153731dcb8f118403d96390933909bb4a6", features = ["testing"] }
8485
blockifier = { git = "https://github.com/starkware-libs/sequencer.git", rev = "3f010d153731dcb8f118403d96390933909bb4a6" }
8586
starknet-rs-signers = { version = "0.11.0", package = "starknet-signers" }
@@ -105,9 +106,9 @@ cairo-lang-syntax = "=2.10.0"
105106
cairo-lang-utils = "=2.10.0"
106107

107108
# Inner dependencies
108-
starknet-types = { version = "0.4.2", path = "crates/starknet-devnet-types", package = "starknet-devnet-types" }
109-
starknet-core = { version = "0.4.2", path = "crates/starknet-devnet-core", package = "starknet-devnet-core" }
110-
server = { version = "0.4.2", path = "crates/starknet-devnet-server", package = "starknet-devnet-server" }
109+
starknet-types = { version = "0.4.3", path = "crates/starknet-devnet-types", package = "starknet-devnet-types" }
110+
starknet-core = { version = "0.4.3", path = "crates/starknet-devnet-core", package = "starknet-devnet-core" }
111+
server = { version = "0.4.3", path = "crates/starknet-devnet-server", package = "starknet-devnet-server" }
111112

112113
# Dependabot alerts
113114
zerocopy = "0.7.31"

crates/starknet-devnet-core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starknet-devnet-core"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
edition.workspace = true
55
repository.workspace = true
66
license-file.workspace = true

crates/starknet-devnet-server/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starknet-devnet-server"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
edition = "2021"
55
repository.workspace = true
66
license-file.workspace = true

crates/starknet-devnet-types/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starknet-devnet-types"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
edition = "2021"
55
description = "Starknet types for the devnet"
66
repository.workspace = true

crates/starknet-devnet/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "starknet-devnet"
3-
version = "0.4.2"
3+
version = "0.4.3"
44
edition = "2021"
55
repository.workspace = true
66
license-file.workspace = true
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Account impersonation
2+
3+
:::info
4+
5+
This page is about account impersonation. To read about account class selection and deployment, click [here](./predeployed).
6+
7+
:::
8+
9+
## Introduction
10+
11+
Devnet allows you to impersonate an account that exists on the Starknet mainnet or testnet. This is achieved by skipping the validation step of transactions for all or some accounts, on a running Devnet via JSON-RPC.
12+
13+
A transaction sent from an impersonated account will not fail with an invalid signature error, which is what happens in the general case of locally absent accounts. For impersonation to work, Devnet needs to [fork](./forking.md) the network that has the desired account.
14+
15+
:::warning Caveat
16+
17+
- Only `INVOKE` and `DECLARE` transactions are supported. `DEPLOY_ACCOUNT` transaction is not supported, but you can create an `INVOKE` transaction to UDC.
18+
- Due to the validation step being skipped, the overall fee of transactions sent with an impersonated account will be lower than regular transactions.
19+
- Trying to send a transaction with an account that **does not** even exist in the origin network returns an error:
20+
- `ContractNotFound` if, during transaction preparation, you do not specify a nonce value, leading to the implicit querying of Devnet for the nonce.
21+
- `InsufficientAccountBalance` or similar if the nonce is supplied in the transaction; this happens because the token balance of a non-existent contract is 0 indeed insufficient.
22+
23+
:::
24+
25+
## Tips
26+
27+
- The impersonated account may have had all or a part of its funds used up on the origin network. You may need to give it more funds via [minting](./balance.md).
28+
- If you're defining a new account in your Starknet client application (starknet.js, starknet.rs, starkli...), you may need to specify a private key for it. Since the signature validation is skipped, you may provide a dummy key.
29+
30+
## API
31+
32+
Account impersonation follows JSON-RPC method specification. Each method returns an empty response:
33+
34+
### devnet_impersonateAccount
35+
36+
Impersonates a specific account address nonexistent in the local state.
37+
38+
```js
39+
{
40+
"jsonrpc": "2.0",
41+
"id": "1",
42+
"method": "devnet_impersonateAccount",
43+
"params": {
44+
"account_address": "0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7"
45+
}
46+
}
47+
```
48+
49+
### devnet_stopImpersonateAccount
50+
51+
Stops the impersonation of an account previously marked for impersonation.
52+
53+
```js
54+
{
55+
"jsonrpc": "2.0",
56+
"id": "1",
57+
"method": "devnet_stopImpersonateAccount",
58+
"params": {
59+
"account_address": "0x49D36570D4E46F48E99674BD3FCC84644DDD6B96F7C741B1562B82F9E004DC7"
60+
}
61+
}
62+
```
63+
64+
### devnet_autoImpersonate
65+
66+
Enables automatic account impersonation. Every account that does not exist in the local state will be impersonated.
67+
68+
```js
69+
{
70+
"jsonrpc": "2.0",
71+
"id": "1",
72+
"method": "devnet_autoImpersonate",
73+
"params": {}
74+
}
75+
```
76+
77+
### devnet_stopAutoImpersonate
78+
79+
Stops the effect of [automatic impersonation](#devnet_autoimpersonate).
80+
81+
```js
82+
{
83+
"jsonrpc": "2.0",
84+
"id": "1",
85+
"method": "devnet_stopAutoImpersonate",
86+
"params": {}
87+
}
88+
```
89+
90+
## Preventing impersonation
91+
92+
If you want to learn about completely preventing impersonation from being activated on your Devnet, click [here](./restrictive.md).
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
5+
# API
6+
7+
## JSON-RPC API
8+
9+
Both Starknet's and Devnet's JSON-RPC API are reachable at `/rpc` and `/`. E.g. if spawning Devnet with default settings, these URLs are functionally equivalent: `http://127.0.0.1:5050/rpc` and `http://127.0.0.1:5050/`. The difference between these two groups of methods is their prefix: `starknet_` (e.g. `starknet_getNonce`) and `devnet_` (e.g. `devnet_mint`).
10+
11+
### Starknet API
12+
13+
Unlike Pythonic Devnet, which also supported Starknet's gateway and feeder gateway API, Devnet in Rust supports [Starknet's JSON-RPC API](https://github.com/starkware-libs/starknet-specs/tree/master/api), including [WebSocket support](#websocket).
14+
15+
Due to how Devnet internally works, the method `starknet_getStorageProof` is not applicable, and thus not supported.
16+
17+
Since JSON-RPC v0.6.0, to find out which JSON-RPC version is supported by which Devnet version, check out the [releases page](https://github.com/0xspaceshard/starknet-devnet/releases).
18+
19+
### Devnet API
20+
21+
Devnet has many additional features which are available via their own endpoints and JSON-RPC. The RPC methods are documented throughout the documentation in their corresponding pages, but are also aggregated [here](https://github.com/0xSpaceShard/starknet-devnet/blob/main/website/static/devnet_api.json).
22+
23+
:::warning Deprecation notice
24+
25+
New features are only supported as part of the JSON-RPC API. Older non-RPC requests are still supported, but considered deprecated - they will be removed in the future, except the [healthcheck endpoint](#healthcheck).
26+
27+
:::
28+
29+
#### Healthcheck
30+
31+
To check if a Devnet instance is alive, send an HTTP request `GET /is_alive`. If alive, Devnet will reply with a `200 OK` and an appropriate message.
32+
33+
### WebSocket
34+
35+
:::note Scope
36+
37+
Only Starknet's WebSocket methods are available via this protocol. General JSON-RPC support via WebSocket is not yet a feature of Devnet, meaning it does not support methods like `devnet_mint` or `starknet_getNonce`.
38+
39+
:::
40+
41+
JSON-RPC [WebSocket methods](https://github.com/starkware-libs/starknet-specs/blob/v0.8.0/api/starknet_ws_api.json) can be accessed via the WebSocket protocol, using text or binary messages. Devnet listens for new WebSocket connections at `ws://<HOST>:<PORT>/ws` (notice the protocol scheme). E.g. using [`wscat`](https://www.npmjs.com/package/wscat) on the same computer where Devnet is spawned at default host and port:
42+
43+
```
44+
$ wscat -c ws://127.0.0.1:5050/ws
45+
Connected (press CTRL+C to quit)
46+
> { "jsonrpc": "2.0", "id": 0, "method": "starknet_subscribeNewHeads" }
47+
< {"id":0,"result":2935616350010920547,"jsonrpc":"2.0"}
48+
```
49+
50+
## Interacting with Devnet in JavaScript and TypeScript
51+
52+
To spawn Devnet and interact with it using the [Devnet API](#devnet-api), you can use [`starknet-devnet-js`](https://github.com/0xSpaceShard/starknet-devnet-js/). This can be especially useful in achieving [L1-L2 communication](./postman.md).
53+
54+
To interact with Devnet using the [Starknet API](#starknet-api), use [starknet.js](https://www.starknetjs.com/).
55+
56+
## Config API
57+
58+
To retrieve the current configuration of Devnet, as specified via [CLI](running/cli.md) and later requests, send a `GET` request to `/config` or `JSON-RPC` request with method name `devnet_getConfig`. Example response is attached below. It can be interpreted as a JSON mapping of CLI input parameters, both specified and default ones, with some irrelevant parameters omitted. So use `starknet-devnet --help` to better understand the meaning of each value, though keep in mind that some of the parameters have slightly modified names. The exact values may have changed and should not be referenced.
59+
60+
```json
61+
{
62+
"seed": 4063802897,
63+
"total_accounts": 10,
64+
"account_contract_class_hash": "0x61dac032f228abef9c6626f995015233097ae253a7f72d68552db02f2971b8f",
65+
"predeployed_accounts_initial_balance": "1000000000000000000000",
66+
"start_time": null,
67+
"gas_price_wei": 100000000000,
68+
"gas_price_fri": 100000000000,
69+
"data_gas_price_wei": 100000000000,
70+
"data_gas_price_fri": 100000000000,
71+
"l2_gas_price_wei": 100000000000,
72+
"l2_gas_price_fri": 100000000000,
73+
"chain_id": "SN_SEPOLIA",
74+
"dump_on": "exit",
75+
"dump_path": "dump_path.json",
76+
"state_archive": "none",
77+
"fork_config": {
78+
"url": "http://rpc.pathfinder.equilibrium.co/integration-sepolia/rpc/v0_7",
79+
"block_number": 26429
80+
},
81+
"server_config": {
82+
"host": "127.0.0.1",
83+
"port": 5050,
84+
"timeout": 120,
85+
"restricted_methods": null
86+
},
87+
"block_generation": null,
88+
"lite_mode": false,
89+
"eth_erc20_class_hash": "0x046ded64ae2dead6448e247234bab192a9c483644395b66f2155f2614e5804b0",
90+
"strk_erc20_class_hash": "0x046ded64ae2dead6448e247234bab192a9c483644395b66f2155f2614e5804b0"
91+
}
92+
```
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Account balance
2+
3+
Other than using prefunded predeployed accounts, you can also add funds to an account that you deployed yourself.
4+
5+
Separate tokens use separate ERC20 contracts for minting and charging fees. These are the token contracts predeployed by Devnet and the addresses where they are located:
6+
7+
- ETH: `0x49d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7`
8+
- STRK: `0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d`
9+
10+
## Mint token - Local faucet
11+
12+
By sending a `POST` request to `/mint` or `JSON-RPC` request with method name `devnet_mint` for a token, you initiate a transaction on that token's ERC20 contract. The response contains the hash of this transaction, as well as the new balance after minting. The token is specified by providing the unit, and defaults to `FRI` (the unit of `STRK`).
13+
14+
The value of `amount` is in WEI or FRI. The precision is preserved if specifying an integer or a float whose fractional part is zero (e.g. `1000.0`, `1e21`). If the fractional part is non-zero, the amount is truncated to the nearest integer (e.g. `3.9` becomes `3` and `1.23e1` becomes `12`).
15+
16+
```
17+
POST /mint
18+
{
19+
"address": "0x6e3205f...",
20+
"amount": 500000,
21+
"unit": "WEI" | "FRI"
22+
}
23+
```
24+
25+
```
26+
JSON-RPC
27+
{
28+
"jsonrpc": "2.0",
29+
"id": "1",
30+
"method": "devnet_mint",
31+
"params": {
32+
"address": "0x6e3205f...",
33+
"amount": 500000,
34+
"unit": "WEI" | "FRI"
35+
}
36+
}
37+
```
38+
39+
Response:
40+
41+
```
42+
{
43+
"new_balance": 500000,
44+
"unit": "WEI" | "FRI",
45+
"tx_hash": "0xa24f23..."
46+
}
47+
```
48+
49+
In case of a reverted minting request, an error is returned containing the stringified revert reason and the hex string of the hash of the reverted transaction for further inspection:
50+
51+
```
52+
{
53+
"tx_hash": "0x123..."
54+
"revert_reason": "Something happened"
55+
}
56+
```
57+
58+
## Check balance
59+
60+
Check the balance of an address by sending a `GET` request to `/account_balance`. The address should be a 0x-prefixed hex string; `unit` defaults to `FRI` (the unit of `STRK`) and `block_tag` to `latest`.
61+
62+
```
63+
GET /account_balance?address=<ADDRESS>[&unit=<FRI|WEI>][&block_tag=<latest|pending>]
64+
```
65+
66+
```
67+
JSON-RPC
68+
{
69+
"jsonrpc": "2.0",
70+
"id": "1",
71+
"method": "devnet_getAccountBalance",
72+
"params": {
73+
"address": "0x6e3205f...",
74+
"unit": "WEI" | "FRI",
75+
"block_tag": "latest" | "pending"
76+
}
77+
}
78+
```

0 commit comments

Comments
 (0)