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

refactor: clarify data request transaction weight formula #1966

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

tmpolaczyk
Copy link
Contributor

No description provided.

@@ -379,20 +384,18 @@ impl DRTransactionBody {

/// Data Request Transaction weight
pub fn weight(&self) -> u32 {
// DR_weight = DR_size*alpha + W*COMMIT + W*REVEAL*beta + TALLY*beta + W*OUTPUT_SIZE
// DR_weight = DR_output_size + W*COMMIT + W*REVEAL*beta + TALLY*beta + (W + M)*OUTPUT_SIZE + N*INPUT_SIZE
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
// DR_weight = DR_output_size + W*COMMIT + W*REVEAL*beta + TALLY*beta + (W + M)*OUTPUT_SIZE + N*INPUT_SIZE
// DR_weight = DR_output_size*alpha + W*COMMIT + W*REVEAL*beta + TALLY*beta + (W + M)*OUTPUT_SIZE + N*INPUT_SIZE


let inputs_len = u32::try_from(self.inputs.len()).unwrap_or(u32::MAX);
let outputs_len = u32::try_from(self.outputs.len()).unwrap_or(u32::MAX);
let dr_weight = self.dr_output.weight().saturating_mul(ALPHA);
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
let dr_weight = self.dr_output.weight().saturating_mul(ALPHA);
let dr_output_size = self.dr_output.weight().saturating_mul(ALPHA);

Comment on lines 385 to 387
/// Data Request Transaction weight
pub fn weight(&self) -> u32 {
// DR_weight = DR_size*alpha + W*COMMIT + W*REVEAL*beta + TALLY*beta + W*OUTPUT_SIZE
// DR_weight = DR_output_size*alpha + W*COMMIT + W*REVEAL*beta + TALLY*beta + N*INPUT_SIZE + (W + M)*OUTPUT_SIZE
Copy link
Member

Choose a reason for hiding this comment

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

What about moving the formula to the documentation of the function?

@tmpolaczyk tmpolaczyk merged commit dfdb813 into witnet:master Jun 18, 2021
@tmpolaczyk tmpolaczyk deleted the fix-wip-0007 branch July 19, 2021 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants