Starknet Devnet

New version of starknet-devnet (v0.1.10) has been released (GitHub):

  • Adapt to work with cairo-lang v0.6.2.
  • Replicate the new transaction statuses (transactions are now ACCEPTED_ON_L2).

Features to come (most likely not in the next version): supporting starknet get_block, supporting starknet get_transaction_receipt, L1-L2 interaction, testnet/mainnet forking.

23 Likes

So, the command starknet get_code:

  • receives a contract_address
  • returns an object with two parts:
    • abi
    • bytecode

I don’t understand two things

  1. How can abi and bytecode be used to reconstruct the state? Can a StarknetContract or its StarknetState be reconstructed in the testing framework using those artifacts? Or, hypothetically speaking, could it be possible to redeploy a contract from those two artifacts?
  2. get_code also receives a block identifier (hash or number) - how does that come into play? Does the code change over time?

I’ve only been able to make little progress on this topic, mostly because of dealing with other project-related issues; I apologize for not having done more.

25 Likes

New version of starknet-devnet (v0.1.11) has been released:

  • Add block support.

  • Add partial receipt support (missing for deploy transactions; coming with next version of cairo-lang).

  • Use official hash calculation function (instead of numbering tx hashes in order; block hash calculation coming with next version of cairo-lang).

  • Refactor to prepare for the incoming forking support.

26 Likes

New version of starknet-devnet (v0.1.12) has been released:

  • Prevent Internal Server Error (500) from arising if deployment fails.
  • Ignore duplicate deployments (e.g. in case of same salt).
22 Likes

New version of starkent-devnet (v0.1.13) has been released:

  • Use cairo-lang 0.7.0 for internal execution (will allow deploying contracts compiled with 0.7.0).
  • Support arrays of structs in function inputs.
  • Include execution info in deploy transaction receipt.
  • Calculate block hash correctly.
  • Improve logging if case of version mismatch (mismatch between version used for compilation and version used by devnet).
22 Likes

New version of starknet-devnet (v0.1.14) has been released:

  • Include events in transaction receipts.
  • Allow transactions/calls with no signature (so far empty signature was accepted, but some tools provide no signature at all, e.g. starknet.js).
  • In transaction and receipt objects, rename transaction_failure_reason to tx_failure_reason:
    • This enables the --error_message option of starknet tx_status.
24 Likes

Hello!

I have been having some difficulty with Devnet. I was hoping that I might get some direction. I will set out detail below. There may be a simple answer to my issue. I have just begun experimenting with Devnet to assist with developing for StarkNet. To start with, I have just used contract.cairo from the Hello, StarkNet tutorial as a starting point. It would appear that I can deploy the contract successfully. However, when I come to invoke the increase_balance function the invocation fails with the following error:

No contract at the provided address (0x076b1b7dc0ff2f07e02f670f21e949ba5a3db0f3e7070859ec454c9901e122a1)

I am using the Devnet docker image. This is running the image and the output from the transactions below:

docker run -it -p 127.0.0.1:5000:5000 shardlabs/starknet-devnet

  • Running on all addresses.
    WARNING: This is a development server. Do not use it in a production deployment.
  • Running on http://172.17.0.2:5000/ (Press CTRL+C to quit)

172.17.0.1 - - [08/Feb/2022 04:32:52] “POST /gateway/add_transaction HTTP/1.1” 200 -
172.17.0.1 - - [08/Feb/2022 04:34:00] “GET /feeder_gateway/get_transaction_status?transactionHash=0x0093bb167b667a00828fa2be1c08bf6b9f78e4d633fed2776ad16c73679f32c0 HTTP/1.1” 200 -
172.17.0.1 - - [08/Feb/2022 04:34:54] “GET /feeder_gateway/get_block?blockHash=0x038b3c5078754e95fe70390814b44c52ee3d04a13d88d3a1ae62fc143b7c7238 HTTP/1.1” 200 -
172.17.0.1 - - [08/Feb/2022 04:36:04] “POST /feeder_gateway/call_contract?blockNumber=pending HTTP/1.1” 500 -

Deployment of the contract:

starknet deploy --feeder_gateway_url http://127.0.0.1:5000/feeder_gateway/ --gateway_url http://127.0.0.1:5000/gateway/ --contract ./build/contract_compiled.json
Deploy transaction was sent.
Contract address: 0x03f2ed603357926a00c1ccf0151a0a5c634335bb1a16d26d5760037d91143b94
Transaction hash: 0x0093bb167b667a00828fa2be1c08bf6b9f78e4d633fed2776ad16c73679f32c0

Transaction status:

