@@ -50,3 +50,33 @@ func TestQualityForWeight(t *testing.T) {
5050 }
5151 }
5252}
53+
54+ // matches builtin-actors/actors/miner/tests/policy_test.rs
55+ func TestDailyProofFeeCalc (t * testing.T ) {
56+ // Given a CS of 680M FIL, 32GiB QAP, a fee multiplier of 7.4e-15 per 32GiB QAP, the daily proof
57+ // fee should be 5032 nanoFIL.
58+ // 680M * 7.4e-15 = 0.000005032 FIL
59+ // 0.000005032 * 1e9 = 5032 nanoFIL
60+ // 0.000005032 * 1e18 = 5032000000000 attoFIL
61+ // As a per-byte multiplier we use 2.1536e-25, a close approximation of 7.4e-15 / 32GiB.
62+ // 680M * 32GiB * 2.1536e-25 = 0.000005031805013354 FIL
63+ // 0.000005031805013354 * 1e18 = 5031805013354 attoFIL
64+ circulatingSupply := big .Mul (big .NewInt (680_000_000 ), builtin .TokenPrecision )
65+ ref32GibFee := big .NewInt (5031805013354 )
66+
67+ for _ , tc := range []struct {
68+ size uint64
69+ expected big.Int
70+ }{
71+ {32 , ref32GibFee },
72+ {64 , big .Mul (ref32GibFee , big .NewInt (2 ))},
73+ {32 * 10 , big .Mul (ref32GibFee , big .NewInt (10 ))},
74+ {32 * 5 , big .Mul (ref32GibFee , big .NewInt (5 ))},
75+ {64 * 10 , big .Mul (ref32GibFee , big .NewInt (20 ))},
76+ } {
77+ power := big .NewInt (int64 (tc .size << 30 )) // 32GiB raw QAP
78+ fee := miner .DailyProofFee (circulatingSupply , power )
79+ delta := big .Sub (fee , tc .expected ).Abs ()
80+ require .LessOrEqual (t , delta .Uint64 (), uint64 (2 ), "fee: %s, expected: %s" , fee , tc .expected )
81+ }
82+ }
0 commit comments