diff --git a/cmd/crates/soroban-spec-json/src/lib.rs b/cmd/crates/soroban-spec-json/src/lib.rs index 9394f33d..8626262b 100644 --- a/cmd/crates/soroban-spec-json/src/lib.rs +++ b/cmd/crates/soroban-spec-json/src/lib.rs @@ -55,6 +55,7 @@ pub fn generate_from_wasm(wasm: &[u8]) -> Result { Ok(json) } +/// # Panics pub fn generate(spec: &[ScSpecEntry]) -> String { let collected: Vec<_> = spec.iter().map(Entry::from).collect(); serde_json::to_string_pretty(&collected).expect("serialization of the spec entries should not have any failure cases as all keys are strings and the serialize implementations are derived") diff --git a/cmd/soroban-cli/src/commands/contract/invoke.rs b/cmd/soroban-cli/src/commands/contract/invoke.rs index 2a6a404a..a5227f0c 100644 --- a/cmd/soroban-cli/src/commands/contract/invoke.rs +++ b/cmd/soroban-cli/src/commands/contract/invoke.rs @@ -570,7 +570,7 @@ fn build_custom_cmd(name: &str, spec: &Spec) -> Result { let long_doc: &'static str = Box::leak(arg_file_help(doc).into_boxed_str()); cmd = cmd.about(Some(doc)).long_about(long_doc); - for (name, type_) in inputs_map.iter() { + for (name, type_) in inputs_map { let mut arg = clap::Arg::new(name); let file_arg_name = fmt_arg_file_name(name); let mut file_arg = clap::Arg::new(&file_arg_name); diff --git a/cmd/soroban-cli/src/commands/version.rs b/cmd/soroban-cli/src/commands/version.rs index 44848322..21be0743 100644 --- a/cmd/soroban-cli/src/commands/version.rs +++ b/cmd/soroban-cli/src/commands/version.rs @@ -22,7 +22,7 @@ pub fn short() -> String { pub fn long() -> String { let env = soroban_env_host::VERSION; let xdr = soroban_env_host::VERSION.xdr; - vec![ + [ short(), format!("soroban-env {} ({})", env.pkg, env.rev), format!("soroban-env interface version {}", meta::INTERFACE_VERSION), diff --git a/cmd/soroban-cli/src/log/event.rs b/cmd/soroban-cli/src/log/event.rs index acd92fee..33d150ca 100644 --- a/cmd/soroban-cli/src/log/event.rs +++ b/cmd/soroban-cli/src/log/event.rs @@ -1,7 +1,7 @@ use soroban_env_host::events::HostEvent; pub fn events(events: &[HostEvent]) { - for event in events.iter() { + for event in events { tracing::info!(log = event.to_string()); } } diff --git a/cmd/soroban-cli/src/rpc/transaction.rs b/cmd/soroban-cli/src/rpc/transaction.rs index 08c83418..ab1ecda0 100644 --- a/cmd/soroban-cli/src/rpc/transaction.rs +++ b/cmd/soroban-cli/src/rpc/transaction.rs @@ -129,7 +129,8 @@ pub fn sign_soroban_authorizations( let SorobanAuthorizationEntry { credentials: SorobanCredentials::Address(ref mut credentials), .. - } = auth else { + } = auth + else { // Doesn't need special signing return Ok(auth); }; @@ -187,7 +188,8 @@ pub fn sign_soroban_authorization_entry( let SorobanAuthorizationEntry { credentials: SorobanCredentials::Address(ref mut credentials), .. - } = auth else { + } = auth + else { // Doesn't need special signing return Ok(auth); }; diff --git a/cmd/soroban-cli/src/utils.rs b/cmd/soroban-cli/src/utils.rs index be49aebc..3792c63d 100644 --- a/cmd/soroban-cli/src/utils.rs +++ b/cmd/soroban-cli/src/utils.rs @@ -84,7 +84,7 @@ pub fn add_contract_code_to_ledger_entries( }), ext: LedgerEntryExt::V0, }; - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if **k == code_key { **e = code_entry; return Ok(hash); @@ -125,7 +125,7 @@ pub fn add_contract_to_ledger_entries( }), ext: LedgerEntryExt::V0, }; - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if **k == contract_key { **e = contract_entry; return; @@ -138,7 +138,7 @@ pub fn bump_ledger_entry_expirations( entries: &mut [(Box, Box)], lookup: &HashMap, ) { - for (k, e) in entries.iter_mut() { + for (k, e) in &mut *entries { if let Some(min_expiration) = lookup.get(k.as_ref()) { if let LedgerEntryData::ContractData(entry) = &mut e.data { entry.expiration_ledger_seq = *min_expiration; diff --git a/cmd/soroban-rpc/internal/jsonrpc.go b/cmd/soroban-rpc/internal/jsonrpc.go index ca55f36a..4c674731 100644 --- a/cmd/soroban-rpc/internal/jsonrpc.go +++ b/cmd/soroban-rpc/internal/jsonrpc.go @@ -266,7 +266,7 @@ func NewJSONRPCHandler(cfg *config.Config, params HandlerParams) Handler { Namespace: params.Daemon.MetricsNamespace(), Subsystem: "network", Name: "global_request_execution_duration_threshold_limit", Help: "The metric measures the count of requests that surpassed the limit threshold for execution time", }) - durationLimitedBridge := network.MakeHTTPRequestDurationLimiter( + var handler http.Handler = network.MakeHTTPRequestDurationLimiter( queueLimitedBridge, cfg.RequestExecutionWarningThreshold, cfg.MaxRequestExecutionDuration, @@ -274,9 +274,12 @@ func NewJSONRPCHandler(cfg *config.Config, params HandlerParams) Handler { globalQueueRequestExecutionDurationLimitCounter, params.Logger) + // Limit request sizes to 10MB + handler = http.MaxBytesHandler(handler, 1024*1024*10) + return Handler{ bridge: bridge, logger: params.Logger, - Handler: durationLimitedBridge, + Handler: handler, } } diff --git a/cmd/soroban-rpc/lib/preflight/src/fees.rs b/cmd/soroban-rpc/lib/preflight/src/fees.rs index c0c59fb8..efc2d69b 100644 --- a/cmd/soroban-rpc/lib/preflight/src/fees.rs +++ b/cmd/soroban-rpc/lib/preflight/src/fees.rs @@ -166,7 +166,6 @@ fn get_fee_configurations( ledger_storage.get_configuration_setting(ConfigSettingId::ContractComputeV0)? else { bail!("unexpected config setting entry for ComputeV0 key"); - }; let ConfigSettingEntry::ContractLedgerCostV0(ledger_cost) = @@ -195,9 +194,9 @@ fn get_fee_configurations( let ConfigSettingEntry::StateExpiration(state_expiration) = ledger_storage.get_configuration_setting(ConfigSettingId::StateExpiration)? - else { - bail!("unexpected config setting entry for StateExpiration key"); - }; + else { + bail!("unexpected config setting entry for StateExpiration key"); + }; let write_fee_configuration = WriteFeeConfiguration { bucket_list_target_size_bytes: ledger_cost.bucket_list_target_size_bytes, @@ -395,9 +394,9 @@ pub(crate) fn compute_restore_footprint_transaction_data_and_min_fee( ) -> Result<(SorobanTransactionData, i64)> { let ConfigSettingEntry::StateExpiration(state_expiration) = ledger_storage.get_configuration_setting(ConfigSettingId::StateExpiration)? - else { - bail!("unexpected config setting entry for StateExpiration key"); - }; + else { + bail!("unexpected config setting entry for StateExpiration key"); + }; let rent_changes = compute_restore_footprint_rent_changes( &footprint, ledger_storage, diff --git a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs index 0bcd807d..4159dda2 100644 --- a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs +++ b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs @@ -115,11 +115,11 @@ impl LedgerStorage { let setting_id = ConfigSettingId::StateExpiration; let ConfigSettingEntry::StateExpiration(state_expiration) = ledger_storage.get_configuration_setting(setting_id)? - else { - return Err( - Error::UnexpectedConfigLedgerEntry { setting_id: setting_id.name().to_string() } - ); - }; + else { + return Err(Error::UnexpectedConfigLedgerEntry { + setting_id: setting_id.name().to_string(), + }); + }; // Now that we have the state expiration config, we can build the tracker ledger_storage.restore_tracker = Some(EntryRestoreTracker { current_ledger_seq: current_ledger_sequence, diff --git a/cmd/soroban-rpc/lib/preflight/src/preflight.rs b/cmd/soroban-rpc/lib/preflight/src/preflight.rs index e1b64bf2..e413242b 100644 --- a/cmd/soroban-rpc/lib/preflight/src/preflight.rs +++ b/cmd/soroban-rpc/lib/preflight/src/preflight.rs @@ -211,21 +211,21 @@ fn host_events_to_diagnostic_events(events: &Events) -> Vec { fn get_budget_from_network_config_params(ledger_storage: &LedgerStorage) -> Result { let ConfigSettingEntry::ContractComputeV0(compute) = ledger_storage.get_configuration_setting(ConfigSettingId::ContractComputeV0)? - else { - bail!("unexpected config setting entry for ComputeV0 key"); - }; + else { + bail!("unexpected config setting entry for ComputeV0 key"); + }; let ConfigSettingEntry::ContractCostParamsCpuInstructions(cost_params_cpu) = ledger_storage .get_configuration_setting(ConfigSettingId::ContractCostParamsCpuInstructions)? - else { - bail!("unexpected config setting entry for CostParamsCpuInstructions key"); - }; + else { + bail!("unexpected config setting entry for CostParamsCpuInstructions key"); + }; let ConfigSettingEntry::ContractCostParamsMemoryBytes(cost_params_memory) = ledger_storage.get_configuration_setting(ConfigSettingId::ContractCostParamsMemoryBytes)? - else { - bail!("unexpected config setting entry for CostParamsMemoryBytes key"); - }; + else { + bail!("unexpected config setting entry for CostParamsMemoryBytes key"); + }; let budget = Budget::try_from_configs( compute.tx_max_instructions as u64,