Skip to content

Commit a43fbe9

Browse files
muXxerjkrvivian
andcommitted
feat(simulacrum): add simulacrum server (#9737)
# Description of change This PR add a simulacrum binary, that hosts a gRPC interface to interact with the fullnode API, and a REST API to control the simulacrum. This is useful to run simulacrum in the CI in non-rust projects. ## Links to any relevant issues fixes #7844 ## How the change has been tested - [x] Basic tests (linting, compilation, formatting, unit/integration tests) - [ ] Patch-specific tests (correctness, functionality coverage) - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have checked that new and existing unit tests pass locally with my changes ### Release Notes - [ ] Protocol: - [x] Nodes (Validators and Full nodes): Add simulacrum-server binary to simulate an IOTA blockchain - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --------- Co-authored-by: jkrvivian <jkrvivian@gmail.com>
1 parent 8c6df05 commit a43fbe9

File tree

34 files changed

+2297
-460
lines changed

34 files changed

+2297
-460
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
/crates/iota-upgrade-compatibility-transactional-tests/ @iotaledger/vm-language
9393
/crates/iota-verifier-transactional-tests/ @iotaledger/vm-language
9494
/crates/prometheus-closure-metric/ @iotaledger/node
95-
/crates/simulacrum/ @iotaledger/vm-language
95+
/crates/simulacrum/ @iotaledger/node @iotaledger/vm-language
96+
/crates/simulacrum-server/ @iotaledger/node
9697
/crates/starfish/ @iotaledger/consensus
9798
/crates/telemetry-subscribers/ @iotaledger/core-protocol
9899
/crates/transaction-fuzzer/ @iotaledger/node @iotaledger/vm-language

.github/crates-filters.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ prometheus-closure-metric:
188188
- "crates/prometheus-closure-metric/**"
189189
simulacrum:
190190
- "crates/simulacrum/**"
191+
simulacrum-server:
192+
- "crates/simulacrum-server/**"
191193
telemetry-subscribers:
192194
- "crates/telemetry-subscribers/**"
193195
test-cluster:

Cargo.lock

Lines changed: 45 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ members = [
160160
"crates/iota-verifier-transactional-tests",
161161
"crates/prometheus-closure-metric",
162162
"crates/simulacrum",
163+
"crates/simulacrum-server",
163164
"crates/starfish/config",
164165
"crates/starfish/core",
165166
"crates/starfish/simtests",
@@ -321,13 +322,15 @@ parking_lot = { version = "0.12.3", features = ["arc_lock"] }
321322
passkey-authenticator = "0.4.0"
322323
passkey-client = "0.4.0"
323324
passkey-types = "0.4.0"
325+
petgraph = { version = ">=0.6, <=0.7", default-features = false }
324326
pin-project-lite = "0.2.15"
325327
pretty_assertions = "1.3.0"
326328
proc-macro2 = "1.0.95"
327329
prometheus = "0.14.0"
328330
proptest = "1.6.0"
329331
proptest-derive = "0.5.1"
330332
prost = "0.14"
333+
prost-types = "0.14"
331334
quinn-proto = "0.11.7"
332335
quote = "1.0.23"
333336
rand = "0.8.5"
@@ -371,7 +374,6 @@ tonic = { version = "0.14", features = ["zstd", "transport"] }
371374
tonic-build = "0.14"
372375
tonic-health = "0.14"
373376
tonic-prost = "0.14"
374-
tonic-prost-build = "0.14"
375377
tonic-rustls = "0.3.0"
376378
tower = { version = "0.4.12", features = ["util", "timeout", "load-shed", "limit"] }
377379
tower-http = { version = "0.5", features = ["cors", "timeout", "trace", "set-header", "propagate-header"] }
@@ -498,6 +500,7 @@ move-vm-profiler = { path = "external-crates/move/crates/move-vm-profiler" }
498500
move-vm-test-utils = { path = "external-crates/move/crates/move-vm-test-utils/", features = ["tiered-gas"] }
499501
prometheus-closure-metric = { path = "crates/prometheus-closure-metric" }
500502
simulacrum = { path = "crates/simulacrum" }
503+
simulacrum-server = { path = "crates/simulacrum-server" }
501504
starfish-config = { path = "crates/starfish/config" }
502505
starfish-core = { path = "crates/starfish/core" }
503506
starfish-simtests = { path = "crates/starfish/simtests" }

crates/iota-analytics-indexer/src/handlers/transaction_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ mod tests {
212212

213213
#[tokio::test]
214214
pub async fn test_transaction_handler() -> anyhow::Result<()> {
215-
let mut sim = Simulacrum::new();
215+
let sim = Simulacrum::new();
216216

217217
// Execute a simple transaction.
218218
let transfer_recipient = IotaAddress::random_for_testing_only();

crates/iota-graphql-rpc/tests/e2e_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ mod tests {
8282
async fn prep_executor_cluster() -> (ConnectionConfig, ExecutorCluster) {
8383
let rng = StdRng::from_seed([12; 32]);
8484
let data_ingestion_path = tempdir().unwrap().keep();
85-
let mut sim = Simulacrum::new_with_rng(rng);
85+
let sim = Simulacrum::new_with_rng(rng);
8686
sim.set_data_ingestion_path(data_ingestion_path.clone());
8787

8888
sim.create_checkpoint();
@@ -152,17 +152,15 @@ mod tests {
152152
#[serial]
153153
async fn test_simple_client_simulator_cluster() {
154154
let rng = StdRng::from_seed([12; 32]);
155-
let mut sim = Simulacrum::new_with_rng(rng);
155+
let sim = Simulacrum::new_with_rng(rng);
156156
let data_ingestion_path = tempdir().unwrap().keep();
157157
sim.set_data_ingestion_path(data_ingestion_path.clone());
158158

159159
sim.create_checkpoint();
160160
sim.create_checkpoint();
161161

162162
let genesis_checkpoint_digest1 = *sim
163-
.store()
164-
.get_checkpoint_by_sequence_number(0)
165-
.unwrap()
163+
.with_store(|store| store.get_checkpoint_by_sequence_number(0).cloned().unwrap())
166164
.digest();
167165

168166
let chain_id_actual = format!("{}", ChainIdentifier::from(genesis_checkpoint_digest1));

crates/iota-graphql-rpc/tests/examples_validation_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod tests {
144144
async fn good_examples_within_limits() {
145145
let rng = StdRng::from_seed([12; 32]);
146146
let data_ingestion_path = tempdir().unwrap().keep();
147-
let mut sim = Simulacrum::new_with_rng(rng);
147+
let sim = Simulacrum::new_with_rng(rng);
148148
let (mut max_nodes, mut max_output_nodes, mut max_depth, mut max_payload) = (0, 0, 0, 0);
149149

150150
sim.set_data_ingestion_path(data_ingestion_path.clone());
@@ -211,7 +211,7 @@ mod tests {
211211
async fn bad_examples_fail() {
212212
let rng = StdRng::from_seed([12; 32]);
213213
let data_ingestion_path = tempdir().unwrap().keep();
214-
let mut sim = Simulacrum::new_with_rng(rng);
214+
let sim = Simulacrum::new_with_rng(rng);
215215
let (mut max_nodes, mut max_output_nodes, mut max_depth, mut max_payload) = (0, 0, 0, 0);
216216
sim.set_data_ingestion_path(data_ingestion_path.clone());
217217

crates/iota-grpc-server/src/transaction_execution_service/simulate.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,9 @@ pub fn estimate_gas_budget_from_gas_cost(
302302
// Round up to the nearest gas rounding step (in gas units)
303303
let rounded_gas_loading_cost_units =
304304
if let Some(step) = protocol_config.gas_rounding_step_as_option() {
305-
match gas_loading_cost_units.checked_next_multiple_of(step) {
306-
Some(rounded) => rounded,
307-
None => u64::MAX,
308-
}
305+
gas_loading_cost_units
306+
.checked_next_multiple_of(step)
307+
.unwrap_or(u64::MAX)
309308
} else {
310309
gas_loading_cost_units
311310
};

crates/iota-indexer/tests/ingestion_tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod ingestion_tests {
5656
#[tokio::test]
5757
pub async fn checkpoint_objects_ingestion() -> Result<(), IndexerError> {
5858
let tempdir = tempdir().unwrap();
59-
let mut sim = Simulacrum::new();
59+
let sim = Simulacrum::new();
6060
let data_ingestion_path = tempdir.path().to_path_buf();
6161
sim.set_data_ingestion_path(data_ingestion_path.clone());
6262

@@ -80,7 +80,7 @@ mod ingestion_tests {
8080

8181
#[tokio::test]
8282
pub async fn transaction_table() -> Result<(), IndexerError> {
83-
let mut sim = Simulacrum::new();
83+
let sim = Simulacrum::new();
8484
let data_ingestion_path = tempdir().unwrap().keep();
8585
sim.set_data_ingestion_path(data_ingestion_path.clone());
8686

@@ -131,7 +131,7 @@ mod ingestion_tests {
131131

132132
#[tokio::test]
133133
pub async fn object_type() -> Result<(), IndexerError> {
134-
let mut sim = Simulacrum::new();
134+
let sim = Simulacrum::new();
135135
let data_ingestion_path = tempdir().unwrap().keep();
136136
sim.set_data_ingestion_path(data_ingestion_path.clone());
137137

@@ -184,7 +184,7 @@ mod ingestion_tests {
184184
#[tokio::test]
185185
pub async fn objects_snapshot() -> Result<(), IndexerError> {
186186
let tempdir = tempdir().unwrap();
187-
let mut sim = Simulacrum::new();
187+
let sim = Simulacrum::new();
188188
let data_ingestion_path = tempdir.path().to_path_buf();
189189
sim.set_data_ingestion_path(data_ingestion_path.clone());
190190

@@ -260,7 +260,7 @@ mod ingestion_tests {
260260

261261
#[tokio::test]
262262
pub async fn tx_global_order_table() -> Result<(), IndexerError> {
263-
let mut sim = Simulacrum::new();
263+
let sim = Simulacrum::new();
264264
let data_ingestion_path = tempdir().unwrap().keep();
265265
sim.set_data_ingestion_path(data_ingestion_path.clone());
266266

@@ -316,7 +316,7 @@ mod ingestion_tests {
316316

317317
#[tokio::test]
318318
pub async fn tx_global_order_table_on_conflict_do_nothing() -> Result<(), IndexerError> {
319-
let mut sim = Simulacrum::new();
319+
let sim = Simulacrum::new();
320320
let data_ingestion_path = tempdir().unwrap().keep();
321321
sim.set_data_ingestion_path(data_ingestion_path.clone());
322322

@@ -390,7 +390,7 @@ mod ingestion_tests {
390390
#[tokio::test]
391391
pub async fn test_insert_large_batch_tx_indices() -> Result<(), IndexerError> {
392392
let tempdir = tempdir().unwrap();
393-
let mut sim = Simulacrum::new();
393+
let sim = Simulacrum::new();
394394
let data_ingestion_path = tempdir.path().to_path_buf();
395395
sim.set_data_ingestion_path(data_ingestion_path.clone());
396396

@@ -427,7 +427,7 @@ mod ingestion_tests {
427427
#[tokio::test]
428428
pub async fn test_insert_large_batch_event_indices() -> Result<(), IndexerError> {
429429
let tempdir = tempdir().unwrap();
430-
let mut sim = Simulacrum::new();
430+
let sim = Simulacrum::new();
431431
let data_ingestion_path = tempdir.path().to_path_buf();
432432
sim.set_data_ingestion_path(data_ingestion_path.clone());
433433

@@ -457,7 +457,7 @@ mod ingestion_tests {
457457
#[tokio::test]
458458
pub async fn test_epoch_boundary() -> Result<(), IndexerError> {
459459
let tempdir = tempdir().unwrap();
460-
let mut sim = Simulacrum::new();
460+
let sim = Simulacrum::new();
461461
let data_ingestion_path = tempdir.path().to_path_buf();
462462
sim.set_data_ingestion_path(data_ingestion_path.clone());
463463

0 commit comments

Comments
 (0)