diff --git a/chain/actors/builtin/market/diff.go b/chain/actors/builtin/market/diff.go index d0b4a2fd3f6..ed581b5b4ef 100644 --- a/chain/actors/builtin/market/diff.go +++ b/chain/actors/builtin/market/diff.go @@ -9,7 +9,21 @@ import ( ) func DiffDealProposals(pre, cur DealProposals) (*DealProposalChanges, error) { + preRoot, err := pre.array().Root() + if err != nil { + return nil, err + } + curRoot, err := cur.array().Root() + if err != nil { + return nil, err + } + results := new(DealProposalChanges) + // no change. + if curRoot.Equals(preRoot) { + return results, nil + } + if err := adt.DiffAdtArray(pre.array(), cur.array(), &marketProposalsDiffer{results, pre, cur}); err != nil { return nil, fmt.Errorf("diffing deal states: %w", err) } @@ -45,7 +59,21 @@ func (d *marketProposalsDiffer) Remove(key uint64, val *cbg.Deferred) error { } func DiffDealStates(pre, cur DealStates) (*DealStateChanges, error) { + preRoot, err := pre.array().Root() + if err != nil { + return nil, err + } + curRoot, err := cur.array().Root() + if err != nil { + return nil, err + } + results := new(DealStateChanges) + // no change. + if curRoot.Equals(preRoot) { + return results, nil + } + if err := adt.DiffAdtArray(pre.array(), cur.array(), &marketStatesDiffer{results, pre, cur}); err != nil { return nil, fmt.Errorf("diffing deal states: %w", err) } diff --git a/chain/actors/builtin/miner/diff.go b/chain/actors/builtin/miner/diff.go index dde4db89002..7b08d5520ee 100644 --- a/chain/actors/builtin/miner/diff.go +++ b/chain/actors/builtin/miner/diff.go @@ -7,8 +7,6 @@ import ( ) func DiffPreCommits(pre, cur State) (*PreCommitChanges, error) { - results := new(PreCommitChanges) - prep, err := pre.precommits() if err != nil { return nil, err @@ -19,6 +17,22 @@ func DiffPreCommits(pre, cur State) (*PreCommitChanges, error) { return nil, err } + preRoot, err := prep.Root() + if err != nil { + return nil, err + } + + curRoot, err := curp.Root() + if err != nil { + return nil, err + } + + results := new(PreCommitChanges) + // no change. + if curRoot.Equals(preRoot) { + return results, nil + } + err = adt.DiffAdtMap(prep, curp, &preCommitDiffer{results, pre, cur}) if err != nil { return nil, err @@ -63,8 +77,6 @@ func (m *preCommitDiffer) Remove(key string, val *cbg.Deferred) error { } func DiffSectors(pre, cur State) (*SectorChanges, error) { - results := new(SectorChanges) - pres, err := pre.sectors() if err != nil { return nil, err @@ -75,6 +87,22 @@ func DiffSectors(pre, cur State) (*SectorChanges, error) { return nil, err } + preRoot, err := pres.Root() + if err != nil { + return nil, err + } + + curRoot, err := curs.Root() + if err != nil { + return nil, err + } + + results := new(SectorChanges) + // no change. + if curRoot.Equals(preRoot) { + return results, nil + } + err = adt.DiffAdtArray(pres, curs, §orDiffer{results, pre, cur}) if err != nil { return nil, err diff --git a/chain/actors/builtin/power/diff.go b/chain/actors/builtin/power/diff.go index 3daa7056956..2d99304e435 100644 --- a/chain/actors/builtin/power/diff.go +++ b/chain/actors/builtin/power/diff.go @@ -26,7 +26,6 @@ type ClaimInfo struct { } func DiffClaims(pre, cur State) (*ClaimChanges, error) { - results := new(ClaimChanges) prec, err := pre.claims() if err != nil { @@ -38,6 +37,21 @@ func DiffClaims(pre, cur State) (*ClaimChanges, error) { return nil, err } + preRoot, err := prec.Root() + if err != nil { + return nil, err + } + curRoot, err := curc.Root() + if err != nil { + return nil, err + } + + results := new(ClaimChanges) + // no change. + if preRoot.Equals(curRoot) { + return results, nil + } + if err := adt.DiffAdtMap(prec, curc, &claimDiffer{results, pre, cur}); err != nil { return nil, err }