Skip to content

Commit

Permalink
[move] Tower rewards (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: 0o-de-lally <[email protected]>
  • Loading branch information
sirouk and 0o-de-lally authored Oct 3, 2023
1 parent 57f64ed commit 97b691f
Show file tree
Hide file tree
Showing 42 changed files with 795 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: master
hooks:
- id: fmt
- id: fmt
76 changes: 38 additions & 38 deletions framework/cached-packages/src/libra_framework_sdk_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ pub enum EntryFunctionCall {
account_public_key_bytes: Vec<u8>,
},

/// Only a Voucher of the validator can flip the unjail bit.
/// This is a way to make sure the validator is ready to rejoin.
JailUnjailByVoucher {
addr: AccountAddress,
},

/// Only callable in tests and testnets where the core resources account exists.
/// Claim the delegated mint capability and destroy the delegated token.
GasCoinClaimMintCapability {},
Expand All @@ -273,12 +279,6 @@ pub enum EntryFunctionCall {
amount: u64,
},

/// Only a Voucher of the validator can flip the unjail bit.
/// This is a way to make sure the validator is ready to rejoin.
JailUnjailByVoucher {
addr: AccountAddress,
},

/// Similar to add_owners, but only allow adding one owner.
MultisigAccountAddOwner {
new_owner: AccountAddress,
Expand Down Expand Up @@ -734,10 +734,10 @@ impl EntryFunctionCall {
DummyUseFnFromDiemStd {
account_public_key_bytes,
} => dummy_use_fn_from_diem_std(account_public_key_bytes),
JailUnjailByVoucher { addr } => jail_unjail_by_voucher(addr),
GasCoinClaimMintCapability {} => gas_coin_claim_mint_capability(),
GasCoinDelegateMintCapability { to } => gas_coin_delegate_mint_capability(to),
GasCoinMintToImpl { dst_addr, amount } => gas_coin_mint_to_impl(dst_addr, amount),
JailUnjailByVoucher { addr } => jail_unjail_by_voucher(addr),
MultisigAccountAddOwner { new_owner } => multisig_account_add_owner(new_owner),
MultisigAccountAddOwners { new_owners } => multisig_account_add_owners(new_owners),
MultisigAccountApproveTransaction {
Expand Down Expand Up @@ -1559,6 +1559,23 @@ pub fn dummy_use_fn_from_diem_std(account_public_key_bytes: Vec<u8>) -> Transact
))
}

/// Only a Voucher of the validator can flip the unjail bit.
/// This is a way to make sure the validator is ready to rejoin.
pub fn jail_unjail_by_voucher(addr: AccountAddress) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("jail").to_owned(),
),
ident_str!("unjail_by_voucher").to_owned(),
vec![],
vec![bcs::to_bytes(&addr).unwrap()],
))
}

/// Only callable in tests and testnets where the core resources account exists.
/// Claim the delegated mint capability and destroy the delegated token.
pub fn gas_coin_claim_mint_capability() -> TransactionPayload {
Expand Down Expand Up @@ -1613,23 +1630,6 @@ pub fn gas_coin_mint_to_impl(dst_addr: AccountAddress, amount: u64) -> Transacti
))
}

/// Only a Voucher of the validator can flip the unjail bit.
/// This is a way to make sure the validator is ready to rejoin.
pub fn jail_unjail_by_voucher(addr: AccountAddress) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(
AccountAddress::new([
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1,
]),
ident_str!("jail").to_owned(),
),
ident_str!("unjail_by_voucher").to_owned(),
vec![],
vec![bcs::to_bytes(&addr).unwrap()],
))
}

/// Similar to add_owners, but only allow adding one owner.
pub fn multisig_account_add_owner(new_owner: AccountAddress) -> TransactionPayload {
TransactionPayload::EntryFunction(EntryFunction::new(
Expand Down Expand Up @@ -2840,6 +2840,16 @@ mod decoder {
}
}

pub fn jail_unjail_by_voucher(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::JailUnjailByVoucher {
addr: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}

pub fn gas_coin_claim_mint_capability(
payload: &TransactionPayload,
) -> Option<EntryFunctionCall> {
Expand Down Expand Up @@ -2873,16 +2883,6 @@ mod decoder {
}
}

pub fn jail_unjail_by_voucher(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::JailUnjailByVoucher {
addr: bcs::from_bytes(script.args().get(0)?).ok()?,
})
} else {
None
}
}

pub fn multisig_account_add_owner(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
if let TransactionPayload::EntryFunction(script) = payload {
Some(EntryFunctionCall::MultisigAccountAddOwner {
Expand Down Expand Up @@ -3485,6 +3485,10 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
"dummy_use_fn_from_diem_std".to_string(),
Box::new(decoder::dummy_use_fn_from_diem_std),
);
map.insert(
"jail_unjail_by_voucher".to_string(),
Box::new(decoder::jail_unjail_by_voucher),
);
map.insert(
"gas_coin_claim_mint_capability".to_string(),
Box::new(decoder::gas_coin_claim_mint_capability),
Expand All @@ -3497,10 +3501,6 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
"gas_coin_mint_to_impl".to_string(),
Box::new(decoder::gas_coin_mint_to_impl),
);
map.insert(
"jail_unjail_by_voucher".to_string(),
Box::new(decoder::jail_unjail_by_voucher),
);
map.insert(
"multisig_account_add_owner".to_string(),
Box::new(decoder::multisig_account_add_owner),
Expand Down
1 change: 1 addition & 0 deletions framework/libra-framework/sources/block.move
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module diem_framework::block {
use diem_framework::system_addresses;
use diem_framework::timestamp;
use diem_framework::transaction_fee;
// use diem_std::debug::print;

//////// 0L ////////
use ol_framework::epoch_boundary;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,6 @@ module diem_framework::stake {

let min_f = 3;
let current_vals = get_current_validators();

// check if this is not test. Failover doesn't apply here
if (testnet::is_testnet()) {
if (vector::length(&proposed) == 0) {
Expand Down
Loading

0 comments on commit 97b691f

Please sign in to comment.