Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Modify randomness logic for PublishStorageDeals (#1439)
Browse files Browse the repository at this point in the history
* Modify randomness logic for PublishStorageDeals

Co-authored-by: ZenGround0 <ZenGround0@users.noreply.github.com>
  • Loading branch information
arajasek and ZenGround0 authored May 28, 2021
1 parent 89955f0 commit 566ad95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions actors/builtin/market/market_actor.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func (a Actor) PublishStorageDeals(rt Runtime, params *PublishStorageDealsParams

// We should randomize the first epoch for when the deal will be processed so an attacker isn't able to
// schedule too many deals for the same tick.
processEpoch, err := genRandNextEpoch(rt.CurrEpoch(), &deal.Proposal, rt.GetRandomnessFromBeacon)
processEpoch, err := genRandNextEpoch(rt.CurrEpoch(), &deal.Proposal, rt.GetRandomnessFromTickets)
builtin.RequireNoErr(rt, err, exitcode.ErrIllegalState, "failed to generate random process epoch")

err = msm.dealsByEpoch.Put(processEpoch, id)
Expand Down Expand Up @@ -642,7 +642,7 @@ func genRandNextEpoch(currEpoch abi.ChainEpoch, deal *DealProposal, rbF func(cry
return epochUndefined, xerrors.Errorf("failed to marshal proposal: %w", err)
}

rb := rbF(crypto.DomainSeparationTag_MarketDealCronSeed, currEpoch-1, buf.Bytes())
rb := rbF(crypto.DomainSeparationTag_MarketDealCronSeed, currEpoch, buf.Bytes())

// generate a random epoch in [baseEpoch, baseEpoch + DealUpdatesInterval)
offset := binary.BigEndian.Uint64(rb)
Expand Down
2 changes: 1 addition & 1 deletion actors/builtin/market/market_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2898,7 +2898,7 @@ func (h *marketActorTestHarness) expectGetRandom(rt *mock.Runtime, deal *market.
diff := uint64(requiredProcessEpoch - deal.StartEpoch)
require.NoError(h.t, deal.MarshalCBOR(&dealBuf))
require.NoError(h.t, binary.Write(&epochBuf, binary.BigEndian, diff))
rt.ExpectGetRandomnessBeacon(crypto.DomainSeparationTag_MarketDealCronSeed, rt.Epoch()-1, dealBuf.Bytes(), epochBuf.Bytes())
rt.ExpectGetRandomnessTickets(crypto.DomainSeparationTag_MarketDealCronSeed, rt.Epoch(), dealBuf.Bytes(), epochBuf.Bytes())
}

func (h *marketActorTestHarness) publishDeals(rt *mock.Runtime, minerAddrs *minerAddrs, publishDealReqs ...publishDealReq) []abi.DealID {
Expand Down

0 comments on commit 566ad95

Please sign in to comment.