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

fvm: return gasused when verifying consensus faults #235

Merged
merged 2 commits into from
Feb 18, 2022
Merged

Conversation

arajasek
Copy link
Contributor

@arajasek
Copy link
Contributor Author

@Stebalien I assume asr/fvm is functionally the fvm dev branch by this point?

rust/Cargo.toml Outdated
@@ -74,8 +74,8 @@ bindgen=[]
# Patched in
[patch.crates-io]
cid = { git = "https://github.com/multiformats/rust-cid", branch = "steb/cbor-hack" }
fvm = { git = "https://github.com/filecoin-project/ref-fvm", branch = "steb/extern" }
fvm_shared = { git = "https://github.com/filecoin-project/ref-fvm", branch = "steb/extern" }
fvm = { path = '../../../../fvm/fvm' }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Drop after filecoin-project/ref-fvm#330 lands, but not sure what to patch to? master? no patch at all?

Copy link
Member

Choose a reason for hiding this comment

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

I think we can drop the patch entirely and just depend on the git version.

@@ -69,6 +69,7 @@ func cgo_extern_verify_consensus_fault(
miner_id *C.uint64_t,
epoch *C.int64_t,
fault *C.int64_t,
gas_used *C.int64_t,
Copy link
Member

Choose a reason for hiding this comment

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

Given that we're already using an "out" pointer here, what if we passed in a pointer to some gas_remaining variable? That would let us stop early without changing the parameters. I.e.:

  1. Read the current gas remaining from the gas_remaining parameter.
  2. Update it locally, stopping if/when we run out.
  3. Write back the final value.

Copy link
Member

@Stebalien Stebalien Feb 16, 2022

Choose a reason for hiding this comment

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

Although I guess this might complicate some other parts of the API a bit? We can always revisit this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a fair point...I'm gonna open an issue and kick the can down the road for now

cgo/interface.go Outdated
@@ -30,7 +31,7 @@ const (
type Externs interface {
GetChainRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) ([]byte, error)
GetBeaconRandomness(ctx context.Context, personalization crypto.DomainSeparationTag, epoch abi.ChainEpoch, entropy []byte) ([]byte, error)
VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte) (*ConsensusFault, error)
VerifyConsensusFault(ctx context.Context, h1, h2, extra []byte) *ConsensusFaultWithGas
Copy link
Member

Choose a reason for hiding this comment

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

Maybe just return multiple values?

Copy link
Member

Choose a reason for hiding this comment

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

(ConsensusFaultWithGas is a bit of a strange type)

) {
0 => Ok(Some(ConsensusFault {
target: Address::new_id(miner_id),
0 => Ok(ConsensusFaultWithGas {
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'd return a tuple instead of a new type.

Also, this was clearly broken before as we had no case that returned None, but I don't think that having a "no fault" variant is the right fix. See filecoin-project/ref-fvm#330 (comment).

cgo/extern.go Outdated
Comment on lines 85 to 86
id, err := address.IDFromAddress(res.Target)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Is this valid if there's "no fault"?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we need to say:

  1. If there's "no fault", we write that back to fault.
  2. Otherwise, we write everything else.

@arajasek arajasek merged commit 9ff2301 into asr/fvm Feb 18, 2022
@arajasek arajasek deleted the asr/fault branch April 5, 2022 19:38
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.

2 participants