-
Notifications
You must be signed in to change notification settings - Fork 22
feat: ciphernode economic contracts [skip-line-limit] #766
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
Merged
Merged
Changes from all commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
315b77b
chore: copy over contracts from tokenomics branch
hmzakhalid 030e0ff
feat: policy can ban nodes
hmzakhalid 03632d5
feat: ticket checkpoints
hmzakhalid 7677604
feat: ticket usdc wrapper with votes:
hmzakhalid f777154
feat: rewards distribution
hmzakhalid 4acd3a4
feat: add ignition modules
hmzakhalid 7aace0b
feat: add bonding registry tests
hmzakhalid 85cf66e
fix: stack too deep error
hmzakhalid c9cce4e
fix: enclave tests
hmzakhalid 6089fa5
feat: deployment scripts
hmzakhalid 10b36f5
feat: ciphernode add script
hmzakhalid f19e8a8
chore: fix linting errors
hmzakhalid 58cfe9f
chore: refactor
hmzakhalid af8d7ac
fix: mint USDC when requesting committee:
hmzakhalid 1c4cb16
fix: contract addresses
hmzakhalid 8b1f9ee
fix: review fixes
hmzakhalid 14711f3
chore: updates
hmzakhalid 66b3ec4
fix: more review fixes
hmzakhalid 0a3958d
fix: contract updates and TODO comments
hmzakhalid f4f73f0
chore: wip
hmzakhalid 30dfad9
Merge branch 'dev' into hmza/economics
hmzakhalid 005dcf9
chore: review fixes
hmzakhalid 498c9fd
chore: merge economics ciphernode integration
hmzakhalid bade2f7
fix: crisp cli request fix
hmzakhalid 4005ae4
chore: lint
hmzakhalid 6c95d1a
chore: lint
hmzakhalid 97fe0db
Merge branch 'dev' into hmza/economics
hmzakhalid ee767e0
chore: merge dev
hmzakhalid c083619
chore: add header
hmzakhalid d79b571
fix: remove bonding registry artifacts from gitignore
hmzakhalid 59f64d5
fix: remove filter
hmzakhalid 6cb50fc
Merge branch 'dev' into hmza/economics
hmzakhalid 9f85fa6
Merge branch 'dev' into hmza/economics
hmzakhalid a2074e0
chore: fix test
hmzakhalid a4b219c
feat: onchain committee sortition
hmzakhalid 2b78cc4
chore: header
hmzakhalid b63d6bb
chore: linter fix
hmzakhalid cc2fa56
Merge branch 'dev' into hmza/economics
hmzakhalid d524e35
chore: merge dev to hmza/economics
hmzakhalid 225e445
chore: add CommitteeSortition to gitigore
hmzakhalid 6491252
fix: pass posideonT3 to Ciphernode deployment
hmzakhalid 492bf7c
chore: remove old contracts from hardhat config
hmzakhalid f736216
chore: add contracts to hh config
hmzakhalid 85a9a23
Merge branch 'dev' into hmza/economics
hmzakhalid 56eec15
chore: update deployment addresses
hmzakhalid 367817b
fix: minor deployment errors
hmzakhalid b30eebc
chore: remove ignition (#887)
ctrlc03 0d3e17f
fix: interface fix
hmzakhalid f460597
Merge branch 'dev' into hmza/economics
hmzakhalid b8fd610
fix: ciphernode builder contract registry writer
hmzakhalid 005e803
chore: committee sorition
hmzakhalid 8f41d25
chore: merge sortition to ciphernode contract
hmzakhalid 21bc518
feat: ciphernode contract methods in crates
hmzakhalid fcd2bca
feat: integrate committee finalizer
hmzakhalid be717ba
Merge branch 'dev' into hmza/economics
hmzakhalid ac2f7b2
chore: merge dev
hmzakhalid 31764ca
chore: remove unused contracts
hmzakhalid 5028edc
fix: coderabbit review fixes
hmzakhalid 7d77897
fix: error handling for committee finalizer
hmzakhalid 0805bd9
fix: update nodes addresses
hmzakhalid c5658c6
feat(sync): implement persistent node state, finalized committees, an…
hmzakhalid d15361a
fix: add score sorition to integration test
hmzakhalid c6c4437
fix: integration test
hmzakhalid 96ef2ef
fix: dont call sortition on Committee Finalized
hmzakhalid 77f81ff
fix: dont call sortition on Committee Finalized
hmzakhalid 64b60e5
fix: integration test passing
hmzakhalid 1b6e85c
chore(sdk): approve fee token for e3 request
hmzakhalid a0e9675
fix: fetch time from RPC
hmzakhalid a614dd8
Merge branch 'dev' into hmza/economics
hmzakhalid 80c5689
fix: trust committee finalized event for party ids
hmzakhalid 7ef399d
fix: sdk test
hmzakhalid 083c09f
feat(sortition): add sortition to ciphernode builder and make distanc…
hmzakhalid 233bcd4
fix: contract addresses for crisp e2e test
hmzakhalid 3c97583
feat: tests for new sortition changes
hmzakhalid 0cec52a
chore: linter fixes
hmzakhalid 9ff6c74
Merge branch 'dev' into hmza/economics
hmzakhalid 3a143de
fix: increase publish cound
hmzakhalid 79efc75
fix: increase E3 window time
hmzakhalid b8208b0
fix: aggreagtor wallet setup
hmzakhalid 5ebdd1b
fix: legacy integration tests
hmzakhalid 065ea2b
fix: debug the correct timestamp
hmzakhalid 088df6a
chore: documentation for score sortition flow
hmzakhalid 424d42d
feat: remove node state manager actor and create a single sortition a…
hmzakhalid 8ccc0b7
fix: a few little fixes
hmzakhalid cc97082
fix: chain setter error
hmzakhalid d1aaee3
fix: testing with a sleep fix
hmzakhalid 9366fe6
fix: revert test
hmzakhalid d1385b2
Merge branch 'dev' into hmza/economics
hmzakhalid 54e295b
fix: crisp version mismatch [skip ci]
hmzakhalid 4fce862
fix: remove fee token from sdk
hmzakhalid ffdcf80
fix: trying out with workspace *
hmzakhalid b269b14
fix: fetch timestamp after feeQuote
hmzakhalid a11a8b3
fix: add feetoken to sdk and committee publish timeout to e2e test
hmzakhalid da1badc
fix: router scoping issue
hmzakhalid d3672d9
fix: use setup in integration test & remove recipient from committee …
hmzakhalid ea97768
fix: update package.json to include browser conditions
hmzakhalid de8ab47
fix: update package.json to include browser conditions
hmzakhalid 0ace70b
fix: test out sdk version in crisp
hmzakhalid adfa7a9
fix: update pnpm lock
hmzakhalid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
| // | ||
| // This file is provided WITHOUT ANY WARRANTY; | ||
| // without even the implied warranty of MERCHANTABILITY | ||
| // or FITNESS FOR A PARTICULAR PURPOSE. | ||
|
|
||
| use actix::prelude::*; | ||
| use e3_events::{ | ||
| CommitteeFinalizeRequested, CommitteeRequested, EnclaveEvent, EventBus, Shutdown, Subscribe, | ||
| }; | ||
| use std::collections::HashMap; | ||
| use std::time::Duration; | ||
| use tracing::{error, info}; | ||
|
|
||
| /// CommitteeFinalizer is an actor that listens to CommitteeRequested events and dispatches | ||
| /// CommitteeFinalizeRequested events after the submission deadline has passed. | ||
| pub struct CommitteeFinalizer { | ||
| bus: Addr<EventBus<EnclaveEvent>>, | ||
| pending_committees: HashMap<String, SpawnHandle>, | ||
| } | ||
|
|
||
| impl CommitteeFinalizer { | ||
| pub fn new(bus: &Addr<EventBus<EnclaveEvent>>) -> Self { | ||
| Self { | ||
| bus: bus.clone(), | ||
| pending_committees: HashMap::new(), | ||
| } | ||
| } | ||
|
|
||
| pub fn attach(bus: &Addr<EventBus<EnclaveEvent>>) -> Addr<Self> { | ||
| let addr = CommitteeFinalizer::new(bus).start(); | ||
|
|
||
| bus.do_send(Subscribe::new( | ||
| "CommitteeRequested", | ||
| addr.clone().recipient(), | ||
| )); | ||
| bus.do_send(Subscribe::new("Shutdown", addr.clone().recipient())); | ||
|
|
||
| addr | ||
| } | ||
| } | ||
|
|
||
| impl Actor for CommitteeFinalizer { | ||
| type Context = Context<Self>; | ||
| } | ||
|
|
||
| impl Handler<EnclaveEvent> for CommitteeFinalizer { | ||
| type Result = (); | ||
| fn handle(&mut self, msg: EnclaveEvent, ctx: &mut Self::Context) -> Self::Result { | ||
| match msg { | ||
| EnclaveEvent::CommitteeRequested { data, .. } => ctx.notify(data), | ||
| EnclaveEvent::Shutdown { data, .. } => ctx.notify(data), | ||
| _ => (), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl Handler<CommitteeRequested> for CommitteeFinalizer { | ||
| type Result = (); | ||
|
|
||
| fn handle(&mut self, msg: CommitteeRequested, ctx: &mut Self::Context) -> Self::Result { | ||
| let e3_id = msg.e3_id.clone(); | ||
| let submission_deadline = msg.submission_deadline; | ||
|
|
||
| const FINALIZATION_BUFFER_SECONDS: u64 = 1; | ||
|
|
||
| let e3_id_for_log = e3_id.clone(); | ||
| let fut = async move { | ||
| match e3_evm::helpers::get_current_timestamp().await { | ||
| Ok(timestamp) => Some(timestamp), | ||
| Err(e) => { | ||
| error!( | ||
| e3_id = %e3_id_for_log, | ||
| error = %e, | ||
| "Failed to get current timestamp from RPC" | ||
| ); | ||
| None | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| let e3_id_for_async = e3_id; | ||
| ctx.spawn( | ||
| fut.into_actor(self) | ||
| .then(move |current_timestamp, act, ctx| { | ||
| if let Some(current_timestamp) = current_timestamp { | ||
| let seconds_until_deadline = if submission_deadline > current_timestamp { | ||
| (submission_deadline - current_timestamp) + FINALIZATION_BUFFER_SECONDS | ||
| } else { | ||
| info!( | ||
| e3_id = %e3_id_for_async, | ||
| submission_deadline = submission_deadline, | ||
| current_timestamp = current_timestamp, | ||
| "Submission deadline already passed, finalizing with buffer" | ||
| ); | ||
| FINALIZATION_BUFFER_SECONDS | ||
| }; | ||
|
|
||
| info!( | ||
| e3_id = %e3_id_for_async, | ||
| submission_deadline = submission_deadline, | ||
| current_timestamp = current_timestamp, | ||
| seconds_to_wait = seconds_until_deadline, | ||
| "Scheduling committee finalization" | ||
| ); | ||
|
|
||
| let bus = act.bus.clone(); | ||
| let e3_id_clone = e3_id_for_async.clone(); | ||
|
|
||
| let handle = ctx.run_later( | ||
| Duration::from_secs(seconds_until_deadline), | ||
| move |act, _ctx| { | ||
| info!(e3_id = %e3_id_clone, "Dispatching CommitteeFinalizeRequested event"); | ||
|
|
||
| bus.do_send(EnclaveEvent::from(CommitteeFinalizeRequested { | ||
| e3_id: e3_id_clone.clone(), | ||
| })); | ||
|
|
||
| act.pending_committees.remove(&e3_id_clone.to_string()); | ||
| }, | ||
| ); | ||
|
|
||
| act.pending_committees | ||
| .insert(e3_id_for_async.to_string(), handle); | ||
| } else { | ||
| error!( | ||
| e3_id = %e3_id_for_async, | ||
| "Skipping committee finalization due to timestamp fetch failure" | ||
| ); | ||
| } | ||
|
hmzakhalid marked this conversation as resolved.
|
||
|
|
||
| async {}.into_actor(act) | ||
| }), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| impl Handler<Shutdown> for CommitteeFinalizer { | ||
| type Result = (); | ||
| fn handle(&mut self, _msg: Shutdown, ctx: &mut Self::Context) -> Self::Result { | ||
| info!("Killing CommitteeFinalizer"); | ||
| // Cancel all pending finalization tasks | ||
| for (_, handle) in self.pending_committees.drain() { | ||
| ctx.cancel_future(handle); | ||
| } | ||
| ctx.stop(); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.