w3f / PSPs

Polkadot Smart Contract Proposals
Creative Commons Zero v1.0 Universal
158 stars 68 forks source link

[WIP] Base weights for Host implementations #49

Closed lamafab closed 2 years ago

lamafab commented 2 years ago

This is based on https://github.com/paritytech/substrate/pull/10918

This draft still needs more work, explanations and numbers, especially regarding bandwidths. On polkadot's side there's a branch regarding this that hasn't been worked on in months. I'll leave this open for now and will continue on this once the implementation respectively the design decision is clearer.

Preview: https://github.com/w3f/PSPs/blob/weights/PSPs/drafts/psp-49.md

xlc commented 2 years ago

what’s the purpose of this? this looks like a documentation rather standard proposal. why placing all the actual numbers here that are subject to change? and it is all about weight v1 instead v2

lamafab commented 2 years ago

I think the motivation section makes the purpose of this quite clear?

The Substrate implementation determined weights based on the resources that it provides to the Runtime for consumption, such as I/O, computation and network bandwidth. Given that alternative implementations are available and can be developed in the future, those weights should be reflected by those alternative implemenations so that the fee structure is justifiable for the diverse network of participants at large. The goal is to avoid situations where alternative implemenations are too strict or too loose in terms of costs of their resource requirements which could lead to bad economic outcomes and a fractured network of implemenations.

Basically, Hosts that execute the Runtime should roughly know what the expected overhead of the database, etc, is. I'm aware those numbers are subject to change, but they don't get updated often and will most likely even become more conservative as time goes on. Also, as mentioned above, bandwidth weights are still missing and the inner details of the the weight structures/systems are not relevant here given that the Runtime handles that stuff (and Substrate devs), not the Host.

Also, this was first written for our spec, I proposed to make it a PSP. But maybe it should actually be in the spec instead.

xlc commented 2 years ago

The whole reason we automatically benchmark the weights is that we can adjust them easily to reflect new optimizations / recommended hardwares. We do want to make sure the weights are always up to dated. I can see it is useful to have those number documented but yeah it should be part of the polkadot host implementation spec, not really a standard. We still don't really have a good idea on what should be included to PSP and sounds like we need to figure it out. In this particular case, I don't think it is suitable here.