Polimec / polimec-node

Decentralized community-driven funding protocol for Web3
https://www.polimec.org/
GNU General Public License v3.0
14 stars 6 forks source link

🔧 Add Funding and Dispenser weights #297

Closed lrazovic closed 6 months ago

lrazovic commented 6 months ago

What?

Add Funding and Dispenser weights

Todo

JuaniRios commented 6 months ago
~/Documents/Projects/polimec-node git:[leo/more-weights]
subweight --verbose compare files --old ~/Desktop/weights.rs --new pallets/funding/src/weights.rs --method guess-worst --unit time
+------------+--------------------------------------------------------+----------+----------+----------------+
| File       | Extrinsic                                              | Old      | New      | Change [%]     |
+============================================================================================================+
| weights.rs | settle_successful_evaluation                           | 0ps      | 736.99us |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | settle_successful_contribution                         | 0ps      | 1.30ms   |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | settle_successful_bid                                  | 0ps      | 1.28ms   |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | settle_failed_evaluation                               | 0ps      | 481.87us |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | settle_failed_contribution                             | 0ps      | 740.78us |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | settle_failed_bid                                      | 0ps      | 740.77us |  +inf   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | start_community_funding                                | 144.28ms | 269.51ms | +86.80  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | start_evaluation                                       | 323.78us | 461.38us | +42.50  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | contribution                                           | 1.10ms   | 1.56ms   | +41.64  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_funding_awaiting_decision_evaluators_unchanged     | 320.99us | 426.56us | +32.89  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_funding_awaiting_decision_evaluators_slashed       | 321.39us | 426.99us | +32.86  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_funding_automatically_rejected_evaluators_slashed  | 326.04us | 428.59us | +31.45  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | bid                                                    | 1.11ms   | 1.42ms   | +28.32  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | evaluation                                             | 723.94us | 881.81us | +21.81  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_funding_automatically_accepted_evaluators_rewarded | 614.57us | 705.70us | +14.83  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_evaluation_success                                 | 3.09ms   | 2.92ms   | -5.72   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | project_decision                                       | 294.00us | 269.31us | -8.40   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | end_evaluation_failure                                 | 285.00us | 237.02us | -16.84  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | decide_project_outcome                                 | 512.33us | 345.42us | -32.58  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | start_auction_manually                                 | 11.26ms  | 3.09ms   | -72.57  |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | edit_metadata                                          | 194.00us |          | Removed |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | create                                                 | 769.00us |          | Removed |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | remove_project                                         |          | 579.14us | Added   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | edit_project                                           |          | 482.43us | Added   |
|------------+--------------------------------------------------------+----------+----------+----------------|
| weights.rs | create_project                                         |          | 863.11us | Added   |
+------------+--------------------------------------------------------+----------+----------+----------------+
JuaniRios commented 6 months ago
~/Documents/Projects/polimec-node git:[leo/more-weights]
subweight --verbose compare files --old ~/Desktop/weights.rs --new pallets/funding/src/weights.rs --method guess-worst --unit proof 
+------------+--------------------------------+-----------+-----------+----------------+
| File       | Extrinsic                      | Old       | New       | Change [%]     |
+======================================================================================+
| weights.rs | settle_successful_evaluation   | 0B        | 6.32KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | settle_successful_contribution | 0B        | 6.32KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | settle_successful_bid          | 0B        | 6.32KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | settle_failed_evaluation       | 0B        | 4.51KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | settle_failed_contribution     | 0B        | 6.06KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | settle_failed_bid              | 0B        | 6.06KiB   |  +inf   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | project_decision               | 5.85KiB   | 3.75KiB   | -35.85  |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | decide_project_outcome         | 409.34KiB | 245.55KiB | -40.01  |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | end_evaluation_failure         | 11.98KiB  | 3.75KiB   | -68.66  |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | start_auction_manually         | 990.30KiB | 245.55KiB | -75.20  |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | edit_metadata                  | 3.72KiB   |           | Removed |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | create                         | 3.51KiB   |           | Removed |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | remove_project                 |           | 3.75KiB   | Added   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | edit_project                   |           | 3.75KiB   | Added   |
|------------+--------------------------------+-----------+-----------+----------------|
| weights.rs | create_project                 |           | 3.51KiB   | Added   |
+------------+--------------------------------+-----------+-----------+----------------+
JuaniRios commented 6 months ago

Our biggest benchmark is the WAP calculation. Running it with the max values of x=99, y=512, z=512:

[runtimes/polimec/src/lib.rs:304] weights::pallet_funding::WeightInfo::<Runtime>::start_community_funding(99,
    512, 512) = Weight {
    ref_time: 425075813897,
    proof_size: 3531038,
}

This are the operational block weights defined in the Polimec runtime:

    operational: {
      baseExtrinsic: {
        refTime: 125,000,000
        proofSize: 0
      }
      maxExtrinsic: {
        refTime: 474,875,000,000
        proofSize: 4,980,736
      }
      maxTotal: {
        refTime: 500,000,000,000
        proofSize: 5,242,880
      }
      reserved: {
        refTime: 125,000,000,000
        proofSize: 1,310,720
      }
    }

We are dangerously close...