Skip to content

Commit

Permalink
main: rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
akhercha committed Oct 8, 2024
2 parents 330658d + 66543dd commit c3b9982
Show file tree
Hide file tree
Showing 41 changed files with 320 additions and 241 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

- feat: `exex_pragma_dispatch` implementation
- feat: Madara ExExs proof of concept
- fix: override chain config
- fix: estimate_fee should through an error if any txn fails
- fix: rejected transaction block production panic
- fix(sync): pending block retrying mechanism
- feat(clean): dc_db: rename `DbBlockId::BlockN` to `DbBlockId::Number`
- feat(cli): Environment variables can be used to specify Madara parameters
- fix:(tests): Add testing feature to mc-db dev dependency (#294)
- feat: new crate gateway client & server
- test: Starknet-js basic tests added
Expand Down
19 changes: 1 addition & 18 deletions Cargo.lock

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

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,18 @@ Toggle details for each namespace to view additional settings:
### Environment Variables
Set up your node's environment variables using the `STARKNET_` prefix. For example:
Set up your node's environment variables using the `MADARA_` prefix. For example:

- `STARKNET_BASE_PATH=/path/to/data`
- `STARKNET_LOG=info`
- `MADARA_BASE_PATH=/path/to/data`
- `MADARA_RPC_PORT=1111`

These variables allow you to adjust the node's configuration without using command-line arguments.
These variables allow you to adjust the node's configuration without using command-line arguments. If the command-line
argument is specified then it takes precedent over the environment variable.
> [!CAUTION]
> Environment variables can be visible beyond the current process and are not
> encrypted. You should take special care when setting _secrets_ through
> environment variables, such as `MADARA_L1_ENDPOINT` or `MADARA_GATEWAY_KEY`
### Configuration File
Expand Down
2 changes: 1 addition & 1 deletion configs/chain_config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"

# Paths to JSON files containing blockifier's constants for different versions
versioned_constants:
versioned_constants_path:
"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"
Expand Down
5 changes: 0 additions & 5 deletions configs/presets/devnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ chain_name: "Madara"
chain_id: "MADARA_DEVNET"
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
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"
eth_core_contract_address: "0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057"
latest_protocol_version: "0.13.2"
block_time: "1s"
Expand Down
7 changes: 1 addition & 6 deletions configs/presets/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ chain_name: "Starknet Sepolia"
chain_id: "SN_INTEGRATION_SEPOLIA"
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
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"
eth_core_contract_address: "0x4737c0c1B4D5b1A687B42610DdabEE781152359c"
latest_protocol_version: "0.13.2"
block_time: "30s"
Expand All @@ -30,5 +25,5 @@ bouncer_config:
message_segment_length: 18446744073709551615
n_events: 18446744073709551615
state_diff_size: 131072
sequencer_address: "0x0"
sequencer_address: "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"
max_nonce_for_validation_skip: 2
7 changes: 1 addition & 6 deletions configs/presets/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ chain_name: "Starknet Mainnet"
chain_id: "SN_MAIN"
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
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"
eth_core_contract_address: "0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4"
latest_protocol_version: "0.13.2"
block_time: "30s"
Expand All @@ -30,5 +25,5 @@ bouncer_config:
message_segment_length: 18446744073709551615
n_events: 18446744073709551615
state_diff_size: 131072
sequencer_address: "0x0"
sequencer_address: "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"
max_nonce_for_validation_skip: 2
7 changes: 1 addition & 6 deletions configs/presets/sepolia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ chain_name: "Starknet Sepolia"
chain_id: "SN_SEPOLIA"
native_fee_token_address: "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
parent_fee_token_address: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
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"
eth_core_contract_address: "0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057"
latest_protocol_version: "0.13.2"
block_time: "30s"
Expand All @@ -30,5 +25,5 @@ bouncer_config:
message_segment_length: 18446744073709551615
n_events: 18446744073709551615
state_diff_size: 131072
sequencer_address: "0x0"
sequencer_address: "0x1176a1bd84444c89232ec27754698e5d2e7e1a7f1539f12027f28b23ec9f3d8"
max_nonce_for_validation_skip: 2
1 change: 0 additions & 1 deletion crates/client/block_import/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ mp-convert.workspace = true
mp-receipt.workspace = true
mp-state-update.workspace = true
mp-transactions.workspace = true
mp-utils.workspace = true

bonsai-trie.workspace = true
starknet-core.workspace = true
Expand Down
1 change: 0 additions & 1 deletion crates/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ 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
16 changes: 8 additions & 8 deletions crates/client/db/src/block_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,17 @@ impl MadaraBackend {

pub(crate) fn id_to_storage_type(&self, id: &BlockId) -> Result<Option<DbBlockId>> {
match id {
BlockId::Hash(hash) => Ok(self.block_hash_to_block_n(hash)?.map(DbBlockId::BlockN)),
BlockId::Number(block_n) => Ok(Some(DbBlockId::BlockN(*block_n))),
BlockId::Tag(BlockTag::Latest) => Ok(self.get_latest_block_n()?.map(DbBlockId::BlockN)),
BlockId::Hash(hash) => Ok(self.block_hash_to_block_n(hash)?.map(DbBlockId::Number)),
BlockId::Number(block_n) => Ok(Some(DbBlockId::Number(*block_n))),
BlockId::Tag(BlockTag::Latest) => Ok(self.get_latest_block_n()?.map(DbBlockId::Number)),
BlockId::Tag(BlockTag::Pending) => Ok(Some(DbBlockId::Pending)),
}
}

fn storage_to_info(&self, id: &DbBlockId) -> Result<Option<MadaraMaybePendingBlockInfo>> {
match id {
DbBlockId::Pending => Ok(Some(MadaraMaybePendingBlockInfo::Pending(self.get_pending_block_info()?))),
DbBlockId::BlockN(block_n) => {
DbBlockId::Number(block_n) => {
Ok(self.get_block_info_from_block_n(*block_n)?.map(MadaraMaybePendingBlockInfo::NotPending))
}
}
Expand All @@ -283,7 +283,7 @@ impl MadaraBackend {
fn storage_to_inner(&self, id: &DbBlockId) -> Result<Option<MadaraBlockInner>> {
match id {
DbBlockId::Pending => Ok(Some(self.get_pending_block_inner()?)),
DbBlockId::BlockN(block_n) => self.get_block_inner_from_block_n(*block_n),
DbBlockId::Number(block_n) => self.get_block_inner_from_block_n(*block_n),
}
}

Expand All @@ -292,7 +292,7 @@ impl MadaraBackend {
pub fn get_block_n(&self, id: &impl DbBlockIdResolvable) -> Result<Option<u64>> {
let Some(ty) = id.resolve_db_block_id(self)? else { return Ok(None) };
match &ty {
DbBlockId::BlockN(block_id) => Ok(Some(*block_id)),
DbBlockId::Number(block_id) => Ok(Some(*block_id)),
DbBlockId::Pending => Ok(None),
}
}
Expand All @@ -301,7 +301,7 @@ impl MadaraBackend {
let Some(ty) = id.resolve_db_block_id(self)? else { return Ok(None) };
match &ty {
// TODO: fast path if id is already a block hash..
DbBlockId::BlockN(block_n) => Ok(self.get_block_info_from_block_n(*block_n)?.map(|b| b.block_hash)),
DbBlockId::Number(block_n) => Ok(self.get_block_info_from_block_n(*block_n)?.map(|b| b.block_hash)),
DbBlockId::Pending => Ok(None),
}
}
Expand All @@ -310,7 +310,7 @@ impl MadaraBackend {
let Some(ty) = id.resolve_db_block_id(self)? else { return Ok(None) };
match ty {
DbBlockId::Pending => Ok(Some(self.get_pending_block_state_update()?)),
DbBlockId::BlockN(block_n) => self.get_state_update(block_n),
DbBlockId::Number(block_n) => self.get_state_update(block_n),
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/client/db/src/class_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl MadaraBackend {

let valid = match (requested_id, info.block_id) {
(DbBlockId::Pending, _) => true,
(DbBlockId::BlockN(block_n), DbBlockId::BlockN(real_block_n)) => real_block_n <= block_n,
(DbBlockId::Number(block_n), DbBlockId::Number(real_block_n)) => real_block_n <= block_n,
_ => false,
};
if !valid {
Expand Down Expand Up @@ -174,7 +174,7 @@ impl MadaraBackend {
block_number: u64,
converted_classes: &[ConvertedClass],
) -> Result<(), MadaraStorageError> {
self.store_classes(DbBlockId::BlockN(block_number), converted_classes, Column::ClassInfo, Column::ClassCompiled)
self.store_classes(DbBlockId::Number(block_number), converted_classes, Column::ClassInfo, Column::ClassCompiled)
}

/// NB: This functions needs to run on the rayon thread pool
Expand Down
2 changes: 1 addition & 1 deletion crates/client/db/src/contract_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl MadaraBackend {
let Some(block_n) = self.get_latest_block_n()? else { return Ok(None) };
block_n
}
DbBlockId::BlockN(block_n) => block_n,
DbBlockId::Number(block_n) => block_n,
};

// We try to find history values.
Expand Down
6 changes: 3 additions & 3 deletions crates/client/db/src/db_block_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{MadaraBackend, MadaraStorageError};
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum DbBlockId {
Pending,
BlockN(u64),
Number(u64),
}

impl DbBlockId {
Expand Down Expand Up @@ -42,7 +42,7 @@ impl fmt::Display for DbBlockId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Pending => write!(f, "#<pending>"),
Self::BlockN(block_n) => write!(f, "#{block_n}"),
Self::Number(block_n) => write!(f, "#{block_n}"),
}
}
}
Expand All @@ -60,6 +60,6 @@ mod test {
#[test]
fn test_db_block_id() {
assert!(DbBlockId::Pending.is_pending());
assert!(!DbBlockId::BlockN(0).is_pending());
assert!(!DbBlockId::Number(0).is_pending());
}
}
6 changes: 3 additions & 3 deletions crates/client/db/src/tests/test_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ mod block_tests {
backend.store_block(block.clone(), state_diff.clone(), vec![]).unwrap();
backend.store_block(pending_block_one(), pending_state_diff_one(), vec![]).unwrap();

assert_eq!(backend.resolve_block_id(&BlockId::Hash(block_hash)).unwrap().unwrap(), DbBlockId::BlockN(0));
assert_eq!(backend.resolve_block_id(&BlockId::Number(0)).unwrap().unwrap(), DbBlockId::BlockN(0));
assert_eq!(backend.resolve_block_id(&BlockId::Hash(block_hash)).unwrap().unwrap(), DbBlockId::Number(0));
assert_eq!(backend.resolve_block_id(&BlockId::Number(0)).unwrap().unwrap(), DbBlockId::Number(0));
assert_eq!(backend.resolve_block_id(&DbBlockId::Pending).unwrap().unwrap(), DbBlockId::Pending);
}

Expand All @@ -43,7 +43,7 @@ mod block_tests {

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

let db = temp_db().await;
let backend = db.backend();
Expand Down
1 change: 0 additions & 1 deletion crates/client/devnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ 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

0 comments on commit c3b9982

Please sign in to comment.