Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

feat: script cleanup, ProofFromByteSlices, gadget for voting power #6

Merged
merged 27 commits into from
Jul 28, 2023

Conversation

ratankaliani
Copy link
Member

@ratankaliani ratankaliani commented Jul 26, 2023

Features

  • Clean up tests
  • Migrate to tendermint-rs for merkle proof gen
  • Add rust port of select functions from tendermint-go
  • Generate celestia sig fixture from RPC
  • Sub-circuit for accumulating voting power for Celestia

Fixes

  • Constrain accumulate_voting_power to avoid b^2 term
  • Assert MSB of i64Target is 0

@ratankaliani ratankaliani changed the title feat: Add script format feat: Script cleanup, Port ProofFromByteSlices, Gadget for Voting Power Jul 27, 2023
@ratankaliani ratankaliani changed the title feat: Script cleanup, Port ProofFromByteSlices, Gadget for Voting Power feat: script cleanup, ProofFromByteSlices, gadget for voting power Jul 27, 2023
hashed_leaves
}

#[derive(Clone)]
Copy link
Contributor

Choose a reason for hiding this comment

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

link go source code

src/validator.rs Outdated
fn voting_power_greater_than_threshold(
&mut self,
accumulated_power: &I64Target,
threshold: &I64Target
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong variable name

src/validator.rs Outdated
// Compute total_vp * 2
let (scaled_total_vp_low, scaled_total_vp_high) = self.mul_i64_by_u32(&threshold, two_u32);

// Check that the accumulated voting power is greater than 2/3 of the total voting power.
Copy link
Contributor

Choose a reason for hiding this comment

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

i suggest abstracting this into another function that just compares two i64s

src/validator.rs Outdated
(lower_product, upper_sum)
}

fn voting_power_greater_than_threshold(
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also pass in 2, 3 here into the function so we can control the threshold

pass
}

fn check_voting_power(
Copy link
Contributor

Choose a reason for hiding this comment

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

also pass in threshold numerator / denominator here for max flexibility

@ratankaliani ratankaliani merged commit 9f3b231 into main Jul 28, 2023
1 check passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants