Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
67f8e61
refactor: remove unneeded CURRENT_DB_VERSION in database init (#71)
pauldelucia Nov 18, 2024
7a28317
chore: rename ZMQ log (#75)
ogabrielides Nov 19, 2024
68cdd20
fix: error messages in dpns screen (#72)
pauldelucia Nov 19, 2024
d45990d
fix: remove duplicate testnet nodes in env and remove unused env in e…
pauldelucia Nov 20, 2024
8d452aa
fix error message
pauldelucia Nov 20, 2024
d6cc46a
feat: dont display seconds in dpns screen last updated column (#78)
pauldelucia Nov 20, 2024
f7d6bb2
fix
pauldelucia Nov 20, 2024
c9cc4e7
undo gitignore change
pauldelucia Nov 20, 2024
6c8bc08
Merge pull request #79 from dashpay/fix/env-files
pauldelucia Nov 20, 2024
2874410
feat: custom dash-qt path and conf (#73)
ogabrielides Nov 21, 2024
5c2628d
feat: disable refresh button in dpns screen when already refreshing (…
pauldelucia Nov 22, 2024
b23f121
feat: detect CPU incompatibility (#84)
ogabrielides Nov 22, 2024
f6ad81f
feat: retry vote poll end times query and insert proof logs (#81)
pauldelucia Nov 22, 2024
06bc890
feat: make proof logs screen default tool screen (#90)
pauldelucia Nov 25, 2024
77759be
fix: network chooser screen statuses (#89)
pauldelucia Nov 25, 2024
679340a
feat: fund with Wallet Balance (#92)
QuantumExplorer Nov 25, 2024
9b36bf9
fix: mn voting keys were not always displaying (#95)
pauldelucia Nov 26, 2024
62d13d1
fix: limit 100 in dpns end time query (#91)
pauldelucia Nov 26, 2024
07ffa35
feat: simulate heartbeat for windows zmq (#93)
ogabrielides Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MAINNET_WALLET_PRIVATE_KEY=

# Testnet configuration
TESTNET_SHOW_IN_UI=true
TESTNET_DAPI_ADDRESSES=https://34.214.48.68:1443,https://35.166.18.166:1443,https://52.12.176.90:1443,https://44.233.44.95:1443,https://52.12.176.90:1443,https://44.233.44.95:1443,https://52.34.144.50:1443,https://44.240.98.102:1443,https://54.201.32.131:1443,https://52.10.229.11:1443,https://52.13.132.146:1443,https://44.228.242.181:1443,https://35.82.197.197:1443,https://52.40.219.41:1443,https://44.239.39.153:1443,https://54.149.33.167:1443,https://35.164.23.245:1443,https://52.33.28.47:1443,https://52.43.86.231:1443,https://52.43.13.92:1443,https://35.163.144.230:1443,https://52.89.154.48:1443,https://52.24.124.162:1443,https://35.85.21.179:1443,https://54.187.14.232:1443,https://54.68.235.201:1443,https://52.13.250.182:1443,https://35.82.49.196:1443,https://44.232.196.6:1443,https://54.189.164.39:1443,https://54.213.204.85:1443
TESTNET_DAPI_ADDRESSES=https://34.214.48.68:1443,https://35.166.18.166:1443,https://52.12.176.90:1443,https://44.233.44.95:1443,https://52.34.144.50:1443,https://44.240.98.102:1443,https://54.201.32.131:1443,https://52.10.229.11:1443,https://52.13.132.146:1443,https://44.228.242.181:1443,https://35.82.197.197:1443,https://52.40.219.41:1443,https://44.239.39.153:1443,https://54.149.33.167:1443,https://35.164.23.245:1443,https://52.33.28.47:1443,https://52.43.86.231:1443,https://52.43.13.92:1443,https://35.163.144.230:1443,https://52.89.154.48:1443,https://52.24.124.162:1443,https://35.85.21.179:1443,https://54.187.14.232:1443,https://54.68.235.201:1443,https://52.13.250.182:1443,https://35.82.49.196:1443,https://44.232.196.6:1443,https://54.189.164.39:1443,https://54.213.204.85:1443
TESTNET_CORE_HOST=127.0.0.1
TESTNET_CORE_RPC_PORT=19998
TESTNET_CORE_RPC_USER=dashrpc
Expand Down
12 changes: 11 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ edition = "2021"
default-run = "dash-evo-tool"
rust-version = "1.81"

[build]
rustflags = [
"-C", "target-feature=+avx,-avx2,-avx512f,-avx512cd,-avx512er,-avx512pf,-avx512bw,-avx512dq,-avx512vl"
]

[dependencies]
bip39 = { version = "2.1.0", features = ["all-languages", "rand"] }
derive_more = "1.0.0"
accesskit = "=0.16.1"
egui = { version = "0.29.1" }
egui_extras = "0.29.1"
rfd = "0.15.1"
qrcode = "0.14.1"
eframe = { version = "0.29.1", features = ["persistence"] }
strum = { version = "0.26.1", features = ["derive"] }
Expand Down Expand Up @@ -59,4 +65,8 @@ regex = "1.11"
zmq = "0.10"

[target.'cfg(target_os = "windows")'.dependencies]
zeromq = "0.4.1"
zeromq = "0.4.1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consider updating zeromq version for Windows

The Windows-specific zeromq dependency (v0.4.1) is significantly older than the non-Windows zmq dependency (v0.10). This version disparity could lead to:

  • Missing security patches
  • Feature inconsistencies between platforms
  • Maintenance challenges

Consider upgrading to a newer version or using the same zmq crate for Windows.


[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
native-dialog = "0.7.0"
raw-cpuid = "11.2.0"
Comment on lines +70 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Architecture-specific implementation needs error handling for non-x86 platforms

The code properly implements x86/x86_64-specific CPU compatibility checks using conditional compilation, but lacks explicit handling for other architectures. The current implementation:

  • Correctly uses #[cfg] attributes for x86/x86_64 platforms
  • Implements AVX, AVX2, and AVX512 feature detection
  • Shows appropriate error dialogs when CPU features are missing

However, there's no explicit handling for non-x86 architectures, which could lead to silent failures.

  • Add an else block in src/cpu_compatibility.rs to handle non-x86 architectures explicitly
  • Consider using cfg_if! macro for better readability and maintainability
🔗 Analysis chain

Verify architecture-specific implementations

The new x86/x86_64-specific dependencies suggest platform-specific handling. Let's ensure proper implementation across architectures.

Run the following to check the implementation:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify proper architecture-specific implementations

# Check for proper conditional compilation
rg "#\[cfg\(any\(target_arch = \"x86\"" -A 5

# Look for potential platform-specific code paths
rg "native_dialog::|raw_cpuid::" -A 5

# Verify error handling for unsupported architectures
ast-grep --pattern 'cfg_if! {
  if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
    $$$
  } else {
    $$$
  }
}'

Length of output: 3129

17 changes: 15 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl AppState {

let password_info = settings
.clone()
.map(|(_, _, password_info)| password_info)
.map(|(_, _, password_info, _, _)| password_info)
.flatten();

let mainnet_app_context =
Expand All @@ -150,10 +150,23 @@ impl AppState {
let mut proof_log_screen = ProofLogScreen::new(&mainnet_app_context);
let mut document_query_screen = DocumentQueryScreen::new(&mainnet_app_context);
let mut withdraws_status_screen = WithdrawsStatusScreen::new(&mainnet_app_context);

let (custom_dash_qt_path, overwrite_dash_conf) = match settings.clone() {
Some((.., db_custom_dash_qt_path, db_overwrite_dash_qt)) => {
(db_custom_dash_qt_path, db_overwrite_dash_qt)
}
_ => {
// Default values: Use system default path and overwrite conf
(None, true)
}
};

let mut network_chooser_screen = NetworkChooserScreen::new(
&mainnet_app_context,
testnet_app_context.as_ref(),
Network::Dash,
custom_dash_qt_path,
overwrite_dash_conf,
Comment on lines +168 to +169

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

NetworkChooserScreen initialization is inconsistent

The verification reveals a mismatch between the implementation and usage. The NetworkChooserScreen::new() implementation expects 5 parameters:

  • mainnet_app_context
  • testnet_app_context
  • current_network
  • custom_dash_qt_path
  • overwrite_dash_conf

However, the actual call in src/app.rs only provides 3 parameters, missing the newly added custom_dash_qt_path and overwrite_dash_conf.

  • src/app.rs: Update the NetworkChooserScreen::new() call to include all required parameters
🔗 Analysis chain

Verify NetworkChooserScreen parameter usage

New parameters have been added to NetworkChooserScreen initialization. Let's verify their usage across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check NetworkChooserScreen::new usage patterns
# Expected: All calls should include the new parameters

# Search for NetworkChooserScreen::new usage
ast-grep --pattern 'NetworkChooserScreen::new($_)'

# Search for struct definition to verify parameter order
ast-grep --pattern 'impl NetworkChooserScreen {
  $$$
  fn new($_) {
    $$$
  }
  $$$
}'

Length of output: 144


Script:

#!/bin/bash
# Let's try a different approach using ripgrep to find NetworkChooserScreen usage and implementation

# Search for NetworkChooserScreen::new calls
rg "NetworkChooserScreen::new" -A 3

# Search for NetworkChooserScreen implementation
rg "impl NetworkChooserScreen" -A 20

Length of output: 1684

);

let mut wallets_balances_screen = WalletsBalancesScreen::new(&mainnet_app_context);
Expand All @@ -162,7 +175,7 @@ impl AppState {

let mut chosen_network = Network::Dash;

if let Some((network, screen_type, password_info)) = settings {
if let Some((network, screen_type, password_info, _, _)) = settings {
selected_main_screen = screen_type;
chosen_network = network;
if chosen_network == Network::Testnet && testnet_app_context.is_some() {
Expand Down
8 changes: 3 additions & 5 deletions src/app_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ pub fn copy_env_file_if_not_exists() {
let app_data_dir =
app_user_data_dir_path().expect("Failed to determine application data directory");
let env_file_in_app_dir = app_data_dir.join(".env".to_string());
if env_file_in_app_dir.exists() && env_file_in_app_dir.is_file() {
} else {
if !env_file_in_app_dir.exists() || !env_file_in_app_dir.is_file() {
let env_example_file_in_exe_dir = PathBuf::from(".env.example");
if env_example_file_in_exe_dir.exists() && env_example_file_in_exe_dir.is_file() {
fs::copy(&env_example_file_in_exe_dir, env_file_in_app_dir)
.expect("Failed to copy main net env file");
.expect("Failed to copy env file");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace expect with proper error handling

Using expect for file operations can lead to program termination. Consider propagating errors to allow graceful handling by the caller.

Consider this approach:

-                .expect("Failed to copy env file");
+                .map_err(|e| log::error!("Failed to copy env file: {}", e))?;

Also, consider adding different error messages for different scenarios (source missing vs. copy failure).

Also applies to: 55-55

} else {
let env_file_in_exe_dir = PathBuf::from(".env");
fs::copy(&env_file_in_exe_dir, env_file_in_app_dir)
.expect("Failed to copy main net env file");
fs::copy(&env_file_in_exe_dir, env_file_in_app_dir).expect("Failed to copy env file");
}
}
Comment on lines +48 to 57

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance function robustness and documentation

The function could benefit from several improvements to make it more reliable and maintainable.

Consider these enhancements:

  1. Return a Result type:
-pub fn copy_env_file_if_not_exists() {
+pub fn copy_env_file_if_not_exists() -> std::io::Result<()> {
  1. Add logging and proper error handling:
pub fn copy_env_file_if_not_exists() -> std::io::Result<()> {
    let app_data_dir = app_user_data_dir_path()?;
    let env_file_in_app_dir = app_data_dir.join(".env");
    
    log::debug!("Checking .env file at: {:?}", env_file_in_app_dir);
    
    match fs::metadata(&env_file_in_app_dir) {
        Ok(metadata) if metadata.is_file() => {
            log::debug!(".env file already exists");
            Ok(())
        }
        _ => {
            let env_example_file = PathBuf::from(".env.example");
            let source_file = if env_example_file.is_file() {
                env_example_file
            } else {
                PathBuf::from(".env")
            };
            
            log::info!("Copying {:?} to {:?}", source_file, env_file_in_app_dir);
            fs::copy(&source_file, &env_file_in_app_dir)
                .map(|_| log::info!("Successfully copied env file"))
                .map_err(|e| {
                    log::error!("Failed to copy env file: {}", e);
                    e
                })?;
            
            Ok(())
        }
    }
}
  1. Add documentation:
/// Copies the environment configuration file to the application data directory.
/// 
/// # Source Files
/// Looks for source files in the following order:
/// 1. `.env.example` in the current directory
/// 2. `.env` in the current directory
/// 
/// # Errors
/// Returns an error if:
/// - Application data directory cannot be accessed
/// - Source file cannot be found
/// - Copy operation fails

}
85 changes: 1 addition & 84 deletions src/backend_task/contested_names/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl AppContext {
sdk: &Sdk,
sender: mpsc::Sender<TaskResult>,
) -> Result<BackendTaskSuccessResult, String> {
let sdk = sdk.clone();
match &task {
ContestedResourceTask::QueryDPNSContestedResources => self
.query_dpns_contested_resources(sdk, sender)
Expand All @@ -39,89 +38,7 @@ impl AppContext {
ContestedResourceTask::VoteOnDPNSName(name, vote_choice, voters) => {
self.vote_on_dpns_name(name, *vote_choice, voters, sdk, sender)
.await
} // ContestedResourceTask::VoteOnContestedResource(vote_poll, vote_choice) => {
// let mut vote = Vote::default();
// let identity_private_keys_lock = self.known_identities_private_keys.lock().await;
// let loaded_identity_lock = match self.loaded_identity.lock().await.clone() {
// Some(identity) => identity,
// None => {
// return BackendEvent::TaskCompleted {
// task: Task::Document(task),
// execution_result: Err(
// "No loaded identity for signing vote transaction".to_string(),
// ),
// };
// }
// };
//
// let mut signer = SimpleSigner::default();
// let Identity::V0(identity_v0) = &loaded_identity_lock;
// for (key_id, public_key) in &identity_v0.public_keys {
// let identity_key_tuple = (identity_v0.id, *key_id);
// if let Some(private_key_bytes) =
// identity_private_keys_lock.get(&identity_key_tuple)
// {
// signer
// .private_keys
// .insert(public_key.clone(), private_key_bytes.clone());
// }
// }
//
// let voting_public_key = match loaded_identity_lock.get_first_public_key_matching(
// Purpose::VOTING,
// HashSet::from(SecurityLevel::full_range()),
// HashSet::from(KeyType::all_key_types()),
// false,
// ) {
// Some(voting_key) => voting_key,
// None => {
// return BackendEvent::TaskCompleted {
// task: Task::Document(task),
// execution_result: Err(
// "No voting key in the loaded identity. Are you sure it's a masternode identity?".to_string()
// ),
// };
// }
// };
//
// match vote {
// Vote::ResourceVote(ref mut resource_vote) => match resource_vote {
// ResourceVote::V0(ref mut resource_vote_v0) => {
// resource_vote_v0.vote_poll = vote_poll.clone();
// resource_vote_v0.resource_vote_choice = *vote_choice;
// let pro_tx_hash = self
// .loaded_identity_pro_tx_hash
// .lock()
// .await
// .expect("Expected a proTxHash in AppState");
// match vote
// .put_to_platform_and_wait_for_response(
// pro_tx_hash,
// voting_public_key,
// sdk,
// &signer,
// None,
// )
// .await
// {
// Ok(_) => {
// // TODO: Insert vote result into the database
// BackendEvent::TaskCompleted {
// task: Task::Document(task),
// execution_result: Ok(CompletedTaskPayload::String(
// "Vote cast successfully".to_string(),
// )),
// }
// }
// Err(e) => BackendEvent::TaskCompleted {
// task: Task::Document(task),
// execution_result: Err(e.to_string()),
// },
// }
// }
// },
// }
// }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

SDK parameter consistency needs attention in query_ending_times.rs

The verification reveals an inconsistency in SDK parameter types across the contested names modules:

  • Most modules use sdk: &Sdk (reference):
    • vote_on_dpns_name.rs
    • query_dpns_vote_contenders.rs
    • query_dpns_contested_resources.rs
    • mod.rs
  • However, query_ending_times.rs uses sdk: Sdk (owned type)

This inconsistency should be addressed to maintain uniform parameter types across the module.

🔗 Analysis chain

Verify SDK reference changes across related modules

The AI summary indicates that SDK parameter types were changed from Sdk to &Sdk in related files. Let's verify these changes are consistent across all contested name handlers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check SDK parameter types in related contested name handlers

# Search for function signatures in related modules
echo "Checking SDK parameter types in contested name handlers..."
rg -A 1 "fn.*sdk.*Sdk" src/backend_task/contested_names/

Length of output: 185


Script:

#!/bin/bash
# Let's try a broader search for SDK usage patterns
echo "Searching for SDK parameter patterns..."
rg -p "sdk: (&)?Sdk" src/backend_task/contested_names/

# Also search for function definitions that might use SDK
echo -e "\nSearching for function definitions with SDK..."
ast-grep --pattern 'fn $_($$$) -> $$ {
  $$$
}'  src/backend_task/contested_names/

Length of output: 730

}
}
}
Loading