Skip to content

Commit

Permalink
feat: add proxy monerod resiliency (#6637)
Browse files Browse the repository at this point in the history
Description
---
Added resiliency to the merge mining proxy monerod connection:
- At startup if the `monero.fail` is not available
- With the default list of monerod servers (it is not necessary anymore
to populate the list in `config.toml` or from the command line)
- When qualifying the starting list of monerod servers
- When getting the fully qualified monerod URL to send requests to
during runtime

Motivation and Context
---
All the things addressed in this PR were handled inadequately.

How Has This Been Tested?
---
- Added unit tests.
- System-level testing:
  - Start the merge mining proxy using the default config. **[PASSED]**
- Start the merge mining proxy where `use_dynamic_fail_data = false`.
**[PASSED]**
- Start the merge mining proxy where `use_dynamic_fail_data = true` but
`monero_fail_url` is invalid. **[PASSED]**
- Start the merge mining proxy where `use_dynamic_fail_data = false`
with 5 entries in the `monerod_url` list but where the first 4 entries
are invalid. **[PASSED]**
- Perform a merge mining proxy + monerod stress test by issuing json rpc
commands to the proxy that needs responses from the monerod server,
testing multiple access paths into `match inner.handle(&method_name,
request).await {`, all of this while merge mining is taking place.
**[PASSED]**

Stress test results

```
method: get_height, tick: 1.00s
  1: method: get_height; time now: 07:41:12.966; duration: 354.83ms, response length: 124
  2: method: get_height; time now: 07:41:14.976; duration: 367.71ms, response length: 124
  3: method: get_height; time now: 07:41:16.974; duration: 360.16ms, response length: 124
  4: method: get_height; time now: 07:41:18.976; duration: 354.45ms, response length: 124
  5: method: get_height; time now: 07:41:20.990; duration: 373.91ms, response length: 124
  ...
method: get_version, tick: 1.00s
  1: method: get_version; time now: 07:41:22.963; duration: 355.97ms, response length: 686
  2: method: get_version; time now: 07:41:25.003; duration: 378.83ms, response length: 686
  3: method: get_version; time now: 07:41:26.978; duration: 369.92ms, response length: 686
  4: method: get_version; time now: 07:41:28.978; duration: 362.31ms, response length: 686
  5: method: get_version; time now: 07:41:30.979; duration: 358.23ms, response length: 686
  ...
method: get_block_template, tick: 1.00s
  1: method: get_block_template; time now: 07:41:33.023; duration: 408.98ms, response length: 1490
  2: method: get_block_template; time now: 07:41:35.007; duration: 388.51ms, response length: 1490
  3: method: get_block_template; time now: 07:41:37.002; duration: 388.86ms, response length: 1490
  4: method: get_block_template; time now: 07:41:39.005; duration: 386.01ms, response length: 1490
  5: method: get_block_template; time now: 07:41:41.018; duration: 410.48ms, response length: 1490
  ...
```


![image](https://github.com/user-attachments/assets/9393ebc5-8b2b-41b5-88c9-58aaf38ce143)


![image](https://github.com/user-attachments/assets/59b922ba-0c73-4070-bf77-24cbb5310ee3)

What process can a PR reviewer use to test or verify this change?
---
- Code review
- System-level testing as above

<!-- Checklist -->
<!-- 1. Is the title of your PR in the form that would make nice release
notes? The title, excluding the conventional commit
tag, will be included exactly as is in the CHANGELOG, so please think
about it carefully. -->


Breaking Changes
---

- [x] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [ ] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
<!-- BREAKING CHANGE: Description what the user should do, e.g. delete a
database, resync the chain -->
  • Loading branch information
hansieodendaal authored Oct 18, 2024
1 parent c6cbbc1 commit c51ba7a
Show file tree
Hide file tree
Showing 8 changed files with 413 additions and 144 deletions.
2 changes: 1 addition & 1 deletion applications/minotari_merge_mining_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ hex = "0.4.2"
hyper = { version ="0.14.12", features = ["default"] }
jsonrpc = "0.12.0"
log = { version = "0.4.8", features = ["std"] }
markup5ever = "0.11.0"
monero = { version = "0.21.0" }
reqwest = { version = "0.11.4", features = ["json"] }
serde = { version = "1.0.136", features = ["derive"] }
Expand All @@ -57,5 +58,4 @@ scraper = "0.19.0"
tari_features = { path = "../../common/tari_features", version = "1.7.0-pre.2" }

[dev-dependencies]
markup5ever = "0.11.0"
hyper = { version ="0.14.12", features = ["full"] }
35 changes: 34 additions & 1 deletion applications/minotari_merge_mining_proxy/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,40 @@ impl Default for MergeMiningProxyConfig {
override_from: None,
use_dynamic_fail_data: true,
monero_fail_url: MONERO_FAIL_MAINNET_URL.into(),
monerod_url: StringList::default(),
monerod_url: StringList::from(vec![
"http://node.c3pool.org:18081".to_string(),
"http://xmr-full.p2pool.uk:18089".to_string(),
"http://monero.stackwallet.com:18081".to_string(),
"http://xmr.support:18081".to_string(),
"https://xmr-01.tari.com".to_string(),
"http://node1.xmr-tw.org:18081".to_string(),
"http://monero-g2.hexhex.online:18081".to_string(),
"http://137.220.120.19:18089".to_string(),
"http://185.218.124.120:18489".to_string(),
"http://185.218.124.120:18789".to_string(),
"https://xmr-de-2.boldsuck.org:18081".to_string(),
"http://46.32.46.171:18081".to_string(),
"http://185.218.124.120:18089".to_string(),
"http://185.218.124.120:18589".to_string(),
"http://xmr-de-1.boldsuck.org:18081".to_string(),
"http://185.218.124.120:18889".to_string(),
"http://pinodexmr.hopto.org:18081".to_string(),
"http://node.tincloud.eu:18081".to_string(),
"http://183.6.24.33:18081".to_string(),
"http://147.45.196.232:18089".to_string(),
"http://h-helix.com:18089".to_string(),
"http://185.218.124.120:18689".to_string(),
"http://185.218.124.120:18289".to_string(),
"https://node.tincloud.eu".to_string(),
"https://xmr-de.boldsuck.org:18081".to_string(),
"https://monero.booze.org".to_string(),
"https://xmr.mailia.be:18088".to_string(),
"https://xmr.lolfox.au".to_string(),
"https://xmr1.doggett.tech:18089".to_string(),
"https://node.icefiles.nz:18081".to_string(),
"http://45.8.132.220:18089".to_string(),
"http://82.147.85.13:18089".to_string(),
]),
monerod_username: String::new(),
monerod_password: String::new(),
monerod_use_auth: false,
Expand Down
6 changes: 3 additions & 3 deletions applications/minotari_merge_mining_proxy/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ pub enum MmProxyError {
InvalidHeaderValue(#[from] InvalidHeaderValue),
#[error("Block was lost due to a failed precondition, and should be retried")]
FailedPreconditionBlockLostRetry,
#[error("Could not convert data:{0}")]
#[error("Could not convert data: {0}")]
ConversionError(String),
#[error("No reachable servers in configuration")]
ServersUnavailable,
#[error("No reachable servers in configuration: {0}")]
ServersUnavailable(String),
#[error("Invalid difficulty: {0}")]
DifficultyError(#[from] DifficultyError),
#[error("TLS connection error: {0}")]
Expand Down
Loading

0 comments on commit c51ba7a

Please sign in to comment.