-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix: many incorrect pointer equality comparisons #1018
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -36,7 +36,9 @@ func (DeadlineInfoExtractor) Extract(ctx context.Context, a actorstate.ActorInfo | |||||||||
if err != nil { | ||||||||||
return nil, err | ||||||||||
} | ||||||||||
if prevDeadlineInfo == currDeadlineInfo { | ||||||||||
// TODO implement equality function | ||||||||||
// dereference pointers to check equality | ||||||||||
if *prevDeadlineInfo == *currDeadlineInfo { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is brittle. We have to be sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is brittle. We have to be sure that
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we know the miner has state we can safely assume it has non-nil deadline information. (the method that creates deadline info will never return null: https://github.com/filecoin-project/specs-actors/blob/v8.0.1/actors/builtin/miner/deadlines.go#L15 |
||||||||||
return nil, nil | ||||||||||
} | ||||||||||
} | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,11 @@ func (LockedFundsExtractor) Extract(ctx context.Context, a actorstate.ActorInfo, | |
if err != nil { | ||
return nil, fmt.Errorf("loading previous miner locked funds: %w", err) | ||
} | ||
if prevLocked == currLocked { | ||
|
||
// if all values are equal there is no change. | ||
if prevLocked.VestingFunds.Equals(currLocked.VestingFunds) && | ||
prevLocked.PreCommitDeposits.Equals(currLocked.PreCommitDeposits) && | ||
prevLocked.InitialPledgeRequirement.Equals(currLocked.InitialPledgeRequirement) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Protect against nil-deref panic here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the |
||
return nil, nil | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -119,11 +119,12 @@ type MsigExtractionContext struct { | |||||
CurrState multisig.State | ||||||
CurrTs *types.TipSet | ||||||
|
||||||
Store adt.Store | ||||||
Store adt.Store | ||||||
PreviousState bool | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
} | ||||||
|
||||||
func (m *MsigExtractionContext) HasPreviousState() bool { | ||||||
return !(m.CurrTs.Height() == 1 || m.CurrState == m.PrevState) | ||||||
return m.PreviousState | ||||||
} | ||||||
|
||||||
func NewMultiSigExtractionContext(ctx context.Context, a actorstate.ActorInfo, node actorstate.ActorStateAPI) (*MsigExtractionContext, error) { | ||||||
|
@@ -140,11 +141,12 @@ func NewMultiSigExtractionContext(ctx context.Context, a actorstate.ActorInfo, n | |||||
// actor was created in the current state. | ||||||
if err == types.ErrActorNotFound { | ||||||
return &MsigExtractionContext{ | ||||||
PrevState: prevState, | ||||||
CurrActor: &a.Actor, | ||||||
CurrState: curState, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PrevState: prevState, | ||||||
CurrActor: &a.Actor, | ||||||
CurrState: curState, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PreviousState: false, | ||||||
}, nil | ||||||
} | ||||||
return nil, fmt.Errorf("loading previous multisig %s at tipset %s epoch %d: %w", a.Address, a.Executed.Key(), a.Current.Height(), err) | ||||||
|
@@ -157,10 +159,11 @@ func NewMultiSigExtractionContext(ctx context.Context, a actorstate.ActorInfo, n | |||||
} | ||||||
|
||||||
return &MsigExtractionContext{ | ||||||
PrevState: prevState, | ||||||
CurrActor: &a.Actor, | ||||||
CurrState: curState, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PrevState: prevState, | ||||||
CurrActor: &a.Actor, | ||||||
CurrState: curState, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PreviousState: true, | ||||||
}, nil | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,11 +20,12 @@ type VerifiedRegistryExtractionContext struct { | |||||
PrevState, CurrState verifreg.State | ||||||
PrevTs, CurrTs *types.TipSet | ||||||
|
||||||
Store adt.Store | ||||||
Store adt.Store | ||||||
PreviousState bool | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
} | ||||||
|
||||||
func (v *VerifiedRegistryExtractionContext) HasPreviousState() bool { | ||||||
return !(v.CurrTs.Height() == 1 || v.PrevState == v.CurrState) | ||||||
return v.PreviousState | ||||||
} | ||||||
|
||||||
func NewVerifiedRegistryExtractorContext(ctx context.Context, a actorstate.ActorInfo, node actorstate.ActorStateAPI) (*VerifiedRegistryExtractionContext, error) { | ||||||
|
@@ -41,11 +42,12 @@ func NewVerifiedRegistryExtractorContext(ctx context.Context, a actorstate.Actor | |||||
// actor was created in the current state. | ||||||
if err == types.ErrActorNotFound { | ||||||
return &VerifiedRegistryExtractionContext{ | ||||||
PrevState: prevState, | ||||||
CurrState: curState, | ||||||
PrevTs: a.Executed, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PrevState: prevState, | ||||||
CurrState: curState, | ||||||
PrevTs: a.Executed, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PreviousState: false, | ||||||
}, nil | ||||||
} | ||||||
return nil, fmt.Errorf("loading previous verified registry actor at tipset %s epoch %d: %w", a.Executed.Key(), a.Current.Height(), err) | ||||||
|
@@ -57,11 +59,12 @@ func NewVerifiedRegistryExtractorContext(ctx context.Context, a actorstate.Actor | |||||
} | ||||||
} | ||||||
return &VerifiedRegistryExtractionContext{ | ||||||
PrevState: prevState, | ||||||
CurrState: curState, | ||||||
PrevTs: a.Executed, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PrevState: prevState, | ||||||
CurrState: curState, | ||||||
PrevTs: a.Executed, | ||||||
CurrTs: a.Current, | ||||||
Store: node.Store(), | ||||||
PreviousState: true, | ||||||
}, nil | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: A slightly more expressive name: