Skip to content

Commit 924b3ea

Browse files
committed
Add update box creation height to CastBallotBoxVoteParameters
1 parent 57effa2 commit 924b3ea

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

core/src/box_kind/ballot_box.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,23 @@ impl BallotBoxWrapper {
9191
reward_token_id,
9292
reward_token_quantity,
9393
pool_box_address_hash,
94+
update_box_creation_height,
9495
}) = inputs.parameters.vote_parameters.as_ref()
9596
{
96-
if ergo_box
97+
let register_update_box_creation_height = ergo_box
9798
.get_register(NonMandatoryRegisterId::R5.into())
9899
.ok_or(BallotBoxError::NoUpdateBoxCreationHeightInR5)?
99-
.try_extract_into::<i32>()
100-
.is_err()
101-
{
102-
return Err(BallotBoxError::NoUpdateBoxCreationHeightInR5);
100+
.try_extract_into::<i32>()?;
101+
102+
if register_update_box_creation_height != *update_box_creation_height {
103+
warn!("Update box creation height in R5 register differs to config. Could be due to vote.");
103104
}
104105

105106
let register_pool_box_address_hash = ergo_box
106107
.get_register(NonMandatoryRegisterId::R6.into())
107108
.ok_or(BallotBoxError::NoPoolBoxAddressInR6)?
108109
.try_extract_into::<Digest32>()?;
110+
109111
if *pool_box_address_hash != register_pool_box_address_hash {
110112
warn!("Pool box address in R6 register differs to config. Could be due to vote.");
111113
}
@@ -114,6 +116,7 @@ impl BallotBoxWrapper {
114116
.get_register(NonMandatoryRegisterId::R7.into())
115117
.ok_or(BallotBoxError::NoRewardTokenIdInR7)?
116118
.try_extract_into::<TokenId>()?;
119+
117120
if register_reward_token_id != *reward_token_id {
118121
warn!("Reward token id in R7 register differs to config. Could be due to vote.");
119122
}
@@ -177,14 +180,10 @@ impl VoteBallotBoxWrapper {
177180
{
178181
return Err(BallotBoxError::NoGroupElementInR4);
179182
}
180-
if ergo_box
183+
let update_box_creation_height = ergo_box
181184
.get_register(NonMandatoryRegisterId::R5.into())
182185
.ok_or(BallotBoxError::NoUpdateBoxCreationHeightInR5)?
183-
.try_extract_into::<i32>()
184-
.is_err()
185-
{
186-
return Err(BallotBoxError::NoUpdateBoxCreationHeightInR5);
187-
}
186+
.try_extract_into::<i32>()?;
188187

189188
let pool_box_address_hash = ergo_box
190189
.get_register(NonMandatoryRegisterId::R6.into())
@@ -205,6 +204,7 @@ impl VoteBallotBoxWrapper {
205204
pool_box_address_hash,
206205
reward_token_id,
207206
reward_token_quantity,
207+
update_box_creation_height,
208208
};
209209
Ok(Self {
210210
ergo_box,

core/src/cli_commands/update_pool.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ fn build_update_pool_box_tx(
210210
let vote_parameters = CastBallotBoxVoteParameters {
211211
pool_box_address_hash: pool_box_hash,
212212
reward_token_id: reward_tokens.token_id.clone(),
213-
reward_token_quantity: *reward_tokens.amount.as_u64(), // TODO: Change vote parameters to i64
213+
reward_token_quantity: *reward_tokens.amount.as_u64(),
214+
update_box_creation_height: update_box.get_box().creation_info().0,
214215
};
215216
// Find ballot boxes that are voting for the new pool hash
216217
let mut sorted_ballot_boxes = ballot_boxes.get_ballot_boxes()?;

core/src/cli_commands/vote_update_pool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ mod tests {
376376
reward_token_id: force_any_val::<TokenId>(),
377377
reward_token_quantity: 100000,
378378
pool_box_address_hash: force_any_val::<Digest32>(),
379+
update_box_creation_height: force_any_val::<i32>().abs()
379380
}),
380381
};
381382
let inputs = BallotBoxWrapperInputs {

core/src/oracle_config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub struct CastBallotBoxVoteParameters {
5656
pub pool_box_address_hash: Digest32,
5757
pub reward_token_id: TokenId,
5858
pub reward_token_quantity: u64,
59+
pub update_box_creation_height: i32,
5960
}
6061

6162
/// Holds the token ids of every important token used by the oracle pool.

0 commit comments

Comments
 (0)