diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 14581ded9..99ac2f109 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -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 diff --git a/chain/store/weight.go b/chain/store/weight.go index ac51aeb45..ab663f700 100644 --- a/chain/store/weight.go +++ b/chain/store/weight.go @@ -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() { @@ -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() { diff --git a/chain/types/bigint_test.go b/chain/types/bigint_test.go index ea98f672d..d337bfc85 100644 --- a/chain/types/bigint_test.go +++ b/chain/types/bigint_test.go @@ -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)), " ", "")