Skip to content

Commit

Permalink
feat(rpc): expose epoch height for local reconstruct vmcontext (#4221)
Browse files Browse the repository at this point in the history
reproduce contract call with vm standalone requires a vmcontext, which takes epoch height instead of epoch id. This only introduce new field in view, should not cause any protocol change or breaking existing code use `validator` rpc

Test Plan
------------
CI
  • Loading branch information
ailisp authored Apr 21, 2021
1 parent 893731a commit 5b4eef3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions chain/chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,7 @@ impl RuntimeAdapter for KeyValueRuntime {
current_proposals: vec![],
prev_epoch_kickout: vec![],
epoch_start_height: 0,
epoch_height: 1,
})
}

Expand Down
2 changes: 2 additions & 0 deletions chain/epoch_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ impl EpochManager {
ValidatorInfoIdentifier::BlockHash(ref b) => self.get_block_info(b)?.epoch_id().clone(),
};
let cur_epoch_info = self.get_epoch_info(&epoch_id)?.clone();
let epoch_height = cur_epoch_info.epoch_height();
let epoch_start_height = self.get_epoch_start_from_epoch_id(&epoch_id)?;
let mut validator_to_shard = (0..cur_epoch_info.validators_len())
.map(|_| HashSet::default())
Expand Down Expand Up @@ -1051,6 +1052,7 @@ impl EpochManager {
current_proposals: all_proposals,
prev_epoch_kickout,
epoch_start_height,
epoch_height,
})
}

Expand Down
4 changes: 3 additions & 1 deletion core/primitives/src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,10 @@ pub struct EpochValidatorInfo {
pub current_proposals: Vec<ValidatorStakeView>,
/// Kickout in the previous epoch
pub prev_epoch_kickout: Vec<ValidatorKickoutView>,
/// Epoch start height
/// Epoch start block height
pub epoch_start_height: BlockHeight,
/// Epoch height
pub epoch_height: EpochHeight,
}

#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
Expand Down
3 changes: 2 additions & 1 deletion neard/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2422,7 +2422,8 @@ mod test {
)
.into()],
prev_epoch_kickout: Default::default(),
epoch_start_height: 1
epoch_start_height: 1,
epoch_height: 1,
}
);
env.step_default(vec![]);
Expand Down

0 comments on commit 5b4eef3

Please sign in to comment.