Skip to content

Commit

Permalink
Address @magik6k CR
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Sztandera <[email protected]>
  • Loading branch information
Jakub Sztandera committed Jun 24, 2020
1 parent 36d5880 commit 88352c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions chain/gen/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ func IsRoundWinner(ctx context.Context, ts *types.TipSet, round abi.ChainEpoch,
return nil, xerrors.Errorf("failed to compute VRF: %w", err)
}

// TODO: wire in real power
// TODO: is above TODO still applicable?
ep := &types.ElectionProof{VRFProof: vrfout}
j := ep.ComputeWinCount(mbi.MinerPower, mbi.NetworkPower)
ep.WinCount = j
Expand Down
6 changes: 3 additions & 3 deletions chain/store/weight.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
if ts == nil {
return types.NewInt(0), nil
}
// >>> w[r] <<< + wFunction(totalPowerAtTipset(ts)) * 2^8 + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks.ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
// >>> w[r] <<< + wFunction(totalPowerAtTipset(ts)) * 2^8 + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)

var out = new(big.Int).Set(ts.Blocks()[0].ParentWeight.Int)

// >>> wFunction(totalPowerAtTipset(ts)) * 2^8 <<< + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks.ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
// >>> wFunction(totalPowerAtTipset(ts)) * 2^8 <<< + (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)

tpow := big2.Zero()
{
Expand Down Expand Up @@ -57,7 +57,7 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn

out.Add(out, big.NewInt(log2P<<8))

// (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks.ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)
// (wFunction(totalPowerAtTipset(ts)) * sum(ts.blocks[].ElectionProof.WinCount) * wRatio_num * 2^8) / (e * wRatio_den)

totalJ := uint64(0)
for _, b := range ts.Blocks() {
Expand Down
2 changes: 1 addition & 1 deletion chain/types/bigint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestSizeStrUnitsSymmetry(t *testing.T) {
s := rand.NewSource(time.Now().UnixNano())
r := rand.New(s)

for i := 0; i < 1000; i++ {
for i := 0; i < 10000; i++ {
n := r.Uint64()
l := strings.ReplaceAll(units.BytesSize(float64(n)), " ", "")
r := strings.ReplaceAll(SizeStr(NewInt(n)), " ", "")
Expand Down

0 comments on commit 88352c7

Please sign in to comment.