Skip to content

Commit f7ceeb4

Browse files
dborehamCrispin Fitz PianissimoMontague Saint StagCaty PrestoRaffa O'Adagio
authored
[reauth] reauth tally refactor, page rank fixes (#391)
Co-authored-by: xyz <xyz> Co-authored-by: Crispin Fitz Pianissimo <[email protected]> Co-authored-by: Montague Saint Stag <[email protected]> Co-authored-by: Caty Presto <[email protected]> Co-authored-by: Raffa O'Adagio <raffa_o'[email protected]> Co-authored-by: Vale Hind <[email protected]> Co-authored-by: Sere McTempo <[email protected]> Co-authored-by: Sere Cony <[email protected]> Co-authored-by: Nora Cony <[email protected]> Co-authored-by: Bea Von Hind <[email protected]> Co-authored-by: Giulietta Ritardando <[email protected]> Co-authored-by: Peregrine De Bittern <[email protected]> Co-authored-by: Basil Vivace <[email protected]> Co-authored-by: Nora Fitz Hind <[email protected]> Co-authored-by: Franci di Sforzando <[email protected]> Co-authored-by: Raffa Fitz Stag <[email protected]> Co-authored-by: Giulietta Saint Mezzo <[email protected]> Co-authored-by: Reginald Marten <[email protected]>
1 parent 6646b69 commit f7ceeb4

21 files changed

+609
-299
lines changed

framework/cached-packages/src/libra_framework_sdk_builder.rs

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,6 @@ pub enum EntryFunctionCall {
191191
/// Public function for production triggering of epoch boundary.
192192
DiemGovernanceTriggerEpoch {},
193193

194-
/// Standalone function to close the poll after threshold or expiration passed
195-
/// The reason for a separate function is so that closing the poll and
196-
/// voting may not need to be in the same transaction. They can be atomic
197-
/// and produce better error messages.
198-
DonorVoiceTxsMaybeTallyReauthTx {
199-
multisig_address: AccountAddress,
200-
},
201-
202194
/// A signer of the multisig can propose a payment
203195
/// Public entry function required for txs cli
204196
DonorVoiceTxsProposeAdvanceTx {
@@ -340,6 +332,13 @@ pub enum EntryFunctionCall {
340332
amount: u64,
341333
},
342334

335+
/// Refresh the cache
336+
/// state updates must be called by a user.
337+
/// Vouch tree updates could be a DDOS vector
338+
PageRankLazyRefreshCache {
339+
user: AccountAddress,
340+
},
341+
343342
/// retract bid
344343
ProofOfFeePofRetractBid {},
345344

@@ -500,9 +499,6 @@ impl EntryFunctionCall {
500499
} => diem_governance_ol_vote(proposal_id, should_pass),
501500
DiemGovernanceSmokeTriggerEpoch {} => diem_governance_smoke_trigger_epoch(),
502501
DiemGovernanceTriggerEpoch {} => diem_governance_trigger_epoch(),
503-
DonorVoiceTxsMaybeTallyReauthTx { multisig_address } => {
504-
donor_voice_txs_maybe_tally_reauth_tx(multisig_address)
505-
}
506502
DonorVoiceTxsProposeAdvanceTx {
507503
multisig_address,
508504
payee,
@@ -553,6 +549,7 @@ impl EntryFunctionCall {
553549
} => multisig_account_update_signatures_required(new_num_signatures_required),
554550
OlAccountCreateAccount { auth_key } => ol_account_create_account(auth_key),
555551
OlAccountTransfer { to, amount } => ol_account_transfer(to, amount),
552+
PageRankLazyRefreshCache { user } => page_rank_lazy_refresh_cache(user),
556553
ProofOfFeePofRetractBid {} => proof_of_fee_pof_retract_bid(),
557554
ProofOfFeePofUpdateBid { bid, epoch_expiry } => {
558555
proof_of_fee_pof_update_bid(bid, epoch_expiry)
@@ -1001,27 +998,6 @@ pub fn diem_governance_trigger_epoch() -> TransactionPayload {
1001998
))
1002999
}
10031000

1004-
/// Standalone function to close the poll after threshold or expiration passed
1005-
/// The reason for a separate function is so that closing the poll and
1006-
/// voting may not need to be in the same transaction. They can be atomic
1007-
/// and produce better error messages.
1008-
pub fn donor_voice_txs_maybe_tally_reauth_tx(
1009-
multisig_address: AccountAddress,
1010-
) -> TransactionPayload {
1011-
TransactionPayload::EntryFunction(EntryFunction::new(
1012-
ModuleId::new(
1013-
AccountAddress::new([
1014-
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,
1015-
0, 0, 0, 1,
1016-
]),
1017-
ident_str!("donor_voice_txs").to_owned(),
1018-
),
1019-
ident_str!("maybe_tally_reauth_tx").to_owned(),
1020-
vec![],
1021-
vec![bcs::to_bytes(&multisig_address).unwrap()],
1022-
))
1023-
}
1024-
10251001
/// A signer of the multisig can propose a payment
10261002
/// Public entry function required for txs cli
10271003
pub fn donor_voice_txs_propose_advance_tx(
@@ -1431,6 +1407,24 @@ pub fn ol_account_transfer(to: AccountAddress, amount: u64) -> TransactionPayloa
14311407
))
14321408
}
14331409

1410+
/// Refresh the cache
1411+
/// state updates must be called by a user.
1412+
/// Vouch tree updates could be a DDOS vector
1413+
pub fn page_rank_lazy_refresh_cache(user: AccountAddress) -> TransactionPayload {
1414+
TransactionPayload::EntryFunction(EntryFunction::new(
1415+
ModuleId::new(
1416+
AccountAddress::new([
1417+
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,
1418+
0, 0, 0, 1,
1419+
]),
1420+
ident_str!("page_rank_lazy").to_owned(),
1421+
),
1422+
ident_str!("refresh_cache").to_owned(),
1423+
vec![],
1424+
vec![bcs::to_bytes(&user).unwrap()],
1425+
))
1426+
}
1427+
14341428
/// retract bid
14351429
pub fn proof_of_fee_pof_retract_bid() -> TransactionPayload {
14361430
TransactionPayload::EntryFunction(EntryFunction::new(
@@ -1851,18 +1845,6 @@ mod decoder {
18511845
}
18521846
}
18531847

1854-
pub fn donor_voice_txs_maybe_tally_reauth_tx(
1855-
payload: &TransactionPayload,
1856-
) -> Option<EntryFunctionCall> {
1857-
if let TransactionPayload::EntryFunction(script) = payload {
1858-
Some(EntryFunctionCall::DonorVoiceTxsMaybeTallyReauthTx {
1859-
multisig_address: bcs::from_bytes(script.args().first()?).ok()?,
1860-
})
1861-
} else {
1862-
None
1863-
}
1864-
}
1865-
18661848
pub fn donor_voice_txs_propose_advance_tx(
18671849
payload: &TransactionPayload,
18681850
) -> Option<EntryFunctionCall> {
@@ -2101,6 +2083,16 @@ mod decoder {
21012083
}
21022084
}
21032085

2086+
pub fn page_rank_lazy_refresh_cache(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
2087+
if let TransactionPayload::EntryFunction(script) = payload {
2088+
Some(EntryFunctionCall::PageRankLazyRefreshCache {
2089+
user: bcs::from_bytes(script.args().first()?).ok()?,
2090+
})
2091+
} else {
2092+
None
2093+
}
2094+
}
2095+
21042096
pub fn proof_of_fee_pof_retract_bid(payload: &TransactionPayload) -> Option<EntryFunctionCall> {
21052097
if let TransactionPayload::EntryFunction(_script) = payload {
21062098
Some(EntryFunctionCall::ProofOfFeePofRetractBid {})
@@ -2298,10 +2290,6 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
22982290
"diem_governance_trigger_epoch".to_string(),
22992291
Box::new(decoder::diem_governance_trigger_epoch),
23002292
);
2301-
map.insert(
2302-
"donor_voice_txs_maybe_tally_reauth_tx".to_string(),
2303-
Box::new(decoder::donor_voice_txs_maybe_tally_reauth_tx),
2304-
);
23052293
map.insert(
23062294
"donor_voice_txs_propose_advance_tx".to_string(),
23072295
Box::new(decoder::donor_voice_txs_propose_advance_tx),
@@ -2386,6 +2374,10 @@ static SCRIPT_FUNCTION_DECODER_MAP: once_cell::sync::Lazy<EntryFunctionDecoderMa
23862374
"ol_account_transfer".to_string(),
23872375
Box::new(decoder::ol_account_transfer),
23882376
);
2377+
map.insert(
2378+
"page_rank_lazy_refresh_cache".to_string(),
2379+
Box::new(decoder::page_rank_lazy_refresh_cache),
2380+
);
23892381
map.insert(
23902382
"proof_of_fee_pof_retract_bid".to_string(),
23912383
Box::new(decoder::proof_of_fee_pof_retract_bid),

framework/libra-framework/sources/ol_sources/activity.move

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module ol_framework::activity {
66

77
friend ol_framework::filo_migration;
88
friend ol_framework::ol_account;
9+
friend ol_framework::donor_voice_migration;
910
friend diem_framework::transaction_validation;
1011

1112
#[test_only]

0 commit comments

Comments
 (0)