Skip to content

Commit

Permalink
Add Block and State deserialization (#40)
Browse files Browse the repository at this point in the history
* Add BlockHeader deserialization

* Add Block deserialization

* Add TODO in main for visibility

* Remove model.Address

* Add Account deserialization

* Add State deserialization

* Undo remove tx from mock block
  • Loading branch information
ClementWalter authored Sep 27, 2024
1 parent 21626dd commit 1e11218
Show file tree
Hide file tree
Showing 43 changed files with 1,136 additions and 1,359 deletions.
1 change: 0 additions & 1 deletion .codespellignore

This file was deleted.

4 changes: 4 additions & 0 deletions .trunk/configs/cspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: "0.2"
# Suggestions can sometimes take longer on CI machines,
# leading to inconsistent results.
suggestionsTimeout: 5000 # ms
4 changes: 3 additions & 1 deletion .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ runtimes:
system_version: allowed
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
disabled:
- codespell
files:
- name: cairo
extensions:
Expand Down Expand Up @@ -53,13 +55,13 @@ lint:
read_output_from: stdout
run_linter_from: workspace
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- cairo@SYSTEM
- [email protected]
- clippy@SYSTEM
- [email protected]
- git-diff-check
- [email protected]
- [email protected]
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"python.testing.pytestArgs": ["cairo"],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"jupyter.notebookFileRoot": "${workspaceFolder}/cairo"
"jupyter.notebookFileRoot": "${workspaceFolder}/cairo",
"githubPullRequests.remotes": ["kakarot", "upstream"]
}
18 changes: 0 additions & 18 deletions cairo/programs/fibonacci.cairo

This file was deleted.

260 changes: 0 additions & 260 deletions cairo/programs/fibonacci.json

This file was deleted.

28 changes: 12 additions & 16 deletions cairo/programs/os.cairo
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
%builtins output
%builtins pedersen output

from starkware.cairo.common.memcpy import memcpy
from starkware.cairo.common.cairo_builtins import HashBuiltin

from src.model import model

func main{output_ptr: felt*}() {
tempvar block_info: model.BlockInfo* = cast(nondet %{ segments.add() %}, model.BlockInfo*);
%{ block_info %}

assert [output_ptr] = block_info.coinbase;
assert [output_ptr + 1] = block_info.timestamp;
assert [output_ptr + 2] = block_info.number;
assert [output_ptr + 3] = block_info.prev_randao.low;
assert [output_ptr + 4] = block_info.prev_randao.high;
assert [output_ptr + 5] = block_info.gas_limit;
assert [output_ptr + 6] = block_info.chain_id;
assert [output_ptr + 7] = block_info.base_fee;

let output_ptr = output_ptr + 8;

func main{pedersen_ptr: HashBuiltin*, output_ptr: felt*}() {
%{ dict_manager %}
tempvar block: model.Block*;
tempvar state: model.State*;
%{ block %}
%{ state %}
// TODO: Compute initial state root hash and compare with block.parent_hash
// TODO: Loop through transactions and apply them to the initial state
// TODO: Compute the state root hash after applying all transactions
// TODO: Compare the final state root hash with block.state_root
return ();
}
Loading

0 comments on commit 1e11218

Please sign in to comment.