Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configurable chain config #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
362a313
Update mod.rs
azurwastaken Sep 6, 2024
0acc536
created preset + added parsing from yaml
azurwastaken Sep 9, 2024
1c58ec6
added unit test and fixed variable parsing
azurwastaken Sep 10, 2024
03035f9
add override values
azurwastaken Sep 10, 2024
da4c06d
fixed test and config
azurwastaken Sep 11, 2024
b3eb255
Merge remote-tracking branch 'upstream/main' into feat/configurable-c…
azurwastaken Sep 11, 2024
6670607
merge main into branch
azurwastaken Sep 11, 2024
cffaa23
Update CHANGELOG.md
azurwastaken Sep 11, 2024
529974c
toml lint
azurwastaken Sep 11, 2024
5fd477a
remove uselss
azurwastaken Sep 11, 2024
f9611dc
fix Deserialization issues
azurwastaken Sep 11, 2024
d9d6b0b
lint
azurwastaken Sep 12, 2024
9d5e1a6
moved to a struct + lint
azurwastaken Sep 12, 2024
e9105f8
Merge branch 'main' into feat/configurable-chain-config
azurwastaken Sep 12, 2024
f81b380
Merge remote-tracking branch 'upstream/main' into feat/configurable-c…
azurwastaken Sep 12, 2024
c31af38
merge main
azurwastaken Sep 12, 2024
a7aaf5b
lint
azurwastaken Sep 12, 2024
8d8d729
Update chain_config.rs
azurwastaken Sep 12, 2024
8fc53d8
Update chain_config.rs
azurwastaken Sep 12, 2024
1aaf41f
ci
azurwastaken Sep 12, 2024
babb130
Update chain_config.rs
azurwastaken Sep 12, 2024
7ba0131
unwrap
azurwastaken Sep 12, 2024
3a73371
Update test_block.rs
azurwastaken Sep 12, 2024
cf3a210
fix test
azurwastaken Sep 13, 2024
a7bc276
test again
azurwastaken Sep 13, 2024
2ea6cb2
テスト
azurwastaken Sep 13, 2024
c01b7bf
यह अच्छा होना चाहिए
azurwastaken Sep 13, 2024
6e5fc70
Update lib.rs
azurwastaken Sep 13, 2024
5b56064
Update test.yaml
azurwastaken Sep 13, 2024
e19a493
Update test.yaml
azurwastaken Sep 13, 2024
07029b3
Update lib.rs
azurwastaken Sep 13, 2024
44ad980
Merge remote-tracking branch 'upstream/main' into feat/configurable-c…
azurwastaken Sep 16, 2024
693ce9b
fix test with correct constant
azurwastaken Sep 17, 2024
5f9a00e
*
azurwastaken Sep 17, 2024
e0a7cf5
Merge branch 'main' into feat/configurable-chain-config
azurwastaken Sep 17, 2024
02d89b4
adding docs
azurwastaken Sep 17, 2024
6a5fcff
Merge branch 'feat/configurable-chain-config' of github.com:astraly-l…
azurwastaken Sep 17, 2024
792970b
update
azurwastaken Sep 17, 2024
4235f72
u
azurwastaken Sep 17, 2024
fce1bcc
p
azurwastaken Sep 17, 2024
7ceaaa5
Merge remote-tracking branch 'upstream/main' into feat/configurable-c…
azurwastaken Sep 17, 2024
8a777ac
s
azurwastaken Sep 17, 2024
c9ba894
fmt
azurwastaken Sep 17, 2024
cc09fb3
clippy
azurwastaken Sep 17, 2024
d0cb02a
Update chain_config_overrides.rs
azurwastaken Sep 17, 2024
d3893d0
refacto + create test_utils
azurwastaken Sep 17, 2024
6a68537
Update chain_config_overrides.rs
azurwastaken Sep 17, 2024
a8d316c
fmt
azurwastaken Sep 17, 2024
b99a918
clippy
azurwastaken Sep 17, 2024
8556a1d
fix black magic with unused import
azurwastaken Sep 17, 2024
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- feat: add config file and preset configure chain
- refactor: change default chain id and add custom flag to override
- fix: generate a fixed set of public and private keys for devnet
- fix: defaulted l1 gas price in devnet mode
Expand Down
32 changes: 32 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ reqwest = { version = "0.12", features = ["json"] }
rstest = "0.18"
serde = { version = "1.0", default-features = false, features = ["std"] }
serde_json = { version = "1.0", default-features = false, features = ["std"] }
serde_yaml = { version = "0.9.34" }
thiserror = "1.0"
tokio = { version = "1.34", features = ["signal"] }
url = "2.4"
Expand Down
62 changes: 62 additions & 0 deletions config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Name of the blockchain network
chain_name: "Starknet Mainnet"

