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

Function to check quorum for arbitrary number of participants #61

Open
CICS-Oleg opened this issue Jan 27, 2025 · 4 comments
Open

Function to check quorum for arbitrary number of participants #61

CICS-Oleg opened this issue Jan 27, 2025 · 4 comments
Assignees
Labels
answered Tutorial question is answered but not added to docs help wanted Extra attention is needed question Further information is requested tutorial Tutorial question

Comments

@CICS-Oleg
Copy link
Contributor

Suppose we have a set of stakeholders with corresponding stakes in %.

(= (spk_holder h1) 2)

(= (spk_holder h2) 4)

(= (spk_holder h3) 5)

(= (spk_holder h4) 2)

(= (spk_holder h5) 0.5)

To start а discussion it has to be a minimum quorum thresh based on the aggregate stake size of the participants. Arbitrary number of participants can come to a meeting. What is the best way/representation to make a function to determine if a quorum is present?

@CICS-Oleg CICS-Oleg added help wanted Extra attention is needed question Further information is requested tutorial Tutorial question labels Jan 27, 2025
@Necr0x0Der
Copy link
Contributor

Well, in a slightly awkward way, it can be done with something like this:

(= (spk_holder h1) 2)
(= (spk_holder h2) 4)
(= (spk_holder h3) 5)
(= (spk_holder h4) 2)
(= (spk_holder h5) 0.5)

(= (stake-size $participants)
   (let $lst (collapse (spk_holder (superpose $participants)))
       (foldl-atom $lst 0 $x $y (+ $x $y)))
)

(= (enough-stake-size? $participants $threshold)
   (>= (stake-size $participants) $threshold)
)

!(enough-stake-size? (h1 h3 h5) 7)
!(enough-stake-size? (h1 h3 h5) 8)

@Necr0x0Der
Copy link
Contributor

What is slightly inconvenient here is that we need to use superpose and collapse. It seems like a common pattern that we want to fold over non-deterministic results. Having functions like foldl-nd or even car-nd might be nice, but the latter may need reimplementing non-deterministic results as streams, which was already discussed, but may require more considerations.

Another minor thing is that it would be more traditional to have lambdas, so instead of passing separate arguments $x, $y, (+ $x $y) we could write (\ ($x $y) (+ $x $y)) and, hence, just +. I'm not sure to what extent it is easily doable now.

So, I'm not proposing these changes specifically for the present issue, but just want to mention these points, @vsbogd , for a later discussion

@CICS-Oleg CICS-Oleg added the answered Tutorial question is answered but not added to docs label Jan 29, 2025
@vsbogd
Copy link
Contributor

vsbogd commented Jan 29, 2025

I believe one can use map-atom instead of (collapse (spk_holder (superpose $participants)), but collapse/superpose looks even more compact.

Yeah, it is interesting point about non-deterministic fold/car. Let's discuss it further later.

@Adam-Vandervorst
Copy link
Collaborator

I think it's completely reasonable to add summation and other MPI reduction strategies to spaces/nondeterministic results.
I.e. (summation (spk_holder (superpose $participants))).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered Tutorial question is answered but not added to docs help wanted Extra attention is needed question Further information is requested tutorial Tutorial question
Projects
None yet
Development

No branches or pull requests

4 participants