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 batch report #2166

Merged
merged 12 commits into from
Mar 25, 2022
Merged

Bridge batch report #2166

merged 12 commits into from
Mar 25, 2022

Conversation

tmpolaczyk
Copy link
Contributor

@tmpolaczyk tmpolaczyk commented Mar 16, 2022

Close #2163
Fix #2046
Fix #2131

@@ -10,14 +10,14 @@ use crate::{
};
use actix::prelude::*;
use std::{collections::HashSet, sync::Arc, time::Duration};
use web3::contract::tokens::Tokenize;
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt

@@ -68,12 +68,20 @@ impl DrReporter {
}
}

/// Report the result of this data request id to ethereum
/// Report the result of this data requests to ethereum
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Report the result of this data requests to ethereum
/// Report the results of this data requests to ethereum

Comment on lines 83 to 84
// Data Request Bytes
//pub dr_bytes: Bytes,
Copy link
Contributor

Choose a reason for hiding this comment

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

if we are not using, should we remove it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

{
let dr_database_addr = DrDatabase::from_registry();
dr_database_addr.send(set_dr_info_bridge_msg).await.ok();
// The request is already resolved, remove it from list
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we modify this message?

@@ -1,3 +1,4 @@
use crate::actors::dr_reporter::Report;
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt

@@ -1,3 +1,4 @@
use crate::actors::dr_reporter::Report;
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt

@@ -68,12 +68,20 @@ impl DrReporter {
}
}

/// Report the result of this data request id to ethereum
/// Report the result of this data requests to ethereum
Copy link
Member

Choose a reason for hiding this comment

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

Even better:

Suggested change
/// Report the result of this data requests to ethereum
/// Report the results of these data requests to Ethereum

"Request [{}] is already being resolved, ignoring DrReporterMsg",
msg.dr_id
);
// Remove all reports that have already been reported, but the transaction is pending
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Remove all reports that have already been reported, but the transaction is pending
// Remove all reports that have already been reported, but whose reporting transaction is still pending

// Remove all reports that have already been reported, but the transaction is pending
msg.reports.retain(|report| {
if self.pending_report_result.contains(&report.dr_id) {
// Timeout not elapsed, abort
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Timeout not elapsed, abort
// Timeout is not over yet, no action is needed

{
let dr_database_addr = DrDatabase::from_registry();
dr_database_addr.send(set_dr_info_bridge_msg).await.ok();
// The request is already resolved, remove it from list
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// The request is already resolved, remove it from list
// The request was already resolved, we can remove it from the list

log::error!("reportResultBatch{:?}: {:?}", params_str, e);
}
Err(_e) => {
// Timeout elapsed
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Timeout elapsed
// Timeout is over

}
Err(_e) => {
// Timeout elapsed
log::warn!("reportResultBatch{:?}: timeout elapsed", params_str);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log::warn!("reportResultBatch{:?}: timeout elapsed", params_str);
log::warn!("reportResultBatch{:?}: timeout is over", params_str);

Comment on lines 295 to 327
// The gas price of the report transaction should be the maximum gas price of any
// request
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// The gas price of the report transaction should be the maximum gas price of any
// request
// The gas price of the report transaction should equal the maximum gas price paid
// by any of the requests being solved here

@tmpolaczyk tmpolaczyk force-pushed the bridge-batch-report branch 2 times, most recently from 35cf787 to 70f6988 Compare March 17, 2022 16:44
@@ -10,14 +10,14 @@ use crate::{
};
use actix::prelude::*;
use std::{collections::HashSet, sync::Arc, time::Duration};
use web3::ethabi::Token;
Copy link
Contributor

Choose a reason for hiding this comment

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

fmt

};

let block_number = block.block_header.beacon.checkpoint;
// TODO: get constants from somewhere instead of hardcoding them here?
Copy link
Contributor

Choose a reason for hiding this comment

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

image
There is a jsonrpc method that returns the consensus constants

// transactions are created one epoch earlier.
// TODO: first block with commits is hard to obtain, we are simply using the
// block that included the data request.
let timestamp = {
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be in a function?

@lrubiorod
Copy link
Contributor

lrubiorod commented Mar 23, 2022

Do you return the timestamp according to block explorer way (+1 epoch)?

@tmpolaczyk
Copy link
Contributor Author

Do you return the timestamp according to block explorer way (+1 epoch)?

No, because this should be the timestamp of when the commit transaction was created, not the timestamp of the block that includes that transaction.

@lrubiorod
Copy link
Contributor

Do you return the timestamp according to block explorer way (+1 epoch)?

No, because this should be the timestamp of when the commit transaction was created, not the timestamp of the block that includes that transaction.

According with a TODO comment in the wit_poller, we are using the timestamp when the request was included, so using the timestamp when the block that includes the data request is included in the blockchain could be nearer to the timestamp when the commit transaction was created, what do you think?

@tmpolaczyk
Copy link
Contributor Author

Do you return the timestamp according to block explorer way (+1 epoch)?

No, because this should be the timestamp of when the commit transaction was created, not the timestamp of the block that includes that transaction.

According with a TODO comment in the wit_poller, we are using the timestamp when the request was included, so using the timestamp when the block that includes the data request is included in the blockchain could be nearer to the timestamp when the commit transaction was created, what do you think?

Ok, I changed the block epoch from "the block that included the data request" to "that + 1", which will be more accurate, but it is still wrong in cases when there is more than one commit round.

@lrubiorod lrubiorod dismissed aesedepece’s stale review March 24, 2022 14:35

Requested changes already included

@tmpolaczyk tmpolaczyk merged commit 4c16477 into witnet:master Mar 25, 2022
@tmpolaczyk tmpolaczyk deleted the bridge-batch-report branch July 11, 2022 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants