Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jobs:
test:
name: test
runs-on: ubuntu-latest
environment: testing
steps:
- uses: actions/checkout@v3

Expand Down
109 changes: 104 additions & 5 deletions Cargo.lock

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

10 changes: 10 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ starkbiter-macros = { path = "macros" }

uuid = { version = "=1.17.0", features = ["v4"] }


starknet-devnet-core = { git = "https://github.com/baitcode/starknet-devnet.git", branch = "experiment" }
starknet-devnet-types = { git = "https://github.com/baitcode/starknet-devnet.git", branch = "experiment" }
starknet_api = "=0.14.0-rc.3"
Expand All @@ -56,6 +57,14 @@ starknet-core = "=0.14.0"
starknet-accounts = "=0.14.0"
starknet-signers = "=0.12.0"

blockifier = { version = "0.14.0-rc.3" }

r2d2 = { version = "0.8.10" }
r2d2_sqlite = { version = "0.31.0" }
rusqlite = { version = "0.37.0" }

zstd = { version = "0.13.3" }

# Arbiter crates.io for release, these need to be used to do crate releases!
# arbiter-bindings = "0.1.7"
# arbiter-core = "0.11.0"
Expand All @@ -78,6 +87,7 @@ async-trait = { version = "0.1.80" }
crossbeam-channel = { version = "0.5.12" }

syn = { version = "2.0.60", features = ["full"] }
proc-macro = { version = "*" }
proc-macro2 = { version = "1.0.79" }

tracing = "0.1.40"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
![Github Actions](https://github.com/astraly-labs/starkbiter/workflows/test/badge.svg)

## Overview
> **Starkbiter** is a framework for orchestrating event based agentic simulations on top of Starknet Devnet sandbox.
> **Starkbiter** is a framework for orchestrating event based agentic simulations on top of Starknet Devnet sandbox. Allows for using with local sqlite snapshot (`Pathfinder` structure) which operates blazingly fast.

Starkbiter provides a Full JSON-RPC Starknet Node capabilities with additional methods to control block production, contract and account deployments and declaration. It integrates deeply with starknet-devnet and starknet-rs types crates allowing for seamless integration for all the tooling that depends on those. Thus, it also provides additional layer of well known contract bindings generated by [cainome](https://github.com/cartridge-gg/cainome).

Expand Down Expand Up @@ -47,7 +47,12 @@ It will also be helpful to get the `cargo-generate` package, which you can insta
cargo install cargo-generate
```

## Using from python code

For an example usage of python library and reference wrapper implementation check out [this](https://github.com/baitcode/starkbiter-python-example) repo

### Examples

We have an example that will run what we have set up in a template.
To run this, you can clone the repository and update the submodules:
```bash
Expand Down
11 changes: 10 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ starknet-devnet-core.workspace = true
starknet-devnet-types.workspace = true
starknet_api.workspace = true

blockifier.workspace = true

# Serialization
serde.workspace = true
serde_json.workspace = true
Expand All @@ -32,6 +34,14 @@ crossbeam-channel.workspace = true

futures.workspace = true
auto_impl = "1.3.0"
url.workspace = true

# Database
r2d2.workspace = true
r2d2_sqlite.workspace = true

# Utils
zstd.workspace = true

# Errors
anyhow.workspace = true
Expand All @@ -44,7 +54,6 @@ tracing.workspace = true
[dev-dependencies]
cainome.workspace = true
starkbiter-bindings.workspace = true
url.workspace = true
tracing-subscriber = "0.3.18"

# For bench
Expand Down
Binary file added core/mainnet-trimmed.sqlite
Binary file not shown.
2 changes: 2 additions & 0 deletions core/src/environment/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ pub enum CheatInstruction {
/// Fetches block with transactions by its identifier
/// and adds them on top of pending block in DevNet.
ReplayBlockWithTxs {
/// The URL of the node API to fetch block from.
url: Url,
/// The identifier of the block to retrieve.
block_id: core_types::BlockId,
/// Checks if transaction has events matching filters and applies it if
Expand Down
21 changes: 9 additions & 12 deletions core/src/environment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,14 @@ use tracing::debug;

use super::*;
use crate::tokens::get_token_data;

pub mod instruction;

/// This module provides a reader for the Starknet state stored in a SQLite
/// database. It is compatible with starknet-devnet defaulter implementation,
/// and allows to replace node api http requests for state storage data with
/// SQLite queries for Pathfinder formatted sqlite database.
pub mod sqlite_state_reader;

use instruction::{Instruction, NodeInstruction, NodeOutcome, Outcome};

mod utils;
Expand Down Expand Up @@ -1679,6 +1685,7 @@ async fn process_instructions(
}
}
instruction::CheatInstruction::ReplayBlockWithTxs {
url,
block_id,
has_events: filters,
override_nonce,
Expand All @@ -1689,16 +1696,6 @@ async fn process_instructions(
"Environment. Received ReplayBlockWithTxs instruction: tx_hash: {:?}",
block_id,
);
let maybe_url = starknet.config.fork_config.clone().url;
if maybe_url.is_none() {
if let Err(e) = sender.send(Err(StarkbiterCoreError::NoForkConfig)) {
error!("Failed to send Cheating GetBlockWithTxs error: {:?}", e);
stop = true;
}
continue;
}

let url = maybe_url.unwrap();

let provider = JsonRpcClient::new(HttpTransport::new(url.clone()));

Expand All @@ -1708,7 +1705,7 @@ async fn process_instructions(
if let Err(e) =
sender.send(Err(StarkbiterCoreError::InternalError(e.to_string())))
{
error!("Failed to send Cheating GetBlockWithTxs error: {:?}", e);
error!("Failed to send Cheating ReplayBlockWithTxs error: {:?}", e);
stop = true;
}
continue;
Expand Down
Loading
Loading