forked from casper-network/casper-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4775: Precursor for reserved delegator slots r=darthsiroftardis a=j-chmielewski This is a minimal PR to make sure relevant breaking changes to data structures are in place for 2.0 / condor release. This allows us to avoid introducing breaking changes in the future release that includes the full implementation of the reserved delegator slots functionality. Changes: * added `ValidatorBid::reserved_slots` field to track number of reserved slots (defaulted to 0) * added `add_reservations` and `cancel_reservations` auction contracts with stubbed implementations * added `struct Reservation` to track reservations * added `BidKind::Reservation(Box<Reservation>)` and `BidKindTag::Reservation` variants * added `BidAddr::Reservation` and `BidAddrTag::Reservation` variants * added `TransactionEntryPoint::{AddReservations, CancelReservations}` variants * added auction costs for add/cancel reservations ops Co-authored-by: Jacek Chmielewski <[email protected]>
- Loading branch information
Showing
33 changed files
with
690 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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 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 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 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 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 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 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
16 changes: 16 additions & 0 deletions
16
smart_contracts/contracts/client/add-reservations/Cargo.toml
This file contains 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,16 @@ | ||
[package] | ||
name = "add-reservations" | ||
version = "0.1.0" | ||
authors = ["Jacek Chmielewski <[email protected]>"] | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "add_reservations" | ||
path = "src/main.rs" | ||
bench = false | ||
doctest = false | ||
test = false | ||
|
||
[dependencies] | ||
casper-contract = { path = "../../../contract" } | ||
casper-types = { path = "../../../../types" } |
24 changes: 24 additions & 0 deletions
24
smart_contracts/contracts/client/add-reservations/src/main.rs
This file contains 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,24 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
|
||
use alloc::vec::Vec; | ||
|
||
use casper_contract::contract_api::runtime; | ||
use casper_types::system::auction::{Reservation, ARG_RESERVATIONS}; | ||
|
||
fn add_reservations(_reservations: Vec<Reservation>) { | ||
todo!(); | ||
} | ||
|
||
// Add delegators to validator's reserved list. | ||
// | ||
// Accepts reservations. | ||
// Issues an add_reservations request to the auction contract. | ||
#[no_mangle] | ||
pub extern "C" fn call() { | ||
let reservations: Vec<Reservation> = runtime::get_named_arg(ARG_RESERVATIONS); | ||
|
||
add_reservations(reservations); | ||
} |
16 changes: 16 additions & 0 deletions
16
smart_contracts/contracts/client/cancel-reservations/Cargo.toml
This file contains 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,16 @@ | ||
[package] | ||
name = "cancel-reservations" | ||
version = "0.1.0" | ||
authors = ["Jacek Chmielewski <[email protected]>"] | ||
edition = "2021" | ||
|
||
[[bin]] | ||
name = "cancel_reservations" | ||
path = "src/main.rs" | ||
bench = false | ||
doctest = false | ||
test = false | ||
|
||
[dependencies] | ||
casper-contract = { path = "../../../contract" } | ||
casper-types = { path = "../../../../types" } |
28 changes: 28 additions & 0 deletions
28
smart_contracts/contracts/client/cancel-reservations/src/main.rs
This file contains 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,28 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate alloc; | ||
|
||
use alloc::vec::Vec; | ||
|
||
use casper_contract::contract_api::runtime; | ||
use casper_types::{ | ||
system::auction::{ARG_DELEGATORS, ARG_VALIDATOR}, | ||
PublicKey, | ||
}; | ||
|
||
fn cancel_reservations(_validator: PublicKey, _delegators: Vec<PublicKey>) { | ||
todo!(); | ||
} | ||
|
||
// Remove delegators from validator's reserved list. | ||
// | ||
// Accepts delegators' and validator's public keys. | ||
// Issues a cancel_reservations request to the auction contract. | ||
#[no_mangle] | ||
pub extern "C" fn call() { | ||
let delegators: Vec<PublicKey> = runtime::get_named_arg(ARG_DELEGATORS); | ||
let validator = runtime::get_named_arg(ARG_VALIDATOR); | ||
|
||
cancel_reservations(validator, delegators); | ||
} |
This file contains 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 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 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.