# Unique identifier for the blockchain network
chain_id: "SN_MAIN"

# Contract address of the token used to pay transaction fees on this network (STRK)
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"

# Contract address of the token used for fees on the parent chain (ETH)
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"

# Paths to JSON files containing blockifier's constants for different versions
versioned_constants:
"0.13.0": "crates/primitives/chain_config/resources/versioned_constants_13_0.json"
"0.13.1": "crates/primitives/chain_config/resources/versioned_constants_13_1.json"
"0.13.1.1": "crates/primitives/chain_config/resources/versioned_constants_13_1_1.json"
"0.13.2": "crates/primitives/chain_config/resources/versioned_constants_13_2.json"

# Address of the core contract on the L1 network that interacts with this L2 network
eth_core_contract_address: "0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"

# Most recent version supported
latest_protocol_version: "0.13.2"

# Target time interval between blocks, in seconds
block_time: 360

# How often the pending block is updated, in seconds
pending_block_update_time: 2

# Settings for the transaction bouncer
bouncer_config:
block_max_capacity:
# Limits for various built-in operations (set to max uint64 value)
builtin_count:
add_mod: 18446744073709551615
bitwise: 18446744073709551615
ecdsa: 18446744073709551615
ec_op: 18446744073709551615
keccak: 18446744073709551615
mul_mod: 18446744073709551615
pedersen: 18446744073709551615
poseidon: 18446744073709551615
range_check: 18446744073709551615
range_check96: 18446744073709551615
# Maximum gas limit per block
gas: 5000000
# Maximum number of steps per block
n_steps: 40000000
# Maximum length of message segments
message_segment_length: 18446744073709551615
# Maximum number of events per block
n_events: 18446744073709551615
# Maximum size of state differences per block
state_diff_size: 131072

# Address of the sequencer (0x0 for a full node).
sequencer_address: "0x0"

# Maximum nonce difference allowed for skipping validation of intermediate transactions
max_nonce_for_validation_skip: 2
1 change: 1 addition & 0 deletions crates/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bincode = { workspace = true }
log = { workspace = true, default-features = true }
rayon = { workspace = true }
rocksdb.workspace = true
rstest = { workspace = true }
serde = { workspace = true }
tempfile = { workspace = true, optional = true }
thiserror = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/client/db/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ use tempfile::TempDir;

pub async fn temp_db() -> DatabaseService {
let temp_dir = TempDir::new().unwrap();
let chain_config = std::sync::Arc::new(ChainConfig::test_config());
let chain_config = std::sync::Arc::new(ChainConfig::test_config().expect("failed to retrieve test chain config"));
DatabaseService::new(temp_dir.path(), None, false, chain_config).await.unwrap()
}
37 changes: 25 additions & 12 deletions crates/client/db/tests/test_block.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod common;
use common::temp_db;

use common::*;
use mc_db::db_block_id::DbBlockIdResolvable;
use mc_db::{block_db::TxIndex, db_block_id::DbBlockId};
use mp_block::BlockId;
Expand All @@ -17,17 +18,21 @@ use mp_transactions::{
DeployAccountTransactionV3, DeployTransaction, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3,
L1HandlerTransaction,
};
use mp_utils::tests_common::*;
use rstest::*;
use starknet_types_core::felt::Felt;