starknet tx_status --feeder_gateway_url http://127.0.0.1:5000/feeder_gateway/ --gateway_url http://127.0.0.1:5000/gateway/ --hash 0x0093bb167b667a00828fa2be1c08bf6b9f78e4d633fed2776ad16c73679f32c0
{
“block_hash”: “0x038b3c5078754e95fe70390814b44c52ee3d04a13d88d3a1ae62fc143b7c7238”,
“tx_status”: “ACCEPTED_ON_L2”
}

Contract invocation and error:

starknet invoke --feeder_gateway_url http://127.0.0.1:5000/feeder_gateway/ --gateway_url http://127.0.0.1:5000/gateway/ --address 0x03f2ed603357926a00c1ccf0151a0a5c634335bb1a16d26d5760037d91143b94 --abi ./build/contract_abi.json --function increase_balance --inputs 1234
Got BadRequest
Traceback (most recent call last):
File “/Users/david/cairo_venv/lib/python3.7/site-packages/services/external_api/base_client.py”, line 116, in _send_request
raise BadRequest(status_code=response.status, text=text)
services.external_api.base_client.BadRequest: HTTP error ocurred. Status: 500. Text: No contract at the provided address (0x076b1b7dc0ff2f07e02f670f21e949ba5a3db0f3e7070859ec454c9901e122a1).
Error: BadRequest: HTTP error ocurred. Status: 500. Text: No contract at the provided address (0x076b1b7dc0ff2f07e02f670f21e949ba5a3db0f3e7070859ec454c9901e122a1).

The above works correctly using alpha-goerli but not in devnet. Any ideas what I am doing wrong? Or, is there a known issue causing this error?

19 Likes

Hi, thanks for reaching out.
What’s your Starknet version and what’s your Docker image tag?

18 Likes

Actually your problem is probably caused by interacting with your contract.cairo through a wallet. This is done implicitly when you’re using Starknet CLI with STARKNET_WALLET variable set. The address that’s reported as missing is actually the address of your account which is deployed only on alpha-goerli (as witnessed here: StarkNet - Alpha Block Explorer), that’s why it works only there.

You can either use the --no_wallet flag when running starknet invoke or you can unset STARKNET_WALLET.

Also an important note, Devnet currently doesn’t support interaction through Accounts; we’re waiting for the next cairo-lang version, which will hopefully have what we need to support Accounts.

EDIT: corrected the flag after @davek’s note

18 Likes

Thanks @FabijanC I will try that and report back.

19 Likes

Thanks @FabijanC that was my problem. I thought that I should also note, in case others read this thread, that the correct flag is --no_wallet not --no-wallet.

21 Likes

New version of starknet-devnet (v0.1.15) has been released:

Include postman L1 <> L2 interaction with local test networks

  • 2 new HTTP POST endpoints added: /postman/load_l1_messaging_contract and /postman/flush
  • Details of usage specified in Readme
22 Likes

New version of starknet-devnet (v0.1.16) has been released:

  • Support cairo-lang version 0.7.1.
  • Endpoints for new parts of the API (get_full_contract and get_state_update) not yet introduced.
21 Likes

New starknet-devnet version (v0.1.17) has been released:

  • You can now save and load your Devnet instance to save setup time: docs.
  • Supported starknet get_full_contract (get_state_update still pending).
  • Improved L1-L2 communication (postman)

Dump:

$ starknet-devnet --dump-path <PATH> --dump-on <WHEN>

Load:

$ starknet-devnet --load-path <PATH>
20 Likes

New starknet-devnet version (v0.1.18) has been released:

  • Support devnet dumping/loading on macOS.
  • Support starknet get_state_update (command that was introduced with cairo-lang 0.7.1).
18 Likes

New starknet-devnet version (v0.1.19) has been released:

  • Reduce Docker image size (635 MB → 232 MB)
  • Support cairo-lang 0.8.0:
    • Add estimate_fee endpoint (currently not able to charge accounts with actual fees).
    • Add get_transaction_trace endpoint.

We plan to change the default port soon and apply some optimization techniques as these are two things users have complained about.

20 Likes

WOW!!!
so good!!!
amazing!

17 Likes

New starknet-devnet version (v0.1.20) has been released:

  • Support cairo-lang 0.8.1.
  • Performance related optimizations:
    • Use a faster server container.
    • Introduce --lite-mode (skips block and tx hash calculation).
19 Likes

New version of starknet-devnet (v0.1.21) has been released:

18 Likes

New version of starknet-devnet (v0.1.22) has been released:

  • Fixed interaction of Starknet CLI and hardhat plugin when they are using the --wallet functionality.
  • Fixed syscall get_block_timestamp (will not return 0 anymore; more timestamp-related functionality to come)
19 Likes