Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bridge/metrics polishing #2490

Merged
merged 22 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d9a4d55
chore(data_structures): rename aux.rs file for Windows compatibility
aesedepece May 29, 2024
78cfa62
feat(c-bridge): add new config params
guidiaz Aug 19, 2024
d2c5427
feat(c-bridge): count drs per state on dr_database
guidiaz Aug 19, 2024
2a78aa8
feat(c-bridge): implement new watch_dog actor
guidiaz Aug 19, 2024
6c1f181
chore: attend pr review comments
guidiaz Aug 20, 2024
c036894
fix(c-bridge): use wit/rpc client instead of tcp::socket to check wit…
guidiaz Aug 20, 2024
b612476
chore: fix deps to create::staking::helpers
guidiaz Aug 20, 2024
e509349
feat(c-bridge): count drs per state on dr_database
guidiaz Aug 19, 2024
1504e49
fix(c-bridge): avoid polling query status while no new query is detected
guidiaz Sep 23, 2024
7c1567d
fix(c-bridge): json metrics syntax
guidiaz Sep 23, 2024
12a88e9
feat(c-bridge): polish drs status metrics
guidiaz Sep 23, 2024
19072d0
chore: attend pr review comments
guidiaz Sep 24, 2024
6117dcb
chore: cargo clippy --fix
guidiaz Sep 24, 2024
3890d6c
fix(c-bridge): watch_dog: witHourlyExpenditure not being reported
guidiaz Oct 9, 2024
2e0cff5
feat(c-bridge): watch_dog: implement new witDailyQueries metric
guidiaz Oct 9, 2024
a6537ac
feat(c-bridge): watch_dog: implement new evmContractVersion
guidiaz Oct 10, 2024
7323eff
fix(c-bridge): remove duplicated entry in wrb_abi.json
guidiaz Oct 10, 2024
d60e700
fix(c-bridge): drsLast* metrics not being updated properly
guidiaz Oct 15, 2024
07a4fd1
feat(c-bridge): new metrics status values
guidiaz Oct 24, 2024
55b51c8
chore: cargo fmt --all
guidiaz Oct 24, 2024
15c8625
feat(c-bridge): report metrics on minutes o'clock
guidiaz Nov 7, 2024
19be557
chore: cargo fmt --all
guidiaz Nov 8, 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
1 change: 1 addition & 0 deletions bridges/centralized-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2018"
[dependencies]
actix = { version = "0.13.0", default-features = false }
async-jsonrpc-client = { git = "https://github.com/witnet/async-jsonrpc-client", features = ["tcp"], branch = "fix-tcp-leak" }
chrono = "0.4.38"
ctrlc = "3.1.3"
env_logger = "0.9.0"
envy = "0.4"
Expand Down
27 changes: 27 additions & 0 deletions bridges/centralized-ethereum/src/actors/dr_database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ impl Message for SetDrState {
type Result = Result<(), ()>;
}

/// Count number of data requests in given state
pub struct CountDrsPerState;

impl Message for CountDrsPerState {
type Result = Result<(u64, u64, u64, u64), ()>;
}

impl Handler<SetDrInfoBridge> for DrDatabase {
type Result = ();

Expand Down Expand Up @@ -274,6 +281,26 @@ impl Handler<SetDrState> for DrDatabase {
}
}

impl Handler<CountDrsPerState> for DrDatabase {
type Result = Result<(u64, u64, u64, u64), ()>;

fn handle(&mut self, _msg: CountDrsPerState, _ctx: &mut Self::Context) -> Self::Result {
Ok(self.dr.iter().fold(
(0u64, 0u64, 0u64, 0u64),
|(mut drs_new, mut drs_pending, mut drs_finished, mut drs_dismissed),
(_dr_id, dr_info)| {
match dr_info.dr_state {
DrState::New => drs_new += 1,
DrState::Pending => drs_pending += 1,
DrState::Finished => drs_finished += 1,
DrState::Dismissed => drs_dismissed += 1,
};
(drs_new, drs_pending, drs_finished, drs_dismissed)
},
))
}
}

/// Required trait for being able to retrieve DrDatabase address from system registry
impl actix::Supervised for DrDatabase {}

Expand Down
12 changes: 6 additions & 6 deletions bridges/centralized-ethereum/src/actors/dr_sender/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ use witnet_data_structures::chain::{RADAggregate, RADRequest, RADRetrieve, RADTa
#[test]
fn deserialize_empty_dr() {
// An empty data request is invalid with error 0xE0: BridgeMalformedRequest
let err = deserialize_and_validate_dr_bytes(&[], 1).unwrap_err();
let err = deserialize_and_validate_dr_bytes(&[], 1, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 224]);
}

#[test]
fn deserialize_dr_not_protobuf() {
// A malformed data request is invalid with error 0xE0: BridgeMalformedRequest
let err = deserialize_and_validate_dr_bytes(&[1, 2, 3, 4], 1).unwrap_err();
let err = deserialize_and_validate_dr_bytes(&[1, 2, 3, 4], 1, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 224]);
}

Expand Down Expand Up @@ -55,7 +55,7 @@ fn deserialize_dr_high_value() {
let dro_bytes = dro.to_pb_bytes().unwrap();
// Setting the maximum allowed value to 1 nanowit below that will result in an error 0xE1:
// BridgePoorIncentives
let err = deserialize_and_validate_dr_bytes(&dro_bytes, total_value - 1).unwrap_err();
let err = deserialize_and_validate_dr_bytes(&dro_bytes, total_value - 1, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 225]);
}

Expand All @@ -78,7 +78,7 @@ fn deserialize_dr_collateral_one_nanowit() {
assert_eq!(total_value, 20_000_000);

let dro_bytes = dro.to_pb_bytes().unwrap();
let err = deserialize_and_validate_dr_bytes(&dro_bytes, total_value).unwrap_err();
let err = deserialize_and_validate_dr_bytes(&dro_bytes, total_value, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 224]);
}

Expand All @@ -95,7 +95,7 @@ fn deserialize_dr_value_overflow() {
};

let dro_bytes = dro.to_pb_bytes().unwrap();
let err = deserialize_and_validate_dr_bytes(&dro_bytes, 1).unwrap_err();
let err = deserialize_and_validate_dr_bytes(&dro_bytes, 1, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 224]);
}

Expand All @@ -115,6 +115,6 @@ fn deserialize_and_validate_dr_bytes_wip_0022() {
let dro_bytes = dro.to_pb_bytes().unwrap();
let witnet_dr_max_value_nanowits = 100_000_000_000;
let err =
deserialize_and_validate_dr_bytes(&dro_bytes, witnet_dr_max_value_nanowits).unwrap_err();
deserialize_and_validate_dr_bytes(&dro_bytes, witnet_dr_max_value_nanowits, 1).unwrap_err();
assert_eq!(err.encode_cbor(), vec![216, 39, 129, 24, 224]);
}
2 changes: 1 addition & 1 deletion bridges/centralized-ethereum/src/actors/eth_poller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl EthPoller {
);
last_dr_id = skip_first;
}
while last_dr_id < next_dr_id {
while last_dr_id + 1 < next_dr_id {
let init_index = usize::try_from(last_dr_id + 1).unwrap();
let last_index = match next_dr_id.cmp(&(last_dr_id + max_batch_size)) {
std::cmp::Ordering::Greater => {
Expand Down
3 changes: 3 additions & 0 deletions bridges/centralized-ethereum/src/actors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ pub mod eth_poller;

/// wit_poller actor module
pub mod wit_poller;

/// watch_dog actor module
pub mod watch_dog;
Loading
Loading