Skip to content

Commit

Permalink
feat: irys token prices data added to the config (#236)
Browse files Browse the repository at this point in the history
* feat: add genesis token price information to the irys config
* feat: config restructuring
* chore: renamed `irys_chain_id` to `chain_id` in the config structs
* feat: if no config is provided, default to testnet config

---------

Co-authored-by: Ernius <[email protected]>
  • Loading branch information
roberts-pumpurs and ernius authored Feb 27, 2025
1 parent 5d699b9 commit 1077e3e
Show file tree
Hide file tree
Showing 52 changed files with 989 additions and 1,308 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,4 @@
"cwd": "${workspaceFolder}"
}
]
}
}
10 changes: 6 additions & 4 deletions Cargo.lock

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

50 changes: 18 additions & 32 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ license = "MIT/Apache-2.0"
repository = "https://github.com/Irys-xyz/irys"
authors = []


[workspace.dependencies]
# Irys
irys-macros = { path = "./crates/macros" }
Expand Down Expand Up @@ -56,45 +55,37 @@ alloy-consensus = { path = "./ext/alloy/crates/consensus", default-features = fa
alloy-core = { path = "./ext/alloy-core/crates/core" }
alloy-eips = { path = "./ext/alloy/crates/eips", default-features = false }
alloy-genesis = { path = "./ext/alloy/crates/genesis", default-features = false }
alloy-primitives = { path = "./ext/alloy-core/crates/primitives", features = [
"arbitrary",
] }
alloy-primitives = { path = "./ext/alloy-core/crates/primitives", features = ["arbitrary"] }
rand = "0.8.5"
hex = "0.4"
base64-url = "2.0.0"
alloy-rlp = "0.3.4"
alloy-rpc-types = { path = "./ext/alloy/crates/rpc-types" }
alloy-rpc-types-engine = { path = "./ext/alloy/crates/rpc-types-engine", features = [
"serde",
] }
alloy-rpc-types-engine = { path = "./ext/alloy/crates/rpc-types-engine", features = ["serde"] }

alloy-rpc-types-trace = { path = "./ext/alloy/crates/rpc-types-trace" }
reth-e2e-test-utils = { path = "./ext/reth/crates/e2e-test-utils" }
alloy-serde = { path = "./ext/alloy/crates/serde", default-features = false }
alloy-signer-local = { path = "./ext/alloy/crates/signer-local" }
alloy-sol-macro = { path = "./ext/alloy-core/crates/sol-macro", features = [
"json",
] }
alloy-sol-macro = { path = "./ext/alloy-core/crates/sol-macro", features = ["json"] }
alloy-sol-types = { path = "./ext/alloy-core/crates/sol-types" }
alloy-contract = { path = "./ext/alloy/crates/contract" }
alloy-provider = { path = "./ext/alloy/crates/provider", features = [
"trace-api",
] }
alloy-provider = { path = "./ext/alloy/crates/provider", features = ["trace-api"] }

arbitrary = { version = "1.3", features = ["derive"] }
once_cell = "1.19.0"
assert_matches = "1.5.0"
once_cell = "1"
assert_matches = "1"
bytes = "1.5"
derive_more = { version = "1", features = ["full"] }
eyre = "0.6"
color-eyre = "0.6.2"
itertools = "0.13.0"
color-eyre = "0.6"
itertools = "0.13"
futures = "0.3"
bytemuck = "1"

nodit = { version = "0.9.2", features = ["serde"] }
modular-bitfield = "0.11.2"
openssl = { version = "0.10.57", features = ["vendored"] }
nodit = { version = "0.9", features = ["serde"] }
modular-bitfield = "0.11"
openssl = { version = "0.10", features = ["vendored"] }
proptest-derive = "0.5"
reth = { path = "./ext/reth/bin/reth" }
reth-auto-seal-consensus = { path = "./ext/reth/crates/consensus/auto-seal" }
Expand Down Expand Up @@ -154,27 +145,23 @@ serde = { version = "1", default-features = false }
reth-rpc-layer = { path = "./ext/reth/crates/rpc/rpc-layer" }
serde_json = "1"
test-fuzz = "6"
thiserror = "1.0"
tokio = { version = "1.40.0", features = ["rt", "macros"] }
thiserror = "1"
tokio = { version = "1", features = ["rt", "macros"] }
toml = "0.8"
derive-syn-parse = "0"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
tracing = "0.1.0"
tracing-subscriber = { version = "0.3", default-features = false, features = [
"env-filter",
"fmt",
"json",
"ansi",
] }
tracing-error = "0.2"
tracing-subscriber = { version = "0.3", default-features = false, features = ["env-filter", "fmt", "json", "ansi"] }
alloy-signer = { path = "./ext/alloy/crates/signer" }
tempfile = "3.10"
tempfile = "3"
jsonrpsee = "0.24"
jsonrpsee-core = "0.24"
jsonrpsee-http-client = "0.24"
jsonrpsee-types = "0.24"
futures-util = "0.3.30"
futures-util = "0.3"

[patch.crates-io]
revm = { path = "./ext/revm/crates/revm" }
Expand Down Expand Up @@ -359,11 +346,10 @@ too_long_first_doc_paragraph = "allow"
[workspace.metadata.cargo-machete]
ignored = ["modular-bitfield", "test-fuzz"]


# https://github.com/crate-ci/typos/blob/master/docs/reference.md
[workspace.metadata.typos]
default.extend-ignore-re = [
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", # disable a single line: spellchecker:disable-line
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$", # disable a single line: spellchecker:disable-line
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on", # disable blocks of lines: spellchecker:<on|off>
]
files.extend-exclude = ["ext/*", "fixtures/*"]
5 changes: 5 additions & 0 deletions crates/actors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ irys-testing-utils.workspace = true
base58.workspace = true
futures.workspace = true

[dev-dependencies]
irys-types = { workspace = true, features = ["test-utils"] }
irys-config = { workspace = true, features = ["test-utils"] }

[lints]
workspace = true

[features]
nvidia = ["irys-packing/nvidia"]
test-utils = ["irys-types/test-utils", "irys-config/test-utils"]
60 changes: 28 additions & 32 deletions crates/actors/src/block_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ pub fn poa_is_valid(
config.entropy_packing_iterations,
config.chunk_size as usize,
&mut entropy_chunk,
config.chain_id,
);

let mut poa_chunk: Vec<u8> = poa.chunk.clone().into();
Expand Down Expand Up @@ -358,6 +359,7 @@ pub fn poa_is_valid(
config.entropy_packing_iterations,
config.chunk_size as usize,
&mut entropy_chunk,
config.chain_id,
);

if entropy_chunk != poa.chunk.0 {
Expand All @@ -375,9 +377,6 @@ pub fn poa_is_valid(
Ok(())
}

//==============================================================================
// Tests
//------------------------------------------------------------------------------
#[cfg(test)]
mod tests {
use crate::{
Expand All @@ -394,7 +393,7 @@ mod tests {
use irys_database::{BlockIndex, Initialized};
use irys_testing_utils::utils::temporary_directory;
use irys_types::{
irys::IrysSigner, partition::PartitionAssignment, Address, Base64, H256List,
irys::IrysSigner, partition::PartitionAssignment, Address, Base64, Config, H256List,
IrysTransaction, IrysTransactionHeader, Signature, TransactionLedger, H256, U256,
};
use std::sync::{Arc, RwLock};
Expand All @@ -412,6 +411,7 @@ mod tests {
pub miner_address: Address,
pub partition_hash: H256,
pub partition_assignment: PartitionAssignment,
pub testnet_config: Config,
}

async fn init() -> (TempDir, TestContext) {
Expand All @@ -424,31 +424,29 @@ mod tests {
.try_init();

let mut genesis_block = IrysBlockHeader::new_mock_header();
let data_dir = temporary_directory(Some("block_validation_tests"), false);
genesis_block.height = 0;
let arc_genesis = Arc::new(genesis_block);

let miner_address = Address::random();
let chunk_size = 32;

// Create epoch service with random miner address
let storage_config = StorageConfig {
let testnet_config = Config {
chunk_size,
num_chunks_in_partition: 10,
num_chunks_in_recall_range: 2,
num_partitions_in_slot: 1,
miner_address,
min_writes_before_sync: 1,
num_partitions_per_slot: 1,
num_writes_before_sync: 1,
entropy_packing_iterations: 1_000,
chunk_migration_depth: 1, // Testnet / single node config
chunk_migration_depth: 1,
..Config::testnet()
};

let config = EpochServiceConfig {
storage_config: storage_config.clone(),
..Default::default()
};
let data_dir = temporary_directory(Some("block_validation_tests"), false);
let arc_genesis = Arc::new(genesis_block);
let signer = testnet_config.irys_signer();
let miner_address = signer.address();

// Create epoch service with random miner address
let storage_config = StorageConfig::new(&testnet_config);
let epoch_config = EpochServiceConfig::new(&testnet_config);

let epoch_service = EpochServiceActor::new(Some(config.clone()));
let epoch_service = EpochServiceActor::new(epoch_config.clone(), &testnet_config);
let epoch_service_addr = epoch_service.start();

// Tell the epoch service to initialize the ledgers
Expand All @@ -473,11 +471,9 @@ mod tests {
let sub_slots = ledgers.get_slots(Ledger::Submit);

let partition_hash = sub_slots[0].partitions[0];

let arc_config = Arc::new(IrysNodeConfig {
base_directory: data_dir.path().to_path_buf(),
..Default::default()
});
let mut config = IrysNodeConfig::new(&testnet_config);
config.base_directory = data_dir.path().to_path_buf();
let arc_config = Arc::new(config);

let block_index: Arc<RwLock<BlockIndex<Initialized>>> = Arc::new(RwLock::new(
BlockIndex::default()
Expand Down Expand Up @@ -519,13 +515,13 @@ mod tests {
miner_address,
partition_hash,
partition_assignment,
testnet_config,
},
)
}

#[actix::test]
async fn poa_test_3_complete_txs() {
let chunk_size: usize = 32;
let (_tmp, context) = init().await;
// Create a bunch of TX chunks
let data_chunks = vec![
Expand All @@ -536,7 +532,7 @@ mod tests {

// Create a bunch of signed TX from the chunks
// Loop though all the data_chunks and create wrapper tx for them
let signer = IrysSigner::random_signer_with_chunk_size(chunk_size);
let signer = IrysSigner::random_signer(&context.testnet_config);
let mut txs: Vec<IrysTransaction> = Vec::new();

for chunks in &data_chunks {
Expand All @@ -559,7 +555,7 @@ mod tests {
poa_tx_num,
poa_chunk_num,
9,
chunk_size,
context.testnet_config.chunk_size as usize,
)
.await;
}
Expand All @@ -569,10 +565,9 @@ mod tests {
#[actix::test]
async fn poa_not_complete_last_chunk_test() {
let (_tmp, context) = init().await;
let chunk_size: usize = 32;

// Create a signed TX from the chunks
let signer = IrysSigner::random_signer_with_chunk_size(chunk_size);
let signer = IrysSigner::random_signer(&context.testnet_config);
let mut txs: Vec<IrysTransaction> = Vec::new();

let data = vec![3; 40]; //32 + 8 last incomplete chunk
Expand All @@ -581,9 +576,9 @@ mod tests {
txs.push(tx);

let poa_tx_num = 0;

let chunk_size = context.testnet_config.chunk_size as usize;
for poa_chunk_num in 0..2 {
let mut poa_chunk: Vec<u8> = data[poa_chunk_num * chunk_size
let mut poa_chunk: Vec<u8> = data[poa_chunk_num * (chunk_size)
..std::cmp::min((poa_chunk_num + 1) * chunk_size, data.len())]
.to_vec();
poa_test(
Expand Down Expand Up @@ -622,6 +617,7 @@ mod tests {
context.storage_config.entropy_packing_iterations,
chunk_size,
&mut entropy_chunk,
context.storage_config.chain_id,
);

xor_vec_u8_arrays_in_place(poa_chunk, &entropy_chunk);
Expand Down
Loading

0 comments on commit 1077e3e

Please sign in to comment.