From 19d20a8ef77366cbbe9e0b9510591fb550e1fda6 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Tue, 18 Jun 2024 13:56:50 +0200 Subject: [PATCH 01/32] Asc message execution - requery message bytecode after each message execution (#4710) * Requery bytecode * cargo fmt --- massa-execution-worker/src/context.rs | 12 ++++++------ massa-execution-worker/src/execution.rs | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index a58576577b9..e77060c5394 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -364,12 +364,12 @@ impl ExecutionContext { &mut self, max_gas: u64, async_msg_cst_gas_cost: u64, - ) -> Vec<(Option, AsyncMessage)> { - self.speculative_async_pool - .take_batch_to_execute(self.slot, max_gas, async_msg_cst_gas_cost) - .into_iter() - .map(|(_id, msg)| (self.get_bytecode(&msg.destination), msg)) - .collect() + ) -> Vec<(AsyncMessageId, AsyncMessage)> { + self.speculative_async_pool.take_batch_to_execute( + self.slot, + max_gas, + async_msg_cst_gas_cost, + ) } /// Create a new `ExecutionContext` for executing an active slot. diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index 297538ff8e9..fcc1ccb5a07 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1271,7 +1271,9 @@ impl ExecutionState { // Try executing asynchronous messages. // Effects are cancelled on failure and the sender is reimbursed. - for (opt_bytecode, message) in messages { + for (_message_id, message) in messages { + let opt_bytecode = context_guard!(self).get_bytecode(&message.destination); + match self.execute_async_message(message, opt_bytecode) { Ok(_message_return) => { cfg_if::cfg_if! { From dadb75219458cc708843dedc84a2006ded3f55ff Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 21 Jun 2024 08:53:57 +0200 Subject: [PATCH 02/32] fix call stack inconsistency (#4709) --- massa-execution-worker/src/execution.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index fcc1ccb5a07..7cae632a4f9 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1123,7 +1123,7 @@ impl ExecutionState { context.stack = vec![ ExecutionStackElement { address: message.sender, - coins: message.coins, + coins: Default::default(), owned_addresses: vec![message.sender], operation_datastore: None, }, From a6b46f033b3707574e9fbeaf8ce4a7ea895ba910 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Tue, 25 Jun 2024 08:07:36 +0200 Subject: [PATCH 03/32] Improve async message checks (#4706) * Improve async message checks * Change checks for async messages * Add unit tests --- massa-execution-worker/src/execution.rs | 13 +- massa-execution-worker/src/interface_impl.rs | 14 + .../src/tests/scenarios_mandatories.rs | 267 ++++++++++++++++++ .../src/tests/wasm/send_message_expired.wasm | Bin 0 -> 2947 bytes .../tests/wasm/send_message_expired_2.wasm | Bin 0 -> 2949 bytes 5 files changed, 292 insertions(+), 2 deletions(-) create mode 100644 massa-execution-worker/src/tests/wasm/send_message_expired.wasm create mode 100644 massa-execution-worker/src/tests/wasm/send_message_expired_2.wasm diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index 7cae632a4f9..e6c1bc98700 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1175,10 +1175,19 @@ impl ExecutionState { // load and execute the compiled module // IMPORTANT: do not keep a lock here as `run_function` uses the `get_module` interface - let module = self + let Ok(module) = self .module_cache .write() - .load_module(&bytecode, message.max_gas)?; + .load_module(&bytecode, message.max_gas) + else { + let err = + ExecutionError::RuntimeError("could not load module for async execution".into()); + let mut context = context_guard!(self); + context.reset_to_snapshot(context_snapshot, err.clone()); + context.cancel_async_message(&message); + return Err(err); + }; + let response = massa_sc_runtime::run_function( &*self.execution_interface, module, diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index 4dd2f716310..fb33689fecf 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -1183,6 +1183,11 @@ impl Interface for InterfaceImpl { if validity_end.1 >= self.config.thread_count { bail!("validity end thread exceeds the configuration thread count") } + + if max_gas < self.config.gas_costs.max_instance_cost { + bail!("max gas is lower than the minimum instance cost") + } + let target_addr = Address::from_str(target_address)?; // check that the target address is an SC address @@ -1200,6 +1205,15 @@ impl Interface for InterfaceImpl { let mut execution_context = context_guard!(self); let emission_slot = execution_context.slot; + + if Slot::new(validity_end.0, validity_end.1) < Slot::new(validity_start.0, validity_start.1) + { + bail!("validity end is earlier than the validity start") + } + if Slot::new(validity_end.0, validity_end.1) < emission_slot { + bail!("validity end is earlier than the current slot") + } + let emission_index = execution_context.created_message_index; let sender = execution_context.get_current_address()?; let coins = Amount::from_raw(raw_coins); diff --git a/massa-execution-worker/src/tests/scenarios_mandatories.rs b/massa-execution-worker/src/tests/scenarios_mandatories.rs index b80355791cd..154ea28d3cb 100644 --- a/massa-execution-worker/src/tests/scenarios_mandatories.rs +++ b/massa-execution-worker/src/tests/scenarios_mandatories.rs @@ -758,6 +758,273 @@ fn send_and_receive_async_message() { assert_eq!(events[0].data, "message correctly received: 42,42,42,42"); } +#[test] +fn send_and_receive_async_message_expired() { + let exec_cfg = ExecutionConfig::default(); + let finalized_waitpoint = WaitPoint::new(); + let mut foreign_controllers = ExecutionForeignControllers::new_with_mocks(); + selector_boilerplate(&mut foreign_controllers.selector_controller); + foreign_controllers + .selector_controller + .set_expectations(|selector_controller| { + selector_controller + .expect_get_producer() + .returning(move |_| { + Ok(Address::from_public_key( + &KeyPair::from_str(TEST_SK_1).unwrap().get_public_key(), + )) + }); + }); + + foreign_controllers + .ledger_controller + .set_expectations(|ledger_controller| { + ledger_controller + .expect_get_balance() + .returning(move |_| Some(Amount::from_str("100").unwrap())); + + ledger_controller + .expect_entry_exists() + .times(2) + .returning(move |_| false); + + ledger_controller + .expect_entry_exists() + .returning(move |_| true); + }); + let saved_bytecode = Arc::new(RwLock::new(None)); + let finalized_waitpoint_trigger_handle = finalized_waitpoint.get_trigger_handle(); + + // Expected message from SC: send_message.ts (see massa unit tests src repo) + foreign_controllers + .final_state + .write() + .expect_finalize() + .times(1) + .with(predicate::eq(Slot::new(1, 0)), predicate::always()) + .returning(move |_, changes| { + //println!("changes S (1 0): {:?}", changes); + assert_eq!( + changes.async_pool_changes, + AsyncPoolChanges(BTreeMap::new()) + ); + finalized_waitpoint_trigger_handle.trigger(); + }); + + final_state_boilerplate( + &mut foreign_controllers.final_state, + foreign_controllers.db.clone(), + &foreign_controllers.selector_controller, + &mut foreign_controllers.ledger_controller, + Some(saved_bytecode), + None, + None, + ); + let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg.clone()); + + // load bytecodes + universe.deploy_bytecode_block( + &KeyPair::from_str(TEST_SK_1).unwrap(), + Slot::new(1, 0), + include_bytes!("./wasm/send_message_expired.wasm"), + include_bytes!("./wasm/receive_message.wasm"), + ); + println!("waiting for finalized"); + finalized_waitpoint.wait(); + + // retrieve events emitted by smart contracts + let events = universe + .module_controller + .get_filtered_sc_output_event(EventFilter { + start: Some(Slot::new(1, 0)), + end: Some(Slot::new(1, 1)), + ..Default::default() + }); + // match the events + assert!(events.len() == 1, "One event was expected"); + assert!(events[0] + .data + .contains("validity end is earlier than the validity start")); +} + +#[test] +fn send_and_receive_async_message_expired_2() { + let exec_cfg = ExecutionConfig::default(); + let finalized_waitpoint = WaitPoint::new(); + let mut foreign_controllers = ExecutionForeignControllers::new_with_mocks(); + selector_boilerplate(&mut foreign_controllers.selector_controller); + foreign_controllers + .selector_controller + .set_expectations(|selector_controller| { + selector_controller + .expect_get_producer() + .returning(move |_| { + Ok(Address::from_public_key( + &KeyPair::from_str(TEST_SK_1).unwrap().get_public_key(), + )) + }); + }); + + foreign_controllers + .ledger_controller + .set_expectations(|ledger_controller| { + ledger_controller + .expect_get_balance() + .returning(move |_| Some(Amount::from_str("100").unwrap())); + + ledger_controller + .expect_entry_exists() + .times(2) + .returning(move |_| false); + + ledger_controller + .expect_entry_exists() + .returning(move |_| true); + }); + let saved_bytecode = Arc::new(RwLock::new(None)); + let finalized_waitpoint_trigger_handle = finalized_waitpoint.get_trigger_handle(); + + // Expected message from SC: send_message.ts (see massa unit tests src repo) + foreign_controllers + .final_state + .write() + .expect_finalize() + .times(1) + .with(predicate::eq(Slot::new(1, 0)), predicate::always()) + .returning(move |_, changes| { + assert_eq!( + changes.async_pool_changes, + AsyncPoolChanges(BTreeMap::new()) + ); + finalized_waitpoint_trigger_handle.trigger(); + }); + + final_state_boilerplate( + &mut foreign_controllers.final_state, + foreign_controllers.db.clone(), + &foreign_controllers.selector_controller, + &mut foreign_controllers.ledger_controller, + Some(saved_bytecode), + None, + None, + ); + let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg.clone()); + + // load bytecodes + universe.deploy_bytecode_block( + &KeyPair::from_str(TEST_SK_1).unwrap(), + Slot::new(1, 0), + include_bytes!("./wasm/send_message_expired_2.wasm"), + include_bytes!("./wasm/receive_message.wasm"), + ); + println!("waiting for finalized"); + finalized_waitpoint.wait(); + + // retrieve events emitted by smart contracts + let events = universe + .module_controller + .get_filtered_sc_output_event(EventFilter { + start: Some(Slot::new(1, 0)), + end: Some(Slot::new(1, 1)), + ..Default::default() + }); + // match the events + assert!(events.len() == 1, "One event was expected"); + assert!(events[0] + .data + .contains("validity end is earlier than the current slot")); +} + +#[test] +fn send_and_receive_async_message_without_init_gas() { + let mut exec_cfg = ExecutionConfig::default(); + exec_cfg.gas_costs.max_instance_cost = 4000000; + + let finalized_waitpoint = WaitPoint::new(); + let mut foreign_controllers = ExecutionForeignControllers::new_with_mocks(); + selector_boilerplate(&mut foreign_controllers.selector_controller); + foreign_controllers + .selector_controller + .set_expectations(|selector_controller| { + selector_controller + .expect_get_producer() + .returning(move |_| { + Ok(Address::from_public_key( + &KeyPair::from_str(TEST_SK_1).unwrap().get_public_key(), + )) + }); + }); + + foreign_controllers + .ledger_controller + .set_expectations(|ledger_controller| { + ledger_controller + .expect_get_balance() + .returning(move |_| Some(Amount::from_str("100").unwrap())); + + ledger_controller + .expect_entry_exists() + .times(2) + .returning(move |_| false); + + ledger_controller + .expect_entry_exists() + .returning(move |_| true); + }); + let saved_bytecode = Arc::new(RwLock::new(None)); + let finalized_waitpoint_trigger_handle = finalized_waitpoint.get_trigger_handle(); + + // Expected message from SC: send_message.ts (see massa unit tests src repo) + foreign_controllers + .final_state + .write() + .expect_finalize() + .times(1) + .with(predicate::eq(Slot::new(1, 0)), predicate::always()) + .returning(move |_, changes| { + assert_eq!( + changes.async_pool_changes, + AsyncPoolChanges(BTreeMap::new()) + ); + finalized_waitpoint_trigger_handle.trigger(); + }); + + final_state_boilerplate( + &mut foreign_controllers.final_state, + foreign_controllers.db.clone(), + &foreign_controllers.selector_controller, + &mut foreign_controllers.ledger_controller, + Some(saved_bytecode), + None, + None, + ); + let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg.clone()); + + // load bytecodes + universe.deploy_bytecode_block( + &KeyPair::from_str(TEST_SK_1).unwrap(), + Slot::new(1, 0), + include_bytes!("./wasm/send_message.wasm"), + include_bytes!("./wasm/receive_message.wasm"), + ); + println!("waiting for finalized"); + finalized_waitpoint.wait(); + + // retrieve events emitted by smart contracts + let events = universe + .module_controller + .get_filtered_sc_output_event(EventFilter { + start: Some(Slot::new(1, 0)), + end: Some(Slot::new(1, 1)), + ..Default::default() + }); + // match the events + assert!(events.len() == 1, "One event was expected"); + assert!(events[0] + .data + .contains("max gas is lower than the minimum instance cost")); +} + #[test] fn cancel_async_message() { let exec_cfg = ExecutionConfig::default(); diff --git a/massa-execution-worker/src/tests/wasm/send_message_expired.wasm b/massa-execution-worker/src/tests/wasm/send_message_expired.wasm new file mode 100644 index 0000000000000000000000000000000000000000..edfcc3c351fad486be0e7da4aef427aad9cb36fc GIT binary patch literal 2947 zcmaJ@O^g&(5U$s+d!~C{&u$}Pf`j9j2;XIge9Hv2C^qQ!Y&>RF3acgWjXS`Qx#n-uLjMT zm2RJcpxx~Cnhksv?U|)Zd2hD6(CO#%ML%EZj<%9Gon{4&*kj`B<2gMmTtCf26eg%%YE|nSe-O!rAT??`Mw{hj`F-f+rF+SvP(2e>6|pj^9;>YOTfP3NQo+CyudT1I>l6NAz8>@Q~2%Je&w`JD85Tn@7Urq;LG28#?wExvN)<8z#>W&uuv7h}RxnY4ktXyD%NiuO#>UDuBiS<0%;Y!t~kn|J!Il&JNdlD zsiW=NYAdTiD#318V;ERaK|#bvX)d3ejeidh0q;G~kpx8Rv49$cfuh0U%UY~+)rXcRA z@4x(3O{u9r@S=7yu{!b1`$`X(Qc6@3XRwG0EjO_qYe>&6`Fk>5lvt)E#b35v(%(MEnu~buzk!cn3r(crFklde=Kc(4b4kp zyA$Iwo-fc0?E|Kd?;gI-V?T+xhiH*euOnJyc8SFfjA?jZg-@}YbN&mQ%me=s@h#xN z?sjDM3VzRH5yW@NP?&b{Y0{-pq%~OXApWdoR6u+U6LvRh#)uyu;~+kKt31DrNfF=0 zglP9`Pm8t@VFnqU#iu~TVP4mav%F!?4~FP;*aacP%dC#pY#+XE8SH1TU3YMMVp`FyeR@HmLpm*ra0f{9`s7*^N3? zFFRE?+XOv^(S^5Jj0JcG_gg@qrnfQSI@~RH_v0u1uHp1UbYaY#5-&%e@Y01U zEWCWKnRE_YPhl`dBw8;2riQbn sH5ll80DGb}8`oxFKJ{Z-Xh zRp09!YWCWSh}41btQx4nSv?pG2unKa4P;Mr*2fX{gk3xsT#?U}D{|z0rz*NwUJaTv zE8RW?LA%-OH5>RU+A~X+^WJQCq0`Uji+;Y+$rp>uJ*xaaX0F+95|x-8oBhmoi)O!o z*AZgpW<;-8p3B<>NX!>hE!}M24C-_jmiy%Cu{vqeN|Ex&^L;;19p!m}#z7_a28ziH zi0_Y?>d~s-ZZ0g-Sdiz-#YK3|^A7go)jYqjEUP5S^VyZ9rDC>ETTGsJ`~8J{rr9gB zs|+Jyu!mw|f0krGkMaURz&Z*C+iWd?V!hA*cLeLS%MRs&*6m zt;_>vYl}PQ*tYTCmKhH={O+4 za6!fxtM`yqmJWJkJ#$id!sD+edHhVgONih}(n>0smhc|K#18V;ERaKSi4(4h+De(b2|^J8hvgJoH4eY2;+P{b6)!P5 zQB9rf-Sxoj5yiVHWS=F5#u*LCjyMD1i)R4EdlDrztd;N|u5nw~8?H6hx?D?I$c-|+ zn7UP%5?Is_Cy>|#bvX)d3ej1KBU?G%FsYUn2!;ex z0R}@bSjYed`rmkfmAsUy2&!8{F$W-0O$^?1s+D@Nf{Fw4xpMEe#7i_feidh0q;G~kpx8Rv49$cfuh0U%QJ+Hc7~7`4 z|MFWkrKbMCi`vP=>cltiD?MOJDN#wB!6HsQeFT0XF>G+f5b1bB-ul>!cyVjs7YM}< z>sW13LJY}~B*)jrlEC;lGMbbdZ{vRge?7hjv|M=_A#$uUczaY=BXh5v9$d)G%tzm zE{rR9zCbgyADBMAd-%S9{UqidqD4l%j%bnDEfza5rr~`RKE-a%`7dxX5Bx{Ow}A({ zJCWHZ_`Od=5Z@(3VcNx~NtZ{F)?m4l__LZ(0r7QA*xjrdBYu30L-_FR^85}aMSKqv zqCKcRE80ec8Dw-0p8^qwd0jWo@}@DbiT^zqlGhwCmypv6Ec$Lfhi~C28KQ#sO1lS- z*={Q)s7xWlL7v5$u7T_7&Zv%mv-ofM{lXCZ{E)a_lKDU8uss ztN0eylC8x`YGpI9Ucxe)iSJ;m$r9{O_1a=dkq@24h5` Date: Tue, 2 Jul 2024 16:12:08 +0200 Subject: [PATCH 04/32] Fix ledger change to take into account cancelled message balance change (#4715) * Take again the speculative changes after async message cancellation * use .apply() to merge the two LedgerChanges * Fix: we cannot combine two ledger changes with apply * avoid cloning the changes * Remove comment --- massa-execution-worker/src/context.rs | 9 +++------ massa-execution-worker/src/speculative_ledger.rs | 13 ------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index e77060c5394..50eeda621f5 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -893,13 +893,10 @@ impl ExecutionContext { // execute the deferred credits coming from roll sells let deferred_credits_transfers = self.execute_deferred_credits(&slot); - // take the ledger changes first as they are needed for async messages and cache - let ledger_changes = self.speculative_ledger.take(); - // settle emitted async messages and reimburse the senders of deleted messages let deleted_messages = self .speculative_async_pool - .settle_slot(&slot, &ledger_changes); + .settle_slot(&slot, &self.speculative_ledger.added_changes); let mut cancel_async_message_transfers = vec![]; for (_msg_id, msg) in deleted_messages { @@ -909,7 +906,7 @@ impl ExecutionContext { } // update module cache - let bc_updates = ledger_changes.get_bytecode_updates(); + let bc_updates = self.speculative_ledger.added_changes.get_bytecode_updates(); { let mut cache_write_lock = self.module_cache.write(); for bytecode in bc_updates { @@ -935,7 +932,7 @@ impl ExecutionContext { // generate the execution output let state_changes = StateChanges { - ledger_changes, + ledger_changes: self.speculative_ledger.take(), async_pool_changes: self.speculative_async_pool.take(), pos_changes: self.speculative_roll_state.take(), executed_ops_changes: self.speculative_executed_ops.take(), diff --git a/massa-execution-worker/src/speculative_ledger.rs b/massa-execution-worker/src/speculative_ledger.rs index 16bc6a98053..238d3128321 100644 --- a/massa-execution-worker/src/speculative_ledger.rs +++ b/massa-execution-worker/src/speculative_ledger.rs @@ -34,19 +34,6 @@ pub(crate) struct SpeculativeLedger { active_history: Arc>, /// list of ledger changes that were applied to this `SpeculativeLedger` since its creation - #[cfg(all( - not(feature = "gas_calibration"), - not(feature = "benchmarking"), - not(feature = "test-exports"), - not(test) - ))] - added_changes: LedgerChanges, - #[cfg(any( - feature = "gas_calibration", - feature = "benchmarking", - feature = "test-exports", - test - ))] pub added_changes: LedgerChanges, /// max datastore key length From 88823b8462f73fbea76f8fde1b0134ac8060c69e Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Tue, 2 Jul 2024 16:12:28 +0200 Subject: [PATCH 05/32] Fix async msg same slot (#4718) * fix open rpc spec (#4716) * Add eliminated_new_messages in eliminated_msg --------- Co-authored-by: Modship --- massa-execution-worker/src/speculative_async_pool.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index e0d1080a275..4413fd35609 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -221,9 +221,14 @@ impl SpeculativeAsyncPool { } // Query eliminated messages - let eliminated_msg = + let mut eliminated_msg = self.fetch_msgs(eliminated_infos.iter().map(|(id, _)| id).collect(), true); + eliminated_msg.extend(eliminated_new_messages.iter().filter_map(|(k, v)| match v { + SetUpdateOrDelete::Set(v) => Some((*k, v.clone())), + SetUpdateOrDelete::Update(_v) => None, + SetUpdateOrDelete::Delete => None, + })); eliminated_msg } From aa7efcf8938c7b4a8cd0350c792a0e2ed0bae987 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Tue, 16 Jul 2024 07:21:11 +0200 Subject: [PATCH 06/32] Update interface_impl.rs (#4728) --- massa-execution-worker/src/interface_impl.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index fb33689fecf..c1a2648f4dd 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -1518,8 +1518,8 @@ impl Interface for InterfaceImpl { fn get_address_category_wasmv1(&self, to_check: &str) -> Result { let addr = Address::from_str(to_check)?; match addr { - Address::User(_) => Ok(AddressCategory::ScAddress), - Address::SC(_) => Ok(AddressCategory::UserAddress), + Address::User(_) => Ok(AddressCategory::UserAddress), + Address::SC(_) => Ok(AddressCategory::ScAddress), #[allow(unreachable_patterns)] _ => Ok(AddressCategory::Unspecified), } From 5f9f2a70a536a9344f4225e416ac4daa1064c4ca Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Thu, 1 Aug 2024 08:29:25 +0200 Subject: [PATCH 07/32] Fix potential ledger keys boundaries issue (#4731) --- massa-ledger-worker/src/ledger_db.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/massa-ledger-worker/src/ledger_db.rs b/massa-ledger-worker/src/ledger_db.rs index 56886211cb3..a95a3199614 100644 --- a/massa-ledger-worker/src/ledger_db.rs +++ b/massa-ledger-worker/src/ledger_db.rs @@ -464,7 +464,7 @@ impl LedgerDB { STATE_CF, MassaIteratorMode::From(&key_prefix, MassaDirection::Forward), ) - .take_while(|(key, _)| key <= &end_prefix(&key_prefix).unwrap()) + .take_while(|(key, _)| key < &end_prefix(&key_prefix).unwrap()) { db.delete_key(batch, serialized_key.to_vec()); } From 736a9edf4a427e54efaa889819ad4b8b8f2a9103 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Thu, 1 Aug 2024 08:51:08 +0200 Subject: [PATCH 08/32] Consistent expiry period for async message and block operations (#4722) * Asc message execution - requery message bytecode after each message execution (#4710) * Requery bytecode * cargo fmt * fix call stack inconsistency (#4709) * Improve async message checks (#4706) * Improve async message checks * Change checks for async messages * Add unit tests * Fix ledger change to take into account cancelled message balance change (#4715) * Take again the speculative changes after async message cancellation * use .apply() to merge the two LedgerChanges * Fix: we cannot combine two ledger changes with apply * avoid cloning the changes * Remove comment * Fix async msg same slot (#4718) * fix open rpc spec (#4716) * Add eliminated_new_messages in eliminated_msg --------- Co-authored-by: Modship * Consistent expiry period for async message and block operations * Update message validity for expiration * Minor comment fix --------- Co-authored-by: Leo-Besancon Co-authored-by: Modship --- .../src/speculative_async_pool.rs | 68 ++++++++++++++++--- 1 file changed, 57 insertions(+), 11 deletions(-) diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index 4413fd35609..7b5e1219f05 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -97,7 +97,8 @@ impl SpeculativeAsyncPool { } /// Takes a batch of asynchronous messages to execute, - /// removing them from the speculative asynchronous pool and settling their deletion from it in the changes accumulator. + /// removing them from the speculative asynchronous pool and settling their deletion from it + /// in the changes accumulator. /// /// # Arguments /// * `slot`: slot at which the batch is taken (allows filtering by validity interval) @@ -122,9 +123,10 @@ impl SpeculativeAsyncPool { for (message_id, message_info) in message_infos.iter() { let corrected_max_gas = message_info.max_gas.saturating_add(async_msg_cst_gas_cost); + // Note: SecureShareOperation.get_validity_range(...) returns RangeInclusive + // so to be consistent here, use >= & <= checks if available_gas >= corrected_max_gas - && slot >= message_info.validity_start - && slot < message_info.validity_end + && Self::is_message_ready_to_execute(&slot, &message_info.validity_start, &message_info.validity_end) && message_info.can_be_executed { available_gas -= corrected_max_gas; @@ -158,26 +160,27 @@ impl SpeculativeAsyncPool { ) -> Vec<(AsyncMessageId, AsyncMessage)> { // Update the messages_info: remove messages that should be removed // Filter out all messages for which the validity end is expired. - // Note that the validity_end bound is NOT included in the validity interval of the message. + // Note: that the validity_end bound is included in the validity interval of the message. let mut eliminated_infos = Vec::new(); self.message_infos.retain(|id, info| { - if *slot < info.validity_end { - true - } else { + + if Self::is_message_expired(slot, &info.validity_end) { eliminated_infos.push((*id, info.clone())); false + } else { + true } }); let mut eliminated_new_messages = Vec::new(); self.pool_changes.0.retain(|k, v| match v { SetUpdateOrDelete::Set(message) => { - if *slot < message.validity_end { - true - } else { + if Self::is_message_expired(slot, &message.validity_end) { eliminated_new_messages.push((*k, v.clone())); false + } else { + true } } SetUpdateOrDelete::Update(_v) => true, @@ -190,7 +193,7 @@ impl SpeculativeAsyncPool { SetUpdateOrDelete::Delete => None, })); - // Truncate message pool to its max size, removing non-prioritary items + // Truncate message pool to its max size, removing non-priority items let excess_count = self .message_infos .len() @@ -310,9 +313,52 @@ impl SpeculativeAsyncPool { msgs } + + /// Return true if a message (given its validity end) is expired + /// Must be consistent with is_message_valid + fn is_message_expired(slot: &Slot, message_validity_end: &Slot) -> bool { + // Note: SecureShareOperation.get_validity_range(...) returns RangeInclusive + // (for operation validity) so apply the same rule for message validity + *slot > *message_validity_end + } + + /// Return true if a message (given its validity_start & validity end) is ready to execute + /// Must be consistent with is_message_expired + fn is_message_ready_to_execute(slot: &Slot, message_validity_start: &Slot, message_validity_end: &Slot) -> bool { + // Note: SecureShareOperation.get_validity_range(...) returns RangeInclusive + // (for operation validity) so apply the same rule for message validity + slot >= message_validity_start + && slot <= message_validity_end + } } /// Check in the ledger changes if a message trigger has been triggered fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> bool { ledger_changes.has_changes(&filter.address, filter.datastore_key.clone()) } + +#[cfg(test)] +mod tests { + use super::*; + + // Test if is_message_expired & is_message_ready_to_execute are consistent + #[test] + fn test_validity() { + let slot1 = Slot::new(6, 0); + let slot2 = Slot::new(9, 0); + let slot_validity_start = Slot::new(4, 0); + let slot_validity_end = Slot::new(8, 0); + + assert!(!SpeculativeAsyncPool::is_message_expired(&slot1, &slot_validity_end)); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot1, &slot_validity_start, &slot_validity_end)); + + assert!(!SpeculativeAsyncPool::is_message_expired(&slot_validity_start, &slot_validity_end)); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot_validity_start, &slot_validity_start, &slot_validity_end)); + + assert!(!SpeculativeAsyncPool::is_message_expired(&slot_validity_end, &slot_validity_end)); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot_validity_end, &slot_validity_start, &slot_validity_end)); + + assert!(SpeculativeAsyncPool::is_message_expired(&slot2, &slot_validity_end)); + assert!(!SpeculativeAsyncPool::is_message_ready_to_execute(&slot2, &slot_validity_start, &slot_validity_end)); + } +} \ No newline at end of file From 6628fff08d1048422d8a8b2596964013e65b8395 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Thu, 1 Aug 2024 11:37:57 +0200 Subject: [PATCH 09/32] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 680d261af63..acb4384c40f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,7 @@ on: push: branches: [main, staging, trying] pull_request: - branches: [main, 'testnet_*'] + branches: [main, 'mainnet_*'] types: - opened - reopened @@ -205,7 +205,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: install - args: cargo-nextest + args: cargo-nextest --locked - uses: actions-rs/cargo@v1 with: command: nextest From 1f2c6be0292fd7a6a0941405b168319853b7f240 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Thu, 1 Aug 2024 11:41:38 +0200 Subject: [PATCH 10/32] fmt --- .../src/speculative_async_pool.rs | 72 ++++++++++++++----- 1 file changed, 53 insertions(+), 19 deletions(-) diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index 7b5e1219f05..3a5c654d7a8 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -126,7 +126,11 @@ impl SpeculativeAsyncPool { // Note: SecureShareOperation.get_validity_range(...) returns RangeInclusive // so to be consistent here, use >= & <= checks if available_gas >= corrected_max_gas - && Self::is_message_ready_to_execute(&slot, &message_info.validity_start, &message_info.validity_end) + && Self::is_message_ready_to_execute( + &slot, + &message_info.validity_start, + &message_info.validity_end, + ) && message_info.can_be_executed { available_gas -= corrected_max_gas; @@ -164,7 +168,6 @@ impl SpeculativeAsyncPool { let mut eliminated_infos = Vec::new(); self.message_infos.retain(|id, info| { - if Self::is_message_expired(slot, &info.validity_end) { eliminated_infos.push((*id, info.clone())); false @@ -324,11 +327,14 @@ impl SpeculativeAsyncPool { /// Return true if a message (given its validity_start & validity end) is ready to execute /// Must be consistent with is_message_expired - fn is_message_ready_to_execute(slot: &Slot, message_validity_start: &Slot, message_validity_end: &Slot) -> bool { + fn is_message_ready_to_execute( + slot: &Slot, + message_validity_start: &Slot, + message_validity_end: &Slot, + ) -> bool { // Note: SecureShareOperation.get_validity_range(...) returns RangeInclusive // (for operation validity) so apply the same rule for message validity - slot >= message_validity_start - && slot <= message_validity_end + slot >= message_validity_start && slot <= message_validity_end } } @@ -341,24 +347,52 @@ fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> mod tests { use super::*; - // Test if is_message_expired & is_message_ready_to_execute are consistent + // Test if is_message_expired & is_message_ready_to_execute are consistent #[test] fn test_validity() { let slot1 = Slot::new(6, 0); let slot2 = Slot::new(9, 0); let slot_validity_start = Slot::new(4, 0); let slot_validity_end = Slot::new(8, 0); - - assert!(!SpeculativeAsyncPool::is_message_expired(&slot1, &slot_validity_end)); - assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot1, &slot_validity_start, &slot_validity_end)); - - assert!(!SpeculativeAsyncPool::is_message_expired(&slot_validity_start, &slot_validity_end)); - assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot_validity_start, &slot_validity_start, &slot_validity_end)); - - assert!(!SpeculativeAsyncPool::is_message_expired(&slot_validity_end, &slot_validity_end)); - assert!(SpeculativeAsyncPool::is_message_ready_to_execute(&slot_validity_end, &slot_validity_start, &slot_validity_end)); - - assert!(SpeculativeAsyncPool::is_message_expired(&slot2, &slot_validity_end)); - assert!(!SpeculativeAsyncPool::is_message_ready_to_execute(&slot2, &slot_validity_start, &slot_validity_end)); + + assert!(!SpeculativeAsyncPool::is_message_expired( + &slot1, + &slot_validity_end + )); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute( + &slot1, + &slot_validity_start, + &slot_validity_end + )); + + assert!(!SpeculativeAsyncPool::is_message_expired( + &slot_validity_start, + &slot_validity_end + )); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute( + &slot_validity_start, + &slot_validity_start, + &slot_validity_end + )); + + assert!(!SpeculativeAsyncPool::is_message_expired( + &slot_validity_end, + &slot_validity_end + )); + assert!(SpeculativeAsyncPool::is_message_ready_to_execute( + &slot_validity_end, + &slot_validity_start, + &slot_validity_end + )); + + assert!(SpeculativeAsyncPool::is_message_expired( + &slot2, + &slot_validity_end + )); + assert!(!SpeculativeAsyncPool::is_message_ready_to_execute( + &slot2, + &slot_validity_start, + &slot_validity_end + )); } -} \ No newline at end of file +} From 2d6e1ff871484357285ac1015299d2e994db79d2 Mon Sep 17 00:00:00 2001 From: Damir Vodenicarevic Date: Thu, 1 Aug 2024 13:32:39 +0200 Subject: [PATCH 11/32] Fixe issue with fees (#4734) * fix fees * Update test_rewards execution test * Update test with updated reward formula * Update ci.yml * revert test change * Rm dbg and create const value * fmt --------- Co-authored-by: Leo-Besancon --- massa-execution-worker/src/execution.rs | 44 +++- .../src/tests/scenarios_mandatories.rs | 233 ++++++++++++------ massa-execution-worker/src/tests/universe.rs | 17 +- 3 files changed, 194 insertions(+), 100 deletions(-) diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index e6c1bc98700..e884a58f145 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -1359,7 +1359,9 @@ impl ExecutionState { // Set remaining block gas let mut remaining_block_gas = self.config.max_gas_per_block; - // Set block credits + // Block credits count every operation fee, denunciation slash and endorsement reward. + // We initialize the block credits with the block reward to stimulate block production + // even in the absence of operations and denunciations. let mut block_credits = self.config.block_reward; // Try executing the operations of this block in the order in which they appear in the block. @@ -1485,13 +1487,29 @@ impl ExecutionState { // Update speculative rolls state production stats context.update_production_stats(&block_creator_addr, *slot, Some(*block_id)); - // Credit endorsement producers and endorsed block producers - let mut remaining_credit = block_credits; + // Divide the total block credits into parts + remainder + let block_credit_part_count = 3 * (1 + self.config.endorsement_count); let block_credit_part = block_credits - .checked_div_u64(3 * (1 + (self.config.endorsement_count))) + .checked_div_u64(block_credit_part_count) .expect("critical: block_credits checked_div factor is 0"); + let remainder = block_credits + .checked_rem_u64(block_credit_part_count) + .expect("critical: block_credits checked_rem factor is 0"); + + // Give 3 parts + remainder to the block producer to stimulate block production + // even in the absence of endorsements. + let mut block_producer_credit = block_credit_part + .saturating_mul_u64(3) + .saturating_add(remainder); + for endorsement_creator in endorsement_creators { - // credit creator of the endorsement with coins + // Credit the creator of the block with 1 part to stimulate endorsement inclusion of endorsements, + // and dissuade from emitting the block too early (before the endorsements have propageted). + block_producer_credit = block_producer_credit.saturating_add(block_credit_part); + + // Credit creator of the endorsement with 1 part to stimulate the production of endorsements. + // This also motivates endorsers to not publish their endorsements too early (will not endorse the right block), + // and to not publish too late (will not be included in the block). match context.transfer_coins( None, Some(endorsement_creator), @@ -1499,8 +1517,6 @@ impl ExecutionState { false, ) { Ok(_) => { - remaining_credit = remaining_credit.saturating_sub(block_credit_part); - #[cfg(feature = "execution-info")] exec_info .endorsement_creator_rewards @@ -1514,7 +1530,9 @@ impl ExecutionState { } } - // credit creator of the endorsed block with coins + // Credit the creator of the endorsed block with 1 part. + // This is done to incentivize block producers to be endorsed, + // typically by not publishing their blocks too late. match context.transfer_coins( None, Some(endorsement_target_creator), @@ -1522,7 +1540,6 @@ impl ExecutionState { false, ) { Ok(_) => { - remaining_credit = remaining_credit.saturating_sub(block_credit_part); #[cfg(feature = "execution-info")] { exec_info.endorsement_target_reward = @@ -1538,18 +1555,19 @@ impl ExecutionState { } } - // Credit block creator with remaining_credit + // Credit block producer if let Err(err) = - context.transfer_coins(None, Some(block_creator_addr), remaining_credit, false) + context.transfer_coins(None, Some(block_creator_addr), block_producer_credit, false) { debug!( "failed to credit {} coins to block creator {} on block execution: {}", - remaining_credit, block_creator_addr, err + block_producer_credit, block_creator_addr, err ) } else { #[cfg(feature = "execution-info")] { - exec_info.block_producer_reward = Some((block_creator_addr, remaining_credit)); + exec_info.block_producer_reward = + Some((block_creator_addr, block_producer_credit)); } } } else { diff --git a/massa-execution-worker/src/tests/scenarios_mandatories.rs b/massa-execution-worker/src/tests/scenarios_mandatories.rs index 154ea28d3cb..aa210361161 100644 --- a/massa-execution-worker/src/tests/scenarios_mandatories.rs +++ b/massa-execution-worker/src/tests/scenarios_mandatories.rs @@ -15,7 +15,7 @@ use massa_ledger_exports::{ }; use massa_models::bytecode::Bytecode; use massa_models::config::{ - CHAINID, ENDORSEMENT_COUNT, LEDGER_ENTRY_DATASTORE_BASE_SIZE, THREAD_COUNT, + CHAINID, ENDORSEMENT_COUNT, GENESIS_KEY, LEDGER_ENTRY_DATASTORE_BASE_SIZE, THREAD_COUNT, }; use massa_models::prehash::PreHashMap; use massa_models::test_exports::gen_endorsements_for_denunciation; @@ -58,6 +58,7 @@ use std::io::Cursor; const TEST_SK_1: &str = "S18r2i8oJJyhF7Kprx98zwxAc3W4szf7RKuVMX6JydZz8zSxHeC"; const TEST_SK_2: &str = "S1FpYC4ugG9ivZZbLVrTwWtF9diSRiAwwrVX5Gx1ANSRLfouUjq"; const TEST_SK_3: &str = "S1LgXhWLEgAgCX3nm6y8PVPzpybmsYpi6yg6ZySwu5Z4ERnD7Bu"; +const BLOCK_CREDIT_PART_COUNT: u64 = 3 * (1 + ENDORSEMENT_COUNT as u64); fn final_state_boilerplate( mock_final_state: &mut Arc>, @@ -743,7 +744,7 @@ fn send_and_receive_async_message() { let block = ExecutionTestUniverse::create_block(&keypair, Slot::new(1, 1), vec![], vec![], vec![]); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // retrieve events emitted by smart contracts let events = universe @@ -1087,7 +1088,7 @@ fn cancel_async_message() { changes.ledger_changes.0.get(&sender_addr).unwrap(), &SetUpdateOrDelete::Update(LedgerEntryUpdate { balance: massa_ledger_exports::SetOrKeep::Set( - Amount::from_str("100.670399899").unwrap() + Amount::from_str("90.298635211").unwrap() ), bytecode: massa_ledger_exports::SetOrKeep::Keep, datastore: BTreeMap::new() @@ -1170,7 +1171,7 @@ fn cancel_async_message() { let block = ExecutionTestUniverse::create_block(&keypair, Slot::new(1, 1), vec![], vec![], vec![]); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // Sleep to wait (1,1) candidate slot to be executed. We don't have a mock to waitpoint on or empty block @@ -1422,7 +1423,7 @@ fn send_and_receive_async_message_with_trigger() { vec![], ); universe.storage.store_block(block.clone()); - universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block); + universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block, None); finalized_waitpoint.wait(); // retrieve events emitted by smart contracts let events = universe @@ -1516,7 +1517,19 @@ fn send_and_receive_transaction() { .get_balance_or_else(&recipient_address, || None), Some(Amount::from_str("190").unwrap()) ); - // 1.02 for the block rewards + // block rewards computation + let total_rewards = exec_cfg + .block_reward + .saturating_add(Amount::from_str("10").unwrap()); // add 10 MAS for fees + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( changes.ledger_changes.get_balance_or_else( &Address::from_public_key( @@ -1524,11 +1537,7 @@ fn send_and_receive_transaction() { ), || None ), - Some( - exec_cfg - .block_reward - .saturating_add(Amount::from_str("10").unwrap()) // add 10 fee - ) + Some(rewards_for_block_creator) ); finalized_waitpoint_trigger_handle.trigger(); }); @@ -1558,7 +1567,7 @@ fn send_and_receive_transaction() { vec![], ); // store the block in storage - universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block); + universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block, None); finalized_waitpoint.wait(); } @@ -1593,11 +1602,21 @@ fn roll_buy() { assert_eq!(changes.pos_changes.roll_changes.get(&address), Some(&101)); // address has 100 coins before buying roll - // -> (100 (balance) - 100 (roll price)) + 1.02 (block reward) + // -> (100 (balance) - 100 (roll price)) + 1.02 / 17 * 3 (block reward) + let total_rewards = exec_cfg.block_reward; + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( changes.ledger_changes.0.get(&address).unwrap(), &SetUpdateOrDelete::Update(LedgerEntryUpdate { - balance: massa_ledger_exports::SetOrKeep::Set(exec_cfg.block_reward), + balance: massa_ledger_exports::SetOrKeep::Set(rewards_for_block_creator), bytecode: massa_ledger_exports::SetOrKeep::Keep, datastore: BTreeMap::new() }) @@ -1628,7 +1647,7 @@ fn roll_buy() { vec![], ); // set our block as a final block so the purchase is processed - universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block); + universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block, None); finalized_waitpoint.wait(); } @@ -1692,6 +1711,17 @@ fn roll_sell() { .ledger_changes .get_balance_or_else(&address, || None) .unwrap(); + // block rewards computation + let total_rewards = exec_cfg.block_reward; + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( amount, // 100 from the boilerplate @@ -1700,7 +1730,7 @@ fn roll_sell() { // + deferred credits set above .saturating_add(initial_deferred_credits) // + block rewards - .saturating_add(exec_cfg.block_reward) + .saturating_add(rewards_for_block_creator) ); let deferred_credits = changes .pos_changes @@ -1757,7 +1787,7 @@ fn roll_sell() { vec![], ); // set our block as a final block so the purchase is processed - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); } @@ -1873,10 +1903,10 @@ fn auto_sell_on_missed_blocks() { let block = ExecutionTestUniverse::create_block(&keypair, Slot::new(1, 0), vec![], vec![], vec![]); // set our block as a final block so the purchase is processed - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); let block = ExecutionTestUniverse::create_block(&keypair, Slot::new(1, 1), vec![], vec![], vec![]); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); } @@ -1938,13 +1968,25 @@ fn roll_slash() { .ledger_changes .get_balance_or_else(&address, || None) .unwrap(); - // 100 base + reward of the 3 slash (50%) + block reward + + // block rewards computation + let total_rewards = exec_cfg + .block_reward + .saturating_add(Amount::from_str("150").unwrap()); //reward of the 3 slash (50%) + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( balance, Amount::from_mantissa_scale(100, 0) .unwrap() - .saturating_add(exec_cfg.block_reward) - .saturating_add(Amount::from_mantissa_scale(150, 0).unwrap()) + .saturating_add(rewards_for_block_creator) ); waitpoint_trigger_handle.trigger() }); @@ -1994,7 +2036,7 @@ fn roll_slash() { vec![], vec![denunciation, denunciation_2], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); waitpoint.wait(); } @@ -2056,13 +2098,24 @@ fn roll_slash_2() { .ledger_changes .get_balance_or_else(&address, || None) .unwrap(); - // 100 base + reward of the 4 slash (50%) + block reward + // block rewards computation + let total_rewards = exec_cfg + .block_reward + .saturating_add(Amount::from_str("200").unwrap()); //reward of the 4 slash (50%) + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( balance, Amount::from_mantissa_scale(100, 0) .unwrap() - .saturating_add(exec_cfg.block_reward) - .saturating_add(Amount::from_mantissa_scale(200, 0).unwrap()) + .saturating_add(rewards_for_block_creator) ); waitpoint_trigger_handle.trigger() }); @@ -2112,7 +2165,7 @@ fn roll_slash_2() { vec![], vec![denunciation, denunciation_2], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); waitpoint.wait(); } @@ -2154,7 +2207,7 @@ fn sc_execution_error() { vec![], vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // retrieve the event emitted by the execution error let events = universe @@ -2213,7 +2266,7 @@ fn sc_datastore() { vec![], vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // retrieve the event emitted by the execution error let events = universe @@ -2269,7 +2322,7 @@ fn set_bytecode_error() { vec![], vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // retrieve the event emitted by the execution error let events = universe @@ -2347,15 +2400,26 @@ fn datastore_manipulations() { .ledger_changes .get_balance_or_else(&addr, || None) .unwrap(); + // block rewards computation + let total_rewards = exec_cfg + .block_reward + .saturating_add(Amount::from_str("10").unwrap()); // 10 MAS for fees + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( amount, // Base from the boilerplate Amount::from_str("100") .unwrap() .saturating_sub(Amount::const_init(10, 0)) - .saturating_add(exec_cfg.block_reward) - // Gas fee - .saturating_add(Amount::from_str("10").unwrap()) + .saturating_add(rewards_for_block_creator) // Storage cost base .saturating_sub( exec_cfg @@ -2401,7 +2465,7 @@ fn datastore_manipulations() { vec![], vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); let events = universe @@ -2591,7 +2655,7 @@ fn not_enough_instance_gas() { ); // store the block in storage universe.storage.store_block(block.clone()); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); // assert events let events = universe @@ -2730,19 +2794,29 @@ fn test_rewards() { .times(1) .with(predicate::eq(Slot::new(1, 0)), predicate::always()) .returning(move |_, changes| { - let block_credit_part = exec_cfg - .block_reward - .checked_div_u64(3 * (1 + (ENDORSEMENT_COUNT as u64))) - .expect("critical: block_credits checked_div factor is 0") - .saturating_mul_u64(2); - let first_block_reward = exec_cfg.block_reward.saturating_sub(block_credit_part); + let block_credits = exec_cfg.block_reward; + let block_credit_part = block_credits + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: block_credits checked_div factor is 0"); + let remainder = block_credits + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: block_credits checked_rem factor is 0"); + + let first_block_reward_for_block_creator = block_credit_part + .saturating_mul_u64(3) + .saturating_add(remainder) // base reward + .saturating_add(block_credit_part.saturating_mul_u64(2)); // 2 endorsements included + let first_block_reward_for_endorsement_producer_address = + block_credit_part.saturating_mul_u64(2); // produced 2 endorsements that were included in the block + assert_eq!( changes .ledger_changes .get_balance_or_else(&keypair_address, || None), // Reward + 100 base from boilerplate Some( - first_block_reward.saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) + first_block_reward_for_block_creator + .saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) ) ); @@ -2752,7 +2826,8 @@ fn test_rewards() { .get_balance_or_else(&endorsement_producer_address, || None), // Reward + 100 base from boilerplate Some( - block_credit_part.saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) + first_block_reward_for_endorsement_producer_address + .saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) ) ); finalized_waitpoint_trigger_handle.trigger(); @@ -2765,27 +2840,28 @@ fn test_rewards() { .times(1) .with(predicate::eq(Slot::new(1, 1)), predicate::always()) .returning(move |_, changes| { - let block_credit_part_parent_in_thread = exec_cfg - .block_reward - .checked_div_u64(3 * (1 + (ENDORSEMENT_COUNT as u64))) - .expect("critical: block_credits checked_div factor is 0") - .saturating_mul_u64(ENDORSEMENT_COUNT as u64); - let block_credit_part_endorsement_producer = exec_cfg - .block_reward - .checked_div_u64(3 * (1 + (ENDORSEMENT_COUNT as u64))) - .expect("critical: block_credits checked_div factor is 0") - .saturating_mul_u64(ENDORSEMENT_COUNT as u64); - let creator_block_reward = exec_cfg - .block_reward - .saturating_sub(block_credit_part_endorsement_producer) - .saturating_sub(block_credit_part_parent_in_thread); + let block_credits = exec_cfg.block_reward; + let block_credit_part = block_credits + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: block_credits checked_div factor is 0"); + let remainder = block_credits + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: block_credits checked_rem factor is 0"); + + let second_block_reward_for_block_creator = block_credit_part + .saturating_mul_u64(3) + .saturating_add(remainder) // base reward + .saturating_add(block_credit_part.saturating_mul_u64(ENDORSEMENT_COUNT as u64)); // ENDORSEMENT_COUNT endorsements included + let second_block_reward_for_endorsement_producer_address = + block_credit_part.saturating_mul_u64(ENDORSEMENT_COUNT as u64); // produced ENDORSEMENT_COUNT endorsements that were included in the block + assert_eq!( changes .ledger_changes .get_balance_or_else(&keypair2_address, || None), // Reward + 100 base from boilerplate Some( - creator_block_reward + second_block_reward_for_block_creator .saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) ) ); @@ -2796,21 +2872,11 @@ fn test_rewards() { .get_balance_or_else(&endorsement_producer_address, || None), // Reward + 100 base from boilerplate Some( - block_credit_part_endorsement_producer + second_block_reward_for_endorsement_producer_address .saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) ) ); - assert_eq!( - changes - .ledger_changes - .get_balance_or_else(&keypair_address, || None), - // Reward + 100 base from boilerplate - Some( - block_credit_part_parent_in_thread - .saturating_add(Amount::from_mantissa_scale(100, 0).unwrap()) - ) - ); finalized_waitpoint_trigger_handle_2.trigger(); }); let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg.clone()); @@ -2823,11 +2889,6 @@ fn test_rewards() { &endorsement_producer, Slot::new(1, 0), )); - } else { - endorsements.push(ExecutionTestUniverse::create_endorsement( - &keypair, - Slot::new(1, 0), - )); } } let block = ExecutionTestUniverse::create_block( @@ -2837,7 +2898,7 @@ fn test_rewards() { endorsements, vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, Some(GENESIS_KEY.clone())); finalized_waitpoint.wait(); // Second block @@ -2851,7 +2912,7 @@ fn test_rewards() { ], vec![], ); - universe.send_and_finalize(&keypair, block); + universe.send_and_finalize(&keypair, block, None); finalized_waitpoint.wait(); } @@ -3165,6 +3226,18 @@ fn test_dump_block() { Some(Amount::from_str("190").unwrap()) ); // 1.02 for the block rewards + let total_rewards = exec_cfg + .block_reward + .saturating_add(Amount::from_str("10").unwrap()); // add 10 MAS for fees + let rewards_for_block_creator = total_rewards + .checked_div_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_div factor is 0") + .saturating_mul_u64(3) + .saturating_add( + total_rewards + .checked_rem_u64(BLOCK_CREDIT_PART_COUNT) + .expect("critical: total_rewards checked_rem factor is 0"), + ); assert_eq!( changes.ledger_changes.get_balance_or_else( &Address::from_public_key( @@ -3172,11 +3245,7 @@ fn test_dump_block() { ), || None ), - Some( - exec_cfg - .block_reward - .saturating_add(Amount::from_str("10").unwrap()) // add 10 fee - ) + Some(rewards_for_block_creator) ); finalized_waitpoint_trigger_handle.trigger(); }); @@ -3207,7 +3276,7 @@ fn test_dump_block() { vec![], ); // store the block in storage - universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block); + universe.send_and_finalize(&KeyPair::from_str(TEST_SK_1).unwrap(), block, None); finalized_waitpoint.wait(); std::thread::sleep(Duration::from_secs(1)); diff --git a/massa-execution-worker/src/tests/universe.rs b/massa-execution-worker/src/tests/universe.rs index bfffa6c80d9..85b98a0846e 100644 --- a/massa-execution-worker/src/tests/universe.rs +++ b/massa-execution-worker/src/tests/universe.rs @@ -18,7 +18,7 @@ use massa_execution_exports::{ use massa_final_state::{FinalStateController, MockFinalStateController}; use massa_ledger_exports::MockLedgerControllerWrapper; use massa_metrics::MassaMetrics; -use massa_models::config::CHAINID; +use massa_models::config::{CHAINID, GENESIS_KEY}; use massa_models::{ address::Address, amount::Amount, @@ -248,10 +248,15 @@ impl ExecutionTestUniverse { ExecutionTestUniverse::create_block(keypair, slot, vec![operation], vec![], vec![]); // set our block as a final block so the message is sent - self.send_and_finalize(keypair, block); + self.send_and_finalize(keypair, block, None); } - pub fn send_and_finalize(&mut self, keypair: &KeyPair, block: SecureShareBlock) { + pub fn send_and_finalize( + &mut self, + keypair: &KeyPair, + block: SecureShareBlock, + same_thread_parent_creator_keypair: Option, + ) { // store the block in storage self.storage.store_block(block.clone()); let mut finalized_blocks: HashMap = Default::default(); @@ -261,7 +266,9 @@ impl ExecutionTestUniverse { block.id, ExecutionBlockMetadata { same_thread_parent_creator: Some(Address::from_public_key( - &keypair.get_public_key(), + &same_thread_parent_creator_keypair + .unwrap_or_else(|| keypair.clone()) + .get_public_key(), )), storage: Some(self.storage.clone()), }, @@ -324,7 +331,7 @@ fn init_execution_worker( storage: &Storage, execution_controller: Box, ) { - let genesis_keypair = KeyPair::generate(0).unwrap(); + let genesis_keypair: KeyPair = GENESIS_KEY.clone(); let genesis_addr = Address::from_public_key(&genesis_keypair.get_public_key()); let mut finalized_blocks: HashMap = HashMap::new(); let mut block_metadata: PreHashMap = PreHashMap::default(); From 261c44fc239e645fd511ea095c6ded698d565924 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 16:10:50 +0200 Subject: [PATCH 12/32] Fix amount remaining to slash 2 (#4733) * Fix amount_remaining_to_slash_2 calculation * Rename slashed_coins and calculation to improve readability * Fix total_slashed_coins to return value --- massa-execution-worker/src/context.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index 50eeda621f5..18e545d3dde 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -780,7 +780,7 @@ impl ExecutionContext { .try_slash_rolls(denounced_addr, roll_count); // convert slashed rolls to coins (as deferred credits => coins) - let mut slashed_coins = self + let slashed_coins_from_rolls = self .config .roll_price .checked_mul_u64(slashed_rolls.unwrap_or_default()) @@ -802,7 +802,9 @@ impl ExecutionContext { roll_count )) })? - .saturating_sub(slashed_coins); + .saturating_sub(slashed_coins_from_rolls); + + let mut total_slashed_coins = slashed_coins_from_rolls; if amount_remaining_to_slash > Amount::zero() { // There is still an amount to slash for this denunciation so we need to slash @@ -811,19 +813,21 @@ impl ExecutionContext { .speculative_roll_state .try_slash_deferred_credits(&self.slot, denounced_addr, &amount_remaining_to_slash); - slashed_coins = slashed_coins.saturating_add(slashed_coins_in_deferred_credits); + total_slashed_coins = + total_slashed_coins.saturating_add(slashed_coins_in_deferred_credits); + let amount_remaining_to_slash_2 = - slashed_coins.saturating_sub(slashed_coins_in_deferred_credits); + amount_remaining_to_slash.saturating_sub(slashed_coins_in_deferred_credits); if amount_remaining_to_slash_2 > Amount::zero() { // Use saturating_mul_u64 to avoid an error (for just a warn!(..)) warn!("Slashed {} coins (by selling rolls) and {} coins from deferred credits of address: {} but cumulative amount is lower than expected: {} coins", - slashed_coins, slashed_coins_in_deferred_credits, denounced_addr, + slashed_coins_from_rolls, slashed_coins_in_deferred_credits, denounced_addr, self.config.roll_price.saturating_mul_u64(roll_count) ); } } - Ok(slashed_coins) + Ok(total_slashed_coins) } /// Update production statistics of an address. From ac1492403d4c9dad8c6ad0911ab12a525338a28f Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 17:27:21 +0200 Subject: [PATCH 13/32] Fix wrong LedgerChanges::Delete handling (#4737) * Fix bad LedgerChanges::Delete handling * Avoid too much code duplication * Update ledger_db.rs * Fix check --- massa-ledger-worker/Cargo.toml | 4 +-- massa-ledger-worker/src/ledger_db.rs | 41 +++++++++++++++++++--------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/massa-ledger-worker/Cargo.toml b/massa-ledger-worker/Cargo.toml index ab37769ceb0..c755a97bc60 100644 --- a/massa-ledger-worker/Cargo.toml +++ b/massa-ledger-worker/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Massa Labs "] edition = "2021" [features] -test-exports = ["tempfile", "massa_models/test-exports", "massa_ledger_exports/test-exports", "massa_db_worker", "parking_lot"] +test-exports = ["tempfile", "massa_models/test-exports", "massa_ledger_exports/test-exports", "massa_db_worker"] [dependencies] serde_json = {workspace = true} # BOM UPGRADE Revert to "1.0" if problem @@ -15,7 +15,7 @@ massa_models = {workspace = true} massa_serialization = {workspace = true} massa_db_exports = {workspace = true} massa_db_worker = {workspace = true, "optional" = true} -parking_lot = {workspace = true, "features" = ["deadlock_detection"], "optional" = true} +parking_lot = {workspace = true, "features" = ["deadlock_detection"]} [dev-dependencies] massa_signature = {workspace = true} diff --git a/massa-ledger-worker/src/ledger_db.rs b/massa-ledger-worker/src/ledger_db.rs index a95a3199614..8dca6c1c74b 100644 --- a/massa-ledger-worker/src/ledger_db.rs +++ b/massa-ledger-worker/src/ledger_db.rs @@ -3,8 +3,8 @@ //! Module to interact with the disk ledger use massa_db_exports::{ - DBBatch, MassaDirection, MassaIteratorMode, ShareableMassaDBController, CRUD_ERROR, - KEY_SER_ERROR, LEDGER_PREFIX, STATE_CF, + DBBatch, MassaDBController, MassaDirection, MassaIteratorMode, ShareableMassaDBController, + CRUD_ERROR, KEY_SER_ERROR, LEDGER_PREFIX, STATE_CF, }; use massa_ledger_exports::*; use massa_models::amount::AmountDeserializer; @@ -16,6 +16,7 @@ use massa_models::{ use massa_serialization::{ DeserializeError, Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer, }; +use parking_lot::{lock_api::RwLockReadGuard, RawRwLock}; use std::collections::{BTreeSet, HashMap}; use std::fmt::Debug; @@ -286,6 +287,9 @@ impl LedgerDB { fn put_entry(&self, addr: &Address, ledger_entry: LedgerEntry, batch: &mut DBBatch) { let db = self.db.read(); + // Ensures any potential previous entry is fully deleted. + delete_datastore_entries(addr, &db, batch); + // Version //TODO: Get version number from parameters let mut bytes_version = Vec::new(); @@ -456,18 +460,29 @@ impl LedgerDB { .expect(KEY_SER_ERROR); db.delete_key(batch, serialized_key); - // datastore - let key_prefix = datastore_prefix_from_address(addr, &[]); + delete_datastore_entries(addr, &db, batch); + } +} - for (serialized_key, _) in db - .iterator_cf( - STATE_CF, - MassaIteratorMode::From(&key_prefix, MassaDirection::Forward), - ) - .take_while(|(key, _)| key < &end_prefix(&key_prefix).unwrap()) - { - db.delete_key(batch, serialized_key.to_vec()); - } +// Helper function to delete all datastore entries for a given address +// Needs to be called in put entry and delete entry +// Note: This function takes a lock on the DB to avoid multiple reads. +fn delete_datastore_entries( + addr: &Address, + db: &RwLockReadGuard>, + batch: &mut std::collections::BTreeMap, Option>>, +) { + // datastore + let key_prefix = datastore_prefix_from_address(addr, &[]); + + for (serialized_key, _) in db + .iterator_cf( + STATE_CF, + MassaIteratorMode::From(&key_prefix, MassaDirection::Forward), + ) + .take_while(|(key, _)| key < &end_prefix(&key_prefix).unwrap()) + { + db.delete_key(batch, serialized_key.to_vec()); } } From da539b191ee461d98e1621fea214c84bc6dda38d Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Mon, 23 Sep 2024 17:44:39 +0200 Subject: [PATCH 14/32] Add runtime condom middleware (#4741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use CondomLimits struct * Apply limits to wasm modules * Add max_runtime_module_exports * update runtime and serde_yaml * Fix outdated UT --------- Co-authored-by: Leo-Besancon Co-authored-by: Jean-François Signed-off-by: Jean-François --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 12 +- Cargo.lock | 832 ++++++++++++------ Cargo.toml | 4 +- massa-api/src/tests/public.rs | 2 +- massa-async-pool/src/test_exports/mod.rs | 1 - massa-client/src/cmds.rs | 10 +- .../src/test_exports/mod.rs | 2 - massa-execution-exports/src/lib.rs | 2 +- massa-execution-exports/src/settings.rs | 4 +- .../src/test_exports/config.rs | 19 +- .../src/test_exports/mod.rs | 1 - massa-execution-worker/src/controller.rs | 4 +- massa-execution-worker/src/execution.rs | 12 +- massa-execution-worker/src/interface_impl.rs | 6 + massa-factory-exports/src/test_exports/mod.rs | 1 - massa-final-state/src/test_exports/mod.rs | 1 - massa-grpc/src/tests/public.rs | 16 +- massa-grpc/src/tests/stream.rs | 4 +- massa-ledger-worker/src/test_exports/mod.rs | 1 - massa-models/src/config/constants.rs | 49 ++ massa-module-cache/src/config.rs | 4 +- massa-module-cache/src/controller.rs | 26 +- massa-module-cache/src/hd_cache.rs | 41 +- massa-node/src/main.rs | 31 +- massa-pool-exports/src/test_exports/mod.rs | 2 - massa-pos-exports/src/pos_final_state.rs | 2 +- massa-pos-exports/src/test_exports/mod.rs | 1 - .../src/handlers/block_handler/messages.rs | 20 +- .../src/handlers/block_handler/mod.rs | 4 +- .../handlers/endorsement_handler/messages.rs | 12 +- .../handlers/operation_handler/messages.rs | 8 +- .../src/handlers/peer_handler/messages.rs | 12 +- massa-protocol-worker/src/messages.rs | 10 +- massa-versioning/src/versioning_ser_der.rs | 8 +- rust-toolchain.toml | 2 +- 36 files changed, 772 insertions(+), 396 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index fcdf6fb8215..2bf58277123 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -55,7 +55,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acb4384c40f..da2415cf039 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 - uses: Swatinem/rust-cache@v2 with: shared-key: "check" @@ -82,7 +82,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 components: clippy override: true - uses: Swatinem/rust-cache@v2 @@ -191,7 +191,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 override: true - uses: Swatinem/rust-cache@v2 with: @@ -239,7 +239,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 components: rustfmt override: true - uses: actions/checkout@v3 @@ -274,7 +274,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.74.1 + toolchain: 1.75.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 diff --git a/Cargo.lock b/Cargo.lock index f70c9ee664c..f2615370c73 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -175,7 +175,7 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "as-ffi-bindings" version = "0.2.5" -source = "git+https://github.com/massalabs/as-ffi-bindings.git?tag=v0.5.5#a1c338eedc68502e85995123a384261a90cbb409" +source = "git+https://github.com/massalabs/as-ffi-bindings.git?branch=feature/update_wasmer_4_3_4#c0afa48488418a66d872a8c51bc7fa30fe4f8a11" dependencies = [ "anyhow", "wasmer", @@ -203,8 +203,8 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "726535892e8eae7e70657b4c8ea93d26b8553afb1ce617caee529ef96d7dee6c" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", "synstructure", ] @@ -215,8 +215,8 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2777730b2039ac0f95f093556e61b6d26cebed5393ca6f152717777cec3a42ed" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -252,9 +252,9 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -263,9 +263,9 @@ version = "0.1.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdf6721fb0140e4f897002dd086c06f6c27775df19cfe1fccb21181a48fd2c98" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -346,6 +346,12 @@ version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -374,12 +380,12 @@ dependencies = [ "lazycell", "peeking_take_while", "prettyplease", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "regex", "rustc-hash", "shlex", - "syn 2.0.43", + "syn 2.0.75", ] [[package]] @@ -471,8 +477,8 @@ version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7ec4c6f261935ad534c0c22dbef2201b45918860eb1c574b972bd213a76af61" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -487,6 +493,18 @@ name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +dependencies = [ + "serde", +] + +[[package]] +name = "bytesize" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" +dependencies = [ + "serde", +] [[package]] name = "bzip2-sys" @@ -626,9 +644,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -678,7 +696,7 @@ dependencies = [ "rust-ini", "serde", "serde_json", - "toml", + "toml 0.5.11", "yaml-rust", ] @@ -1006,9 +1024,9 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -1039,8 +1057,8 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "strsim", "syn 1.0.109", ] @@ -1053,10 +1071,10 @@ checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "strsim", - "syn 2.0.43", + "syn 2.0.75", ] [[package]] @@ -1066,7 +1084,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" dependencies = [ "darling_core 0.14.4", - "quote 1.0.33", + "quote 1.0.37", "syn 1.0.109", ] @@ -1077,8 +1095,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", - "quote 1.0.33", - "syn 2.0.43", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -1094,6 +1112,20 @@ dependencies = [ "parking_lot_core", ] +[[package]] +name = "dashmap" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.3", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "data-encoding" version = "2.5.0" @@ -1140,8 +1172,39 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling 0.14.4", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", "syn 1.0.109", ] @@ -1211,9 +1274,9 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -1222,12 +1285,27 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0688c2a7f92e427f44895cd63841bff7b29f8d7a1648b9e7e07a4a365b2e1257" +[[package]] +name = "document-features" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb6969eaabd2421f8a2775cfd2471a2b634372b4a25d41e3bd647b79912850a0" +dependencies = [ + "litrs", +] + [[package]] name = "downcast" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1435fa1053d8b2fbbe9be7e97eca7f33d37b28409959813daefc1446a14247f1" +[[package]] +name = "dyn-clone" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125" + [[package]] name = "dynasm" version = "1.2.3" @@ -1238,8 +1316,8 @@ dependencies = [ "byteorder", "lazy_static", "proc-macro-error", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -1313,8 +1391,8 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c134c37760b27a871ba422106eedbb8247da973a09e82558bf26d619c882b159" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -1325,8 +1403,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8ea75f31022cba043afe037940d73684327e915f88f62478e778c3de914cd0a" dependencies = [ "enum_delegate_lib", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -1336,8 +1414,8 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e1f6c3800b304a6be0012039e2a45a322a093539c45ab818d9e6895a39c90fe" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "rand", "syn 1.0.109", ] @@ -1358,9 +1436,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af" dependencies = [ "darling 0.20.3", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -1423,7 +1501,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef033ed5e9bad94e55838ca0ca906db0e043f517adda0c8b79c7a8c66c93c1b5" dependencies = [ "cfg-if", - "rustix 0.38.28", + "rustix 0.38.34", "windows-sys 0.48.0", ] @@ -1433,6 +1511,18 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" +[[package]] +name = "filetime" +version = "0.2.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +dependencies = [ + "cfg-if", + "libc", + "libredox 0.1.3", + "windows-sys 0.59.0", +] + [[package]] name = "fixedbitset" version = "0.4.2" @@ -1554,9 +1644,9 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -1620,13 +1710,15 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.11" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] @@ -1720,7 +1812,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap 2.1.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -1733,15 +1825,6 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash 0.7.7", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -1987,9 +2070,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.1.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -2038,7 +2121,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.28", + "rustix 0.38.34", "windows-sys 0.48.0", ] @@ -2051,15 +2134,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.12.0" @@ -2198,9 +2272,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" dependencies = [ "heck", - "proc-macro-crate 1.3.1", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro-crate", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -2294,9 +2368,9 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.151" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libloading" @@ -2322,7 +2396,18 @@ checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8" dependencies = [ "bitflags 2.4.1", "libc", - "redox_syscall", + "redox_syscall 0.4.1", +] + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.4.1", + "libc", + "redox_syscall 0.5.3", ] [[package]] @@ -2418,6 +2503,12 @@ version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" +[[package]] +name = "litrs" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" + [[package]] name = "lock_api" version = "0.4.11" @@ -2450,7 +2541,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0fbfc88337168279f2e9ae06e157cfed4efd3316e14dc96ed074d4f2e6c5952" dependencies = [ - "quote 1.0.33", + "quote 1.0.37", "syn 1.0.109", ] @@ -2465,10 +2556,10 @@ dependencies = [ ] [[package]] -name = "mach" -version = "0.3.2" +name = "mach2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" dependencies = [ "libc", ] @@ -2579,7 +2670,7 @@ dependencies = [ [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?rev=80352eb9f2a6b90a441cd64433d8874c33fb384f#80352eb9f2a6b90a441cd64433d8874c33fb384f" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#c00be0a2d0976af5a96b59ffba9abc3df2a8e9c9" dependencies = [ "anyhow", "as-ffi-bindings", @@ -3547,8 +3638,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ce75669015c4f47b289fd4d4f56e894e4c96003ffdf3ac51313126f94c6cbb" dependencies = [ "cfg-if", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -3558,9 +3649,9 @@ version = "0.11.2" source = "git+https://github.com/AurelienFT/mockall-wrap?rev=18f88253a000df96cf407dfe4b9158c69c0aeb96#18f88253a000df96cf407dfe4b9158c69c0aeb96" dependencies = [ "cfg-if", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -3743,20 +3834,20 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate 2.0.0", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro-crate", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] name = "object" -version = "0.28.4" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "crc32fast", - "hashbrown 0.11.2", + "hashbrown 0.12.3", "indexmap 1.9.3", "memchr", ] @@ -3857,7 +3948,7 @@ dependencies = [ "cfg-if", "libc", "petgraph", - "redox_syscall", + "redox_syscall 0.4.1", "smallvec", "thread-id", "windows-targets 0.48.5", @@ -3966,9 +4057,9 @@ checksum = "68bd1206e71118b5356dae5ddc61c8b11e28b09ef6a31acbd15ea48a28e0c227" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -3989,7 +4080,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" dependencies = [ "fixedbitset", - "indexmap 2.1.0", + "indexmap 2.4.0", ] [[package]] @@ -4007,9 +4098,9 @@ version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -4128,8 +4219,8 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ - "proc-macro2 1.0.71", - "syn 2.0.43", + "proc-macro2 1.0.86", + "syn 2.0.75", ] [[package]] @@ -4142,15 +4233,6 @@ dependencies = [ "toml_edit 0.19.15", ] -[[package]] -name = "proc-macro-crate" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" -dependencies = [ - "toml_edit 0.20.7", -] - [[package]] name = "proc-macro-error" version = "1.0.4" @@ -4158,8 +4240,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", "version_check", ] @@ -4170,8 +4252,8 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "version_check", ] @@ -4186,9 +4268,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.71" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -4241,7 +4323,7 @@ checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" dependencies = [ "bytes", "heck", - "itertools 0.11.0", + "itertools 0.10.5", "log", "multimap", "once_cell", @@ -4250,7 +4332,7 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.43", + "syn 2.0.75", "tempfile", "which 4.4.2", ] @@ -4262,10 +4344,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", - "itertools 0.11.0", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "itertools 0.10.5", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -4298,8 +4380,8 @@ version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -4334,11 +4416,11 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ - "proc-macro2 1.0.71", + "proc-macro2 1.0.86", ] [[package]] @@ -4448,6 +4530,15 @@ dependencies = [ "bitflags 1.3.2", ] +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.4.1", +] + [[package]] name = "redox_users" version = "0.4.4" @@ -4455,7 +4546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a18479200779601e498ada4e8c1e1f50e3ee19deb0259c25825a98b5603b2cb4" dependencies = [ "getrandom", - "libredox", + "libredox 0.0.1", "thiserror", ] @@ -4517,14 +4608,14 @@ checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "region" -version = "3.0.0" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76e189c2369884dce920945e2ddf79b3dff49e071a167dd1817fa9c4c00d512e" +checksum = "e6b6ebd13bc009aef9cd476c1310d49ac354d36e240cf1bd753290f3dc7199a7" dependencies = [ "bitflags 1.3.2", "libc", - "mach", - "winapi", + "mach2", + "windows-sys 0.52.0", ] [[package]] @@ -4590,8 +4681,8 @@ version = "0.7.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5c462a1328c8e67e4d6dbad1eb0355dd43e8ab432c6e227a43657f16ade5033" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] @@ -4688,9 +4779,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.28" +version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ "bitflags 2.4.1", "errno", @@ -4777,9 +4868,9 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a32af5427251d2e4be14fc151eabe18abb4a7aad5efee7044da9f096c906a43" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -4806,6 +4897,31 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "schemars" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09c024468a378b7e36765cd36702b7a90cc3cba11654f6685c8f233408e89e92" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", + "url", +] + +[[package]] +name = "schemars_derive" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1eee588578aff73f856ab961cd2f79e36bc45d7ded33a7562adba4667aecc0e" +dependencies = [ + "proc-macro2 1.0.86", + "quote 1.0.37", + "serde_derive_internals", + "syn 2.0.75", +] + [[package]] name = "schnellru" version = "0.2.1" @@ -4873,6 +4989,9 @@ name = "semver" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" +dependencies = [ + "serde", +] [[package]] name = "send_wrapper" @@ -4882,9 +5001,9 @@ checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" [[package]] name = "serde" -version = "1.0.193" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] @@ -4900,15 +5019,36 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "serde_cbor" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" +dependencies = [ + "half", + "serde", +] + [[package]] name = "serde_derive" -version = "1.0.193" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", +] + +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -4933,6 +5073,15 @@ dependencies = [ "thiserror", ] +[[package]] +name = "serde_spanned" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +dependencies = [ + "serde", +] + [[package]] name = "serde_with" version = "3.4.0" @@ -4943,7 +5092,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.1.0", + "indexmap 2.4.0", "serde", "serde_json", "serde_with_macros", @@ -4957,18 +5106,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ "darling 0.20.3", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] name = "serde_yaml" -version = "0.9.29" +version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15e0ef66bf939a7c890a0bf6d5a733c70202225f9888a89ed5c62298b019129" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -4981,7 +5130,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" dependencies = [ - "dashmap", + "dashmap 5.5.3", "futures", "lazy_static", "log", @@ -4995,9 +5144,9 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -5220,10 +5369,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ "heck", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "rustversion", - "syn 2.0.43", + "syn 2.0.75", ] [[package]] @@ -5231,7 +5380,7 @@ name = "substruct" version = "0.1.0" source = "git+https://github.com/massalabs/substruct?rev=2fb3ae0dc9d913a0566ce6415eaa7a7ca1690fe1#2fb3ae0dc9d913a0566ce6415eaa7a7ca1690fe1" dependencies = [ - "quote 1.0.33", + "quote 1.0.37", "syn 1.0.109", ] @@ -5258,19 +5407,19 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.43" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee659fb5f3d355364e1f3e5bc10fb82068efbf824a1e9d1c9504244a6469ad53" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "unicode-ident", ] @@ -5286,8 +5435,8 @@ version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", "unicode-xid 0.2.4", ] @@ -5298,6 +5447,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" +[[package]] +name = "tar" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +dependencies = [ + "filetime", + "libc", + "xattr", +] + [[package]] name = "target-lexicon" version = "0.12.12" @@ -5312,8 +5472,8 @@ checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", - "redox_syscall", - "rustix 0.38.28", + "redox_syscall 0.4.1", + "rustix 0.38.34", "windows-sys 0.48.0", ] @@ -5338,9 +5498,9 @@ version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "268026685b2be38d7103e9e507c938a1fcb3d7e6eb15e87870b617bf37b6d581" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -5452,9 +5612,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -5503,11 +5663,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.22.20", +] + [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -5515,31 +5690,33 @@ version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.4.0", "toml_datetime", - "winnow", + "winnow 0.5.31", ] [[package]] name = "toml_edit" -version = "0.20.7" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.4.0", "toml_datetime", - "winnow", + "winnow 0.5.31", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.1.0", + "indexmap 2.4.0", + "serde", + "serde_spanned", "toml_datetime", - "winnow", + "winnow 0.6.18", ] [[package]] @@ -5580,10 +5757,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" dependencies = [ "prettyplease", - "proc-macro2 1.0.71", + "proc-macro2 1.0.86", "prost-build", - "quote 1.0.33", - "syn 2.0.43", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -5701,9 +5878,9 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -5759,8 +5936,8 @@ version = "0.1.0" source = "git+https://github.com/massalabs/transition.git?rev=93fa3bf82f9f5ff421c78536879b7fd1b948ca75#93fa3bf82f9f5ff421c78536879b7fd1b948ca75" dependencies = [ "darling 0.14.4", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", "unsigned-varint 0.7.1", ] @@ -5840,9 +6017,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.10" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" [[package]] name = "unsigned-varint" @@ -5882,6 +6059,7 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", + "serde", ] [[package]] @@ -5908,7 +6086,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aae2faf80ac463422992abf4de234731279c058aaf33171ca70277c98406b124" dependencies = [ - "quote 1.0.33", + "quote 1.0.37", "syn 1.0.109", ] @@ -5968,9 +6146,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", "wasm-bindgen-shared", ] @@ -5992,7 +6170,7 @@ version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ - "quote 1.0.33", + "quote 1.0.37", "wasm-bindgen-macro-support", ] @@ -6002,9 +6180,9 @@ version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6026,9 +6204,9 @@ dependencies = [ [[package]] name = "wasmer" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce45cc009177ca345a6d041f9062305ad467d15e7d41494f5b81ab46d62d7a58" +checksum = "3be5fa49d7d97f83e095f090dcc178d923f2970f588443283cd7a94974ab8cbe" dependencies = [ "bytes", "cfg-if", @@ -6042,6 +6220,7 @@ dependencies = [ "shared-buffer", "target-lexicon", "thiserror", + "tracing", "wasm-bindgen", "wasmer-compiler", "wasmer-compiler-cranelift", @@ -6049,14 +6228,14 @@ dependencies = [ "wasmer-types", "wasmer-vm", "wat", - "winapi", + "windows-sys 0.59.0", ] [[package]] name = "wasmer-compiler" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e044f6140c844602b920deb4526aea3cc9c0d7cf23f00730bb9b2034669f522a" +checksum = "9696a040f935903db440078cd287c0288ab152394122de442fdd21b3eaa8cd2c" dependencies = [ "backtrace", "bytes", @@ -6065,6 +6244,7 @@ dependencies = [ "enumset", "lazy_static", "leb128", + "libc", "memmap2 0.5.10", "more-asserts 0.2.2", "region", @@ -6077,14 +6257,15 @@ dependencies = [ "wasmer-types", "wasmer-vm", "wasmparser", - "winapi", + "windows-sys 0.59.0", + "xxhash-rust", ] [[package]] name = "wasmer-compiler-cranelift" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32ce02358eb44a149d791c1d6648fb7f8b2f99cd55e3c4eef0474653ec8cc889" +checksum = "c5959da148d41a5870d1b18a880e19353add47c0ca95e510061275ea467b6b44" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -6101,9 +6282,9 @@ dependencies = [ [[package]] name = "wasmer-compiler-singlepass" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45dc438250a91d6c0a57912714f8b3b899a0f5bb3a5f1eae5bc97858b7a006a9" +checksum = "5fcaa0fa11a5680268d85b17dc032ec90b63138caa66c8484b8f8f6923d7619f" dependencies = [ "byteorder", "dynasm", @@ -6118,23 +6299,45 @@ dependencies = [ "wasmer-types", ] +[[package]] +name = "wasmer-config" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b4a632496950fde9ad821e195ef1a301440076f7c7d80de55239a140359bcbd" +dependencies = [ + "anyhow", + "bytesize", + "derive_builder", + "hex", + "indexmap 2.4.0", + "schemars", + "semver", + "serde", + "serde_cbor", + "serde_json", + "serde_yaml", + "thiserror", + "toml 0.8.19", + "url", +] + [[package]] name = "wasmer-derive" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c782d80401edb08e1eba206733f7859db6c997fc5a7f5fb44edc3ecd801468f6" +checksum = "6f448efbe12d656ba96d997c9e338f15cd80934c81f2286c2730cb9224d4e41d" dependencies = [ "proc-macro-error", - "proc-macro2 1.0.71", - "quote 1.0.33", + "proc-macro2 1.0.86", + "quote 1.0.37", "syn 1.0.109", ] [[package]] name = "wasmer-middlewares" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66d4f27f76b7b5325476c8851f34920ae562ef0de3c830fdbc4feafff6782187" +checksum = "c4a3c1a7474e5abd75fe6bde4d34fee77c22261b45f157bb769d4a297749463c" dependencies = [ "wasmer", "wasmer-types", @@ -6143,67 +6346,73 @@ dependencies = [ [[package]] name = "wasmer-object" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66dc76ddf602e15266c6cc792dde7592cb3fcfe2bf55b792c51bb400d7a26c0b" +checksum = "70dabd8c3abd7b72a89052f0dd1991aeeabed2a783d474f6c06bca42c8ce73c4" dependencies = [ - "object 0.28.4", + "object 0.29.0", "thiserror", "wasmer-types", ] [[package]] name = "wasmer-types" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd09e80d4d74bb9fd0ce6c3c106b1ceba1a050f9948db9d9b78ae53c172d6157" +checksum = "c8b383ef63005176be3bc2056d3b4078ae1497b324f573d79acbf81036f1c9ec" dependencies = [ "bytecheck", "enum-iterator", "enumset", + "getrandom", + "hex", "indexmap 1.9.3", "more-asserts 0.2.2", "rkyv", + "sha2 0.10.8", "target-lexicon", "thiserror", + "webc", + "xxhash-rust", ] [[package]] name = "wasmer-vm" -version = "4.2.4" +version = "4.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdcd8a4fd36414a7b6a003dbfbd32393bce3e155d715dd877c05c1b7a41d224d" +checksum = "3c371597ec33248e775de641c7a475173fb60f2b5ea085c74d34cee9fad06b83" dependencies = [ "backtrace", "cc", "cfg-if", "corosensei", "crossbeam-queue", - "dashmap", + "dashmap 6.0.1", "derivative", "enum-iterator", "fnv", "indexmap 1.9.3", "lazy_static", "libc", - "mach", + "mach2", "memoffset", "more-asserts 0.2.2", "region", "scopeguard", "thiserror", "wasmer-types", - "winapi", + "windows-sys 0.59.0", ] [[package]] name = "wasmparser" -version = "0.95.0" +version = "0.121.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2ea896273ea99b15132414be1da01ab0d8836415083298ecaffbe308eaac87a" +checksum = "9dbe55c8f9d0dbd25d9447a5a889ff90c0cc3feaa7395310d3d826b2c703eaab" dependencies = [ - "indexmap 1.9.3", - "url", + "bitflags 2.4.1", + "indexmap 2.4.0", + "semver", ] [[package]] @@ -6237,6 +6446,35 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "webc" +version = "6.0.0-rc2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb3e2ccb43d303c5bd48f31db7a129481a9aaa5343d623f92951751df190df81" +dependencies = [ + "anyhow", + "base64 0.22.1", + "bytes", + "cfg-if", + "document-features", + "flate2", + "indexmap 1.9.3", + "libc", + "once_cell", + "semver", + "serde", + "serde_cbor", + "serde_json", + "sha2 0.10.8", + "shared-buffer", + "tar", + "tempfile", + "thiserror", + "toml 0.8.19", + "url", + "wasmer-config", +] + [[package]] name = "webpki-roots" version = "0.25.3" @@ -6252,7 +6490,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.28", + "rustix 0.38.34", ] [[package]] @@ -6264,7 +6502,7 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.28", + "rustix 0.38.34", "windows-sys 0.48.0", ] @@ -6345,7 +6583,16 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", ] [[package]] @@ -6380,17 +6627,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -6407,9 +6655,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -6431,9 +6679,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -6455,9 +6703,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -6479,9 +6733,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -6503,9 +6757,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -6521,9 +6775,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -6545,9 +6799,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" @@ -6558,6 +6812,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "winnow" +version = "0.6.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +dependencies = [ + "memchr", +] + [[package]] name = "wyz" version = "0.5.1" @@ -6585,6 +6848,23 @@ dependencies = [ "time", ] +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys 0.4.12", + "rustix 0.38.34", +] + +[[package]] +name = "xxhash-rust" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a5cbf750400958819fb6178eaa83bee5cd9c29a26a40cc241df8c70fdd46984" + [[package]] name = "yaml-rust" version = "0.4.5" @@ -6618,9 +6898,9 @@ version = "0.7.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] @@ -6638,9 +6918,9 @@ version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ - "proc-macro2 1.0.71", - "quote 1.0.33", - "syn 2.0.43", + "proc-macro2 1.0.86", + "quote 1.0.37", + "syn 2.0.75", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index feaaee062ea..85cc98422c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ massa_wallet = { path = "./massa-wallet" } # Massa projects dependencies massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "38950875a7aa406fedc4f0b8336864e5ff290f2c" } -massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "rev" = "80352eb9f2a6b90a441cd64433d8874c33fb384f" } +massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" } peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" } # Common dependencies @@ -175,7 +175,7 @@ serde = "1.0" serde_json = "1.0" serde_qs = "0.12" serde_with = "3.3" -serde_yaml = "0.9" +serde_yaml = "0.9.34" # 0.9.34+deprecated serial_test = "2.0" sha2 = "=0.10" sha3 = "=0.10" diff --git a/massa-api/src/tests/public.rs b/massa-api/src/tests/public.rs index 36646137abd..05d1ddd5903 100644 --- a/massa-api/src/tests/public.rs +++ b/massa-api/src/tests/public.rs @@ -984,7 +984,7 @@ async fn get_datastore_entries() { .await .unwrap(); - let entry = response.get(0).unwrap(); + let entry = response.first().unwrap(); assert_eq!( entry.candidate_value.as_ref().unwrap(), diff --git a/massa-async-pool/src/test_exports/mod.rs b/massa-async-pool/src/test_exports/mod.rs index 69a116360c9..063eca7e08e 100644 --- a/massa-async-pool/src/test_exports/mod.rs +++ b/massa-async-pool/src/test_exports/mod.rs @@ -4,4 +4,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-client/src/cmds.rs b/massa-client/src/cmds.rs index 0d5805d3b80..897883e6c46 100644 --- a/massa-client/src/cmds.rs +++ b/massa-client/src/cmds.rs @@ -866,7 +866,7 @@ impl Command { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < total { client_warning!("this operation may be rejected due to insufficient balance"); @@ -911,7 +911,7 @@ impl Command { if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee || roll_count > info.candidate_roll_count @@ -948,7 +948,7 @@ impl Command { if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee { client_warning!("this operation may be rejected due to insufficient balance"); @@ -994,7 +994,7 @@ impl Command { let fee = parameters[4].parse::()?; if !json { if let Ok(addresses_info) = client.public.get_addresses(vec![addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < fee.saturating_add(max_coins) { client_warning!("this operation may be rejected due to insufficient balance"); @@ -1052,7 +1052,7 @@ impl Command { if let Ok(addresses_info) = client.public.get_addresses(vec![target_addr]).await { - match addresses_info.get(0) { + match addresses_info.first() { Some(info) => { if info.candidate_balance < total { client_warning!("this operation may be rejected due to insufficient balance"); diff --git a/massa-consensus-exports/src/test_exports/mod.rs b/massa-consensus-exports/src/test_exports/mod.rs index 824722968ba..fb2fa597dfe 100644 --- a/massa-consensus-exports/src/test_exports/mod.rs +++ b/massa-consensus-exports/src/test_exports/mod.rs @@ -1,5 +1,3 @@ // Copyright (c) 2022 MASSA LABS mod config; - -pub use config::*; diff --git a/massa-execution-exports/src/lib.rs b/massa-execution-exports/src/lib.rs index 8d76e76f470..4238e43103c 100644 --- a/massa-execution-exports/src/lib.rs +++ b/massa-execution-exports/src/lib.rs @@ -59,7 +59,7 @@ pub use controller_traits::MockExecutionController; pub use controller_traits::{ExecutionController, ExecutionManager}; pub use error::{ExecutionError, ExecutionQueryError}; pub use event_store::EventStore; -pub use massa_sc_runtime::GasCosts; +pub use massa_sc_runtime::{CondomLimits, GasCosts}; pub use settings::{ExecutionConfig, StorageCostsConstants}; pub use types::{ ExecutedBlockInfo, ExecutionAddressInfo, ExecutionBlockMetadata, ExecutionOutput, diff --git a/massa-execution-exports/src/settings.rs b/massa-execution-exports/src/settings.rs index 49ae83b4559..4998cbc3b24 100644 --- a/massa-execution-exports/src/settings.rs +++ b/massa-execution-exports/src/settings.rs @@ -3,7 +3,7 @@ //! This module provides the structures used to provide configuration parameters to the Execution system use massa_models::amount::Amount; -use massa_sc_runtime::GasCosts; +use massa_sc_runtime::{CondomLimits, GasCosts}; use massa_time::MassaTime; use num::rational::Ratio; use std::path::PathBuf; @@ -102,4 +102,6 @@ pub struct ExecutionConfig { pub max_execution_traces_slot_limit: usize, /// Where to dump blocks pub block_dump_folder_path: PathBuf, + /// Runtime condom middleware limits + pub condom_limits: CondomLimits, } diff --git a/massa-execution-exports/src/test_exports/config.rs b/massa-execution-exports/src/test_exports/config.rs index f42f9bd53d2..063fd5a52a0 100644 --- a/massa-execution-exports/src/test_exports/config.rs +++ b/massa-execution-exports/src/test_exports/config.rs @@ -4,7 +4,7 @@ use crate::{ExecutionConfig, StorageCostsConstants}; use massa_models::config::*; -use massa_sc_runtime::GasCosts; +use massa_sc_runtime::{CondomLimits, GasCosts}; use massa_time::MassaTime; use tempfile::TempDir; @@ -81,6 +81,23 @@ impl Default for ExecutionConfig { broadcast_slot_execution_traces_channel_capacity: 5000, max_execution_traces_slot_limit: 320, block_dump_folder_path, + condom_limits: CondomLimits { + max_exports: Some(100), + max_functions: Some(100), + max_signature_len: Some(100), + max_name_len: Some(100), + max_imports_len: Some(100), + max_table_initializers_len: Some(100), + max_passive_elements_len: Some(100), + max_passive_data_len: Some(100), + max_global_initializers_len: Some(100), + max_function_names_len: Some(100), + max_tables_count: Some(16), + max_memories_len: Some(1), + max_globals_len: Some(100), + max_custom_sections_len: Some(100), + max_custom_sections_data_len: Some(1_000_000), + }, } } } diff --git a/massa-execution-exports/src/test_exports/mod.rs b/massa-execution-exports/src/test_exports/mod.rs index ec2eab01eb7..87922d29fb7 100644 --- a/massa-execution-exports/src/test_exports/mod.rs +++ b/massa-execution-exports/src/test_exports/mod.rs @@ -14,4 +14,3 @@ //! with an execution worker within tests. mod config; -pub use config::*; diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 1bd253f4d8a..02d017b5c08 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -236,7 +236,7 @@ impl ExecutionController for ExecutionControllerImpl { ExecutionQueryRequestItem::OpExecutionStatusCandidate(id) => { let (speculative_v, _final_v) = execution_lock .get_ops_exec_status(&[id]) - .get(0) + .first() .map(|(s_v, f_v)| (*s_v, *f_v)) .expect("expected one return value"); match speculative_v { @@ -254,7 +254,7 @@ impl ExecutionController for ExecutionControllerImpl { ExecutionQueryRequestItem::OpExecutionStatusFinal(id) => { let (_speculative_v, final_v) = execution_lock .get_ops_exec_status(&[id]) - .get(0) + .first() .map(|(s_v, f_v)| (*s_v, *f_v)) .expect("expected one return value"); match final_v { diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index e884a58f145..97b892057cf 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -179,6 +179,7 @@ impl ExecutionState { hd_cache_size: config.hd_cache_size, snip_amount: config.snip_amount, max_module_length: config.max_bytecode_size, + condom_limits: config.condom_limits.clone(), }))); // Create an empty placeholder execution context, with shared atomic access @@ -970,6 +971,7 @@ impl ExecutionState { module, *max_gas, self.config.gas_costs.clone(), + self.config.condom_limits.clone(), ) .map_err(|error| ExecutionError::VMError { context: "ExecuteSC".to_string(), @@ -1070,6 +1072,7 @@ impl ExecutionState { param, max_gas, self.config.gas_costs.clone(), + self.config.condom_limits.clone(), ); match response { Ok(Response { init_gas_cost, .. }) @@ -1195,6 +1198,7 @@ impl ExecutionState { &message.function_params, message.max_gas, self.config.gas_costs.clone(), + self.config.condom_limits.clone(), ); match response { Ok(res) => { @@ -1807,7 +1811,7 @@ impl ExecutionState { let call_stack_addr = context.get_call_stack(); // transfer fee - if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.get(0)) { + if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.first()) { context.transfer_coins(Some(*addr), None, fee, false)?; } } @@ -1824,6 +1828,7 @@ impl ExecutionState { module, req.max_gas, self.config.gas_costs.clone(), + self.config.condom_limits.clone(), ) .map_err(|error| ExecutionError::VMError { context: "ReadOnlyExecutionTarget::BytecodeExecution".to_string(), @@ -1852,13 +1857,13 @@ impl ExecutionState { let call_stack_addr = context.get_call_stack(); // transfer fee - if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.get(0)) { + if let (Some(fee), Some(addr)) = (req.fee, call_stack_addr.first()) { context.transfer_coins(Some(*addr), None, fee, false)?; } // transfer coins if let (Some(coins), Some(from), Some(to)) = - (req.coins, call_stack_addr.get(0), call_stack_addr.get(1)) + (req.coins, call_stack_addr.first(), call_stack_addr.get(1)) { context.transfer_coins(Some(*from), Some(*to), coins, false)?; } @@ -1878,6 +1883,7 @@ impl ExecutionState { ¶meter, req.max_gas, self.config.gas_costs.clone(), + self.config.condom_limits.clone(), ); match response { diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index c1a2648f4dd..1ccd389f3d4 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -130,6 +130,7 @@ impl InterfaceImpl { hd_cache_size: config.hd_cache_size, snip_amount: config.snip_amount, max_module_length: config.max_bytecode_size, + condom_limits: config.condom_limits.clone(), }))); // create an empty default store @@ -1701,6 +1702,11 @@ impl Interface for InterfaceImpl { } } } + + /// Interface version to sync with the runtime for its versioning + fn get_interface_version(&self) -> Result { + Ok(0) + } } #[cfg(test)] diff --git a/massa-factory-exports/src/test_exports/mod.rs b/massa-factory-exports/src/test_exports/mod.rs index 27fe6c27396..bbf23fc9ee6 100644 --- a/massa-factory-exports/src/test_exports/mod.rs +++ b/massa-factory-exports/src/test_exports/mod.rs @@ -3,5 +3,4 @@ mod config; mod tools; -pub use config::*; pub use tools::*; diff --git a/massa-final-state/src/test_exports/mod.rs b/massa-final-state/src/test_exports/mod.rs index eae336d5a43..b40738d0768 100644 --- a/massa-final-state/src/test_exports/mod.rs +++ b/massa-final-state/src/test_exports/mod.rs @@ -5,5 +5,4 @@ mod config; mod mock; -pub use config::*; pub use mock::*; diff --git a/massa-grpc/src/tests/public.rs b/massa-grpc/src/tests/public.rs index d9941ce4ae9..4881aeacb2f 100644 --- a/massa-grpc/src/tests/public.rs +++ b/massa-grpc/src/tests/public.rs @@ -142,7 +142,7 @@ async fn get_operations() { let op_type = response .wrapped_operations - .get(0) + .first() .unwrap() .clone() .operation @@ -195,7 +195,7 @@ async fn get_blocks() { .unwrap() .into_inner(); - let s = result.wrapped_blocks.get(0).unwrap().clone().status; + let s = result.wrapped_blocks.first().unwrap().clone().status; assert_eq!(s, BlockStatus::Final as i32); stop_handle.stop(); @@ -328,7 +328,7 @@ async fn get_datastore_entries() { .unwrap() .into_inner(); - let data = result.datastore_entries.get(0).unwrap(); + let data = result.datastore_entries.first().unwrap(); // TODO candidate value should be an option in the api : issue #4427 assert!(data.candidate_value.is_empty()); assert_eq!(data.final_value, "toto".as_bytes()); @@ -539,7 +539,7 @@ async fn get_endorsements() { .into_inner(); assert_eq!(result.wrapped_endorsements.len(), 1); - let endorsement = result.wrapped_endorsements.get(0).unwrap(); + let endorsement = result.wrapped_endorsements.first().unwrap(); assert!(endorsement.is_final); assert!(endorsement.in_blocks.contains(&block_id.to_string())); @@ -583,7 +583,7 @@ async fn get_next_block_best_parents() { .into_inner(); assert_eq!(result.block_parents.len(), 2); - let parent = result.block_parents.get(0).unwrap(); + let parent = result.block_parents.first().unwrap(); assert_eq!( parent.block_id, "B1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC".to_string() @@ -651,7 +651,7 @@ async fn get_sc_execution_events() { .unwrap() .into_inner(); - let event = result.events.get(0).unwrap(); + let event = result.events.first().unwrap(); assert_eq!(event.data, "massa".as_bytes().to_vec()); assert!(event.context.is_some()); let context = event.context.as_ref().unwrap(); @@ -885,7 +885,7 @@ async fn get_selector_draws() { assert_eq!(result.draws.len(), 2); let slots: &Vec = result.draws.as_ref(); - let slot = slots.get(0).unwrap(); + let slot = slots.first().unwrap(); assert!(slot.slot.is_some()); assert!(!slot.endorsement_draws.is_empty()); assert!(slot.block_producer.is_some()); @@ -1159,7 +1159,7 @@ async fn search_blocks() { .unwrap() .into_inner(); - let block_result = result.block_infos.get(0).unwrap(); + let block_result = result.block_infos.first().unwrap(); assert_eq!(block_result.block_id, block_op.id.to_string()); // search address + slot range diff --git a/massa-grpc/src/tests/stream.rs b/massa-grpc/src/tests/stream.rs index 97935bbf2c5..286900bcf54 100644 --- a/massa-grpc/src/tests/stream.rs +++ b/massa-grpc/src/tests/stream.rs @@ -1280,7 +1280,7 @@ async fn send_operations_low_fee() { let keypair = KeyPair::generate(0).unwrap(); // Note: expire_period is set to be higher than current slot (which is computed from config genesis timestamp) // CHeck send_operation.rs where last_slot value is computed - let op2 = create_operation_with_expire_period(&keypair, 1950000); + let op2 = create_operation_with_expire_period(&keypair, 11950000); let mut buffer: Vec = Vec::new(); SecureShareSerializer::new() .serialize(&op2, &mut buffer) @@ -1412,7 +1412,7 @@ async fn send_operations() { // Note: expire_period is set to be higher than current slot (which is computed from config genesis timestamp) // CHeck send_operation.rs where last_slot value is computed - let op2 = create_operation_with_expire_period(&keypair, 1950000); + let op2 = create_operation_with_expire_period(&keypair, 11950000); let mut buffer: Vec = Vec::new(); SecureShareSerializer::new() .serialize(&op2, &mut buffer) diff --git a/massa-ledger-worker/src/test_exports/mod.rs b/massa-ledger-worker/src/test_exports/mod.rs index 6519f517906..95d2d7ae437 100644 --- a/massa-ledger-worker/src/test_exports/mod.rs +++ b/massa-ledger-worker/src/test_exports/mod.rs @@ -4,4 +4,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-models/src/config/constants.rs b/massa-models/src/config/constants.rs index f3469713880..187a61dcb67 100644 --- a/massa-models/src/config/constants.rs +++ b/massa-models/src/config/constants.rs @@ -201,6 +201,55 @@ pub const MAX_FUNCTION_NAME_LENGTH: u16 = u16::MAX; pub const MAX_PARAMETERS_SIZE: u32 = 10_000_000; /// Maximum length of `rng_seed` in thread cycle pub const MAX_RNG_SEED_LENGTH: u32 = PERIODS_PER_CYCLE.saturating_mul(THREAD_COUNT as u64) as u32; + +/// CondomMiddleware limits +/// see test_condom_middleware_calibrate in massa-sc-runtime for origin of +/// values. +/// Maximum number of function defined in a smart contract +const MAX_RUNTIME_MODULE_DEFINED_FUNCTIONS: usize = 512; +/// Maximum number of function used by a smart contract +pub const MAX_RUNTIME_MODULE_FUNCTIONS: usize = + MAX_RUNTIME_MODULE_DEFINED_FUNCTIONS + MAX_RUNTIME_MODULE_FUNCTION_IMPORTS; +/// Maximum number of arguments to a function +const MAX_RUNTIME_MODULE_FUNCTION_ARGS: usize = 64; +/// Maximum number of value a function can return +const MAX_RUNTIME_MODULE_FUNCTION_RETURN_VALUES: usize = 8; +/// Maximum signature length (total number of arguments and return values) for a +/// function of a smart contract module +pub const MAX_RUNTIME_MODULE_SIGNATURE_LEN: usize = + MAX_RUNTIME_MODULE_FUNCTION_ARGS + MAX_RUNTIME_MODULE_FUNCTION_RETURN_VALUES; +/// Maximum length for the name of a function defined in a smart contract +pub const MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN: usize = 256; +/// Maximum length for the name of a smart contract +pub const MAX_RUNTIME_MODULE_NAME_LEN: usize = 256; +/// Maximum number of custom section data +pub const MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN: usize = 1; +/// Maximum length for the custom section data +pub const MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN: usize = 1_000_000; +/// Maximum number of functions a module can import +const MAX_RUNTIME_MODULE_FUNCTION_IMPORTS: usize = 256; +/// Maximum number of memory a module can import +const MAX_RUNTIME_MODULE_MEMORY_IMPORTS: usize = 1; +/// Maximum number of elements a module can import +pub const MAX_RUNTIME_MODULE_IMPORTS: usize = + MAX_RUNTIME_MODULE_FUNCTION_IMPORTS + MAX_RUNTIME_MODULE_MEMORY_IMPORTS; +/// Maximum number of table initializer in a smart contract +pub const MAX_RUNTIME_MODULE_TABLE_INITIALIZER: usize = MAX_RUNTIME_MODULE_DEFINED_FUNCTIONS; +/// Maximum number of passive element in a smart contract +pub const MAX_RUNTIME_MODULE_PASSIVE_ELEMENT: usize = MAX_RUNTIME_MODULE_DEFINED_FUNCTIONS; +/// Maximum number of passive data in a smart contract +pub const MAX_RUNTIME_MODULE_PASSIVE_DATA: usize = 512; +/// Maximum number of global initializer in a smart contract +pub const MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER: usize = 512; +/// Maximum number of table in a smart contract +pub const MAX_RUNTIME_MODULE_TABLE: usize = 16; +/// Maximum number of memories in a smart contract +/// - only 1 supported so far (cf specification) +pub const MAX_RUNTIME_MODULE_MEMORIES: usize = 1; +/// Maximum number of exports for a smart contract module (function and globals) +pub const MAX_RUNTIME_MODULE_EXPORTS: usize = + MAX_RUNTIME_MODULE_DEFINED_FUNCTIONS + MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER; + // *********************** // Bootstrap constants // diff --git a/massa-module-cache/src/config.rs b/massa-module-cache/src/config.rs index 0d202e7d418..48f3c9b82d3 100644 --- a/massa-module-cache/src/config.rs +++ b/massa-module-cache/src/config.rs @@ -1,4 +1,4 @@ -use massa_sc_runtime::GasCosts; +use massa_sc_runtime::{CondomLimits, GasCosts}; use std::path::PathBuf; pub struct ModuleCacheConfig { @@ -16,4 +16,6 @@ pub struct ModuleCacheConfig { pub snip_amount: usize, /// Maximum length of a module pub max_module_length: u64, + /// Runtime condom middleware limits + pub condom_limits: CondomLimits, } diff --git a/massa-module-cache/src/controller.rs b/massa-module-cache/src/controller.rs index 1362970e1a6..18d12ea3935 100644 --- a/massa-module-cache/src/controller.rs +++ b/massa-module-cache/src/controller.rs @@ -41,7 +41,12 @@ impl ModuleCache { /// Internal function to compile and build `ModuleInfo` fn compile_cached(&mut self, bytecode: &[u8], hash: Hash) -> ModuleInfo { - match RuntimeModule::new(bytecode, self.cfg.gas_costs.clone(), Compiler::CL) { + match RuntimeModule::new( + bytecode, + self.cfg.gas_costs.clone(), + Compiler::CL, + self.cfg.condom_limits.clone(), + ) { Ok(module) => { debug!("compilation of module {} succeeded", hash); ModuleInfo::Module(module) @@ -57,7 +62,11 @@ impl ModuleCache { /// Save a new or an already existing module in the cache pub fn save_module(&mut self, bytecode: &[u8]) { let hash = Hash::compute_from(bytecode); - if let Some(hd_module_info) = self.hd_cache.get(hash, self.cfg.gas_costs.clone()) { + if let Some(hd_module_info) = self.hd_cache.get( + hash, + self.cfg.gas_costs.clone(), + self.cfg.condom_limits.clone(), + ) { debug!("save_module: {} present in hd", hash); self.lru_cache.insert(hash, hd_module_info); } else if let Some(lru_module_info) = self.lru_cache.get(hash) { @@ -110,7 +119,11 @@ impl ModuleCache { if let Some(lru_module_info) = self.lru_cache.get(hash) { debug!("load_module: {} present in lru", hash); lru_module_info - } else if let Some(hd_module_info) = self.hd_cache.get(hash, self.cfg.gas_costs.clone()) { + } else if let Some(hd_module_info) = self.hd_cache.get( + hash, + self.cfg.gas_costs.clone(), + self.cfg.condom_limits.clone(), + ) { debug!("load_module: {} missing in lru but present in hd", hash); self.lru_cache.insert(hash, hd_module_info.clone()); hd_module_info @@ -181,7 +194,12 @@ impl ModuleCache { "Provided gas {} is lower than the base instance creation gas cost {}", limit, self.cfg.gas_costs.max_instance_cost )))?; - let module = RuntimeModule::new(bytecode, self.cfg.gas_costs.clone(), Compiler::SP)?; + let module = RuntimeModule::new( + bytecode, + self.cfg.gas_costs.clone(), + Compiler::SP, + self.cfg.condom_limits.clone(), + )?; Ok(module) } } diff --git a/massa-module-cache/src/hd_cache.rs b/massa-module-cache/src/hd_cache.rs index 5eb59cad25d..b5a8ed91ff0 100644 --- a/massa-module-cache/src/hd_cache.rs +++ b/massa-module-cache/src/hd_cache.rs @@ -2,7 +2,7 @@ use crate::types::{ ModuleInfo, ModuleMetadata, ModuleMetadataDeserializer, ModuleMetadataSerializer, }; use massa_hash::Hash; -use massa_sc_runtime::{GasCosts, RuntimeModule}; +use massa_sc_runtime::{CondomLimits, GasCosts, RuntimeModule}; use massa_serialization::{DeserializeError, Deserializer, Serializer}; use rand::RngCore; use rocksdb::{Direction, IteratorMode, WriteBatch, DB}; @@ -137,7 +137,12 @@ impl HDCache { } /// Retrieve a module - pub fn get(&self, hash: Hash, gas_costs: GasCosts) -> Option { + pub fn get( + &self, + hash: Hash, + gas_costs: GasCosts, + condom_limits: CondomLimits, + ) -> Option { let mut iterator = self .db .iterator(IteratorMode::From(&module_key!(hash), Direction::Forward)); @@ -153,9 +158,13 @@ impl HDCache { if let ModuleMetadata::Invalid(err_msg) = metadata { return Some(ModuleInfo::Invalid(err_msg)); } - let module = - RuntimeModule::deserialize(&ser_module, gas_costs.max_instance_cost, gas_costs) - .expect(MOD_DESER_ERROR); + let module = RuntimeModule::deserialize( + &ser_module, + gas_costs.max_instance_cost, + gas_costs, + condom_limits, + ) + .expect(MOD_DESER_ERROR); let result = match metadata { ModuleMetadata::Invalid(err_msg) => ModuleInfo::Invalid(err_msg), ModuleMetadata::NotExecuted => ModuleInfo::Module(module), @@ -233,7 +242,13 @@ mod tests { 0x70, 0x30, ]; ModuleInfo::Module( - RuntimeModule::new(&bytecode, GasCosts::default(), Compiler::CL).unwrap(), + RuntimeModule::new( + &bytecode, + GasCosts::default(), + Compiler::CL, + CondomLimits::default(), + ) + .unwrap(), ) } @@ -251,18 +266,23 @@ mod tests { let init_cost = 100; let gas_costs = GasCosts::default(); + let condom_limits = CondomLimits::default(); cache.insert(hash, module); - let cached_module_v1 = cache.get(hash, gas_costs.clone()).unwrap(); + let cached_module_v1 = cache + .get(hash, gas_costs.clone(), condom_limits.clone()) + .unwrap(); assert!(matches!(cached_module_v1, ModuleInfo::Module(_))); cache.set_init_cost(hash, init_cost); - let cached_module_v2 = cache.get(hash, gas_costs.clone()).unwrap(); + let cached_module_v2 = cache + .get(hash, gas_costs.clone(), condom_limits.clone()) + .unwrap(); assert!(matches!(cached_module_v2, ModuleInfo::ModuleAndDelta(_))); let err_msg = "test_error".to_string(); cache.set_invalid(hash, err_msg.clone()); - let cached_module_v3 = cache.get(hash, gas_costs).unwrap(); + let cached_module_v3 = cache.get(hash, gas_costs, condom_limits.clone()).unwrap(); let ModuleInfo::Invalid(res_err) = cached_module_v3 else { panic!("expected ModuleInfo::Invalid"); }; @@ -299,6 +319,7 @@ mod tests { let module = make_default_module_info(); let gas_costs = GasCosts::default(); + let condom_limits = CondomLimits::default(); for count in 0..cache.max_entry_count { let key = Hash::compute_from(count.to_string().as_bytes()); @@ -309,7 +330,7 @@ mod tests { let mut rbytes = [0u8; 16]; thread_rng().fill_bytes(&mut rbytes); let get_key = Hash::compute_from(&rbytes); - let cached_module = cache.get(get_key, gas_costs.clone()); + let cached_module = cache.get(get_key, gas_costs.clone(), condom_limits.clone()); assert!(cached_module.is_none()); } } diff --git a/massa-node/src/main.rs b/massa-node/src/main.rs index 1709fd5c684..97edbff221b 100644 --- a/massa-node/src/main.rs +++ b/massa-node/src/main.rs @@ -33,7 +33,8 @@ use massa_db_exports::{MassaDBConfig, MassaDBController}; use massa_db_worker::MassaDB; use massa_executed_ops::{ExecutedDenunciationsConfig, ExecutedOpsConfig}; use massa_execution_exports::{ - ExecutionChannels, ExecutionConfig, ExecutionManager, GasCosts, StorageCostsConstants, + CondomLimits, ExecutionChannels, ExecutionConfig, ExecutionManager, GasCosts, + StorageCostsConstants, }; use massa_execution_worker::start_execution_worker; #[cfg(all( @@ -87,7 +88,13 @@ use massa_models::config::constants::{ use massa_models::config::{ BASE_OPERATION_GAS_COST, CHAINID, KEEP_EXECUTED_HISTORY_EXTRA_PERIODS, MAX_BOOTSTRAP_FINAL_STATE_PARTS_SIZE, MAX_BOOTSTRAP_VERSIONING_ELEMENTS_SIZE, - MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, POOL_CONTROLLER_DENUNCIATIONS_CHANNEL_SIZE, + MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN, + MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN, MAX_RUNTIME_MODULE_EXPORTS, + MAX_RUNTIME_MODULE_FUNCTIONS, MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN, + MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER, MAX_RUNTIME_MODULE_IMPORTS, MAX_RUNTIME_MODULE_MEMORIES, + MAX_RUNTIME_MODULE_NAME_LEN, MAX_RUNTIME_MODULE_PASSIVE_DATA, + MAX_RUNTIME_MODULE_PASSIVE_ELEMENT, MAX_RUNTIME_MODULE_SIGNATURE_LEN, MAX_RUNTIME_MODULE_TABLE, + MAX_RUNTIME_MODULE_TABLE_INITIALIZER, POOL_CONTROLLER_DENUNCIATIONS_CHANNEL_SIZE, POOL_CONTROLLER_ENDORSEMENTS_CHANNEL_SIZE, POOL_CONTROLLER_OPERATIONS_CHANNEL_SIZE, }; use massa_models::slot::Slot; @@ -461,6 +468,25 @@ async fn launch( ) .expect("Failed to load gas costs"); + // Limits imposed to wasm files so the compilation phase is smooth + let condom_limits = CondomLimits { + max_exports: Some(MAX_RUNTIME_MODULE_EXPORTS), + max_functions: Some(MAX_RUNTIME_MODULE_FUNCTIONS), + max_signature_len: Some(MAX_RUNTIME_MODULE_SIGNATURE_LEN), + max_name_len: Some(MAX_RUNTIME_MODULE_NAME_LEN), + max_imports_len: Some(MAX_RUNTIME_MODULE_IMPORTS), + max_table_initializers_len: Some(MAX_RUNTIME_MODULE_TABLE_INITIALIZER), + max_passive_elements_len: Some(MAX_RUNTIME_MODULE_PASSIVE_ELEMENT), + max_passive_data_len: Some(MAX_RUNTIME_MODULE_PASSIVE_DATA), + max_global_initializers_len: Some(MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER), + max_function_names_len: Some(MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN), + max_tables_count: Some(MAX_RUNTIME_MODULE_TABLE), + max_memories_len: Some(MAX_RUNTIME_MODULE_MEMORIES), + max_globals_len: Some(MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER), + max_custom_sections_len: Some(MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN), + max_custom_sections_data_len: Some(MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN), + }; + let block_dump_folder_path = SETTINGS.block_dump.block_dump_folder_path.clone(); if !block_dump_folder_path.exists() { info!("Current folder: {:?}", std::env::current_dir().unwrap()); @@ -518,6 +544,7 @@ async fn launch( .broadcast_slot_execution_traces_channel_capacity, max_execution_traces_slot_limit: SETTINGS.execution.execution_traces_limit, block_dump_folder_path, + condom_limits, }; let execution_channels = ExecutionChannels { diff --git a/massa-pool-exports/src/test_exports/mod.rs b/massa-pool-exports/src/test_exports/mod.rs index 824722968ba..fb2fa597dfe 100644 --- a/massa-pool-exports/src/test_exports/mod.rs +++ b/massa-pool-exports/src/test_exports/mod.rs @@ -1,5 +1,3 @@ // Copyright (c) 2022 MASSA LABS mod config; - -pub use config::*; diff --git a/massa-pos-exports/src/pos_final_state.rs b/massa-pos-exports/src/pos_final_state.rs index 4c86f3ce5e8..c7c336edd35 100644 --- a/massa-pos-exports/src/pos_final_state.rs +++ b/massa-pos-exports/src/pos_final_state.rs @@ -1062,7 +1062,7 @@ impl PoSFinalState { let results = db.multi_get_cf(query); - match (results.get(0), results.get(1)) { + match (results.first(), results.get(1)) { (Some(Ok(Some(serialized_fail))), Some(Ok(Some(serialized_success)))) => { let (_, fail) = self .cycle_info_deserializer diff --git a/massa-pos-exports/src/test_exports/mod.rs b/massa-pos-exports/src/test_exports/mod.rs index 0266e18e52a..2983f8c62b5 100644 --- a/massa-pos-exports/src/test_exports/mod.rs +++ b/massa-pos-exports/src/test_exports/mod.rs @@ -5,4 +5,3 @@ mod bootstrap; mod config; pub use bootstrap::*; -pub use config::*; diff --git a/massa-protocol-worker/src/handlers/block_handler/messages.rs b/massa-protocol-worker/src/handlers/block_handler/messages.rs index 0c435f05cf7..833a88accf5 100644 --- a/massa-protocol-worker/src/handlers/block_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/block_handler/messages.rs @@ -7,9 +7,7 @@ use massa_models::{ }, secure_share::{SecureShareDeserializer, SecureShareSerializer}, }; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, sequence::tuple, @@ -120,12 +118,8 @@ impl Serializer for BlockMessageSerializer { value: &BlockMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { BlockMessage::Header(header) => { self.secure_share_serializer.serialize(header, buffer)?; @@ -275,9 +269,7 @@ impl Deserializer for BlockMessageDeserializer { "Failed BlockDataRequest deserialization", tuple(( context("Failed BlockId deserialization", |input| { - self.block_id_deserializer - .deserialize(input) - .map(|(rest, id)| (rest, id)) + self.block_id_deserializer.deserialize(input) }), context("Failed infos deserialization", |input| { let (rest, raw_id) = self.id_deserializer.deserialize(input)?; @@ -317,9 +309,7 @@ impl Deserializer for BlockMessageDeserializer { "Failed BlockDataResponse deserialization", tuple(( context("Failed BlockId deserialization", |input| { - self.block_id_deserializer - .deserialize(input) - .map(|(rest, id)| (rest, id)) + self.block_id_deserializer.deserialize(input) }), context("Failed infos deserialization", |input| { let (rest, raw_id) = self.id_deserializer.deserialize(input)?; diff --git a/massa-protocol-worker/src/handlers/block_handler/mod.rs b/massa-protocol-worker/src/handlers/block_handler/mod.rs index 5beda278b51..b750cb3757d 100644 --- a/massa-protocol-worker/src/handlers/block_handler/mod.rs +++ b/massa-protocol-worker/src/handlers/block_handler/mod.rs @@ -27,9 +27,7 @@ mod retrieval; pub(crate) use messages::{BlockMessage, BlockMessageSerializer}; #[cfg(test)] -pub use messages::{ - AskForBlockInfo, BlockInfoReply, BlockMessageDeserializer, BlockMessageDeserializerArgs, -}; +pub use messages::{AskForBlockInfo, BlockInfoReply}; use super::{ endorsement_handler::{ diff --git a/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs b/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs index 18350203756..2e36072e9d4 100644 --- a/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/endorsement_handler/messages.rs @@ -2,9 +2,7 @@ use massa_models::{ endorsement::{Endorsement, EndorsementDeserializer, SecureShareEndorsement}, secure_share::{SecureShareDeserializer, SecureShareSerializer}, }; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, multi::length_count, @@ -56,12 +54,8 @@ impl Serializer for EndorsementMessageSerializer { value: &EndorsementMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { EndorsementMessage::Endorsements(endorsements) => { self.length_endorsements_serializer diff --git a/massa-protocol-worker/src/handlers/operation_handler/messages.rs b/massa-protocol-worker/src/handlers/operation_handler/messages.rs index 3e07359cebe..40663164fea 100644 --- a/massa-protocol-worker/src/handlers/operation_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/operation_handler/messages.rs @@ -63,12 +63,8 @@ impl Serializer for OperationMessageSerializer { value: &OperationMessage, buffer: &mut Vec, ) -> Result<(), SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { OperationMessage::OperationsAnnouncement(operations) => { self.operation_prefix_ids_serializer diff --git a/massa-protocol-worker/src/handlers/peer_handler/messages.rs b/massa-protocol-worker/src/handlers/peer_handler/messages.rs index 66f9e2afbd3..ac6a62df467 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/messages.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/messages.rs @@ -2,9 +2,7 @@ use std::{collections::HashMap, net::SocketAddr, ops::Bound::Included}; use massa_models::serialization::{IpAddrDeserializer, IpAddrSerializer}; use massa_protocol_exports::{PeerId, PeerIdDeserializer, PeerIdSerializer}; -use massa_serialization::{ - Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, -}; +use massa_serialization::{Deserializer, Serializer, U64VarIntDeserializer, U64VarIntSerializer}; use nom::{ error::{context, ContextError, ParseError}, multi::length_count, @@ -65,12 +63,8 @@ impl Serializer for PeerManagementMessageSerializer { value: &PeerManagementMessage, buffer: &mut Vec, ) -> Result<(), massa_serialization::SerializeError> { - self.id_serializer.serialize( - &MessageTypeId::from(value).try_into().map_err(|_| { - SerializeError::GeneralError(String::from("Failed to serialize id")) - })?, - buffer, - )?; + self.id_serializer + .serialize(&MessageTypeId::from(value).into(), buffer)?; match value { PeerManagementMessage::NewPeerConnected((peer_id, listeners)) => { self.peer_id_serializer.serialize(peer_id, buffer)?; diff --git a/massa-protocol-worker/src/messages.rs b/massa-protocol-worker/src/messages.rs index 20ea6c4b7ef..63807fdeb19 100644 --- a/massa-protocol-worker/src/messages.rs +++ b/massa-protocol-worker/src/messages.rs @@ -137,15 +137,7 @@ impl PeerNetMessagesSerializer for MessagesSerializer { /// Serialize the message fn serialize(&self, message: &Message, buffer: &mut Vec) -> PeerNetResult<()> { self.id_serializer - .serialize( - &MessageTypeId::from(message).try_into().map_err(|_| { - PeerNetError::HandlerError.error( - "MessagesSerializer", - Some(String::from("Failed to serialize id")), - ) - })?, - buffer, - ) + .serialize(&MessageTypeId::from(message).into(), buffer) .map_err(|err| { PeerNetError::HandlerError.error( "MessagesHandler", diff --git a/massa-versioning/src/versioning_ser_der.rs b/massa-versioning/src/versioning_ser_der.rs index 339747f516b..463adb7c7a3 100644 --- a/massa-versioning/src/versioning_ser_der.rs +++ b/massa-versioning/src/versioning_ser_der.rs @@ -168,13 +168,7 @@ impl Deserializer for MipInfoDeserializer { tuple(( context("Failed component deserialization", |input| { let (rem, component_) = self.u32_deserializer.deserialize(input)?; - let component = - MipComponent::try_from(component_).map_err(|_| { - nom::Err::Error(ParseError::from_error_kind( - input, - nom::error::ErrorKind::Fail, - )) - })?; + let component = MipComponent::from(component_); IResult::Ok((rem, component)) }), context("Failed component version deserialization", |input| { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 27ae62c5bcb..7897a24d1a1 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.74.1" +channel = "1.75.0" From 149a6e1ab43d59d3696c666438e8cbb3937be4e3 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Mon, 30 Sep 2024 15:56:02 +0200 Subject: [PATCH 15/32] Update rust version to 1.81 (#4750) * Update rust version to 1.81 * Cargo clippy & fmt pass * Cargo clippy & fmt pass 2 * Cargo clippy & fmt pass 3 * Remove commented code --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 12 ++++++------ .github/workflows/link-check.yml | 6 +++--- Cargo.lock | 16 ++++++++++++---- massa-bootstrap/src/lib.rs | 5 ++--- massa-bootstrap/src/messages.rs | 1 + massa-bootstrap/src/server.rs | 6 +----- massa-bootstrap/src/tests/binders.rs | 4 ++-- massa-bootstrap/src/tests/config.rs | 2 +- massa-bootstrap/src/tests/messages.rs | 4 ++-- massa-bootstrap/src/tests/tools.rs | 2 +- massa-client/src/settings.rs | 1 + massa-consensus-worker/src/lib.rs | 1 + massa-consensus-worker/src/state/mod.rs | 5 +++-- massa-execution-worker/src/context.rs | 1 + massa-execution-worker/src/tests/universe.rs | 1 + massa-models/src/clique.rs | 2 -- massa-models/src/ledger.rs | 1 - massa-node/src/settings.rs | 2 ++ .../src/handlers/peer_handler/mod.rs | 1 + .../src/handlers/peer_handler/models.rs | 1 + massa-protocol-worker/src/tests/universe.rs | 1 + massa-protocol-worker/src/wrap_network.rs | 1 + massa-storage/src/lib.rs | 1 + massa-versioning/src/versioning.rs | 2 +- massa-versioning/src/versioning_factory.rs | 1 + rust-toolchain.toml | 2 +- 27 files changed, 49 insertions(+), 35 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2bf58277123..8aa01264e3d 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -55,7 +55,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 target: ${{ matrix.target }} override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index da2415cf039..a670405614b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 @@ -57,7 +57,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 - uses: Swatinem/rust-cache@v2 with: shared-key: "check" @@ -82,7 +82,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 components: clippy override: true - uses: Swatinem/rust-cache@v2 @@ -191,7 +191,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 override: true - uses: Swatinem/rust-cache@v2 with: @@ -239,7 +239,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 components: rustfmt override: true - uses: actions/checkout@v3 @@ -274,7 +274,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: 1.75.0 + toolchain: 1.81.0 components: rustfmt override: true - uses: Swatinem/rust-cache@v2 diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 1816c95bf4a..281d0ccb854 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -11,11 +11,11 @@ jobs: markdown-link-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: - node-version: '18' + node-version: 18 - name: Install markdown-link-check run: npm install -g markdown-link-check - name: Check links in markdown files diff --git a/Cargo.lock b/Cargo.lock index f2615370c73..a6a4a86c860 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3765,6 +3765,12 @@ dependencies = [ "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.45" @@ -5525,12 +5531,13 @@ dependencies = [ [[package]] name = "time" -version = "0.3.31" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", + "num-conv", "powerfmt", "serde", "time-core", @@ -5545,10 +5552,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.16" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] diff --git a/massa-bootstrap/src/lib.rs b/massa-bootstrap/src/lib.rs index 62bb3109a4e..2251aa13185 100644 --- a/massa-bootstrap/src/lib.rs +++ b/massa-bootstrap/src/lib.rs @@ -15,9 +15,7 @@ use massa_consensus_exports::bootstrapable_graph::BootstrapableGraph; use massa_final_state::FinalStateController; use massa_protocol_exports::BootstrapPeers; use parking_lot::RwLock; -use std::io::{self, ErrorKind}; use std::sync::Arc; -use std::time::{Duration, Instant}; mod bindings; mod client; @@ -65,7 +63,7 @@ impl GlobalBootstrapState { } } } - +/* trait BindingReadExact: io::Read { /// similar to std::io::Read::read_exact, but with a timeout that is function-global instead of per-individual-read fn read_exact_timeout( @@ -112,3 +110,4 @@ trait BindingReadExact: io::Read { /// Internal helper fn set_read_timeout(&mut self, deadline: Option) -> Result<(), std::io::Error>; } +*/ diff --git a/massa-bootstrap/src/messages.rs b/massa-bootstrap/src/messages.rs index 039de714134..e0cc2fa5669 100644 --- a/massa-bootstrap/src/messages.rs +++ b/massa-bootstrap/src/messages.rs @@ -84,6 +84,7 @@ pub enum BootstrapServerMessage { }, } +#[allow(clippy::to_string_trait_impl)] impl ToString for BootstrapServerMessage { fn to_string(&self) -> String { match self { diff --git a/massa-bootstrap/src/server.rs b/massa-bootstrap/src/server.rs index af51016d1d7..c5d462c3abb 100644 --- a/massa-bootstrap/src/server.rs +++ b/massa-bootstrap/src/server.rs @@ -63,11 +63,7 @@ use crate::{ white_black_list::SharedWhiteBlackList, BootstrapConfig, }; -/// Specifies a common interface that can be used by standard, or mockers -#[cfg_attr(test, mockall::automock)] -pub trait BSEventPoller { - fn poll(&mut self) -> Result; -} + /// Abstraction layer over data produced by the listener, and transported /// over to the worker via a channel diff --git a/massa-bootstrap/src/tests/binders.rs b/massa-bootstrap/src/tests/binders.rs index e52b6c118e1..46ef5b1c699 100644 --- a/massa-bootstrap/src/tests/binders.rs +++ b/massa-bootstrap/src/tests/binders.rs @@ -59,7 +59,7 @@ impl BootstrapClientBinder { } pub(crate) fn test_default_config() -> BootstrapClientConfig { BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, @@ -131,7 +131,7 @@ fn init_server_client_pair() -> (BootstrapServerBinder, BootstrapClientBinder) { server.0, server_keypair.clone(), BootstrapSrvBindCfg { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, thread_count: THREAD_COUNT, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, diff --git a/massa-bootstrap/src/tests/config.rs b/massa-bootstrap/src/tests/config.rs index a443ed1777a..027e07637d7 100644 --- a/massa-bootstrap/src/tests/config.rs +++ b/massa-bootstrap/src/tests/config.rs @@ -48,7 +48,7 @@ impl Default for BootstrapConfig { max_simultaneous_bootstraps: 2, ip_list_max_size: 10, per_ip_min_interval: MassaTime::from_millis(10000), - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, thread_count: THREAD_COUNT, diff --git a/massa-bootstrap/src/tests/messages.rs b/massa-bootstrap/src/tests/messages.rs index 950f3101e88..bccd65fe8db 100644 --- a/massa-bootstrap/src/tests/messages.rs +++ b/massa-bootstrap/src/tests/messages.rs @@ -14,7 +14,7 @@ use massa_serialization::{DeserializeError, Deserializer, Serializer}; #[test] fn test_serialize_bootstrap_server_message() { let config = BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, @@ -147,7 +147,7 @@ fn test_serialize_error_cases_clientmsg() { #[test] fn test_serialize_error_cases_servermsg() { let config = BootstrapClientConfig { - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_listeners_per_peer: MAX_LISTENERS_PER_PEER as u32, endorsement_count: ENDORSEMENT_COUNT, max_advertise_length: MAX_ADVERTISE_LENGTH, diff --git a/massa-bootstrap/src/tests/tools.rs b/massa-bootstrap/src/tests/tools.rs index ddfabd23734..f4615ebbda6 100644 --- a/massa-bootstrap/src/tests/tools.rs +++ b/massa-bootstrap/src/tests/tools.rs @@ -353,7 +353,7 @@ pub fn get_bootstrap_config(bootstrap_public_key: NodeId) -> BootstrapConfig { max_simultaneous_bootstraps: 2, ip_list_max_size: 10, per_ip_min_interval: MassaTime::from_millis(10000), - rate_limit: std::u64::MAX, + rate_limit: u64::MAX, max_datastore_key_length: MAX_DATASTORE_KEY_LENGTH, randomness_size_bytes: BOOTSTRAP_RANDOMNESS_SIZE_BYTES, thread_count: THREAD_COUNT, diff --git a/massa-client/src/settings.rs b/massa-client/src/settings.rs index cd177d7cf88..541a5f52004 100644 --- a/massa-client/src/settings.rs +++ b/massa-client/src/settings.rs @@ -10,6 +10,7 @@ lazy_static::lazy_static! { pub static ref SETTINGS: Settings = build_massa_settings("massa-client", "MASSA_CLIENT"); } +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct Settings { pub default_node: DefaultNode, diff --git a/massa-consensus-worker/src/lib.rs b/massa-consensus-worker/src/lib.rs index 7074c71d037..48e617a34c2 100644 --- a/massa-consensus-worker/src/lib.rs +++ b/massa-consensus-worker/src/lib.rs @@ -22,6 +22,7 @@ //! * If the dependencies are already available, the module checks if it can validate the block and add it to a clique. //! * If it's the second block received for the same slot we save it in order to denounce the creator in the future. //! * If it's the third or more we ignore the block unless we asked for it explicitly as a dependency. +//! //! If a queued block reaches the slot time at which it should be processed, the worker wakes up to check it and trigger, if necessary, the consensus algorithm. //! It then prunes the block graph and the caches. diff --git a/massa-consensus-worker/src/state/mod.rs b/massa-consensus-worker/src/state/mod.rs index 23560ae91cd..07dee3ce7a4 100644 --- a/massa-consensus-worker/src/state/mod.rs +++ b/massa-consensus-worker/src/state/mod.rs @@ -37,6 +37,7 @@ mod stats; mod tick; mod verifications; +#[allow(dead_code)] #[derive(Clone)] pub struct ConsensusState { /// Configuration @@ -70,7 +71,7 @@ pub struct ConsensusState { pub new_final_blocks: PreHashSet, /// Newly stale block mapped to creator and slot pub new_stale_blocks: PreHashMap, - /// time at which the node was launched (used for desynchronization detection) + /// time at which the node was launched (used for de-synchronization detection) pub launch_time: MassaTime, /// Final block stats `(time, creator, is_from_protocol)` pub final_block_stats: VecDeque<(MassaTime, Address, bool)>, @@ -80,7 +81,7 @@ pub struct ConsensusState { pub stale_block_stats: VecDeque, /// the time span considered for stats pub stats_history_timespan: MassaTime, - /// the time span considered for desynchronization detection + /// the time span considered for de-synchronization detection pub stats_desync_detection_timespan: MassaTime, /// blocks we want pub wishlist: PreHashMap>, diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index 18e545d3dde..9039cef4994 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -189,6 +189,7 @@ impl ExecutionContext { /// /// # arguments /// * `final_state`: thread-safe access to the final state. + /// /// Note that this will be used only for reading, never for writing /// /// # returns diff --git a/massa-execution-worker/src/tests/universe.rs b/massa-execution-worker/src/tests/universe.rs index 85b98a0846e..8c1ac11a918 100644 --- a/massa-execution-worker/src/tests/universe.rs +++ b/massa-execution-worker/src/tests/universe.rs @@ -79,6 +79,7 @@ impl ExecutionForeignControllers { } } +#[allow(dead_code)] pub struct ExecutionTestUniverse { pub module_controller: Box, pub storage: Storage, diff --git a/massa-models/src/clique.rs b/massa-models/src/clique.rs index 3fa76c31849..f60ef64b8f5 100644 --- a/massa-models/src/clique.rs +++ b/massa-models/src/clique.rs @@ -1,7 +1,5 @@ // Copyright (c) 2022 MASSA LABS -use core::usize; - use massa_serialization::{ Deserializer, SerializeError, Serializer, U32VarIntDeserializer, U32VarIntSerializer, U64VarIntDeserializer, U64VarIntSerializer, diff --git a/massa-models/src/ledger.rs b/massa-models/src/ledger.rs index f6875eb1b6a..95e85f1c44e 100644 --- a/massa-models/src/ledger.rs +++ b/massa-models/src/ledger.rs @@ -7,7 +7,6 @@ use crate::{ error::ModelsResult as Result, prehash::{PreHashMap, PreHashSet}, }; -use core::usize; use massa_serialization::{ Deserializer, SerializeError, Serializer, U64VarIntDeserializer, U64VarIntSerializer, }; diff --git a/massa-node/src/settings.rs b/massa-node/src/settings.rs index 3ee8de250e2..4d1d443dd39 100644 --- a/massa-node/src/settings.rs +++ b/massa-node/src/settings.rs @@ -91,6 +91,7 @@ pub struct FactorySettings { } /// Pool configuration, read from a file configuration +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct PoolSettings { pub max_operation_pool_size: usize, @@ -194,6 +195,7 @@ pub struct MetricsSettings { } /// Protocol Configuration, read from toml user configuration file +#[allow(dead_code)] #[derive(Debug, Deserialize, Clone)] pub struct ProtocolSettings { /// after `ask_block_timeout` milliseconds we try to ask a block to another node diff --git a/massa-protocol-worker/src/handlers/peer_handler/mod.rs b/massa-protocol-worker/src/handlers/peer_handler/mod.rs index bc531327bbb..7b583e5a3aa 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/mod.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/mod.rs @@ -56,6 +56,7 @@ mod tester; pub(crate) use messages::{PeerManagementMessage, PeerManagementMessageSerializer}; +#[allow(dead_code)] pub struct PeerManagementHandler { pub peer_db: SharedPeerDB, pub thread_join: Option>, diff --git a/massa-protocol-worker/src/handlers/peer_handler/models.rs b/massa-protocol-worker/src/handlers/peer_handler/models.rs index 1bf6209458d..7e3c05f44c8 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/models.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/models.rs @@ -186,6 +186,7 @@ pub enum PeerManagementCmd { Stop, } +#[allow(dead_code)] pub struct PeerManagementChannel { pub msg_sender: MassaSender, pub command_sender: MassaSender, diff --git a/massa-protocol-worker/src/tests/universe.rs b/massa-protocol-worker/src/tests/universe.rs index 96c687434d1..2ae3ce16ffc 100644 --- a/massa-protocol-worker/src/tests/universe.rs +++ b/massa-protocol-worker/src/tests/universe.rs @@ -39,6 +39,7 @@ use num::rational::Ratio; use std::ops::Bound::Included; use tracing::{debug, log::warn}; +#[allow(dead_code)] pub struct ProtocolTestUniverse { pub module_controller: Box, module_manager: Box, diff --git a/massa-protocol-worker/src/wrap_network.rs b/massa-protocol-worker/src/wrap_network.rs index b69d3e8b971..d81f73e05bd 100644 --- a/massa-protocol-worker/src/wrap_network.rs +++ b/massa-protocol-worker/src/wrap_network.rs @@ -118,6 +118,7 @@ impl ActiveConnectionsTrait for SharedActiveConnections { } } +#[allow(dead_code)] #[cfg_attr(test, mockall::automock)] pub trait NetworkController: Send + Sync { fn get_active_connections(&self) -> Box; diff --git a/massa-storage/src/lib.rs b/massa-storage/src/lib.rs index d05490dcb64..62744fb121f 100644 --- a/massa-storage/src/lib.rs +++ b/massa-storage/src/lib.rs @@ -95,6 +95,7 @@ impl Storage { /// Creates a new `Storage` instance. Must be called only one time in the execution: /// - In the main for the node /// - At the top of the test in tests + /// /// All others instances of Storage must be cloned from this one using `clone()` or `clone_without_refs()`. pub fn create_root() -> Storage { Storage { diff --git a/massa-versioning/src/versioning.rs b/massa-versioning/src/versioning.rs index 2c73ef54941..3ad72745524 100644 --- a/massa-versioning/src/versioning.rs +++ b/massa-versioning/src/versioning.rs @@ -1123,7 +1123,7 @@ impl MipStoreRaw { .iter() .rev() .filter(|(mi, ms)| { - mi.components.get(component).is_some() + mi.components.contains_key(component) && matches!(ms.state, ComponentState::Active(_)) }) .find_map(|(mi, ms)| { diff --git a/massa-versioning/src/versioning_factory.rs b/massa-versioning/src/versioning_factory.rs index 8897226d36d..33a71989840 100644 --- a/massa-versioning/src/versioning_factory.rs +++ b/massa-versioning/src/versioning_factory.rs @@ -144,6 +144,7 @@ mod test { } } + #[allow(dead_code)] #[derive(Debug)] enum TestAddress { V0(TestAddressV0), diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7897a24d1a1..1de01fa45c4 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.75.0" +channel = "1.81.0" From 6990fe6c738054134d4196fceedef3218c500db6 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Tue, 1 Oct 2024 15:12:32 +0200 Subject: [PATCH 16/32] Update actions/checkout to v4 (#4751) * Update actions/checkout to v4 * Use dtolnay rust action instead of deprecated action-rs * Use dtolnay rust action (2) * Use dtolnay rust action (3) * Update JamesIves action for ci doc --- .github/workflows/ci.yml | 91 ++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 59 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a670405614b..acc37fe716c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,28 +22,29 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +# Actions doc / www page: +# actions/checkout: https://github.com/actions/checkout +# Swatinem/rust-cache: https://github.com/Swatinem/rust-cache +# dtolnay/rust-toolchain: https://github.com/dtolnay/rust-toolchain +# codecov/codecov-action: https://github.com/codecov/codecov-action + jobs: # Quick tests on each commit/PR sanity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 components: rustfmt - override: true - uses: Swatinem/rust-cache@v2 with: shared-key: "sanity" save-if: ${{ github.ref_name == 'main' }} - - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check + - run: cargo fmt --all --check check: if: github.ref != 'refs/heads/staging' @@ -51,12 +52,11 @@ jobs: runs-on: ubuntu-latest continue-on-error: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 - uses: Swatinem/rust-cache@v2 with: @@ -66,9 +66,7 @@ jobs: with: version: '23.x' repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions-rs/cargo@v1 - with: - command: check + - run: cargo check clippy: if: github.ref != 'refs/heads/staging' @@ -76,15 +74,13 @@ jobs: runs-on: ubuntu-latest continue-on-error: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 components: clippy - override: true - uses: Swatinem/rust-cache@v2 with: shared-key: "clippy" @@ -93,10 +89,7 @@ jobs: with: version: '23.x' repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: --no-deps --all-targets + - run: cargo clippy --no-deps --all-targets security: if: github.ref != 'refs/heads/staging' @@ -104,7 +97,7 @@ jobs: runs-on: ubuntu-latest continue-on-error: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" # - uses: actions-rust-lang/audit@v1 @@ -185,14 +178,12 @@ jobs: if: runner.os == 'Linux' run: df -h - uses: ilammy/setup-nasm@v1 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 - override: true - uses: Swatinem/rust-cache@v2 with: shared-key: "massa" @@ -202,22 +193,11 @@ jobs: version: "23.x" include-pre-releases: false repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions-rs/cargo@v1 - with: - command: install - args: cargo-nextest --locked - - uses: actions-rs/cargo@v1 - with: - command: nextest - args: run --retries 10 --profile ci --all-features - - uses: actions-rs/cargo@v1 - with: - command: clean - - uses: actions-rs/cargo@v1 - with: - command: test - args: --doc - - uses: codecov/codecov-action@v3 + - run: cargo install cargo-nextest --locked + - run: cargo nextest run --retries 10 --profile ci --all-features + - run: cargo clean + - run: cargo test --doc + - uses: codecov/codecov-action@v4 with: files: lcov.info fail_ci_if_error: false @@ -233,21 +213,19 @@ jobs: if: github.ref != 'refs/heads/staging' && github.ref != 'refs/heads/main' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 components: rustfmt - override: true - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: massalabs/gas-calibration path: gas-calibration ref: main - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: repository: massalabs/massa-as-sdk path: massa-as-sdk @@ -268,15 +246,13 @@ jobs: doc: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - - uses: actions-rs/toolchain@v1 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: 1.81.0 components: rustfmt - override: true - uses: Swatinem/rust-cache@v2 with: shared-key: "doc" @@ -285,11 +261,8 @@ jobs: with: version: '23.x' repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: actions-rs/cargo@v1 - with: - command: doc - args: --no-deps --document-private-items - - uses: JamesIves/github-pages-deploy-action@4.1.7 + - run: cargo doc --no-deps --document-private-items + - uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages folder: target/doc @@ -297,7 +270,7 @@ jobs: unit_tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: "recursive" - name: setup_tests From 10e439aad589a53144408e67ff88c827c3a35618 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Tue, 1 Oct 2024 17:10:48 +0200 Subject: [PATCH 17/32] Add typos config file (#4753) * Add typos config file * Fix typo errors * Add typos to github CI * Cargo fmt pass * More typo fixes --- .github/workflows/ci.yml | 13 +++++++++ _typos.toml | 27 +++++++++++++++++++ massa-api-exports/src/address.rs | 2 +- massa-api-exports/src/operation.rs | 2 +- massa-api/src/api.rs | 2 +- massa-api/src/lib.rs | 4 +-- massa-async-pool/src/changes.rs | 2 +- massa-async-pool/src/pool.rs | 2 +- massa-bootstrap/src/client.rs | 24 ++++++++++------- massa-bootstrap/src/messages.rs | 4 +-- massa-bootstrap/src/server.rs | 8 +++--- massa-bootstrap/src/tests/binders.rs | 2 +- massa-bootstrap/src/tests/tools.rs | 8 +++--- massa-client/src/display.rs | 2 +- massa-consensus-worker/src/lib.rs | 4 +-- massa-consensus-worker/src/state/mod.rs | 2 +- massa-consensus-worker/src/state/process.rs | 2 +- .../src/tests/three_four_threads_scenarios.rs | 2 +- massa-db-worker/src/massa_db.rs | 2 +- massa-execution-exports/src/lib.rs | 4 +-- massa-execution-exports/src/mapping_grpc.rs | 6 ++--- massa-execution-worker/src/active_history.rs | 2 +- massa-execution-worker/src/context.rs | 2 +- massa-execution-worker/src/lib.rs | 2 +- .../src/speculative_executed_ops.rs | 2 +- .../src/speculative_roll_state.rs | 2 +- .../src/tests/scenarios_mandatories.rs | 2 +- .../src/tests/tests_active_history.rs | 2 +- massa-factory-worker/src/block_factory.rs | 2 +- massa-grpc/src/server.rs | 10 +++---- massa-grpc/src/stream/mod.rs | 2 +- massa-grpc/src/tests/stream.rs | 8 +++--- massa-models/src/block.rs | 2 +- massa-models/src/block_id.rs | 2 +- massa-models/src/config/constants.rs | 4 +-- massa-models/src/endorsement.rs | 4 +-- massa-models/src/secure_share.rs | 6 ++--- massa-node/base_config/config.toml | 4 +-- massa-node/src/main.rs | 14 +++++----- .../src/handlers/block_handler/retrieval.rs | 2 +- .../src/handlers/peer_handler/models.rs | 4 +-- massa-serialization/src/lib.rs | 2 +- massa-storage/src/lib.rs | 4 +-- massa-versioning/src/versioning_ser_der.rs | 4 +-- tools/setup_test.rs | 2 +- 45 files changed, 129 insertions(+), 85 deletions(-) create mode 100644 _typos.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acc37fe716c..708eca3eb17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,8 @@ concurrency: # Swatinem/rust-cache: https://github.com/Swatinem/rust-cache # dtolnay/rust-toolchain: https://github.com/dtolnay/rust-toolchain # codecov/codecov-action: https://github.com/codecov/codecov-action +# JamesIves/github-pages-deploy-action: https://github.com/JamesIves/github-pages-deploy-action +# typos: https://github.com/crate-ci/typos/blob/master/docs/github-action.md jobs: # Quick tests on each commit/PR @@ -103,6 +105,17 @@ jobs: # - uses: actions-rust-lang/audit@v1 # name: Audit Rust Dependencies + typos: + if: github.ref != 'refs/heads/staging' + needs: sanity + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - uses: crate-ci/typos@master + # Full cross-platform tests required to merge on main branch full: name: full diff --git a/_typos.toml b/_typos.toml new file mode 100644 index 00000000000..c758abfbe1c --- /dev/null +++ b/_typos.toml @@ -0,0 +1,27 @@ +[files] +extend-exclude = [ + "lcov.info", + "massa-node/base_config/*.json", + "massa-node/src/tests/config.toml", + "*.patch" +] + +[default] +extend-ignore-re = [ + # Note: + # Address (AU, AS): 32 - 62 characters + # Secret key (S): 18 - 62 characters + # Public key (P): 18 - 62 characters + # NodeId (N) + "(AU|AS|N|S|P)\\d\\w{18,62}", +] + +[default.extend-words] +# short: serialize +ser = "ser" +# short: deserialize +der = "der" +# short: numerator +numer = "numer" +# WONTFIX: grpc_model::operation_type::Type::ExecutSc +Execut = "Execut" \ No newline at end of file diff --git a/massa-api-exports/src/address.rs b/massa-api-exports/src/address.rs index 2815fb17f14..a86c4509249 100644 --- a/massa-api-exports/src/address.rs +++ b/massa-api-exports/src/address.rs @@ -156,7 +156,7 @@ impl std::fmt::Display for CompactAddressInfo { } } -/// filter used when retrieving address informations +/// filter used when retrieving address information #[derive(Debug, Deserialize, Clone, Serialize)] pub struct AddressFilter { /// Address diff --git a/massa-api-exports/src/operation.rs b/massa-api-exports/src/operation.rs index b4caadf85e3..ba2f9aba8eb 100644 --- a/massa-api-exports/src/operation.rs +++ b/massa-api-exports/src/operation.rs @@ -54,7 +54,7 @@ impl std::fmt::Display for OperationInfo { "operation is not final", "finality unknown" ), - display_option_bool(self.op_exec_status, "succes", "failed", "status unknown") + display_option_bool(self.op_exec_status, "success", "failed", "status unknown") )?; writeln!(f, "In blocks:")?; for block_id in &self.in_blocks { diff --git a/massa-api/src/api.rs b/massa-api/src/api.rs index 51d10796e51..bc169c0b8ce 100644 --- a/massa-api/src/api.rs +++ b/massa-api/src/api.rs @@ -151,7 +151,7 @@ impl MassaApiServer for API { } } -// Brodcast the stream(sender) content via a WebSocket +// Broadcast the stream(sender) content via a WebSocket async fn broadcast_via_ws( sender: tokio::sync::broadcast::Sender, pending: PendingSubscriptionSink, diff --git a/massa-api/src/lib.rs b/massa-api/src/lib.rs index 8055167d489..4f721b7ac94 100644 --- a/massa-api/src/lib.rs +++ b/massa-api/src/lib.rs @@ -108,11 +108,11 @@ pub struct Private { pub struct ApiV2 { /// link to the consensus component pub consensus_controller: Box, - /// channels with informations broadcasted by the consensus + /// channels with information broadcasted by the consensus pub consensus_broadcasts: ConsensusBroadcasts, /// link to the execution component pub execution_controller: Box, - /// channels with informations broadcasted by the pool + /// channels with information broadcasted by the pool pub pool_broadcasts: PoolBroadcasts, /// API settings pub api_settings: APIConfig, diff --git a/massa-async-pool/src/changes.rs b/massa-async-pool/src/changes.rs index 22756446237..22ee4cd2700 100644 --- a/massa-async-pool/src/changes.rs +++ b/massa-async-pool/src/changes.rs @@ -334,7 +334,7 @@ mod tests { assert!(msg.can_be_executed); } _ => { - panic!("Unexpect value"); + panic!("Unexpected value"); } } diff --git a/massa-async-pool/src/pool.rs b/massa-async-pool/src/pool.rs index 403787e3388..43b2ce2564b 100644 --- a/massa-async-pool/src/pool.rs +++ b/massa-async-pool/src/pool.rs @@ -1284,7 +1284,7 @@ mod tests { .write_batch(batch, versioning_batch, Some(slot_1)); let content = dump_column(pool.db.clone(), "state"); - assert_eq!(content.len(), 26); // 2 entries added, splitted in 13 prefix + assert_eq!(content.len(), 26); // 2 entries added, split in 13 prefix let mut batch2 = DBBatch::new(); pool.delete_entry(&message_id, &mut batch2); diff --git a/massa-bootstrap/src/client.rs b/massa-bootstrap/src/client.rs index 98d5f07616f..989f4e094a1 100644 --- a/massa-bootstrap/src/client.rs +++ b/massa-bootstrap/src/client.rs @@ -402,7 +402,7 @@ pub fn get_state( genesis_timestamp: MassaTime, end_timestamp: Option, restart_from_snapshot_at_period: Option, - interupted: Arc<(Mutex, Condvar)>, + interrupted: Arc<(Mutex, Condvar)>, massa_metrics: MassaMetrics, ) -> Result { massa_trace!("bootstrap.lib.get_state", {}); @@ -490,8 +490,12 @@ pub fn get_state( let limit = bootstrap_config.rate_limit; loop { - // check for interuption - if *interupted.0.lock().expect("double-lock on interupt-mutex") { + // check for interruption + if *interrupted + .0 + .lock() + .expect("double-lock on interrupt-mutex") + { return Err(BootstrapError::Interrupted( "Sig INT received while getting state".to_string(), )); @@ -547,11 +551,11 @@ pub fn get_state( // Before, we would use a simple sleep(...), and that was fine // in a cancellable async context: the runtime could - // catch the interupt signal, and just cancel this thread: + // catch the interrupt signal, and just cancel this thread: // // let state = tokio::select!{ - // /* detect interupt */ => /* return, cancelling the async get_state */ - // get_state(...) => well, we got the state, and it didn't have to worry about interupts + // /* detect interrupt */ => /* return, cancelling the async get_state */ + // get_state(...) => well, we got the state, and it didn't have to worry about interrupts // }; // // Without an external system to preempt this context, we use a condvar to manage the sleep. @@ -562,14 +566,14 @@ pub fn get_state( // The _magic_ happens when, somewhere else, a clone of the Arc<(Mutex, Condvar)>\ // calls Condvar::notify_[one | all], which prompts this thread to wake up. Assuming that // the mutex-wrapped variable has been set appropriately before the notify, this thread - let int_sig = interupted + let int_sig = interrupted .0 .lock() - .expect("double-lock() on interupted signal mutex"); - let wake = interupted + .expect("double-lock() on interrupted signal mutex"); + let wake = interrupted .1 .wait_timeout(int_sig, bootstrap_config.retry_delay.to_duration()) - .expect("interupt signal mutex poisoned"); + .expect("interrupt signal mutex poisoned"); if *wake.0 { return Err(BootstrapError::Interrupted( "Sig INT during bootstrap retry-wait".to_string(), diff --git a/massa-bootstrap/src/messages.rs b/massa-bootstrap/src/messages.rs index e0cc2fa5669..23e55fceea0 100644 --- a/massa-bootstrap/src/messages.rs +++ b/massa-bootstrap/src/messages.rs @@ -871,10 +871,10 @@ impl Deserializer for BootstrapClientMessageDeserializer context("Failed last_slot deserialization", |input| { self.slot_deserializer.deserialize(input) }), - context("Faild last_state_step deserialization", |input| { + context("Failed last_state_step deserialization", |input| { self.state_step_deserializer.deserialize(input) }), - context("Faild last_versioning_step deserialization", |input| { + context("Failed last_versioning_step deserialization", |input| { self.state_step_deserializer.deserialize(input) }), context("Failed last_consensus_step deserialization", |input| { diff --git a/massa-bootstrap/src/server.rs b/massa-bootstrap/src/server.rs index c5d462c3abb..900e7699d14 100644 --- a/massa-bootstrap/src/server.rs +++ b/massa-bootstrap/src/server.rs @@ -13,13 +13,13 @@ //! Shares an `Arc>` guarded list of white and blacklists with the main worker. //! Periodically does a read-only check to see if list needs updating. //! Creates an updated list then swaps it out with write-locked list -//! Assuming no errors in code, this is the only write occurance, and is only a pointer-swap -//! under the hood, making write contention virtually non-existant. +//! Assuming no errors in code, this is the only write occurrence, and is only a pointer-swap +//! under the hood, making write contention virtually non-existent. //! //! # Worker loop //! //! 1. Checks if the stopper has been invoked. -//! 2. Checks if the client is permited under the white/black list rules +//! 2. Checks if the client is permitted under the white/black list rules //! 3. Checks if there are not too many active sessions already //! 4. Checks if the client has attempted too recently //! 5. All checks have passed: spawn a thread on which to run the bootstrap session @@ -101,7 +101,7 @@ impl BootstrapManager { /// stop the bootstrap server pub fn stop(self) -> Result<(), BootstrapError> { massa_trace!("bootstrap.lib.stop", {}); - // TODO: Refactor the waker so that its existance is tied to the life of the event-loop + // TODO: Refactor the waker so that its existence is tied to the life of the event-loop if self.listener_stopper.stop().is_err() { warn!("bootstrap server already dropped"); } diff --git a/massa-bootstrap/src/tests/binders.rs b/massa-bootstrap/src/tests/binders.rs index 46ef5b1c699..7b39473f18a 100644 --- a/massa-bootstrap/src/tests/binders.rs +++ b/massa-bootstrap/src/tests/binders.rs @@ -248,7 +248,7 @@ fn test_binders_simple() { // This test uses exactly the same principle as the `test_binders_simple` one // Except instead of passing a pair of (ServerMessage, ClientMessage), it will pass a // (bool, Vec, Vec) -// - The boolean defines wether the server or the client will transmit data first, or receive first +// - The boolean defines whether the server or the client will transmit data first, or receive first // - The first vector is a list of server messages generated that the server has to send // - The second vector is a list of client messages generated that the client has to send // Because the direction of the first message is randomly assigned, and the number of messages are random, diff --git a/massa-bootstrap/src/tests/tools.rs b/massa-bootstrap/src/tests/tools.rs index f4615ebbda6..88309c84f89 100644 --- a/massa-bootstrap/src/tests/tools.rs +++ b/massa-bootstrap/src/tests/tools.rs @@ -783,7 +783,7 @@ impl BootstrapServerMessage { "Error in the code of the test for faulty_part 4" ); } - // No limit on the size of this except the u64 boundery + // No limit on the size of this except the u64 boundary let updates_on_previous_elements = BTreeMap::new(); let mut change_id = gen_random_slot(rng); if faulty_part == BootstrapServerMessageFaultyPart::StateChangeIdThreadOverflow { @@ -830,7 +830,7 @@ impl BootstrapServerMessage { new_elements.insert(key, value); new_elements_size += key_len + value_len; } - // No limit on the size of this except the u64 boundery + // No limit on the size of this except the u64 boundary let updates_on_previous_elements = BTreeMap::new(); let mut change_id = gen_random_slot(rng); if faulty_part == BootstrapServerMessageFaultyPart::VersioningChangeIdThreadOverflow { @@ -1020,7 +1020,7 @@ impl BootstrapServerMessage { }, ) => { let state_equal = stream_batch_equal(state1, state2); - let versionning_equal = stream_batch_equal(v1, v2); + let versioning_equal = stream_batch_equal(v1, v2); let mut consensus_equal = true; if c1.final_blocks.len() != c2.final_blocks.len() { return false; @@ -1034,7 +1034,7 @@ impl BootstrapServerMessage { } (s1 == s2) && state_equal - && versionning_equal + && versioning_equal && consensus_equal && (co1 == co2) && (lp1 == lp2) diff --git a/massa-client/src/display.rs b/massa-client/src/display.rs index 7c4732094e5..5973228ef5b 100644 --- a/massa-client/src/display.rs +++ b/massa-client/src/display.rs @@ -82,7 +82,7 @@ pub enum Style { Wallet, /// For any secret information Secret, - /// To separate some informations on the screen by barely visible characters + /// To separate some information on the screen by barely visible characters Separator, /// When displaying a timestamp or date Time, diff --git a/massa-consensus-worker/src/lib.rs b/massa-consensus-worker/src/lib.rs index 48e617a34c2..c7e04d0a6ba 100644 --- a/massa-consensus-worker/src/lib.rs +++ b/massa-consensus-worker/src/lib.rs @@ -5,10 +5,10 @@ //! The consensus worker launches a persistent thread that will run in the background. //! This thread has a `run` function that triggers the consensus algorithm each slot. It can be interrupted by commands //! that are managed on the fly. The consensus worker share a state with a controller. This controller can be called by the others modules. -//! It avoid sending message to the thread just for getting informations on the consensus. +//! It avoids sending message to the thread just for getting information on the consensus. //! //! Communications with execution is blocking. Communications with protocol blocks on sending information to protocol but not blocking -//! when protocol sends informations to this module. +//! when protocol sends information to this module. //! //! This module doesn't use asynchronous code. //! diff --git a/massa-consensus-worker/src/state/mod.rs b/massa-consensus-worker/src/state/mod.rs index 07dee3ce7a4..5dc9b829581 100644 --- a/massa-consensus-worker/src/state/mod.rs +++ b/massa-consensus-worker/src/state/mod.rs @@ -334,7 +334,7 @@ impl ConsensusState { &self, end_slot: Option, ) -> Result, ConsensusError> { - // if an end_slot is provided compute the lastest final block for that given slot + // if an end_slot is provided compute the latest final block for that given slot // if not use the latest_final_blocks_periods let effective_latest_finals: Vec<(BlockId, u64)> = if let Some(slot) = end_slot { self.list_latest_final_blocks_at(slot)? diff --git a/massa-consensus-worker/src/state/process.rs b/massa-consensus-worker/src/state/process.rs index 64cf276a0ca..b80a4d6794f 100644 --- a/massa-consensus-worker/src/state/process.rs +++ b/massa-consensus-worker/src/state/process.rs @@ -31,7 +31,7 @@ use crate::state::{ use super::ConsensusState; -/// All informations necessary to add a block to the graph +/// All information necessary to add a block to the graph pub(crate) struct BlockInfos { /// The block creator pub creator: PublicKey, diff --git a/massa-consensus-worker/src/tests/three_four_threads_scenarios.rs b/massa-consensus-worker/src/tests/three_four_threads_scenarios.rs index e0f10d0e36f..2897921e1af 100644 --- a/massa-consensus-worker/src/tests/three_four_threads_scenarios.rs +++ b/massa-consensus-worker/src/tests/three_four_threads_scenarios.rs @@ -625,7 +625,7 @@ fn test_fts_multiple_max_cliques_2() { register_block(&consensus_controller, block_1_3.clone(), storage.clone()); // Period 2. - // Thread incompatibilies with every blocks of period 1 + // Thread incompatibilities with every block of period 1 let block_2_0 = create_block( Slot::new(2, 0), vec![genesis[0], genesis[1], genesis[2], genesis[3]], diff --git a/massa-db-worker/src/massa_db.rs b/massa-db-worker/src/massa_db.rs index a86ffd9475b..f531929ef76 100644 --- a/massa-db-worker/src/massa_db.rs +++ b/massa-db-worker/src/massa_db.rs @@ -1087,7 +1087,7 @@ mod test { // assert!(dump_column(db_.clone(), "versioning").is_empty()); assert!(dump_column(db.clone(), "versioning").is_empty()); - // Add some datas then remove using prefix + // Add some data then remove using prefix batch.clear(); db.read() .put_or_update_entry_value(&mut batch, vec![97, 98, 1], &[1]); diff --git a/massa-execution-exports/src/lib.rs b/massa-execution-exports/src/lib.rs index 4238e43103c..1ae8c035587 100644 --- a/massa-execution-exports/src/lib.rs +++ b/massa-execution-exports/src/lib.rs @@ -12,9 +12,9 @@ //! an instance of `ExecutionManager` is returned (see the documentation of `start_execution_worker` in `massa-execution-worker`), //! as well as an instance of `ExecutionController`. //! -//! The non-clonable `ExecutionManager` allows stopping the execution worker thread. +//! The non-cloneable `ExecutionManager` allows stopping the execution worker thread. //! -//! The clonable `ExecutionController` allows sending updates on the latest blockclique changes to the execution worker +//! The cloneable `ExecutionController` allows sending updates on the latest blockclique changes to the execution worker //! for it to keep track of them and execute the operations present in blocks. //! It also allows various read-only queries such as executing bytecode //! while ignoring all the changes it would cause to the consensus state (read-only execution), diff --git a/massa-execution-exports/src/mapping_grpc.rs b/massa-execution-exports/src/mapping_grpc.rs index 828e226a0c8..5aa9875442b 100644 --- a/massa-execution-exports/src/mapping_grpc.rs +++ b/massa-execution-exports/src/mapping_grpc.rs @@ -117,13 +117,13 @@ pub fn to_querystate_filter( } //TODO to be checked exec::RequestItem::CycleInfos(value) => { - let addreses = value + let addresses = value .restrict_to_addresses .into_iter() .map(|address| Address::from_str(&address)) .collect::, _>>()?; - let mut addresses_set = PreHashSet::with_capacity(addreses.len()); - addresses_set.extend(addreses); + let mut addresses_set = PreHashSet::with_capacity(addresses.len()); + addresses_set.extend(addresses); Ok(ExecutionQueryRequestItem::CycleInfos { cycle: value.cycle, restrict_to_addresses: Some(addresses_set), diff --git a/massa-execution-worker/src/active_history.rs b/massa-execution-worker/src/active_history.rs index 1b4c41ebb6b..7cf4cd737ab 100644 --- a/massa-execution-worker/src/active_history.rs +++ b/massa-execution-worker/src/active_history.rs @@ -211,7 +211,7 @@ impl ActiveHistory { } /// Gets the deferred credits for a given address that will be credited at a given slot - pub(crate) fn get_adress_deferred_credit_for( + pub(crate) fn get_address_deferred_credit_for( &self, addr: &Address, slot: &Slot, diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index 9039cef4994..60e74219d6f 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -1022,7 +1022,7 @@ impl ExecutionContext { // Set the event index event.context.index_in_slot = self.created_event_index; - // Increment the event counter fot this slot + // Increment the event counter for this slot self.created_event_index += 1; // Add the event to the context store diff --git a/massa-execution-worker/src/lib.rs b/massa-execution-worker/src/lib.rs index 0982892a94a..66515da3101 100644 --- a/massa-execution-worker/src/lib.rs +++ b/massa-execution-worker/src/lib.rs @@ -6,7 +6,7 @@ //! of operations that can contain executable bytecode and managing interactions with the ledger. //! When the worker is launched, a `ExecutionManager` and a `ExecutionController` are returned. //! `ExecutionManager` allows stopping the worker, -//! and `ExecutionController` is the clonable structure through which users interact with the worker. +//! and `ExecutionController` is the cloneable structure through which users interact with the worker. //! //! The worker is fed through the `ExecutionController` with information about blockclique changes and newly finalized blocks //! and will execute the operations in those blocks, as well as pending asynchronous operations on empty slots. diff --git a/massa-execution-worker/src/speculative_executed_ops.rs b/massa-execution-worker/src/speculative_executed_ops.rs index 638d49bf247..1c3d1037678 100644 --- a/massa-execution-worker/src/speculative_executed_ops.rs +++ b/massa-execution-worker/src/speculative_executed_ops.rs @@ -57,7 +57,7 @@ impl SpeculativeExecutedOps { /// Checks if an operation was executed previously pub fn is_op_executed(&self, op_id: &OperationId) -> bool { - // check in the curent changes + // check in the current changes if self.executed_ops.contains_key(op_id) { return true; } diff --git a/massa-execution-worker/src/speculative_roll_state.rs b/massa-execution-worker/src/speculative_roll_state.rs index 9b6a8817500..14f7f8b2118 100644 --- a/massa-execution-worker/src/speculative_roll_state.rs +++ b/massa-execution-worker/src/speculative_roll_state.rs @@ -377,7 +377,7 @@ impl SpeculativeRollState { if let Some(v) = self .active_history .read() - .get_adress_deferred_credit_for(addr, slot) + .get_address_deferred_credit_for(addr, slot) { return Some(v); } diff --git a/massa-execution-worker/src/tests/scenarios_mandatories.rs b/massa-execution-worker/src/tests/scenarios_mandatories.rs index aa210361161..f9009270085 100644 --- a/massa-execution-worker/src/tests/scenarios_mandatories.rs +++ b/massa-execution-worker/src/tests/scenarios_mandatories.rs @@ -3282,7 +3282,7 @@ fn test_dump_block() { std::thread::sleep(Duration::from_secs(1)); // if the the storage backend for the dump-block feature is a rocksdb, this - // is mandatory (the db must be closed before we can reopen it to ckeck the + // is mandatory (the db must be closed before we can reopen it to check the // data) drop(universe); diff --git a/massa-execution-worker/src/tests/tests_active_history.rs b/massa-execution-worker/src/tests/tests_active_history.rs index 9d384b422fb..9826502b069 100644 --- a/massa-execution-worker/src/tests/tests_active_history.rs +++ b/massa-execution-worker/src/tests/tests_active_history.rs @@ -66,7 +66,7 @@ fn test_active_history_deferred_credits() { let active_history = ActiveHistory(VecDeque::from([exec_output_1])); assert_eq!( - active_history.get_adress_deferred_credit_for(&addr1, &slot2), + active_history.get_address_deferred_credit_for(&addr1, &slot2), Some(amount_a1_s2) ); diff --git a/massa-factory-worker/src/block_factory.rs b/massa-factory-worker/src/block_factory.rs index b972b29a983..ea645786a1e 100644 --- a/massa-factory-worker/src/block_factory.rs +++ b/massa-factory-worker/src/block_factory.rs @@ -183,7 +183,7 @@ impl BlockFactoryWorker { .channels .pool .get_block_endorsements(&same_thread_parent_id, &slot); - //TODO: Do we want ot populate only with endorsement id in the future ? + //TODO: Do we want of populate only with endorsement id in the future ? let endorsements: Vec = { let endo_read = endo_storage.read_endorsements(); endorsements_ids diff --git a/massa-grpc/src/server.rs b/massa-grpc/src/server.rs index 5b0b5efcd2c..76a52a28bf2 100644 --- a/massa-grpc/src/server.rs +++ b/massa-grpc/src/server.rs @@ -206,7 +206,7 @@ where } let cert = std::fs::read_to_string(config.server_certificate_path.clone()) - .expect("error, failed to read server certificat"); + .expect("error, failed to read server certificate"); let key = std::fs::read_to_string(config.server_private_key_path.clone()) .expect("error, failed to read server private key"); @@ -324,7 +324,7 @@ fn generate_self_signed_certificates(config: &GrpcConfig) { gen_signed_cert(&ca_cert, config.subject_alt_names.clone()) .expect("error, failed to generate cert"); std::fs::write(config.client_certificate_path.clone(), client_cert_pem) - .expect("error, failed to write client certificat"); + .expect("error, failed to write client certificate"); std::fs::write( config.client_private_key_path.clone(), client_private_key_pem, @@ -333,13 +333,13 @@ fn generate_self_signed_certificates(config: &GrpcConfig) { } std::fs::write(config.certificate_authority_root_path.clone(), ca_cert_pem) - .expect("error, failed to write certificat authority root"); + .expect("error, failed to write certificate authority root"); let (cert_pem, server_private_key_pem) = gen_signed_cert(&ca_cert, config.subject_alt_names.clone()) - .expect("error, failed to generate server certificat"); + .expect("error, failed to generate server certificate"); std::fs::write(config.server_certificate_path.clone(), cert_pem) - .expect("error, failed to write server certificat"); + .expect("error, failed to write server certificate"); std::fs::write( config.server_private_key_path.clone(), server_private_key_pem, diff --git a/massa-grpc/src/stream/mod.rs b/massa-grpc/src/stream/mod.rs index 8c212996e6d..d300120b8b6 100644 --- a/massa-grpc/src/stream/mod.rs +++ b/massa-grpc/src/stream/mod.rs @@ -20,5 +20,5 @@ pub mod send_blocks; pub mod send_endorsements; /// send operations pub mod send_operations; -/// subscribe tx througput +/// subscribe tx throughput pub mod tx_throughput; diff --git a/massa-grpc/src/tests/stream.rs b/massa-grpc/src/tests/stream.rs index 286900bcf54..c6a6286b0dd 100644 --- a/massa-grpc/src/tests/stream.rs +++ b/massa-grpc/src/tests/stream.rs @@ -42,14 +42,14 @@ async fn transactions_throughput_stream() { let mut exec_ctrl = Box::new(MockExecutionController::new()); exec_ctrl.expect_get_stats().returning(|| { let now = MassaTime::now(); - let futur = MassaTime::from_millis( + let future_ = MassaTime::from_millis( now.as_millis() .add(Duration::from_secs(30).as_millis() as u64), ); ExecutionStats { time_window_start: now, - time_window_end: futur, + time_window_end: future_, final_block_count: 10, final_executed_operations_count: 2000, active_cursor: massa_models::slot::Slot { @@ -69,14 +69,14 @@ async fn transactions_throughput_stream() { let mut exec_ctrl = Box::new(MockExecutionController::new()); exec_ctrl.expect_get_stats().returning(|| { let now = MassaTime::now(); - let futur = MassaTime::from_millis( + let future_ = MassaTime::from_millis( now.as_millis() .add(Duration::from_secs(30).as_millis() as u64), ); ExecutionStats { time_window_start: now, - time_window_end: futur, + time_window_end: future_, final_block_count: 10, final_executed_operations_count: 2000, active_cursor: massa_models::slot::Slot { diff --git a/massa-models/src/block.rs b/massa-models/src/block.rs index 74a536fe4c1..836f61f406f 100644 --- a/massa-models/src/block.rs +++ b/massa-models/src/block.rs @@ -62,7 +62,7 @@ pub struct FilledBlock { pub operations: Vec<(OperationId, Option)>, } -/// Block with assosciated meta-data and interfaces allowing trust of data in untrusted network +/// Block with associated meta-data and interfaces allowing trust of data in untrusted network pub type SecureShareBlock = SecureShare; impl SecureShareContent for Block { diff --git a/massa-models/src/block_id.rs b/massa-models/src/block_id.rs index 3bf85225033..ff5689df05d 100644 --- a/massa-models/src/block_id.rs +++ b/massa-models/src/block_id.rs @@ -285,7 +285,7 @@ mod test { #[test] fn test_block_id_errors() { - let actual_error = BlockId::from_str("SomeUnvalidBlockId") + let actual_error = BlockId::from_str("SomeInvalidBlockId") .unwrap_err() .to_string(); let expected_error = "block id parsing error".to_string(); diff --git a/massa-models/src/config/constants.rs b/massa-models/src/config/constants.rs index 187a61dcb67..39a832f59fe 100644 --- a/massa-models/src/config/constants.rs +++ b/massa-models/src/config/constants.rs @@ -223,9 +223,9 @@ pub const MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN: usize = 256; /// Maximum length for the name of a smart contract pub const MAX_RUNTIME_MODULE_NAME_LEN: usize = 256; /// Maximum number of custom section data -pub const MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN: usize = 1; +pub const MAX_RUNTIME_MODULE_CUSTOM_SECTION_LEN: usize = 1; /// Maximum length for the custom section data -pub const MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN: usize = 1_000_000; +pub const MAX_RUNTIME_MODULE_CUSTOM_SECTION_DATA_LEN: usize = 1_000_000; /// Maximum number of functions a module can import const MAX_RUNTIME_MODULE_FUNCTION_IMPORTS: usize = 256; /// Maximum number of memory a module can import diff --git a/massa-models/src/endorsement.rs b/massa-models/src/endorsement.rs index 69d0840a202..1f748b8acbb 100644 --- a/massa-models/src/endorsement.rs +++ b/massa-models/src/endorsement.rs @@ -242,7 +242,7 @@ impl SecureShareEndorsement { return Err(e.into()); } if self.content.slot.thread >= crate::config::THREAD_COUNT { - Err("Endorsement slot on non-existant thread".into()) + Err("Endorsement slot on non-existent thread".into()) } else if self.content.index >= crate::config::ENDORSEMENT_COUNT { Err("Endorsement index out of range".into()) } else { @@ -660,7 +660,7 @@ mod tests { #[test] #[serial] fn test_endorsement_id_errors() { - let actual_error = EndorsementId::from_str("SomeUnvalidEndorsementId") + let actual_error = EndorsementId::from_str("SomeInvalidEndorsementId") .unwrap_err() .to_string(); let expected_error = "endorsement id parsing error".to_string(); diff --git a/massa-models/src/secure_share.rs b/massa-models/src/secure_share.rs index 2cf591102ba..440c360883b 100644 --- a/massa-models/src/secure_share.rs +++ b/massa-models/src/secure_share.rs @@ -15,7 +15,7 @@ use serde::{Deserialize, Serialize}; /// Packages type T such that it can be securely sent and received in a trust-free network /// -/// If the internal content is mutated, then it must be re-wrapped, as the assosciated +/// If the internal content is mutated, then it must be re-wrapped, as the associated /// signature, serialized data, etc. would no longer be in sync #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct SecureShare @@ -23,9 +23,9 @@ where T: Display + SecureShareContent, ID: Id, { - /// Reference contents. Not required for the the security protocols. + /// Reference contents. Not required for the security protocols. /// - /// Use the Lightweight equivilant structures when you need verifiable + /// Use the Lightweight equivalent structures when you need verifiable /// serialized data, but do not need to read the values directly (such as when sending) pub content: T, #[serde(skip)] diff --git a/massa-node/base_config/config.toml b/massa-node/base_config/config.toml index 798875dd871..92510a1f783 100644 --- a/massa-node/base_config/config.toml +++ b/massa-node/base_config/config.toml @@ -273,7 +273,7 @@ message_timeout = 5000 # timeout after which a peer tester will consider the peer unreachable tester_timeout = 10000 - # timeout after whick we consider a node does not have the block we asked for + # timeout after which we consider a node does not have the block we asked for ask_block_timeout = 10000 # Max known blocks we keep during their propagation max_blocks_kept_for_propagation = 300 @@ -391,7 +391,7 @@ max_clock_delta = 5000 # [server] data is cached for cache duration milliseconds cache_duration = 15000 - # max number of simulataneous bootstraps for server + # max number of simultaneous bootstraps for server max_simultaneous_bootstraps = 2 # max size of recently bootstrapped IP cache ip_list_max_size = 10000 diff --git a/massa-node/src/main.rs b/massa-node/src/main.rs index 97edbff221b..8334bad3749 100644 --- a/massa-node/src/main.rs +++ b/massa-node/src/main.rs @@ -88,8 +88,8 @@ use massa_models::config::constants::{ use massa_models::config::{ BASE_OPERATION_GAS_COST, CHAINID, KEEP_EXECUTED_HISTORY_EXTRA_PERIODS, MAX_BOOTSTRAP_FINAL_STATE_PARTS_SIZE, MAX_BOOTSTRAP_VERSIONING_ELEMENTS_SIZE, - MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN, - MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN, MAX_RUNTIME_MODULE_EXPORTS, + MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, MAX_RUNTIME_MODULE_CUSTOM_SECTION_DATA_LEN, + MAX_RUNTIME_MODULE_CUSTOM_SECTION_LEN, MAX_RUNTIME_MODULE_EXPORTS, MAX_RUNTIME_MODULE_FUNCTIONS, MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN, MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER, MAX_RUNTIME_MODULE_IMPORTS, MAX_RUNTIME_MODULE_MEMORIES, MAX_RUNTIME_MODULE_NAME_LEN, MAX_RUNTIME_MODULE_PASSIVE_DATA, @@ -483,8 +483,8 @@ async fn launch( max_tables_count: Some(MAX_RUNTIME_MODULE_TABLE), max_memories_len: Some(MAX_RUNTIME_MODULE_MEMORIES), max_globals_len: Some(MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER), - max_custom_sections_len: Some(MAX_RUNTIME_MODULE_CUSTON_SECTION_LEN), - max_custom_sections_data_len: Some(MAX_RUNTIME_MODULE_CUSTON_SECTION_DATA_LEN), + max_custom_sections_len: Some(MAX_RUNTIME_MODULE_CUSTOM_SECTION_LEN), + max_custom_sections_data_len: Some(MAX_RUNTIME_MODULE_CUSTOM_SECTION_DATA_LEN), }; let block_dump_folder_path = SETTINGS.block_dump.block_dump_folder_path.clone(); @@ -1428,7 +1428,7 @@ async fn run(args: Args) -> anyhow::Result<()> { *sig_int_toggled_clone .0 .lock() - .expect("double-lock on interupt bool in ctrl-c handler") = true; + .expect("double-lock on interrupt bool in ctrl-c handler") = true; sig_int_toggled_clone.1.notify_all(); }) .expect("Error setting Ctrl-C handler"); @@ -1480,11 +1480,11 @@ async fn run(args: Args) -> anyhow::Result<()> { let int_sig = sig_int_toggled .0 .lock() - .expect("double-lock() on interupted signal mutex"); + .expect("double-lock() on interrupted signal mutex"); let wake = sig_int_toggled .1 .wait_timeout(int_sig, Duration::from_millis(100)) - .expect("interupt signal mutex poisoned"); + .expect("interrupt signal mutex poisoned"); if *wake.0 { info!("interrupt signal received"); break false; diff --git a/massa-protocol-worker/src/handlers/block_handler/retrieval.rs b/massa-protocol-worker/src/handlers/block_handler/retrieval.rs index 64f19961501..bbcd6caeacf 100644 --- a/massa-protocol-worker/src/handlers/block_handler/retrieval.rs +++ b/massa-protocol-worker/src/handlers/block_handler/retrieval.rs @@ -409,7 +409,7 @@ impl RetrievalThread { BlockInfoReply::Operations(operations) => { // Send operations to pool, // before performing the below checks, - // and wait for them to have been procesed(i.e. added to storage). + // and wait for them to have been processed (i.e. added to storage). self.on_block_full_operations_received(from_peer_id, block_id, operations); } BlockInfoReply::NotFound => { diff --git a/massa-protocol-worker/src/handlers/peer_handler/models.rs b/massa-protocol-worker/src/handlers/peer_handler/models.rs index 7e3c05f44c8..645868a766a 100644 --- a/massa-protocol-worker/src/handlers/peer_handler/models.rs +++ b/massa-protocol-worker/src/handlers/peer_handler/models.rs @@ -68,7 +68,7 @@ impl Ord for ConnectionMetadata { // Time since last failed peer test, more recent = less priority let test_failure_check = match (self.last_test_failure, other.last_test_failure) { - (Some(st), Some(ot)) => Some(st.cmp(&ot)), + (Some(st), Some(other_)) => Some(st.cmp(&other_)), (Some(_), None) => Some(Ordering::Greater), (None, Some(_)) => Some(Ordering::Less), (None, None) => None, @@ -79,7 +79,7 @@ impl Ord for ConnectionMetadata { // Time since last succeeded peer test, more recent = more priority let test_success_check = match (self.last_test_success, other.last_test_success) { - (Some(st), Some(ot)) => Some(st.cmp(&ot).reverse()), + (Some(st), Some(other_)) => Some(st.cmp(&other_).reverse()), (Some(_), None) => Some(Ordering::Less), (None, Some(_)) => Some(Ordering::Greater), (None, None) => None, diff --git a/massa-serialization/src/lib.rs b/massa-serialization/src/lib.rs index 79d75060879..46179b8f08c 100644 --- a/massa-serialization/src/lib.rs +++ b/massa-serialization/src/lib.rs @@ -486,7 +486,7 @@ mod tests { use num::rational::Ratio; use paste::paste; - // This macro creates a suite of tests for all types of numbers declared as parameters. Ths list of the + // This macro creates a suite of tests for all types of numbers declared as parameters. This list of the // tests for each type : // - Test with a normal case that everything works // - Test with a normal case but a more bigger number that everything works diff --git a/massa-storage/src/lib.rs b/massa-storage/src/lib.rs index 62744fb121f..ca4cd256beb 100644 --- a/massa-storage/src/lib.rs +++ b/massa-storage/src/lib.rs @@ -1,7 +1,7 @@ //! Copyright (c) 2022 MASSA LABS //! //! This crate is used to store shared objects (blocks, operations...) across different modules. -//! The clonable `Storage` structure has thread-safe shared access to the stored objects. +//! The cloneable `Storage` structure has thread-safe shared access to the stored objects. //! //! The `Storage` structure also has lists of object references held by the current instance of `Storage`. //! When no instance of `Storage` claims a reference to a given object anymore, that object is automatically removed from storage. @@ -131,7 +131,7 @@ impl Storage { /// Efficiently extends the current Storage by consuming the refs of another storage. pub fn extend(&mut self, mut other: Storage) { - // Take ownership ot `other`'s references. + // Take ownership of `other`'s references. // Objects owned by both require a counter decrement and are handled when `other` is dropped. other .local_used_ops diff --git a/massa-versioning/src/versioning_ser_der.rs b/massa-versioning/src/versioning_ser_der.rs index 463adb7c7a3..f7f73e01825 100644 --- a/massa-versioning/src/versioning_ser_der.rs +++ b/massa-versioning/src/versioning_ser_der.rs @@ -668,7 +668,7 @@ impl Deserializer for MipStoreStatsDeserializer { )) })?; - let (rem3, latest_annoucements_) = context( + let (rem3, latest_announcements_) = context( "Failed MipStoreStats latest announcements der", length_count( context("Failed latest announcements count der", |input| { @@ -714,7 +714,7 @@ impl Deserializer for MipStoreStatsDeserializer { rem4, MipStoreStats { config: self.config.clone(), - latest_announcements: latest_annoucements_.into_iter().collect(), + latest_announcements: latest_announcements_.into_iter().collect(), network_version_counters: network_version_counters.into_iter().collect(), }, )) diff --git a/tools/setup_test.rs b/tools/setup_test.rs index 3bf11fefd7e..7d17ae45d1e 100644 --- a/tools/setup_test.rs +++ b/tools/setup_test.rs @@ -80,7 +80,7 @@ fn download_src() -> Result { if Path::new(&extract_folder).exists() { println!( - "Please remove the folder: {} before runnning this script", + "Please remove the folder: {} before running this script", extract_folder ); std::process::exit(1); From b6b8fa68f9374f40a9746e99698bc5916ad02ec9 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Thu, 1 Aug 2024 14:27:56 +0200 Subject: [PATCH 18/32] Fix slot index position status (#4736) * Fix SlotIndexPosition from Future to Past in case slots_since returns an error * Update ci.yml --- massa-execution-worker/src/active_history.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/massa-execution-worker/src/active_history.rs b/massa-execution-worker/src/active_history.rs index 7cf4cd737ab..c632a2405be 100644 --- a/massa-execution-worker/src/active_history.rs +++ b/massa-execution-worker/src/active_history.rs @@ -250,7 +250,7 @@ impl ActiveHistory { return SlotIndexPosition::Past; // too old } let index: usize = match slot.slots_since(first_slot, thread_count) { - Err(_) => return SlotIndexPosition::Future, // overflow + Err(_) => return SlotIndexPosition::Past, // overflow Ok(d) => { match d.try_into() { Ok(d) => d, From 8c32b899041c18a36df12632c57001f787f5a431 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 16:18:37 +0200 Subject: [PATCH 19/32] Validate that hd_cache_size >= snip_amount (#4732) --- massa-execution-worker/src/worker.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/massa-execution-worker/src/worker.rs b/massa-execution-worker/src/worker.rs index 332ac92f25e..5fee6e65eac 100644 --- a/massa-execution-worker/src/worker.rs +++ b/massa-execution-worker/src/worker.rs @@ -260,6 +260,10 @@ pub fn start_execution_worker( massa_metrics: MassaMetrics, #[cfg(feature = "dump-block")] block_storage_backend: Arc>, ) -> (Box, Box) { + if config.hd_cache_size < config.snip_amount { + panic!("In config.toml, hd_cache_size must be greater than snip_amount"); + } + // create an execution state let execution_state = Arc::new(RwLock::new(ExecutionState::new( config.clone(), From 2d94edd8d22ccc30386a9a1bfda729d36f1d6a83 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Fri, 2 Aug 2024 16:23:48 +0200 Subject: [PATCH 20/32] Improve handling of HistorySearchResult for fetched executed_ops/denunciations (#4735) * Improve handling of HistorySearchResult * Fix CI --- .../src/speculative_executed_denunciations.rs | 4 +--- massa-execution-worker/src/speculative_executed_ops.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/massa-execution-worker/src/speculative_executed_denunciations.rs b/massa-execution-worker/src/speculative_executed_denunciations.rs index 8c7466bc844..1c8f9bb2c13 100644 --- a/massa-execution-worker/src/speculative_executed_denunciations.rs +++ b/massa-execution-worker/src/speculative_executed_denunciations.rs @@ -73,10 +73,8 @@ impl SpeculativeExecutedDenunciations { HistorySearchResult::Present(_) => { return true; } - HistorySearchResult::Absent => { - return false; - } HistorySearchResult::NoInfo => {} + HistorySearchResult::Absent => unreachable!(), // fetch_executed_denunciation does not return Absent } // check in the final state diff --git a/massa-execution-worker/src/speculative_executed_ops.rs b/massa-execution-worker/src/speculative_executed_ops.rs index 1c3d1037678..d3d0d81c0e1 100644 --- a/massa-execution-worker/src/speculative_executed_ops.rs +++ b/massa-execution-worker/src/speculative_executed_ops.rs @@ -67,10 +67,8 @@ impl SpeculativeExecutedOps { HistorySearchResult::Present(_) => { return true; } - HistorySearchResult::Absent => { - return false; - } HistorySearchResult::NoInfo => {} + HistorySearchResult::Absent => unreachable!(), // fetch_executed_op does not return Absent } // check in the final state From d98df3bf0ac0e3615631570db0286ae86eab503b Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Mon, 12 Aug 2024 15:13:49 +0200 Subject: [PATCH 21/32] Update ASC trigger comment (#4740) * Update ASC trigger comment * Add comment for ledger entry deletions * fmt --- massa-execution-worker/src/speculative_async_pool.rs | 2 +- massa-ledger-exports/src/ledger_changes.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index 3a5c654d7a8..082ed2fb362 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -340,7 +340,7 @@ impl SpeculativeAsyncPool { /// Check in the ledger changes if a message trigger has been triggered fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> bool { - ledger_changes.has_changes(&filter.address, filter.datastore_key.clone()) + ledger_changes.has_writes(&filter.address, filter.datastore_key.clone()) } #[cfg(test)] diff --git a/massa-ledger-exports/src/ledger_changes.rs b/massa-ledger-exports/src/ledger_changes.rs index 02551f0b096..5c4e1eb5839 100644 --- a/massa-ledger-exports/src/ledger_changes.rs +++ b/massa-ledger-exports/src/ledger_changes.rs @@ -835,8 +835,13 @@ impl LedgerChanges { } } - /// Tries to return whether there is a change on a given address in the ledger changes - /// and optionally if a datastore key modification also exists in the address's datastore. + /// Tries to return whether the ledger changes contain a write for the given address + /// and optionally if a datastore key write also exists in the address's datastore. + /// Notes: + /// - A ledger entry could be written to without any changes on the values associated, + /// for example if the value was changed multiple times in the same slot. + /// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case + /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. /// /// # Arguments /// * `addr`: target address @@ -844,7 +849,7 @@ impl LedgerChanges { /// /// # Returns /// * true if the address and, optionally the datastore key, exists in the ledger changes - pub fn has_changes(&self, addr: &Address, key: Option>) -> bool { + pub fn has_writes(&self, addr: &Address, key: Option>) -> bool { // Get the current changes being applied to the ledger entry associated to that address match self.0.get(addr) { // This ledger entry is being replaced by a new one: From 8612838a42bcb5c1790135210f4bd2e8081216a7 Mon Sep 17 00:00:00 2001 From: sydhds Date: Thu, 19 Sep 2024 11:44:43 +0200 Subject: [PATCH 22/32] Fix join error message (was inconsistent with: VM controller thread) --- massa-execution-worker/src/controller.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 02d017b5c08..233ba75902a 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -535,7 +535,7 @@ pub struct ExecutionManagerImpl { impl ExecutionManager for ExecutionManagerImpl { /// stops the worker fn stop(&mut self) { - info!("stopping Execution controller..."); + info!("Stopping Execution controller..."); // notify the worker thread to stop { let mut input_wlock = self.input_data.1.lock(); @@ -544,8 +544,8 @@ impl ExecutionManager for ExecutionManagerImpl { } // join the execution thread if let Some(join_handle) = self.thread_handle.take() { - join_handle.join().expect("VM controller thread panicked"); + join_handle.join().expect("Execution controller thread panicked"); } - info!("execution controller stopped"); + info!("Execution controller stopped"); } } From f29a0b33826363e3ffffa940715108b76a766dc5 Mon Sep 17 00:00:00 2001 From: sydhds Date: Fri, 20 Sep 2024 10:47:45 +0200 Subject: [PATCH 23/32] Cargo fmt pass --- massa-execution-worker/src/controller.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 233ba75902a..6869082b025 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -544,7 +544,9 @@ impl ExecutionManager for ExecutionManagerImpl { } // join the execution thread if let Some(join_handle) = self.thread_handle.take() { - join_handle.join().expect("Execution controller thread panicked"); + join_handle + .join() + .expect("Execution controller thread panicked"); } info!("Execution controller stopped"); } From 266491550a630d15e37d7d7587c06761d8627223 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Wed, 2 Oct 2024 10:38:59 +0200 Subject: [PATCH 24/32] Revert "Fix join error message (was inconsistent with: VM controller thread)" (#4756) --- massa-execution-worker/src/active_history.rs | 2 +- massa-execution-worker/src/controller.rs | 8 +++----- massa-execution-worker/src/speculative_async_pool.rs | 2 +- .../src/speculative_executed_denunciations.rs | 4 +++- .../src/speculative_executed_ops.rs | 4 +++- massa-execution-worker/src/worker.rs | 4 ---- massa-ledger-exports/src/ledger_changes.rs | 11 +++-------- 7 files changed, 14 insertions(+), 21 deletions(-) diff --git a/massa-execution-worker/src/active_history.rs b/massa-execution-worker/src/active_history.rs index c632a2405be..7cf4cd737ab 100644 --- a/massa-execution-worker/src/active_history.rs +++ b/massa-execution-worker/src/active_history.rs @@ -250,7 +250,7 @@ impl ActiveHistory { return SlotIndexPosition::Past; // too old } let index: usize = match slot.slots_since(first_slot, thread_count) { - Err(_) => return SlotIndexPosition::Past, // overflow + Err(_) => return SlotIndexPosition::Future, // overflow Ok(d) => { match d.try_into() { Ok(d) => d, diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 6869082b025..02d017b5c08 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -535,7 +535,7 @@ pub struct ExecutionManagerImpl { impl ExecutionManager for ExecutionManagerImpl { /// stops the worker fn stop(&mut self) { - info!("Stopping Execution controller..."); + info!("stopping Execution controller..."); // notify the worker thread to stop { let mut input_wlock = self.input_data.1.lock(); @@ -544,10 +544,8 @@ impl ExecutionManager for ExecutionManagerImpl { } // join the execution thread if let Some(join_handle) = self.thread_handle.take() { - join_handle - .join() - .expect("Execution controller thread panicked"); + join_handle.join().expect("VM controller thread panicked"); } - info!("Execution controller stopped"); + info!("execution controller stopped"); } } diff --git a/massa-execution-worker/src/speculative_async_pool.rs b/massa-execution-worker/src/speculative_async_pool.rs index 082ed2fb362..3a5c654d7a8 100644 --- a/massa-execution-worker/src/speculative_async_pool.rs +++ b/massa-execution-worker/src/speculative_async_pool.rs @@ -340,7 +340,7 @@ impl SpeculativeAsyncPool { /// Check in the ledger changes if a message trigger has been triggered fn is_triggered(filter: &AsyncMessageTrigger, ledger_changes: &LedgerChanges) -> bool { - ledger_changes.has_writes(&filter.address, filter.datastore_key.clone()) + ledger_changes.has_changes(&filter.address, filter.datastore_key.clone()) } #[cfg(test)] diff --git a/massa-execution-worker/src/speculative_executed_denunciations.rs b/massa-execution-worker/src/speculative_executed_denunciations.rs index 1c8f9bb2c13..8c7466bc844 100644 --- a/massa-execution-worker/src/speculative_executed_denunciations.rs +++ b/massa-execution-worker/src/speculative_executed_denunciations.rs @@ -73,8 +73,10 @@ impl SpeculativeExecutedDenunciations { HistorySearchResult::Present(_) => { return true; } + HistorySearchResult::Absent => { + return false; + } HistorySearchResult::NoInfo => {} - HistorySearchResult::Absent => unreachable!(), // fetch_executed_denunciation does not return Absent } // check in the final state diff --git a/massa-execution-worker/src/speculative_executed_ops.rs b/massa-execution-worker/src/speculative_executed_ops.rs index d3d0d81c0e1..1c3d1037678 100644 --- a/massa-execution-worker/src/speculative_executed_ops.rs +++ b/massa-execution-worker/src/speculative_executed_ops.rs @@ -67,8 +67,10 @@ impl SpeculativeExecutedOps { HistorySearchResult::Present(_) => { return true; } + HistorySearchResult::Absent => { + return false; + } HistorySearchResult::NoInfo => {} - HistorySearchResult::Absent => unreachable!(), // fetch_executed_op does not return Absent } // check in the final state diff --git a/massa-execution-worker/src/worker.rs b/massa-execution-worker/src/worker.rs index 5fee6e65eac..332ac92f25e 100644 --- a/massa-execution-worker/src/worker.rs +++ b/massa-execution-worker/src/worker.rs @@ -260,10 +260,6 @@ pub fn start_execution_worker( massa_metrics: MassaMetrics, #[cfg(feature = "dump-block")] block_storage_backend: Arc>, ) -> (Box, Box) { - if config.hd_cache_size < config.snip_amount { - panic!("In config.toml, hd_cache_size must be greater than snip_amount"); - } - // create an execution state let execution_state = Arc::new(RwLock::new(ExecutionState::new( config.clone(), diff --git a/massa-ledger-exports/src/ledger_changes.rs b/massa-ledger-exports/src/ledger_changes.rs index 5c4e1eb5839..02551f0b096 100644 --- a/massa-ledger-exports/src/ledger_changes.rs +++ b/massa-ledger-exports/src/ledger_changes.rs @@ -835,13 +835,8 @@ impl LedgerChanges { } } - /// Tries to return whether the ledger changes contain a write for the given address - /// and optionally if a datastore key write also exists in the address's datastore. - /// Notes: - /// - A ledger entry could be written to without any changes on the values associated, - /// for example if the value was changed multiple times in the same slot. - /// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case - /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. + /// Tries to return whether there is a change on a given address in the ledger changes + /// and optionally if a datastore key modification also exists in the address's datastore. /// /// # Arguments /// * `addr`: target address @@ -849,7 +844,7 @@ impl LedgerChanges { /// /// # Returns /// * true if the address and, optionally the datastore key, exists in the ledger changes - pub fn has_writes(&self, addr: &Address, key: Option>) -> bool { + pub fn has_changes(&self, addr: &Address, key: Option>) -> bool { // Get the current changes being applied to the ledger entry associated to that address match self.0.get(addr) { // This ledger entry is being replaced by a new one: From 99ce8b7b47bff986616d60ac8e26351b581377dd Mon Sep 17 00:00:00 2001 From: Sydhds Date: Tue, 8 Oct 2024 17:50:58 +0200 Subject: [PATCH 25/32] Update tonic to version 0.12.3 and jsonrpsee to 0.24 (#4759) * Update tonic to version 0.12.3 and jsonrpsee to 0.24 * Cargo fmt pass * Test compilation fixes * Set prost as a workspace dependency (will be easier to later upgrade * Fix massa-api tests * Cargo fmt pass * Update jsonrpsee to 0.24.6 * Remove mut for builder * Move dev local dependencies (commented) * Change massa-sc-runtime & massa-proto-rs branches --- Cargo.lock | 603 +++++++++++------- Cargo.toml | 30 +- massa-api/Cargo.toml | 2 +- massa-api/src/api.rs | 2 +- massa-api/src/lib.rs | 15 +- massa-api/src/private.rs | 2 +- massa-api/src/public.rs | 2 +- massa-api/src/tests/public.rs | 2 +- massa-api/src/tests/server.rs | 26 +- .../src/types_trace_info.rs | 2 +- massa-execution-worker/Cargo.toml | 2 +- massa-grpc/Cargo.toml | 1 + massa-grpc/src/server.rs | 10 +- massa-metrics/Cargo.toml | 3 +- massa-metrics/src/server.rs | 8 +- massa-pool-worker/src/denunciation_pool.rs | 3 +- massa-sdk/Cargo.toml | 4 +- massa-sdk/src/lib.rs | 24 +- 18 files changed, 457 insertions(+), 284 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6a4a86c860..a607752d5a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,15 +226,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" -[[package]] -name = "async-lock" -version = "2.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" -dependencies = [ - "event-listener", -] - [[package]] name = "async-stream" version = "0.3.5" @@ -268,6 +259,12 @@ dependencies = [ "syn 2.0.75", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.1.0" @@ -276,18 +273,17 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "itoa", "matchit", "memchr", @@ -304,17 +300,20 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", "futures-util", - "http", - "http-body", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -358,15 +357,6 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" -[[package]] -name = "beef" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" -dependencies = [ - "serde", -] - [[package]] name = "bindgen" version = "0.65.1" @@ -383,7 +373,7 @@ dependencies = [ "proc-macro2 1.0.86", "quote 1.0.37", "regex", - "rustc-hash", + "rustc-hash 1.1.0", "shlex", "syn 2.0.75", ] @@ -490,9 +480,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.5.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -539,6 +529,12 @@ dependencies = [ "libc", ] +[[package]] +name = "cesu8" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" + [[package]] name = "cexpr" version = "0.6.0" @@ -643,7 +639,7 @@ version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", @@ -681,6 +677,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "combine" +version = "4.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" +dependencies = [ + "bytes", + "memchr", +] + [[package]] name = "config" version = "0.13.4" @@ -1476,12 +1482,6 @@ dependencies = [ "str-buf", ] -[[package]] -name = "event-listener" -version = "2.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" - [[package]] name = "fallible-iterator" version = "0.2.0" @@ -1756,15 +1756,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "gloo-net" -version = "0.4.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ac9e8288ae2c632fa9f8657ac70bfe38a1530f345282d7ba66a1f70b72b7dc4" +checksum = "c06f627b1a58ca3d42b45d6104bf1e1a03799df472df00988b6ba21accc10580" dependencies = [ "futures-channel", "futures-core", "futures-sink", "gloo-utils", - "http", + "http 1.1.0", "js-sys", "pin-project", "serde", @@ -1811,7 +1811,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.11", + "indexmap 2.4.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap 2.4.0", "slab", "tokio", @@ -1862,6 +1881,12 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + [[package]] name = "hermit-abi" version = "0.3.3" @@ -1930,6 +1955,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1937,15 +1973,32 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.11", "pin-project-lite", ] [[package]] -name = "http-range-header" -version = "0.3.1" +name = "http-body" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "pin-project-lite", +] [[package]] name = "httparse" @@ -1967,17 +2020,16 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.28" +version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" +checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "http 0.2.11", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1989,33 +2041,76 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + [[package]] name = "hyper-rustls" -version = "0.24.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", - "http", - "hyper", + "http 1.1.0", + "hyper 1.4.1", + "hyper-util", "log", "rustls", - "rustls-native-certs", + "rustls-pki-types", "tokio", "tokio-rustls", - "webpki-roots", + "tower-service", ] [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" +dependencies = [ + "hyper 1.4.1", + "hyper-util", + "pin-project-lite", + "tokio", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ - "hyper", + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.4.1", "pin-project-lite", + "socket2", "tokio", - "tokio-io-timeout", + "tower", + "tower-service", + "tracing", ] [[package]] @@ -2149,6 +2244,26 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" +[[package]] +name = "jni" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec" +dependencies = [ + "cesu8", + "combine", + "jni-sys", + "log", + "thiserror", + "walkdir", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + [[package]] name = "jobserver" version = "0.1.27" @@ -2180,9 +2295,9 @@ dependencies = [ [[package]] name = "jsonrpsee" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "affdc52f7596ccb2d7645231fc6163bb314630c989b64998f3699a28b4d5d4dc" +checksum = "02f01f48e04e0d7da72280ab787c9943695699c9b32b99158ece105e8ad0afea" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -2198,17 +2313,20 @@ dependencies = [ [[package]] name = "jsonrpsee-client-transport" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b005c793122d03217da09af68ba9383363caa950b90d3436106df8cabce935" +checksum = "d80eccbd47a7b9f1e67663fd846928e941cb49c65236e297dd11c9ea3c5e3387" dependencies = [ + "base64 0.22.1", "futures-channel", "futures-util", "gloo-net", - "http", + "http 1.1.0", "jsonrpsee-core", "pin-project", - "rustls-native-certs", + "rustls", + "rustls-pki-types", + "rustls-platform-verifier", "soketto", "thiserror", "tokio", @@ -2216,46 +2334,51 @@ dependencies = [ "tokio-util", "tracing", "url", - "webpki-roots", ] [[package]] name = "jsonrpsee-core" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da2327ba8df2fdbd5e897e2b5ed25ce7f299d345b9736b6828814c3dbd1fd47b" +checksum = "3c2709a32915d816a6e8f625bf72cf74523ebe5d8829f895d6b041b1d3137818" dependencies = [ - "anyhow", - "async-lock", "async-trait", - "beef", + "bytes", "futures-timer", "futures-util", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "jsonrpsee-types", "parking_lot", + "pin-project", "rand", - "rustc-hash", + "rustc-hash 2.0.0", "serde", "serde_json", - "soketto", "thiserror", "tokio", + "tokio-stream", "tracing", "wasm-bindgen-futures", ] [[package]] name = "jsonrpsee-http-client" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f80c17f62c7653ce767e3d7288b793dfec920f97067ceb189ebdd3570f2bc20" +checksum = "cc54db939002b030e794fbfc9d5a925aa2854889c5a2f0352b0bffa54681707e" dependencies = [ "async-trait", - "hyper", + "base64 0.22.1", + "http-body 1.0.1", + "hyper 1.4.1", "hyper-rustls", + "hyper-util", "jsonrpsee-core", "jsonrpsee-types", + "rustls", + "rustls-platform-verifier", "serde", "serde_json", "thiserror", @@ -2267,28 +2390,32 @@ dependencies = [ [[package]] name = "jsonrpsee-proc-macros" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29110019693a4fa2dbda04876499d098fa16d70eba06b1e6e2b3f1b251419515" +checksum = "3a9a4b2eaba8cc928f49c4ccf4fcfa65b690a73997682da99ed08f3393b51f07" dependencies = [ - "heck", - "proc-macro-crate", + "heck 0.5.0", + "proc-macro-crate 3.2.0", "proc-macro2 1.0.86", "quote 1.0.37", - "syn 1.0.109", + "syn 2.0.75", ] [[package]] name = "jsonrpsee-server" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82c39a00449c9ef3f50b84fc00fc4acba20ef8f559f07902244abf4c15c5ab9c" +checksum = "e30110d0f2d7866c8cc6c86483bdab2eb9f4d2f0e20db55518b2bca84651ba8e" dependencies = [ "futures-util", - "http", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", + "hyper-util", "jsonrpsee-core", "jsonrpsee-types", + "pin-project", "route-recognizer", "serde", "serde_json", @@ -2303,23 +2430,21 @@ dependencies = [ [[package]] name = "jsonrpsee-types" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0be325642e850ed0bdff426674d2e66b2b7117c9be23a7caef68a2902b7d9" +checksum = "1ca331cd7b3fe95b33432825c2d4c9f5a43963e207fdc01ae67f9fd80ab0930f" dependencies = [ - "anyhow", - "beef", + "http 1.1.0", "serde", "serde_json", "thiserror", - "tracing", ] [[package]] name = "jsonrpsee-wasm-client" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7cbb3447cf14fd4d2f407c3cc96e6c9634d5440aa1fbed868a31f3c02b27f0" +checksum = "5c603d97578071dc44d79d3cfaf0775437638fd5adc33c6b622dfe4fa2ec812d" dependencies = [ "jsonrpsee-client-transport", "jsonrpsee-core", @@ -2328,11 +2453,11 @@ dependencies = [ [[package]] name = "jsonrpsee-ws-client" -version = "0.20.3" +version = "0.24.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca9cb3933ccae417eb6b08c3448eb1cb46e39834e5b503e395e5e5bd08546c0" +checksum = "755ca3da1c67671f1fae01cd1a47f41dfb2233a8f19a643e587ab0a663942044" dependencies = [ - "http", + "http 1.1.0", "jsonrpsee-client-transport", "jsonrpsee-core", "jsonrpsee-types", @@ -2657,7 +2782,7 @@ dependencies = [ [[package]] name = "massa-proto-rs" version = "0.1.0" -source = "git+https://github.com/massalabs/massa-proto-rs?rev=38950875a7aa406fedc4f0b8336864e5ff290f2c#38950875a7aa406fedc4f0b8336864e5ff290f2c" +source = "git+https://github.com/massalabs/massa-proto-rs?branch=mainnet_2_3#860785129328e3132a020da1eab1a677e8eeea14" dependencies = [ "glob", "prost", @@ -2665,12 +2790,13 @@ dependencies = [ "prost-types", "tonic", "tonic-build", + "tower-service", ] [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#c00be0a2d0976af5a96b59ffba9abc3df2a8e9c9" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#2081855e026cbb8e19ced6b0e2aae67b0de379f1" dependencies = [ "anyhow", "as-ffi-bindings", @@ -2700,7 +2826,7 @@ dependencies = [ "wasmer-compiler-singlepass", "wasmer-middlewares", "wasmer-types", - "which 5.0.0", + "which", ] [[package]] @@ -2709,7 +2835,7 @@ version = "2.3.0" dependencies = [ "async-trait", "futures", - "hyper", + "http 1.1.0", "itertools 0.12.0", "jsonrpsee", "massa_api_exports", @@ -2737,7 +2863,7 @@ dependencies = [ "tokio", "tokio-stream", "tower", - "tower-http", + "tower-http 0.6.1", "tracing", ] @@ -3099,8 +3225,8 @@ version = "2.3.0" dependencies = [ "displaydoc", "futures-util", - "h2", - "hyper", + "h2 0.3.26", + "hyper 1.4.1", "itertools 0.12.0", "massa-proto-rs", "massa_bootstrap", @@ -3130,7 +3256,8 @@ dependencies = [ "tonic-health", "tonic-reflection", "tonic-web", - "tower-http", + "tower-http 0.6.1", + "tower-service", "tracing", ] @@ -3198,7 +3325,7 @@ dependencies = [ name = "massa_metrics" version = "2.3.0" dependencies = [ - "hyper", + "hyper 0.14.30", "lazy_static", "prometheus", "tokio", @@ -3394,7 +3521,7 @@ dependencies = [ name = "massa_sdk" version = "2.3.0" dependencies = [ - "http", + "http 1.1.0", "jsonrpsee", "jsonrpsee-http-client", "jsonrpsee-ws-client", @@ -3840,7 +3967,7 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c11e44798ad209ccdd91fc192f0526a369a01234f7373e1b141c96d7cee4f0e" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", @@ -4239,6 +4366,15 @@ dependencies = [ "toml_edit 0.19.15", ] +[[package]] +name = "proc-macro-crate" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" +dependencies = [ + "toml_edit 0.22.20", +] + [[package]] name = "proc-macro-error" version = "1.0.4" @@ -4313,9 +4449,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -4323,13 +4459,13 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" +checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck", - "itertools 0.10.5", + "heck 0.4.1", + "itertools 0.12.0", "log", "multimap", "once_cell", @@ -4340,17 +4476,16 @@ dependencies = [ "regex", "syn 2.0.75", "tempfile", - "which 4.4.2", ] [[package]] name = "prost-derive" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.12.0", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", @@ -4358,9 +4493,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.3" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -4751,6 +4886,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +[[package]] +name = "rustc-hash" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" + [[package]] name = "rustc_version" version = "0.4.0" @@ -4798,44 +4939,82 @@ dependencies = [ [[package]] name = "rustls" -version = "0.21.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "log", + "once_cell", "ring 0.17.7", + "rustls-pki-types", "rustls-webpki", - "sct", + "subtle", + "zeroize", ] [[package]] name = "rustls-native-certs" -version = "0.6.3" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile", + "rustls-pki-types", "schannel", "security-framework", ] [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.21.5", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" + +[[package]] +name = "rustls-platform-verifier" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" +dependencies = [ + "core-foundation", + "core-foundation-sys", + "jni", + "log", + "once_cell", + "rustls", + "rustls-native-certs", + "rustls-platform-verifier-android", + "rustls-webpki", + "security-framework", + "security-framework-sys", + "webpki-roots", + "winapi", ] +[[package]] +name = "rustls-platform-verifier-android" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" + [[package]] name = "rustls-webpki" -version = "0.101.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring 0.17.7", + "rustls-pki-types", "untrusted 0.9.0", ] @@ -4945,16 +5124,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "sct" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" -dependencies = [ - "ring 0.17.7", - "untrusted 0.9.0", -] - [[package]] name = "seahash" version = "4.1.0" @@ -4963,22 +5132,23 @@ checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" [[package]] name = "security-framework" -version = "2.9.2" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" +checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" dependencies = [ "bitflags 1.3.2", "core-foundation", "core-foundation-sys", "libc", + "num-bigint", "security-framework-sys", ] [[package]] name = "security-framework-sys" -version = "2.9.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -5156,16 +5326,14 @@ dependencies = [ ] [[package]] -name = "sha-1" -version = "0.9.8" +name = "sha1" +version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ - "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug", + "digest 0.10.7", ] [[package]] @@ -5274,9 +5442,9 @@ checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" [[package]] name = "smallvec" -version = "1.11.2" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" dependencies = [ "serde", ] @@ -5293,18 +5461,18 @@ dependencies = [ [[package]] name = "soketto" -version = "0.7.1" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d1c5305e39e09653383c2c7244f2f78b3bcae37cf50c64cb4789c9f5096ec2" +checksum = "37468c595637c10857701c990f93a40ce0e357cedb0953d1c26c8d8027f9bb53" dependencies = [ - "base64 0.13.1", + "base64 0.22.1", "bytes", "futures", - "http", + "http 1.1.0", "httparse", "log", "rand", - "sha-1", + "sha1", ] [[package]] @@ -5374,7 +5542,7 @@ version = "0.25.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23dc1fa9ac9c169a78ba62f0b841814b7abae11bdd047b9c58f893439e309ea0" dependencies = [ - "heck", + "heck 0.4.1", "proc-macro2 1.0.86", "quote 1.0.37", "rustversion", @@ -5431,9 +5599,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "synstructure" @@ -5604,16 +5772,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.2.0" @@ -5627,19 +5785,20 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.24.1" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", + "rustls-pki-types", "tokio", ] [[package]] name = "tokio-stream" -version = "0.1.14" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -5729,26 +5888,28 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.5", + "base64 0.22.1", "bytes", "flate2", - "h2", - "http", - "http-body", - "hyper", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.4.1", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", "prost", - "rustls", "rustls-pemfile", + "socket2", "tokio", "tokio-rustls", "tokio-stream", @@ -5760,22 +5921,23 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" +checksum = "9557ce109ea773b399c9b9e5dca39294110b74f1f342cb347a80d1fce8c26a11" dependencies = [ "prettyplease", "proc-macro2 1.0.86", "prost-build", + "prost-types", "quote 1.0.37", "syn 2.0.75", ] [[package]] name = "tonic-health" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f80db390246dfb46553481f6024f0082ba00178ea495dbb99e70ba9a4fafb5e1" +checksum = "1eaf34ddb812120f5c601162d5429933c9b527d901ab0e7f930d3147e33a09b2" dependencies = [ "async-stream", "prost", @@ -5786,9 +5948,9 @@ dependencies = [ [[package]] name = "tonic-reflection" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fa37c513df1339d197f4ba21d28c918b9ef1ac1768265f11ecb6b7f1cba1b76" +checksum = "878d81f52e7fcfd80026b7fdb6a9b578b3c3653ba987f87f0dce4b64043cba27" dependencies = [ "prost", "prost-types", @@ -5799,19 +5961,19 @@ dependencies = [ [[package]] name = "tonic-web" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fddb2a37b247e6adcb9f239f4e5cefdcc5ed526141a416b943929f13aea2cce" +checksum = "5299dd20801ad736dccb4a5ea0da7376e59cd98f213bf1c3d478cf53f4834b58" dependencies = [ - "base64 0.21.5", + "base64 0.22.1", "bytes", - "http", - "http-body", - "hyper", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", "pin-project", "tokio-stream", "tonic", - "tower-http", + "tower-http 0.5.2", "tower-layer", "tower-service", "tracing", @@ -5840,17 +6002,29 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.4.1", "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-range-header", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "pin-project-lite", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97" +dependencies = [ + "bitflags 2.4.1", + "bytes", + "http 1.1.0", "pin-project-lite", "tower-layer", "tower-service", @@ -5858,15 +6032,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -6485,20 +6659,11 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" - -[[package]] -name = "which" -version = "4.4.2" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ - "either", - "home", - "once_cell", - "rustix 0.38.34", + "rustls-pki-types", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 85cc98422c9..4178921d123 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -106,9 +106,13 @@ massa_versioning = { path = "./massa-versioning" } massa_wallet = { path = "./massa-wallet" } # Massa projects dependencies -massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", "rev" = "38950875a7aa406fedc4f0b8336864e5ff290f2c" } +massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", branch = "mainnet_2_3" } massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" } peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" } +# Dev only - use local dependencies +# massa-proto-rs = { path = "../massa-proto-rs" } +# massa-sc-runtime = { path = "../massa-sc-runtime_3" } +# peernet = { path = "../peernet" } # Common dependencies transition = { git = "https://github.com/massalabs/transition.git", "rev" = "93fa3bf82f9f5ff421c78536879b7fd1b948ca75" } @@ -138,15 +142,15 @@ futures = "0.3" futures-util = "0.3" h2 = "0.3" hex-literal = "0.4" -http = "0.2" +http = "1.1.0" humantime = "2.1" -hyper = "0.14" +hyper = "1" ip_rfc = "0.1" is-terminal = "0.4" itertools = "0.12" -jsonrpsee = "0.20" -jsonrpsee-http-client = "0.20" -jsonrpsee-ws-client = "0.20" +jsonrpsee = "0.24" +jsonrpsee-http-client = "0.24" +jsonrpsee-ws-client = "0.24" lazy_static = "1.4" libsecp256k1 = "=0.7" mio = "0.8.11" @@ -191,15 +195,17 @@ time = "0.3" tokio = "1.23" tokio-stream = "0.1" toml_edit = "0.21" -tonic = "0.10" -tonic-health = "0.10" -tonic-reflection = "0.10" -tonic-web = "0.10" -tower = "0.4.13" -tower-http = "0.4.0" +tonic = "0.12" +tonic-health = "0.12" +tonic-reflection = "0.12" +tonic-web = "0.12" +tower = "0.4" +tower-http = "0.6" +tower-service = "0.3" tracing = "0.1" tracing-subscriber = "0.3" unsigned-varint = "0.8" variant_count = "1.1" walkdir = "2.3" zeroize = { version = "1.7", features = ["derive"] } +prost = { version = "=0.13" } diff --git a/massa-api/Cargo.toml b/massa-api/Cargo.toml index 6e32839b193..bc5581ce70e 100644 --- a/massa-api/Cargo.toml +++ b/massa-api/Cargo.toml @@ -29,7 +29,6 @@ massa_wallet = { workspace = true } async-trait = { workspace = true } futures = { workspace = true } -hyper = { workspace = true } itertools = { workspace = true } jsonrpsee = { workspace = true, "features" = ["server", "macros"] } parking_lot = { workspace = true, "features" = ["deadlock_detection"] } @@ -40,6 +39,7 @@ tokio-stream = { workspace = true, "features" = ["sync"] } tower = { workspace = true, "features" = ["full"] } tower-http = { workspace = true, "features" = ["cors"] } tracing = { workspace = true } +http = { workspace = true } [dev-dependencies] jsonrpsee = { workspace = true, "features" = ["full"] } diff --git a/massa-api/src/api.rs b/massa-api/src/api.rs index bc169c0b8ce..fc9919b9586 100644 --- a/massa-api/src/api.rs +++ b/massa-api/src/api.rs @@ -7,7 +7,7 @@ use crate::{ApiServer, ApiV2, StopHandle, API}; use async_trait::async_trait; use futures::future::{self, Either}; use futures::StreamExt; -use jsonrpsee::core::{Error as JsonRpseeError, RpcResult, SubscriptionResult}; +use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult, SubscriptionResult}; use jsonrpsee::{PendingSubscriptionSink, SubscriptionMessage}; use massa_api_exports::config::APIConfig; use massa_api_exports::error::ApiError; diff --git a/massa-api/src/lib.rs b/massa-api/src/lib.rs index 4f721b7ac94..7db1bcee6ed 100644 --- a/massa-api/src/lib.rs +++ b/massa-api/src/lib.rs @@ -5,11 +5,11 @@ #![warn(unused_crate_dependencies)] use api_trait::MassaApiServer; -use hyper::Method; -use jsonrpsee::core::{Error as JsonRpseeError, RpcResult}; +use http::Method; +use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult}; use jsonrpsee::proc_macros::rpc; -use jsonrpsee::server::middleware::HostFilterLayer; -use jsonrpsee::server::{BatchRequestConfig, ServerBuilder, ServerHandle}; +use jsonrpsee::server::middleware::http::HostFilterLayer; +use jsonrpsee::server::{BatchRequestConfig, PingConfig, ServerBuilder, ServerHandle}; use jsonrpsee::RpcModule; use massa_api_exports::execution::Transfer; use massa_api_exports::{ @@ -150,6 +150,7 @@ async fn serve( url: &SocketAddr, api_config: &APIConfig, ) -> Result { + let ping_config = PingConfig::new().ping_interval(api_config.ping_interval.to_duration()); let mut server_builder = ServerBuilder::new() .max_request_body_size(api_config.max_request_body_size) .max_response_body_size(api_config.max_response_body_size) @@ -159,7 +160,7 @@ async fn serve( } else { BatchRequestConfig::Disabled }) - .ping_interval(api_config.ping_interval.to_duration()); + .enable_ws_ping(ping_config); if api_config.enable_http && !api_config.enable_ws { server_builder = server_builder.http_only(); @@ -174,7 +175,7 @@ async fn serve( .allow_methods([Method::POST, Method::OPTIONS]) // Allow requests from any origin .allow_origin(Any) - .allow_headers([hyper::header::CONTENT_TYPE]); + .allow_headers([http::header::CONTENT_TYPE]); let hosts = if api_config.allow_hosts.is_empty() { vec!["*:*"] @@ -193,7 +194,7 @@ async fn serve( .layer(allowed_hosts); let server = server_builder - .set_middleware(middleware) + .set_http_middleware(middleware) .build(url) .await .expect("failed to build server"); diff --git a/massa-api/src/private.rs b/massa-api/src/private.rs index a22adc3f7c4..75783118aa5 100644 --- a/massa-api/src/private.rs +++ b/massa-api/src/private.rs @@ -3,7 +3,7 @@ use crate::{MassaRpcServer, Private, RpcServer, StopHandle, Value, API}; use async_trait::async_trait; -use jsonrpsee::core::{Error as JsonRpseeError, RpcResult}; +use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult}; use massa_api_exports::{ address::{AddressFilter, AddressInfo}, block::{BlockInfo, BlockSummary}, diff --git a/massa-api/src/public.rs b/massa-api/src/public.rs index 12fb80efada..b3db1247ba2 100644 --- a/massa-api/src/public.rs +++ b/massa-api/src/public.rs @@ -4,7 +4,7 @@ use crate::{MassaRpcServer, Public, RpcServer, StopHandle, Value, API}; use async_trait::async_trait; use itertools::{izip, Itertools}; -use jsonrpsee::core::{Error as JsonRpseeError, RpcResult}; +use jsonrpsee::core::{client::Error as JsonRpseeError, RpcResult}; use massa_api_exports::{ address::{AddressFilter, AddressInfo}, block::{BlockInfo, BlockInfoContent, BlockSummary}, diff --git a/massa-api/src/tests/public.rs b/massa-api/src/tests/public.rs index 05d1ddd5903..2e10680d35b 100644 --- a/massa-api/src/tests/public.rs +++ b/massa-api/src/tests/public.rs @@ -8,7 +8,7 @@ use std::{ }; use jsonrpsee::{ - core::{client::ClientT, Error}, + core::{client::ClientT, client::Error}, http_client::HttpClientBuilder, rpc_params, }; diff --git a/massa-api/src/tests/server.rs b/massa-api/src/tests/server.rs index f15f76685f7..e67794f79ca 100644 --- a/massa-api/src/tests/server.rs +++ b/massa-api/src/tests/server.rs @@ -83,13 +83,11 @@ async fn max_request_size() { OperationId::from_str("O1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC").unwrap(), OperationId::from_str("O1q4CBcuYo8YANEV34W4JRWVHrzcYns19VJfyAB7jT4qfitAnMC").unwrap(), ]]; - let response: Result, jsonrpsee::core::Error> = + let response: Result, jsonrpsee::core::client::Error> = client.request("get_operations", params).await; - assert!(response - .unwrap_err() - .to_string() - .contains("status code: 413")); + let response_str = response.unwrap_err().to_string(); + assert!(response_str.contains("Request rejected `413`")); api_handle.stop().await; } @@ -142,13 +140,11 @@ async fn http_disabled() { )) .unwrap(); - let response: Result, jsonrpsee::core::Error> = + let response: Result, jsonrpsee::core::client::Error> = client.request("get_operations", rpc_params![]).await; - assert!(response - .unwrap_err() - .to_string() - .contains("status code: 403")); + let response_str = response.unwrap_err().to_string(); + assert!(response_str.contains("Request rejected `403`")); api_handle.stop().await; } @@ -178,7 +174,7 @@ async fn host_allowed() { )) .unwrap(); - let response: Result, jsonrpsee::core::Error> = + let response: Result, jsonrpsee::core::client::Error> = client.request("get_operations", rpc_params![]).await; // response OK but invalid params (no params provided) @@ -205,14 +201,12 @@ async fn host_allowed() { )) .unwrap(); - let response: Result, jsonrpsee::core::Error> = + let response: Result, jsonrpsee::core::client::Error> = client.request("get_operations", rpc_params![]).await; // host not allowed - assert!(response - .unwrap_err() - .to_string() - .contains("status code: 403")); + let response_str = response.unwrap_err().to_string(); + assert!(response_str.contains("Request rejected `403`")); api_handle.stop().await; api_handle2.stop().await; diff --git a/massa-execution-exports/src/types_trace_info.rs b/massa-execution-exports/src/types_trace_info.rs index 9655e473513..36b09d9d578 100644 --- a/massa-execution-exports/src/types_trace_info.rs +++ b/massa-execution-exports/src/types_trace_info.rs @@ -88,7 +88,7 @@ impl AbiTrace { while !to_process.is_empty() { let t = to_process.pop_front(); if let Some(trace) = t { - if abi_names.iter().find(|t| *(*t) == trace.name).is_some() { + if abi_names.iter().any(|t| *(*t) == trace.name) { // filtered.extend(&trace) filtered.push(trace); } diff --git a/massa-execution-worker/Cargo.toml b/massa-execution-worker/Cargo.toml index 6789fe3c23b..20b0d6c4680 100644 --- a/massa-execution-worker/Cargo.toml +++ b/massa-execution-worker/Cargo.toml @@ -89,7 +89,7 @@ tempfile = { workspace = true, optional = true } massa_wallet = { workspace = true } massa-proto-rs = { workspace = true } schnellru = { workspace = true } -prost = { version = "=0.12", optional = true } +prost = { workspace = true, optional = true } cfg-if = { workspace = true } rocksdb = { workspace = true } diff --git a/massa-grpc/Cargo.toml b/massa-grpc/Cargo.toml index 0e7372481e5..da9feac019d 100644 --- a/massa-grpc/Cargo.toml +++ b/massa-grpc/Cargo.toml @@ -21,6 +21,7 @@ tonic-web = { workspace = true } tonic-reflection = { workspace = true } tonic-health = { workspace = true } tower-http = { workspace = true, "features" = ["cors"] } +tower-service = { workspace = true } hyper = { workspace = true } futures-util = { workspace = true } serde = { workspace = true, "features" = ["derive"] } diff --git a/massa-grpc/src/server.rs b/massa-grpc/src/server.rs index 76a52a28bf2..ac357397f19 100644 --- a/massa-grpc/src/server.rs +++ b/massa-grpc/src/server.rs @@ -12,8 +12,7 @@ use std::sync::{Arc, Condvar, Mutex}; use crate::config::{GrpcConfig, ServiceName}; use crate::error::GrpcError; use futures_util::FutureExt; -use hyper::service::Service; -use hyper::{Body, Method, Request, Response}; +use hyper::{Method, Request, Response}; use massa_consensus_exports::{ConsensusBroadcasts, ConsensusController}; use massa_execution_exports::{ExecutionChannels, ExecutionController}; use massa_pool_exports::{PoolBroadcasts, PoolController}; @@ -31,7 +30,7 @@ use massa_wallet::Wallet; use tokio::sync::oneshot; use tonic::body::BoxBody; use tonic::codegen::CompressionEncoding; -use tonic::transport::NamedService; +use tonic::server::NamedService; use tonic::transport::{Certificate, Identity, ServerTlsConfig}; use tonic_health::server::HealthReporter; use tonic_web::GrpcWebLayer; @@ -173,7 +172,7 @@ async fn massa_service_status(mut reporter: HealthReporter) { // Configure and start the gRPC API with the given service async fn serve(service: S, config: &GrpcConfig) -> Result where - S: Service, Response = Response, Error = Infallible> + S: tower_service::Service, Response = Response, Error = Infallible> + NamedService + Clone + Send @@ -241,7 +240,8 @@ where }; let reflection_service = tonic_reflection::server::Builder::configure() .register_encoded_file_descriptor_set(file_descriptor_set) - .build()?; + //.build()?; + .build_v1()?; Some(reflection_service) } else { diff --git a/massa-metrics/Cargo.toml b/massa-metrics/Cargo.toml index aadf3542966..cf9962bb80a 100644 --- a/massa-metrics/Cargo.toml +++ b/massa-metrics/Cargo.toml @@ -9,7 +9,8 @@ sandbox = [] [dependencies] prometheus = {workspace = true, "features" = ["process"]} -hyper = {workspace = true, "features" = ["server", "http1"]} # BOM UPGRADE Revert to {"version": "0.14.26", "features": ["server", "tcp", "http1"]} if problem +# hyper = {workspace = true, "features" = ["server", "http1"]} # BOM UPGRADE Revert to {"version": "0.14.26", "features": ["server", "tcp", "http1"]} if problem +hyper = {"version" = "0.14.26", "features" = ["server", "tcp", "http1"]} tokio = {workspace = true, "features" = ["full"]} # BOM UPGRADE Revert to {"version": "1.28.0", "features": ["full"]} if problem lazy_static = {workspace = true} tracing = {workspace = true} diff --git a/massa-metrics/src/server.rs b/massa-metrics/src/server.rs index 0bf27215ff8..09b48d716d4 100644 --- a/massa-metrics/src/server.rs +++ b/massa-metrics/src/server.rs @@ -1,11 +1,7 @@ use std::net::SocketAddr; -use hyper::{ - body::Body, - header::CONTENT_TYPE, - service::{make_service_fn, service_fn}, - Request, Response, -}; +use hyper::service::make_service_fn; +use hyper::{body::Body, header::CONTENT_TYPE, service::service_fn, Request, Response}; use prometheus::{Encoder, TextEncoder}; use tracing::{error, info}; diff --git a/massa-pool-worker/src/denunciation_pool.rs b/massa-pool-worker/src/denunciation_pool.rs index 3e6286ae561..e3b3272e1da 100644 --- a/massa-pool-worker/src/denunciation_pool.rs +++ b/massa-pool-worker/src/denunciation_pool.rs @@ -48,11 +48,10 @@ impl DenunciationPool { pub fn _contains(&self, denunciation: &Denunciation) -> bool { self.denunciations_cache .iter() - .find(|(_, de_st)| match *de_st { + .any(|(_, de_st)| match de_st { DenunciationStatus::Accumulating(_) => false, DenunciationStatus::DenunciationEmitted(de) => de == denunciation, }) - .is_some() } /// Add a denunciation precursor to the pool - can lead to a Denunciation creation diff --git a/massa-sdk/Cargo.toml b/massa-sdk/Cargo.toml index 43742bdf5a8..46165aaf8bd 100644 --- a/massa-sdk/Cargo.toml +++ b/massa-sdk/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" [dependencies] jsonrpsee = {workspace = true, "features" = ["client"]} -jsonrpsee-http-client = {workspace = true, "features" = ["webpki-tls"]} -jsonrpsee-ws-client = {workspace = true, "features" = ["webpki-tls"]} +jsonrpsee-http-client = {workspace = true} +jsonrpsee-ws-client = {workspace = true} http = {workspace = true} tonic = {workspace = true, "features" = ["gzip"]} # BOM UPGRADE Revert to {"version": "0.9.1", "features": ["gzip"]} if problem thiserror = {workspace = true} diff --git a/massa-sdk/src/lib.rs b/massa-sdk/src/lib.rs index 357968cd77c..a8c3f291123 100644 --- a/massa-sdk/src/lib.rs +++ b/massa-sdk/src/lib.rs @@ -575,7 +575,7 @@ impl RpcClientV2 { /// New produced blocks pub async fn subscribe_new_blocks( &self, - ) -> Result, jsonrpsee::core::Error> { + ) -> Result, jsonrpsee::core::client::Error> { if let Some(client) = self.ws_client.as_ref() { client .subscribe( @@ -592,7 +592,8 @@ impl RpcClientV2 { /// New produced blocks headers pub async fn subscribe_new_blocks_headers( &self, - ) -> Result>, jsonrpsee::core::Error> { + ) -> Result>, jsonrpsee::core::client::Error> + { if let Some(client) = self.ws_client.as_ref() { client .subscribe( @@ -609,7 +610,7 @@ impl RpcClientV2 { /// New produced blocks with operations content. pub async fn subscribe_new_filled_blocks( &self, - ) -> Result, jsonrpsee::core::Error> { + ) -> Result, jsonrpsee::core::client::Error> { if let Some(client) = self.ws_client.as_ref() { client .subscribe( @@ -626,7 +627,7 @@ impl RpcClientV2 { /// New produced operations. pub async fn subscribe_new_operations( &self, - ) -> Result, jsonrpsee::core::Error> { + ) -> Result, jsonrpsee::core::client::error::Error> { if let Some(client) = self.ws_client.as_ref() { client .subscribe( @@ -642,18 +643,23 @@ impl RpcClientV2 { } fn http_client_from_url(url: &str, http_config: &HttpConfig) -> HttpClient { - let mut builder = HttpClientBuilder::default() + let builder = HttpClientBuilder::default() .max_request_size(http_config.client_config.max_request_body_size) .request_timeout(http_config.client_config.request_timeout.to_duration()) - .max_concurrent_requests(http_config.client_config.max_concurrent_requests) + // FIXME: the field max_concurrent_requests is private (jsonrpsee 0.24.6) + // .max_concurrent_requests(http_config.client_config.max_concurrent_requests) .id_format(get_id_kind(http_config.client_config.id_kind.as_str())) .set_headers(get_headers(&http_config.client_config.headers)); + // Note: use_*_rustls() are not available anymore + // keep the config for compatibility reason but this will be unused + /* match http_config.client_config.certificate_store.as_str() { "Native" => builder = builder.use_native_rustls(), "WebPki" => builder = builder.use_webpki_rustls(), _ => {} } + */ builder .build(url) @@ -664,7 +670,7 @@ async fn ws_client_from_url(url: &str, ws_config: &WsConfig) -> WsClient where WsClient: SubscriptionClientT, { - let mut builder = WsClientBuilder::default() + let builder = WsClientBuilder::default() .max_request_size(ws_config.client_config.max_request_body_size) .request_timeout(ws_config.client_config.request_timeout.to_duration()) .max_concurrent_requests(ws_config.client_config.max_concurrent_requests) @@ -673,11 +679,15 @@ where .max_buffer_capacity_per_subscription(ws_config.max_notifs_per_subscription) .max_redirections(ws_config.max_redirections); + // Note: use_*_rustls() are not available anymore + // keep the config for compatibility reason but this will be unused + /* match ws_config.client_config.certificate_store.as_str() { "Native" => builder = builder.use_native_rustls(), "WebPki" => builder = builder.use_webpki_rustls(), _ => {} } + */ builder .build(url) From e55fd9ac2bdc84c4d4fa8496db13c00a31c79c07 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Wed, 9 Oct 2024 10:40:47 +0200 Subject: [PATCH 26/32] Early set operation id (#4758) --- massa-execution-worker/src/execution.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/massa-execution-worker/src/execution.rs b/massa-execution-worker/src/execution.rs index 97b892057cf..1da3f12b680 100644 --- a/massa-execution-worker/src/execution.rs +++ b/massa-execution-worker/src/execution.rs @@ -459,6 +459,11 @@ impl ExecutionState { .saturating_sub(operation.get_max_spending(self.config.roll_price)), ); + // set the context origin operation ID + // Note: set operation ID early as if context.transfer_coins fails, event_create will use + // operation ID in the event message + context.origin_operation_id = Some(operation_id); + // debit the fee from the operation sender if let Err(err) = context.transfer_coins(Some(sender_addr), None, operation.content.fee, false) @@ -478,9 +483,6 @@ impl ExecutionState { // set the creator address context.creator_address = Some(operation.content_creator_address); - // set the context origin operation ID - context.origin_operation_id = Some(operation_id); - Ok(context_snapshot) } From df7411979672c7c96a0fb5942d88226e714627d6 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Wed, 9 Oct 2024 10:40:58 +0200 Subject: [PATCH 27/32] Fix message for ExecutionManager (#4757) --- massa-execution-worker/src/controller.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/massa-execution-worker/src/controller.rs b/massa-execution-worker/src/controller.rs index 02d017b5c08..afe220ece10 100644 --- a/massa-execution-worker/src/controller.rs +++ b/massa-execution-worker/src/controller.rs @@ -535,7 +535,7 @@ pub struct ExecutionManagerImpl { impl ExecutionManager for ExecutionManagerImpl { /// stops the worker fn stop(&mut self) { - info!("stopping Execution controller..."); + info!("Stopping Execution controller..."); // notify the worker thread to stop { let mut input_wlock = self.input_data.1.lock(); @@ -546,6 +546,6 @@ impl ExecutionManager for ExecutionManagerImpl { if let Some(join_handle) = self.thread_handle.take() { join_handle.join().expect("VM controller thread panicked"); } - info!("execution controller stopped"); + info!("Execution controller stopped"); } } From ca70988cc951e2d81b8541b0a1c4a700c89247b4 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Thu, 10 Oct 2024 10:50:23 +0200 Subject: [PATCH 28/32] Add missing default gas cost for some abis (#4761) * Add missing default gas cost for some abis * Add xtask check gas cost definitions * Update massa-sc-runtime in Cargo.lock * Update massa-sc-runtime in Cargo.lock - round 2 * Add eclude list in xtask check_gas_cost_definitions * Cargo fmt pass --- .github/workflows/ci.yml | 18 ++++++ Cargo.lock | 9 +-- Cargo.toml | 2 +- .../base_config/gas_costs/abi_gas_costs.json | 8 ++- massa-xtask/Cargo.toml | 3 + massa-xtask/src/check_gas_cost_definitions.rs | 56 +++++++++++++++++++ massa-xtask/src/main.rs | 4 ++ 7 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 massa-xtask/src/check_gas_cost_definitions.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 708eca3eb17..5eac7cc1003 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,6 +116,24 @@ jobs: submodules: "recursive" - uses: crate-ci/typos@master + misc: + if: github.ref != 'refs/heads/staging' + needs: sanity + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - uses: dtolnay/rust-toolchain@master + with: + toolchain: 1.81.0 + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "clippy" + save-if: ${{ github.ref_name == 'main' }} + - run: cargo xtask check_gas_cost_definitions + # Full cross-platform tests required to merge on main branch full: name: full diff --git a/Cargo.lock b/Cargo.lock index a607752d5a9..71e71a5838b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2796,7 +2796,7 @@ dependencies = [ [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#2081855e026cbb8e19ced6b0e2aae67b0de379f1" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=feature/inconsistent_gas_entries#0555ff2ae5a88c96100b4f9caf55ba15bb6839a2" dependencies = [ "anyhow", "as-ffi-bindings", @@ -3645,6 +3645,7 @@ dependencies = [ name = "massa_xtask" version = "2.3.0" dependencies = [ + "massa-sc-runtime", "massa_models", "toml_edit 0.21.0", "walkdir", @@ -4464,8 +4465,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.4.1", - "itertools 0.12.0", + "heck 0.5.0", + "itertools 0.10.5", "log", "multimap", "once_cell", @@ -4485,7 +4486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.12.0", + "itertools 0.10.5", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", diff --git a/Cargo.toml b/Cargo.toml index 4178921d123..50a5f48bc74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ massa_wallet = { path = "./massa-wallet" } # Massa projects dependencies massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", branch = "mainnet_2_3" } -massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" } +massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "feature/inconsistent_gas_entries" } peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" } # Dev only - use local dependencies # massa-proto-rs = { path = "../massa-proto-rs" } diff --git a/massa-node/base_config/gas_costs/abi_gas_costs.json b/massa-node/base_config/gas_costs/abi_gas_costs.json index 66ad4901324..3d35aa5cfdb 100644 --- a/massa-node/base_config/gas_costs/abi_gas_costs.json +++ b/massa-node/base_config/gas_costs/abi_gas_costs.json @@ -125,5 +125,11 @@ "abi_unsafe_random": 402, "abi_verify_signature": 1192, "abi_chain_id": 301, - "launch_wasmv1": 18641 + "launch_wasmv1": 18641, + "assembly_script_console_log": 171, + "assembly_script_console_info": 171, + "assembly_script_console_debug": 171, + "assembly_script_console_warn": 171, + "assembly_script_console_error": 171, + "assembly_script_trace": 171 } \ No newline at end of file diff --git a/massa-xtask/Cargo.toml b/massa-xtask/Cargo.toml index 7e268a344cd..a5f3c178506 100644 --- a/massa-xtask/Cargo.toml +++ b/massa-xtask/Cargo.toml @@ -4,6 +4,9 @@ version = "2.3.0" edition = "2021" [dependencies] +# update_package_versions dependencies massa_models = {workspace = true} toml_edit = {workspace = true} # BOM UPGRADE Revert to "0.19.8" if problem walkdir = {workspace = true} +# check_gas_costs dependencies +massa-sc-runtime = {workspace = true, features = ["gas_calibration"]} diff --git a/massa-xtask/src/check_gas_cost_definitions.rs b/massa-xtask/src/check_gas_cost_definitions.rs new file mode 100644 index 00000000000..a754238c8ec --- /dev/null +++ b/massa-xtask/src/check_gas_cost_definitions.rs @@ -0,0 +1,56 @@ +use massa_sc_runtime::GasCosts; +use std::collections::HashSet; + +pub(crate) fn check_gas_cost_definitions() -> Result<(), String> { + // Check gas cost definition between: + // massa-node/base_config/gas_costs/abi_gas_costs.json + // massa-sc-runtime GasCosts::default() + + let gas_costs = GasCosts::default(); + let gas_costs_abi_defined = gas_costs + .get_abi_costs() + .keys() + .cloned() + .collect::>(); + + let massa_node_gas_costs = GasCosts::new( + // SETTINGS.execution.abi_gas_costs_file.clone(), + // SETTINGS.execution.wasm_gas_costs_file.clone(), + "massa-node/base_config/gas_costs/abi_gas_costs.json".into(), + "massa-node/base_config/gas_costs/wasm_gas_costs.json".into(), + ) + .expect("Failed to load gas costs"); + + let massa_node_gas_costs_abi_defined = massa_node_gas_costs + .get_abi_costs() + .keys() + .cloned() + .collect::>(); + + let mut found_diff = false; + let diff_1 = gas_costs_abi_defined.difference(&massa_node_gas_costs_abi_defined); + for x1 in diff_1 { + println!("Found in default() but not in json: {x1}"); + found_diff = true; + } + + let diff_2 = massa_node_gas_costs_abi_defined.difference(&gas_costs_abi_defined); + let exclude_list = HashSet::from([ + "cl_compilation", + "launch", + "sp_compilation", + "launch_wasmv1", + "max_instance", + ]); + for x2 in diff_2 { + if !exclude_list.contains(x2.as_str()) { + println!("Found in json but not in default(): {x2}"); + } + } + + if found_diff { + Err("Found gas costs definition differences".to_string()) + } else { + Ok(()) + } +} diff --git a/massa-xtask/src/main.rs b/massa-xtask/src/main.rs index a962ef40764..df8aacee12e 100644 --- a/massa-xtask/src/main.rs +++ b/massa-xtask/src/main.rs @@ -1,4 +1,7 @@ +mod check_gas_cost_definitions; mod update_package_versions; + +use crate::check_gas_cost_definitions::check_gas_cost_definitions; use crate::update_package_versions::update_package_versions; use std::env; @@ -10,6 +13,7 @@ fn main() { match task.as_deref() { // We can add more tasks here Some("update_package_versions") => update_package_versions(), + Some("check_gas_cost_definitions") => check_gas_cost_definitions().unwrap(), _ => panic!("Unknown task"), } } From 3f59fd95a303543ee533206d26b2b96dc71267da Mon Sep 17 00:00:00 2001 From: Sydhds Date: Fri, 11 Oct 2024 09:59:35 +0200 Subject: [PATCH 29/32] Add additional verification for v & s value in evm_signature_verify (#4762) * Add additional verification for v & s value in evm_signature_verify * Cargo fmt pass * Add additional verification for v & s value in evm_get_pubkey_from_signature * Cargo fmt pass * Isolate some tests * Cargo clippy fixes * Reject signature if signature.s is high order --- massa-execution-worker/src/interface_impl.rs | 59 +++++++++++--- massa-execution-worker/src/tests/interface.rs | 79 ++++++++++++++++++- 2 files changed, 128 insertions(+), 10 deletions(-) diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index 1ccd389f3d4..65ae41b08ae 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -883,10 +883,7 @@ impl Interface for InterfaceImpl { } // parse the public key - let public_key = libsecp256k1::PublicKey::parse_slice( - public_key_, - Some(libsecp256k1::PublicKeyFormat::Raw), - )?; + let public_key = libsecp256k1::PublicKey::parse_slice(public_key_, None)?; // build the message let prefix = format!("\x19Ethereum Signed Message:\n{}", message_.len()); @@ -899,10 +896,37 @@ impl Interface for InterfaceImpl { // r is the R.x value of the signature's R point (32 bytes) // s is the signature proof for R.x (32 bytes) // v is a recovery parameter used to ease the signature verification (1 byte) - // we ignore the recovery parameter here // see test_evm_verify for an example of its usage + let recovery_id: u8 = libsecp256k1::RecoveryId::parse_rpc(signature_[64])?.into(); + // Note: parse_rpc returns p - 27 and allow for 27, 28, 29, 30 + // restrict to only 27 & 28 (=> 0 & 1) + if recovery_id != 0 && recovery_id != 1 { + // Note: + // The v value in an EVM signature serves as a recovery ID, + // aiding in the recovery of the public key from the signature. + // Typically, v should be either 27 or 28 + // (or sometimes 0 or 1, depending on the implementation). + // Ensuring that v is within the expected range is crucial + // for correctly recovering the public key. + // the Ethereum yellow paper specifies only 27 and 28, requiring additional checks. + return Err(anyhow!( + "invalid recovery id value (v = {recovery_id}) in evm_signature_verify" + )); + } + let signature = libsecp256k1::Signature::parse_standard_slice(&signature_[..64])?; + // Note: + // The s value in an EVM signature should be in the lower half of the elliptic curve + // in order to prevent malleability attacks. + // If s is in the high-order range, it can be converted to its low-order equivalent, + // which should be enforced during signature verification. + if signature.s.is_high() { + return Err(anyhow!( + "High-Order s Value are prohibited in evm_get_pubkey_from_signature" + )); + } + // verify the signature Ok(libsecp256k1::verify(&message, &signature, &public_key)) } @@ -941,16 +965,33 @@ impl Interface for InterfaceImpl { } // parse the message - let message = libsecp256k1::Message::parse_slice(hash_).unwrap(); + let message = libsecp256k1::Message::parse_slice(hash_)?; // parse the signature as being (r, s, v) use only r and s - let signature = libsecp256k1::Signature::parse_standard_slice(&signature_[..64]).unwrap(); + let signature = libsecp256k1::Signature::parse_standard_slice(&signature_[..64])?; + + // Note: + // See evm_signature_verify explanation + if signature.s.is_high() { + return Err(anyhow!( + "High-Order s Value are prohibited in evm_get_pubkey_from_signature" + )); + } // parse v as a recovery id - let recovery_id = libsecp256k1::RecoveryId::parse_rpc(signature_[64]).unwrap(); + let recovery_id = libsecp256k1::RecoveryId::parse_rpc(signature_[64])?; + + let recovery_id_: u8 = recovery_id.into(); + if recovery_id_ != 0 && recovery_id_ != 1 { + // Note: + // See evm_signature_verify explanation + return Err(anyhow!( + "invalid recovery id value (v = {recovery_id_}) in evm_get_pubkey_from_signature" + )); + } // recover the public key - let recovered = libsecp256k1::recover(&message, &signature, &recovery_id).unwrap(); + let recovered = libsecp256k1::recover(&message, &signature, &recovery_id)?; // return its serialized value Ok(recovered.serialize().to_vec()) diff --git a/massa-execution-worker/src/tests/interface.rs b/massa-execution-worker/src/tests/interface.rs index 506ab937f7a..6ada4d6a134 100644 --- a/massa-execution-worker/src/tests/interface.rs +++ b/massa-execution-worker/src/tests/interface.rs @@ -1,11 +1,15 @@ // Copyright (c) 2022 MASSA LABS +use std::str::FromStr; + use hex_literal::hex; +use sha2::Digest; + use massa_models::address::Address; use massa_sc_runtime::Interface; -use std::str::FromStr; use crate::interface_impl::InterfaceImpl; + #[test] fn test_hash_sha256() { let interface = InterfaceImpl::new_default( @@ -17,3 +21,76 @@ fn test_hash_sha256() { &hex!("3fc9b689459d738f8c88a3a48aa9e33542016b7a4052e001aaa536fca74813cb")[..]; assert_eq!(actual_hash, expected_hash); } + +#[test] +fn test_evm_signature_verify() { + let interface = InterfaceImpl::new_default( + Address::from_str("AU12cMW9zRKFDS43Z2W88VCmdQFxmHjAo54XvuVV34UzJeXRLXW9M").unwrap(), + None, + ); + + let _address = hex!("807a7bb5193edf9898b9092c1597bb966fe52514"); + let message_ = b"test"; + let signature_ = hex!("d0d05c35080635b5e865006c6c4f5b5d457ec342564d8fc67ce40edc264ccdab3f2f366b5bd1e38582538fed7fa6282148e86af97970a10cb3302896f5d68ef51b"); + let private_key_ = hex!("ed6602758bdd68dc9df67a6936ed69807a74b8cc89bdc18f3939149d02db17f3"); + + // build original public key + let private_key = libsecp256k1::SecretKey::parse_slice(&private_key_).unwrap(); + let public_key = libsecp256k1::PublicKey::from_secret_key(&private_key); + + let result = interface.evm_signature_verify(message_, &signature_, &public_key.serialize()); + assert!(result.is_ok()); + + // Invalid v + { + let mut signature_2_ = signature_; + signature_2_[64] ^= 1; + let result = + interface.evm_signature_verify(message_, &signature_2_, &public_key.serialize()); + assert!(result.is_err()); + } +} + +#[test] +fn test_evm_get_pubkey_from_signature() { + let interface = InterfaceImpl::new_default( + Address::from_str("AU12cMW9zRKFDS43Z2W88VCmdQFxmHjAo54XvuVV34UzJeXRLXW9M").unwrap(), + None, + ); + + // let _address = hex!("807a7bb5193edf9898b9092c1597bb966fe52514"); + let message_ = b"test"; + let signature_ = hex!("d0d05c35080635b5e865006c6c4f5b5d457ec342564d8fc67ce40edc264ccdab3f2f366b5bd1e38582538fed7fa6282148e86af97970a10cb3302896f5d68ef51b"); + let private_key_ = hex!("ed6602758bdd68dc9df67a6936ed69807a74b8cc89bdc18f3939149d02db17f3"); + + // build original public key + let private_key = libsecp256k1::SecretKey::parse_slice(&private_key_).unwrap(); + let public_key = libsecp256k1::PublicKey::from_secret_key(&private_key); + + // build the hash + let prefix = format!("\x19Ethereum Signed Message:\n{}", message_.len()); + let to_hash = [prefix.as_bytes(), message_].concat(); + let full_hash = sha3::Keccak256::digest(to_hash); + + let result = interface.evm_get_pubkey_from_signature(&full_hash, &signature_); + assert!(result.is_ok()); + assert_eq!(public_key.serialize(), result.unwrap().as_ref()); + + // Invalid s + { + let mut signature_2 = + libsecp256k1::Signature::parse_standard_slice(&signature_[..64]).unwrap(); + signature_2.s = -signature_2.s; + assert!(signature_2.s.is_high()); + let result = interface.evm_get_pubkey_from_signature(&full_hash, &signature_2.serialize()); + assert!(result.is_err()); + } + + // Invalid v + { + let mut signature_2_ = signature_; + signature_2_[64] ^= 1; + let result = interface.evm_get_pubkey_from_signature(&full_hash, &signature_2_); + assert!(result.is_err()); + } +} From b616bda0998c0f24752fc13dcc09ada231ebd0e1 Mon Sep 17 00:00:00 2001 From: Sydhds Date: Mon, 14 Oct 2024 09:58:51 +0200 Subject: [PATCH 30/32] Remove wasm_gas_costs.json and used a constant value for wasm operator (#4763) * Remove wasm_gas_costs.json and used a constant value for wasm operator * Cargo fmt pass * Update massa-sc-runtime dependency --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- massa-execution-exports/src/test_exports/config.rs | 5 ----- .../base_config/gas_costs/wasm_gas_costs.json | 13 ------------- massa-node/src/main.rs | 7 ++----- massa-node/src/settings.rs | 1 - massa-xtask/src/check_gas_cost_definitions.rs | 1 - 7 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 massa-node/base_config/gas_costs/wasm_gas_costs.json diff --git a/Cargo.lock b/Cargo.lock index 71e71a5838b..6172a1b36d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2796,7 +2796,7 @@ dependencies = [ [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?branch=feature/inconsistent_gas_entries#0555ff2ae5a88c96100b4f9caf55ba15bb6839a2" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#e8040e69f3f4f31b7ab57c30af4aa87820788950" dependencies = [ "anyhow", "as-ffi-bindings", @@ -4465,8 +4465,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.5.0", - "itertools 0.10.5", + "heck 0.4.1", + "itertools 0.12.0", "log", "multimap", "once_cell", @@ -4486,7 +4486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", - "itertools 0.10.5", + "itertools 0.12.0", "proc-macro2 1.0.86", "quote 1.0.37", "syn 2.0.75", diff --git a/Cargo.toml b/Cargo.toml index 50a5f48bc74..4178921d123 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -107,7 +107,7 @@ massa_wallet = { path = "./massa-wallet" } # Massa projects dependencies massa-proto-rs = { git = "https://github.com/massalabs/massa-proto-rs", branch = "mainnet_2_3" } -massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "feature/inconsistent_gas_entries" } +massa-sc-runtime = { git = "https://github.com/massalabs/massa-sc-runtime", "branch" = "next_breaking_update" } peernet = { git = "https://github.com/massalabs/PeerNet", "rev" = "04b05ddd320fbe76cc858115af7b5fc28bdb8310" } # Dev only - use local dependencies # massa-proto-rs = { path = "../massa-proto-rs" } diff --git a/massa-execution-exports/src/test_exports/config.rs b/massa-execution-exports/src/test_exports/config.rs index 063fd5a52a0..c583cb6d6fb 100644 --- a/massa-execution-exports/src/test_exports/config.rs +++ b/massa-execution-exports/src/test_exports/config.rs @@ -56,11 +56,6 @@ impl Default for ExecutionConfig { "/../massa-node/base_config/gas_costs/abi_gas_costs.json" ) .into(), - concat!( - env!("CARGO_MANIFEST_DIR"), - "/../massa-node/base_config/gas_costs/wasm_gas_costs.json" - ) - .into(), ) .unwrap(), base_operation_gas_cost: BASE_OPERATION_GAS_COST, diff --git a/massa-node/base_config/gas_costs/wasm_gas_costs.json b/massa-node/base_config/gas_costs/wasm_gas_costs.json deleted file mode 100644 index bac1b461b78..00000000000 --- a/massa-node/base_config/gas_costs/wasm_gas_costs.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Wasm:Drop": 0, - "Wasm:GlobalGet": 27, - "Wasm:GlobalSet": 75, - "Wasm:I32Add": 38, - "Wasm:I32Const": 11, - "Wasm:I32DivS": 6, - "Wasm:I32Mul": 58, - "Wasm:I32Sub": 0, - "Wasm:If": 44, - "Wasm:LocalGet": 0, - "Wasm:LocalSet": 0 -} \ No newline at end of file diff --git a/massa-node/src/main.rs b/massa-node/src/main.rs index 8334bad3749..c80a594c893 100644 --- a/massa-node/src/main.rs +++ b/massa-node/src/main.rs @@ -462,11 +462,8 @@ async fn launch( }; // gas costs - let gas_costs = GasCosts::new( - SETTINGS.execution.abi_gas_costs_file.clone(), - SETTINGS.execution.wasm_gas_costs_file.clone(), - ) - .expect("Failed to load gas costs"); + let gas_costs = GasCosts::new(SETTINGS.execution.abi_gas_costs_file.clone()) + .expect("Failed to load gas costs"); // Limits imposed to wasm files so the compilation phase is smooth let condom_limits = CondomLimits { diff --git a/massa-node/src/settings.rs b/massa-node/src/settings.rs index 4d1d443dd39..a6a112d568f 100644 --- a/massa-node/src/settings.rs +++ b/massa-node/src/settings.rs @@ -27,7 +27,6 @@ pub struct ExecutionSettings { pub stats_time_window_duration: MassaTime, pub max_read_only_gas: u64, pub abi_gas_costs_file: PathBuf, - pub wasm_gas_costs_file: PathBuf, pub hd_cache_path: PathBuf, pub lru_cache_size: u32, pub hd_cache_size: usize, diff --git a/massa-xtask/src/check_gas_cost_definitions.rs b/massa-xtask/src/check_gas_cost_definitions.rs index a754238c8ec..2976aed9dd4 100644 --- a/massa-xtask/src/check_gas_cost_definitions.rs +++ b/massa-xtask/src/check_gas_cost_definitions.rs @@ -17,7 +17,6 @@ pub(crate) fn check_gas_cost_definitions() -> Result<(), String> { // SETTINGS.execution.abi_gas_costs_file.clone(), // SETTINGS.execution.wasm_gas_costs_file.clone(), "massa-node/base_config/gas_costs/abi_gas_costs.json".into(), - "massa-node/base_config/gas_costs/wasm_gas_costs.json".into(), ) .expect("Failed to load gas costs"); From b691160ad1e0e21e3985b2b97554b5452974bdab Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Tue, 15 Oct 2024 15:08:15 +0200 Subject: [PATCH 31/32] Cargo clippy fix --- massa-ledger-exports/src/ledger_changes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/massa-ledger-exports/src/ledger_changes.rs b/massa-ledger-exports/src/ledger_changes.rs index 5c4e1eb5839..790c4f91122 100644 --- a/massa-ledger-exports/src/ledger_changes.rs +++ b/massa-ledger-exports/src/ledger_changes.rs @@ -839,9 +839,9 @@ impl LedgerChanges { /// and optionally if a datastore key write also exists in the address's datastore. /// Notes: /// - A ledger entry could be written to without any changes on the values associated, - /// for example if the value was changed multiple times in the same slot. + /// for example if the value was changed multiple times in the same slot. /// - This code assumes Delete cannot be shadowed by Set operations in the same slot, which may not be the case - /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. + /// when / if we allow full entry Delete given the current LedgerChanges::Delete handling. In that case, a rework may be necessary. /// /// # Arguments /// * `addr`: target address From 3833083871dc71da097d0dfb323a39b9ed188367 Mon Sep 17 00:00:00 2001 From: Leo-Besancon Date: Wed, 16 Oct 2024 11:19:29 +0200 Subject: [PATCH 32/32] Add SC recursion limit (#4729) * Asc message execution - requery message bytecode after each message execution (#4710) * Requery bytecode * cargo fmt * fix call stack inconsistency (#4709) * Improve async message checks (#4706) * Improve async message checks * Change checks for async messages * Add unit tests * Fix ledger change to take into account cancelled message balance change (#4715) * Take again the speculative changes after async message cancellation * use .apply() to merge the two LedgerChanges * Fix: we cannot combine two ledger changes with apply * avoid cloning the changes * Remove comment * Fix async msg same slot (#4718) * fix open rpc spec (#4716) * Add eliminated_new_messages in eliminated_msg --------- Co-authored-by: Modship * Add initial code for recursion limit * Latest runtime * Run CI on PRs based on mainnet_2_3 * fmt * Fix config and add UTs * Update scenarios_mandatories.rs * Review comments (CI for all branches starting with "mainnet_" + comment) * Update ci.yml * Remove manual increment / decrement in interface implementation * fmt + update sc_runtime + fix warning * Update test * Update constants.rs * Updated execution config for tests * Updated usize -> u16 for recursion counter and limits * Update test comments * Add comments regarding the needs of this limits * Update sc-runtime branch --------- Co-authored-by: Modship --- Cargo.lock | 32 +-- massa-execution-exports/src/settings.rs | 3 + .../src/test_exports/config.rs | 1 + massa-execution-worker/src/context.rs | 11 ++ massa-execution-worker/src/interface_impl.rs | 23 +++ .../src/tests/scenarios_mandatories.rs | 183 ++++++++++++++++++ massa-models/src/config/constants.rs | 2 + massa-node/src/main.rs | 7 +- 8 files changed, 243 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6172a1b36d9..051c0afba0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1120,9 +1120,9 @@ dependencies = [ [[package]] name = "dashmap" -version = "6.0.1" +version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "804c8821570c3f8b70230c2ba75ffa5c0f9a4189b9a432b6656c536712acae28" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" dependencies = [ "cfg-if", "crossbeam-utils", @@ -1513,9 +1513,9 @@ checksum = "27573eac26f4dd11e2b1916c3fe1baa56407c83c71a773a8ba17ec0bca03b6b7" [[package]] name = "filetime" -version = "0.2.24" +version = "0.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" dependencies = [ "cfg-if", "libc", @@ -2532,7 +2532,7 @@ checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ "bitflags 2.4.1", "libc", - "redox_syscall 0.5.3", + "redox_syscall 0.5.7", ] [[package]] @@ -2796,7 +2796,7 @@ dependencies = [ [[package]] name = "massa-sc-runtime" version = "0.10.0" -source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#e8040e69f3f4f31b7ab57c30af4aa87820788950" +source = "git+https://github.com/massalabs/massa-sc-runtime?branch=next_breaking_update#095d6253bf6c31e725f056c79b4df9994f39380e" dependencies = [ "anyhow", "as-ffi-bindings", @@ -4465,7 +4465,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c1318b19085f08681016926435853bbf7858f9c082d0999b80550ff5d9abe15" dependencies = [ "bytes", - "heck 0.4.1", + "heck 0.5.0", "itertools 0.12.0", "log", "multimap", @@ -4674,9 +4674,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.4.1", ] @@ -5252,9 +5252,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -5624,9 +5624,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "tar" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" dependencies = [ "filetime", "libc", @@ -6570,7 +6570,7 @@ dependencies = [ "cfg-if", "corosensei", "crossbeam-queue", - "dashmap 6.0.1", + "dashmap 6.1.0", "derivative", "enum-iterator", "fnv", @@ -6631,9 +6631,9 @@ dependencies = [ [[package]] name = "webc" -version = "6.0.0-rc2" +version = "6.0.0-rc3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb3e2ccb43d303c5bd48f31db7a129481a9aaa5343d623f92951751df190df81" +checksum = "b85ffb11d1fabf0ebfc458a3d1d34ccf6d4d9596ca7576370cae4eab554c63d1" dependencies = [ "anyhow", "base64 0.22.1", diff --git a/massa-execution-exports/src/settings.rs b/massa-execution-exports/src/settings.rs index 4998cbc3b24..f62cc08ae01 100644 --- a/massa-execution-exports/src/settings.rs +++ b/massa-execution-exports/src/settings.rs @@ -102,6 +102,9 @@ pub struct ExecutionConfig { pub max_execution_traces_slot_limit: usize, /// Where to dump blocks pub block_dump_folder_path: PathBuf, + /// Max recursive calls depth in SC + /// Used to limit the recursion_counter value in the context, to avoid stack overflow issues. + pub max_recursive_calls_depth: u16, /// Runtime condom middleware limits pub condom_limits: CondomLimits, } diff --git a/massa-execution-exports/src/test_exports/config.rs b/massa-execution-exports/src/test_exports/config.rs index c583cb6d6fb..c0d51bd747c 100644 --- a/massa-execution-exports/src/test_exports/config.rs +++ b/massa-execution-exports/src/test_exports/config.rs @@ -76,6 +76,7 @@ impl Default for ExecutionConfig { broadcast_slot_execution_traces_channel_capacity: 5000, max_execution_traces_slot_limit: 320, block_dump_folder_path, + max_recursive_calls_depth: 25, condom_limits: CondomLimits { max_exports: Some(100), max_functions: Some(100), diff --git a/massa-execution-worker/src/context.rs b/massa-execution-worker/src/context.rs index 60e74219d6f..54f65417f60 100644 --- a/massa-execution-worker/src/context.rs +++ b/massa-execution-worker/src/context.rs @@ -91,6 +91,11 @@ pub struct ExecutionContextSnapshot { /// The gas remaining before the last subexecution. /// so *excluding* the gas used by the last sc call. pub gas_remaining_before_subexecution: Option, + + /// recursion counter, incremented for each new nested call + /// This is used to avoid stack overflow issues in the VM (that would crash the node instead of failing the call), + /// by limiting the depth of recursion contracts can have with the max_recursive_calls_depth value. + pub recursion_counter: u16, } /// An execution context that needs to be initialized before executing bytecode, @@ -179,6 +184,9 @@ pub struct ExecutionContext { /// The gas remaining before the last subexecution. /// so *excluding* the gas used by the last sc call. pub gas_remaining_before_subexecution: Option, + + /// recursion counter, incremented for each new nested call + pub recursion_counter: u16, } impl ExecutionContext { @@ -244,6 +252,7 @@ impl ExecutionContext { address_factory: AddressFactory { mip_store }, execution_trail_hash, gas_remaining_before_subexecution: None, + recursion_counter: 0, } } @@ -265,6 +274,7 @@ impl ExecutionContext { event_count: self.events.0.len(), unsafe_rng: self.unsafe_rng.clone(), gas_remaining_before_subexecution: self.gas_remaining_before_subexecution, + recursion_counter: self.recursion_counter, } } @@ -293,6 +303,7 @@ impl ExecutionContext { self.stack = snapshot.stack; self.unsafe_rng = snapshot.unsafe_rng; self.gas_remaining_before_subexecution = snapshot.gas_remaining_before_subexecution; + self.recursion_counter = snapshot.recursion_counter; // For events, set snapshot delta to error events. for event in self.events.0.range_mut(snapshot.event_count..) { diff --git a/massa-execution-worker/src/interface_impl.rs b/massa-execution-worker/src/interface_impl.rs index 65ae41b08ae..4f55eaef0cc 100644 --- a/massa-execution-worker/src/interface_impl.rs +++ b/massa-execution-worker/src/interface_impl.rs @@ -227,6 +227,29 @@ impl Interface for InterfaceImpl { Ok(()) } + fn increment_recursion_counter(&self) -> Result<()> { + let mut context = context_guard!(self); + + context.recursion_counter += 1; + + if context.recursion_counter > self.config.max_recursive_calls_depth { + bail!("recursion depth limit reached"); + } + + Ok(()) + } + + fn decrement_recursion_counter(&self) -> Result<()> { + let mut context = context_guard!(self); + + match context.recursion_counter.checked_sub(1) { + Some(value) => context.recursion_counter = value, + None => bail!("recursion counter underflow"), + } + + Ok(()) + } + /// Initialize the call when bytecode calls a function from another bytecode /// This function transfers the coins passed as parameter, /// prepares the current execution context by pushing a new element on the top of the call stack, diff --git a/massa-execution-worker/src/tests/scenarios_mandatories.rs b/massa-execution-worker/src/tests/scenarios_mandatories.rs index f9009270085..b811f83235e 100644 --- a/massa-execution-worker/src/tests/scenarios_mandatories.rs +++ b/massa-execution-worker/src/tests/scenarios_mandatories.rs @@ -449,6 +449,189 @@ fn test_nested_call_gas_usage() { ); } +/// Test the recursion depth limit in nested calls using call SC operation +/// +/// We call a smart contract that has a nested function call, while setting the max_recursive_calls_depth to 0. +/// We expect the execution of the smart contract call to fail with a message that the recursion depth limit was reached. +#[test] +fn test_nested_call_recursion_limit_reached() { + // setup the period duration + let exec_cfg = ExecutionConfig { + max_recursive_calls_depth: 0, // This limit will be reached + ..Default::default() + }; + + let finalized_waitpoint = WaitPoint::new(); + let mut foreign_controllers = ExecutionForeignControllers::new_with_mocks(); + selector_boilerplate(&mut foreign_controllers.selector_controller); + + foreign_controllers + .ledger_controller + .set_expectations(|ledger_controller| { + ledger_controller + .expect_get_balance() + .returning(move |_| Some(Amount::from_str("100").unwrap())); + + ledger_controller + .expect_entry_exists() + .times(2) + .returning(move |_| false); + + ledger_controller + .expect_entry_exists() + .times(1) + .returning(move |_| true); + }); + let saved_bytecode = expect_finalize_deploy_and_call_blocks( + Slot::new(1, 0), + Some(Slot::new(1, 1)), + finalized_waitpoint.get_trigger_handle(), + &mut foreign_controllers.final_state, + ); + final_state_boilerplate( + &mut foreign_controllers.final_state, + foreign_controllers.db.clone(), + &foreign_controllers.selector_controller, + &mut foreign_controllers.ledger_controller, + Some(saved_bytecode), + None, + None, + ); + let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg); + + // load bytecodes + universe.deploy_bytecode_block( + &KeyPair::from_str(TEST_SK_1).unwrap(), + Slot::new(1, 0), + include_bytes!("./wasm/nested_call.wasm"), + include_bytes!("./wasm/test.wasm"), + ); + finalized_waitpoint.wait(); + let address = universe.get_address_sc_deployed(Slot::new(1, 0)); + + // Call the function test of the smart contract + let operation = ExecutionTestUniverse::create_call_sc_operation( + &KeyPair::from_str(TEST_SK_2).unwrap(), + 10000000, + Amount::from_str("0").unwrap(), + Amount::from_str("0").unwrap(), + Address::from_str(&address).unwrap(), + String::from("test"), + address.as_bytes().to_vec(), + ) + .unwrap(); + universe.call_sc_block( + &KeyPair::from_str(TEST_SK_2).unwrap(), + Slot::new(1, 1), + operation, + ); + finalized_waitpoint.wait(); + + // Get the events of the smart contract execution. We expect the call to have failed, so we check for the error message. + let events = universe + .module_controller + .get_filtered_sc_output_event(EventFilter { + start: Some(Slot::new(1, 1)), + ..Default::default() + }); + assert!(events.len() >= 2); + //println!("events: {:?}", events); + assert!(events[1].data.contains("recursion depth limit reached")); +} + +/// Test the recursion depth limit in nested calls using call SC operation +/// +/// We call a smart contract that has a nested function call, while setting the max_recursive_calls_depth to 2. +/// We expect the execution of the smart contract call to succeed as the recursion depth limit was not reached. +#[test] +fn test_nested_call_recursion_limit_not_reached() { + // setup the period duration + let exec_cfg = ExecutionConfig { + max_recursive_calls_depth: 2, // This limit will not be reached + ..Default::default() + }; + + let finalized_waitpoint = WaitPoint::new(); + let mut foreign_controllers = ExecutionForeignControllers::new_with_mocks(); + selector_boilerplate(&mut foreign_controllers.selector_controller); + + foreign_controllers + .ledger_controller + .set_expectations(|ledger_controller| { + ledger_controller + .expect_get_balance() + .returning(move |_| Some(Amount::from_str("100").unwrap())); + + ledger_controller + .expect_entry_exists() + .times(2) + .returning(move |_| false); + + ledger_controller + .expect_entry_exists() + .times(1) + .returning(move |_| true); + }); + let saved_bytecode = expect_finalize_deploy_and_call_blocks( + Slot::new(1, 0), + Some(Slot::new(1, 1)), + finalized_waitpoint.get_trigger_handle(), + &mut foreign_controllers.final_state, + ); + final_state_boilerplate( + &mut foreign_controllers.final_state, + foreign_controllers.db.clone(), + &foreign_controllers.selector_controller, + &mut foreign_controllers.ledger_controller, + Some(saved_bytecode), + None, + None, + ); + let mut universe = ExecutionTestUniverse::new(foreign_controllers, exec_cfg); + + // load bytecodes + universe.deploy_bytecode_block( + &KeyPair::from_str(TEST_SK_1).unwrap(), + Slot::new(1, 0), + include_bytes!("./wasm/nested_call.wasm"), + include_bytes!("./wasm/test.wasm"), + ); + finalized_waitpoint.wait(); + let address = universe.get_address_sc_deployed(Slot::new(1, 0)); + + // Call the function test of the smart contract + let operation = ExecutionTestUniverse::create_call_sc_operation( + &KeyPair::from_str(TEST_SK_2).unwrap(), + 10000000, + Amount::from_str("0").unwrap(), + Amount::from_str("0").unwrap(), + Address::from_str(&address).unwrap(), + String::from("test"), + address.as_bytes().to_vec(), + ) + .unwrap(); + universe.call_sc_block( + &KeyPair::from_str(TEST_SK_2).unwrap(), + Slot::new(1, 1), + operation, + ); + finalized_waitpoint.wait(); + + // Get the events. We expect the call to have succeeded, so we check for the length of the events. + // The smart contract emits 4 events in total, (to check gas usage), so we expect at least 4 events, + // and none of them should contain the error message. + let events = universe + .module_controller + .get_filtered_sc_output_event(EventFilter { + start: Some(Slot::new(1, 1)), + ..Default::default() + }); + assert!(events.len() >= 4); + for event in events.iter() { + assert!(!event.data.contains("recursion depth limit reached")); + } +} + /// Test the ABI get call coins /// /// Deploy an SC with a method `test` that generate an event saying how many coins he received diff --git a/massa-models/src/config/constants.rs b/massa-models/src/config/constants.rs index 39a832f59fe..abaf17faa6f 100644 --- a/massa-models/src/config/constants.rs +++ b/massa-models/src/config/constants.rs @@ -310,6 +310,8 @@ pub const ASYNC_MSG_CST_GAS_COST: u64 = 750_000; pub const BASE_OPERATION_GAS_COST: u64 = 800_000; // approx MAX_GAS_PER_BLOCK / MAX_OPERATIONS_PER_BLOCK /// Maximum event size in bytes pub const MAX_EVENT_DATA_SIZE: usize = 50_000; +/// Maximum number of recursion for calls +pub const MAX_RECURSIVE_CALLS_DEPTH: u16 = 25; // // Constants used in network diff --git a/massa-node/src/main.rs b/massa-node/src/main.rs index c80a594c893..119f901af02 100644 --- a/massa-node/src/main.rs +++ b/massa-node/src/main.rs @@ -88,9 +88,9 @@ use massa_models::config::constants::{ use massa_models::config::{ BASE_OPERATION_GAS_COST, CHAINID, KEEP_EXECUTED_HISTORY_EXTRA_PERIODS, MAX_BOOTSTRAP_FINAL_STATE_PARTS_SIZE, MAX_BOOTSTRAP_VERSIONING_ELEMENTS_SIZE, - MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, MAX_RUNTIME_MODULE_CUSTOM_SECTION_DATA_LEN, - MAX_RUNTIME_MODULE_CUSTOM_SECTION_LEN, MAX_RUNTIME_MODULE_EXPORTS, - MAX_RUNTIME_MODULE_FUNCTIONS, MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN, + MAX_EVENT_DATA_SIZE, MAX_MESSAGE_SIZE, MAX_RECURSIVE_CALLS_DEPTH, + MAX_RUNTIME_MODULE_CUSTOM_SECTION_DATA_LEN, MAX_RUNTIME_MODULE_CUSTOM_SECTION_LEN, + MAX_RUNTIME_MODULE_EXPORTS, MAX_RUNTIME_MODULE_FUNCTIONS, MAX_RUNTIME_MODULE_FUNCTION_NAME_LEN, MAX_RUNTIME_MODULE_GLOBAL_INITIALIZER, MAX_RUNTIME_MODULE_IMPORTS, MAX_RUNTIME_MODULE_MEMORIES, MAX_RUNTIME_MODULE_NAME_LEN, MAX_RUNTIME_MODULE_PASSIVE_DATA, MAX_RUNTIME_MODULE_PASSIVE_ELEMENT, MAX_RUNTIME_MODULE_SIGNATURE_LEN, MAX_RUNTIME_MODULE_TABLE, @@ -541,6 +541,7 @@ async fn launch( .broadcast_slot_execution_traces_channel_capacity, max_execution_traces_slot_limit: SETTINGS.execution.execution_traces_limit, block_dump_folder_path, + max_recursive_calls_depth: MAX_RECURSIVE_CALLS_DEPTH, condom_limits, };