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

Stateful entry points #68

Merged
merged 2 commits into from
Nov 18, 2024
Merged

Conversation

fjarri
Copy link
Member

@fjarri fjarri commented Nov 9, 2024

Stacked on top of #67

This PR makes EntryPoint types stateful - that is, this removes the need for EntryPoint::Inputs because the EntryPoint-implementing type becomes the inputs itself. Fixes #64.

Benefits:

  • No need to expose Round types, only the EntryPoint impl can be public
  • Protocol writers can write custom constructors (basically what we do in synedrion in constructors.rs) with additional consistency checks or convenience methods

Also added Round::may_produce_result(). Fixes #66

@fjarri fjarri force-pushed the stateful-entry-points branch from 041ce21 to ab9893e Compare November 9, 2024 22:00
@coveralls
Copy link

coveralls commented Nov 9, 2024

Pull Request Test Coverage Report for Build 11902736853

Details

  • 50 of 63 (79.37%) changed or added relevant lines in 6 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 69.393%

Changes Missing Coverage Covered Lines Changed/Added Lines %
manul/src/combinators/misbehave.rs 13 16 81.25%
manul/src/combinators/chain.rs 21 31 67.74%
Files with Coverage Reduction New Missed Lines %
manul/src/combinators/misbehave.rs 1 90.24%
Totals Coverage Status
Change from base Build 11891570079: -0.1%
Covered Lines: 1773
Relevant Lines: 2555

💛 - Coveralls

@fjarri fjarri mentioned this pull request Nov 13, 2024
@fjarri fjarri force-pushed the stateful-entry-points branch 3 times, most recently from e331cc7 to 6139888 Compare November 13, 2024 21:18
@fjarri fjarri marked this pull request as ready for review November 15, 2024 18:21
@fjarri fjarri force-pushed the stateful-entry-points branch from da76ef6 to c805dbb Compare November 15, 2024 18:22
@fjarri fjarri requested a review from dvdplm November 15, 2024 18:25
@fjarri fjarri self-assigned this Nov 15, 2024
@fjarri fjarri force-pushed the stateful-entry-points branch 2 times, most recently from 0727d12 to 2a00e23 Compare November 15, 2024 22:18
@fjarri fjarri mentioned this pull request Nov 15, 2024
Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

LGTM.

Left nitpicks and suggestions, feel free to ignore and/or defer to separate PR(s).

examples/src/simple_chain.rs Show resolved Hide resolved
examples/src/simple_chain.rs Outdated Show resolved Hide resolved
examples/src/simple_chain.rs Outdated Show resolved Hide resolved
manul/Cargo.toml Outdated
rand = { version = "0.8", default-features = false }
serde_asn1_der = "0.8"
criterion = "0.5"
serde-persistent-deserializer = "0.3"
postcard = { version = "1", default-features = false, features = ["alloc"] }
serde_json = { version = "1", default-features = false, features = ["alloc"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
Copy link
Contributor

Choose a reason for hiding this comment

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

I have tinkered a bit with a crate called test-log. It's just a simple little wrapper around tracing and provides an alternative #[test] macro that sets up tracing behind the scenes such that a tracing-enabled test is just #[test] fn some_test(){ assert!(some_call()) } and any calls to info!/debug!/trace! show up nicely colored when passing RUSTLOG=<level> cargo t -- --nocapture.

Maybe worth using?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks interesting, we can avoid adding a tracing-enabled run_sync() in #71

manul/src/combinators/chain.rs Outdated Show resolved Hide resolved
manul/src/combinators/misbehave.rs Outdated Show resolved Hide resolved
/// The default behavior: sends broadcasts and receives echoed messages, or does neither.
///
/// That is, this node will be a part of the echo round if [`Round::make_echo_broadcast`] generates a message.
Default,
Copy link
Contributor

Choose a reason for hiding this comment

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

You didn't like Full for this? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not sold on it, but maybe it's not that important since it'll probably never get specified explicitly anyway, being the default. Let's discuss naming in a separate PR.

} else {
let echo_round_participation = round.as_ref().echo_round_participation();

let round_sends_echo_broadcast = !echo_broadcast.payload().is_none();
Copy link
Contributor

Choose a reason for hiding this comment

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

My brain stumbles a bit on double negations ("not is none"). Would using is_some() work here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a method of EchoBroadcast, not Option, so there's currently no is_some(). Perhaps there should be. (also I think this is a change from #68)

manul/src/testing/run_sync.rs Outdated Show resolved Hide resolved
for (_id, report) in reports {
assert!(matches!(report.outcome, SessionOutcome::Result(_)));
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's nice to see how clean this test is. :)

@fjarri fjarri force-pushed the stateful-entry-points branch from 2a00e23 to 53ceede Compare November 18, 2024 23:04
@fjarri fjarri merged commit bcfb81a into entropyxyz:master Nov 18, 2024
8 checks passed
fjarri added a commit to fjarri/manul that referenced this pull request Nov 19, 2024
@fjarri fjarri deleted the stateful-entry-points branch November 19, 2024 00:33
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.

Determining that a round may produce a result Stateful entry points
3 participants