#[rstest]
#[tokio::test]
async fn test_chain_info() {
async fn test_chain_info(_set_workdir: ()) {
let db = temp_db().await;
let chain_config = db.backend().chain_config();
assert_eq!(chain_config.chain_id, ChainConfig::test_config().chain_id);
assert_eq!(chain_config.chain_id, ChainConfig::test_config().unwrap().chain_id);
}

#[rstest]
#[tokio::test]
async fn test_block_id() {
async fn test_block_id(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

Expand All @@ -43,16 +48,18 @@ async fn test_block_id() {
assert_eq!(backend.resolve_block_id(&DbBlockId::Pending).unwrap().unwrap(), DbBlockId::Pending);
}

#[rstest]
#[tokio::test]
async fn test_block_id_not_found() {
async fn test_block_id_not_found(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

assert!(backend.resolve_block_id(&BlockId::Hash(Felt::from(0))).unwrap().is_none());
}

#[rstest]
#[tokio::test]
async fn test_store_block() {
async fn test_store_block(_set_workdir: ()) {
const BLOCK_ID_0: DbBlockId = DbBlockId::BlockN(0);

let db = temp_db().await;
Expand All @@ -74,8 +81,9 @@ async fn test_store_block() {
assert_eq!(backend.get_block_state_diff(&BLOCK_ID_0).unwrap().unwrap(), state_diff);
}

#[rstest]
#[tokio::test]
async fn test_store_pending_block() {
async fn test_store_pending_block(_set_workdir: ()) {
const BLOCK_ID_PENDING: DbBlockId = DbBlockId::Pending;

let db = temp_db().await;
Expand All @@ -95,8 +103,9 @@ async fn test_store_pending_block() {
assert_eq!(backend.get_block_state_diff(&BLOCK_ID_PENDING).unwrap().unwrap(), state_diff);
}

#[rstest]
#[tokio::test]
async fn test_erase_pending_block() {
async fn test_erase_pending_block(_set_workdir: ()) {
const BLOCK_ID_PENDING: DbBlockId = DbBlockId::Pending;

let db = temp_db().await;
Expand Down Expand Up @@ -126,8 +135,9 @@ async fn test_erase_pending_block() {
assert_eq!(backend.get_block_state_diff(&BLOCK_ID_PENDING).unwrap().unwrap(), state_diff);
}

#[rstest]
#[tokio::test]
async fn test_store_latest_block() {
async fn test_store_latest_block(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

Expand All @@ -139,8 +149,9 @@ async fn test_store_latest_block() {
assert_eq!(backend.get_latest_block_n().unwrap().unwrap(), 1);
}

#[rstest]
#[tokio::test]
async fn test_latest_confirmed_block() {
async fn test_latest_confirmed_block(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

Expand All @@ -151,8 +162,9 @@ async fn test_latest_confirmed_block() {
assert_eq!(backend.get_l1_last_confirmed_block().unwrap().unwrap(), 0);
}

#[rstest]
#[tokio::test]
async fn test_store_block_transactions() {
async fn test_store_block_transactions(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

Expand All @@ -166,8 +178,9 @@ async fn test_store_block_transactions() {
assert_eq!(backend.find_tx_hash_block(&tx_hash_1).unwrap().unwrap(), (block, TxIndex(1)));
}

#[rstest]
#[tokio::test]
async fn test_store_block_transactions_pending() {
async fn test_store_block_transactions_pending(_set_workdir: ()) {
let db = temp_db().await;
let backend = db.backend();

Expand Down
16 changes: 11 additions & 5 deletions crates/client/db/tests/test_open.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
mod common;

use common::temp_db;
use common::*;
use mc_db::DatabaseService;
use mp_chain_config::ChainConfig;
use mp_utils::tests_common::*;
use rstest::*;

#[rstest]
#[tokio::test]
async fn test_open_db() {
async fn test_open_db(_set_workdir: ()) {
temp_db().await;
}

#[rstest]
#[tokio::test]
async fn test_open_different_chain_id() {
async fn test_open_different_chain_id(_set_workdir: ()) {
let temp_dir = tempfile::TempDir::new().unwrap();
{
let chain_config = std::sync::Arc::new(ChainConfig::starknet_integration());
let chain_config = std::sync::Arc::new(
ChainConfig::starknet_integration().expect("failed to retrieve integration chain config"),
);
let _db = DatabaseService::new(temp_dir.path(), None, false, chain_config).await.unwrap();
}
let chain_config = std::sync::Arc::new(ChainConfig::test_config());
let chain_config = std::sync::Arc::new(ChainConfig::test_config().expect("failed to retrieve test chain config"));
assert!(DatabaseService::new(temp_dir.path(), None, false, chain_config).await.is_err());
}
1 change: 1 addition & 0 deletions crates/client/devnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ mp-convert.workspace = true
mp-receipt.workspace = true
mp-state-update.workspace = true
mp-transactions.workspace = true
mp-utils.workspace = true

# Starknet
blockifier.workspace = true
Expand Down
Loading
Loading