Description
The current pricing scheme for opcodes is not in a good state as is shown by the attacks and the hard fork, there needs to be something more decentralized and faster reacting to both attacks and hardware / software improvements.
Having a hard fork each time these opcodes require changing is not sustainable and will require setting the opcodes higher than they should and likely will mean they never get reduced even with speed improvements.
The solution I have allows miners (who create blocks) decide what these opcodes should ultimately cost, allowing both quick action to both opcode price increase or decrease and allowing it to be decentralized.
Proposal A
- Target a block in the future
- The price the opcode the miner wants to be (within the range*)
- Taking the average price of what the miners set their price over 64 blocks
- The range is limited to 2x increase of decrease of current price, minimum limit is the default cost of opcode, if default cost was 0 and it increases, it may never return to 0.
Proposal B
- Target a block in the future
- Factor in the time it took to process the transactions into the block
- Weigh in the amount of times each opcode was used and the time it took to process the block
- Every 16 blocks adjust the pricing so it matches the amount of time it took for each opcode
Proposal C
- Target a block in the future
- Record the amount of times an opcode is used over 32 blocks
- If a certain opcode is used very often and processing is taking longer than expected increase the gas cost of that opcode
- If the opcode stops being used frequently and processing remains higher reduce price of opcode and increase price of another highly used opcode
- If the opcode continues to be used but the processing lowers reduces dramatically the opcode price back in between new and old value.
Proposal A is more simple and ultimately gives the decision to the miners to set it to whatever they wish similar to block limit. It is slower than the other two methods and requires miners to change their pricing to react to attacks / badly priced opcodes.
There is a WIP of this proposal which shows an incomplete implementation of how it would look like in go-ethereum: BlameByte/go-ethereum@c15b516
Proposal B takes the approach of automatically timing each opcode but to keep consensus (faster or slower machines) we rely on the speed of the miner, but this is across the past 16 blocks so it will not be any one miner. It is also the fastest reacting to an attack.
Proposal C is likely the most complicated and is also automatic. It is primarily to protect against attacks as if there are opcodes that are being used frequently to slow down the network it will increase the costs associated to them. It will also recover the prices of opcodes after they are used less frequently.