Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: FVM no longer draws randomness for you #1848

Merged
merged 4 commits into from
Aug 25, 2023

Conversation

arajasek
Copy link
Contributor

#1847

I might need to iron out the FVM-actors-FVM dependencies for green CI, but should be reviewable.

@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2023

Codecov Report

❗ No coverage uploaded for pull request base (next@5e743b9). Click here to learn what that means.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             next    #1848   +/-   ##
=======================================
  Coverage        ?   75.34%           
=======================================
  Files           ?      149           
  Lines           ?    14603           
  Branches        ?        0           
=======================================
  Hits            ?    11002           
  Misses          ?     3601           
  Partials        ?        0           

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic LGTM

Comment on lines 759 to 760
// TODO
.on_get_randomness(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's pass in the lookback length and put this "todo" in the price list itself (that way, all of our todos are in the price-list side of things and we can merge this before we necessarily have final gas numbers.

fvm/src/kernel/default.rs Outdated Show resolved Hide resolved
let t = self.call_manager.charge_gas(
self.call_manager
.price_list()
.on_get_randomness(entropy.len()),
.on_get_randomness(self.call_manager.context().epoch - rand_epoch),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.on_get_randomness(self.call_manager.context().epoch - rand_epoch),
.on_get_randomness(current_epoch - rand_epoch),

@Stebalien
Copy link
Member

Nest step: disable conformance tests in next then merge this.

Copy link
Member

@Stebalien Stebalien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have carefully checked that we're using the right randomness functions.

(and I swear to never build another blockchain with two randomness functions)

) -> Result<[u8; RANDOMNESS_LENGTH]> {
let current_epoch = self.call_manager.context().epoch;
if rand_epoch > current_epoch {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI... it is possible to write this as:

Suggested change
if rand_epoch > current_epoch {
let lookback = current_epoch.checked_sub(rand_epoch)
.ok_or_else(syscall_error!(IllegalArgument; "randomness epoch {} is in the future", rand_epoch))?;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(lets you skip the subtraction below)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that you necessarily should do it this way. I just figured I'd let you know.

sdk/src/rand.rs Outdated
Comment on lines 29 to 23
round: ChainEpoch,
entropy: &[u8],
) -> SyscallResult<[u8; RANDOMNESS_LENGTH]> {
let ret = unsafe {
sys::rand::get_beacon_randomness(dst, round, entropy.as_ptr(), entropy.len() as u32)?
};
pub fn get_beacon_randomness(round: ChainEpoch) -> SyscallResult<[u8; RANDOMNESS_LENGTH]> {
let ret = unsafe { sys::rand::get_beacon_randomness(round)? };
Ok(ret)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need for the temporary ret variable, the entire function can be written as:

unsafe { sys::rand::get_beacon_randomness(round) }

@arajasek arajasek merged commit 0af54c0 into next Aug 25, 2023
12 checks passed
@arajasek arajasek deleted the asr/stop-hashing-randomness branch August 25, 2023 15:40
Stebalien pushed a commit that referenced this pull request Sep 21, 2023
* feat: FVM no longer draws randomness for you

* update actors bundle

* address review

* disable Hygge test vectors
Stebalien pushed a commit that referenced this pull request Sep 21, 2023
* feat: FVM no longer draws randomness for you

* update actors bundle

* address review

* disable Hygge test vectors
Stebalien pushed a commit that referenced this pull request Sep 21, 2023
* feat: FVM no longer draws randomness for you

* update actors bundle

* address review

* disable Hygge test vectors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants