From 263636b296c326af178be092e4ab1b50bb26f6b2 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 16 Dec 2024 13:00:55 +1100 Subject: [PATCH] fix: make DealStatesEqual work properly (#12783) --- chain/actors/builtin/market/actor.go.template | 25 +++++++++++-------- chain/actors/builtin/market/market.go | 25 +++++++++++-------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/chain/actors/builtin/market/actor.go.template b/chain/actors/builtin/market/actor.go.template index febc93c1f8..9750f1352a 100644 --- a/chain/actors/builtin/market/actor.go.template +++ b/chain/actors/builtin/market/actor.go.template @@ -156,7 +156,19 @@ type DealState interface { } func DealStatesEqual(a, b DealState) bool { - return DealStatesEqual(a, b) + if a.SectorNumber() != b.SectorNumber() { + return false + } + if a.SectorStartEpoch() != b.SectorStartEpoch() { + return false + } + if a.LastUpdatedEpoch() != b.LastUpdatedEpoch() { + return false + } + if a.SlashEpoch() != b.SlashEpoch() { + return false + } + return true } type DealStateChanges struct { @@ -207,16 +219,7 @@ func (e *emptyDealState) SlashEpoch() abi.ChainEpoch { } func (e *emptyDealState) Equals(other DealState) bool { - if e.SectorStartEpoch() != other.SectorStartEpoch() { - return false - } - if e.LastUpdatedEpoch() != other.LastUpdatedEpoch() { - return false - } - if e.SlashEpoch() != other.SlashEpoch() { - return false - } - return true + return DealStatesEqual(e, other) } func EmptyDealState() DealState { diff --git a/chain/actors/builtin/market/market.go b/chain/actors/builtin/market/market.go index 4b603d6588..10e58663c0 100644 --- a/chain/actors/builtin/market/market.go +++ b/chain/actors/builtin/market/market.go @@ -284,7 +284,19 @@ type DealState interface { } func DealStatesEqual(a, b DealState) bool { - return DealStatesEqual(a, b) + if a.SectorNumber() != b.SectorNumber() { + return false + } + if a.SectorStartEpoch() != b.SectorStartEpoch() { + return false + } + if a.LastUpdatedEpoch() != b.LastUpdatedEpoch() { + return false + } + if a.SlashEpoch() != b.SlashEpoch() { + return false + } + return true } type DealStateChanges struct { @@ -334,16 +346,7 @@ func (e *emptyDealState) SlashEpoch() abi.ChainEpoch { } func (e *emptyDealState) Equals(other DealState) bool { - if e.SectorStartEpoch() != other.SectorStartEpoch() { - return false - } - if e.LastUpdatedEpoch() != other.LastUpdatedEpoch() { - return false - } - if e.SlashEpoch() != other.SlashEpoch() { - return false - } - return true + return DealStatesEqual(e, other) } func EmptyDealState() DealState {