This repository has been archived by the owner on Oct 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
ECIP-1042: GASPAY #89
Open
splix
wants to merge
1
commit into
master
Choose a base branch
from
splix/gaspay
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
ECIP: 1042 | ||
Title: GASPAY opcode | ||
Author: Igor Artamonov <[email protected]> | ||
Status: Draft | ||
Type: Standard | ||
Created: 2018-03-08 | ||
|
||
# ECIP-1042 - GASPAY opcode | ||
|
||
# Abstract | ||
Add an operation to consume gas and add amount paid for that gas to token balance. | ||
|
||
# Motivation | ||
A useful Smart Contract (i.e. valuable) should expect small reward for its execution. A micropayment could be very | ||
small a sub-cent payment but sending an additional value to a contract will make it more complicated and cost of such | ||
transfer or contract execution could exceed requested reward. | ||
|
||
It’s proposed here to introduce a new EVM Operation that will allow a developer to consume a portion of transaction fee | ||
(amount paid for a gas) and transfer it to current Smart Contract. | ||
|
||
Using a gas payment provided with transaction provides flexibility and independence from market price of Ether. Gas Price | ||
is dynamic value and supposed to represent fair market price of contract execution, therefore making micropayment value | ||
proportional to const of transaction and more stable in long term. | ||
|
||
# Specification | ||
Provide a new operation `GASPAY a` where `a` is amount of gas to consume, and `0x0 <= a <= 0x0fffff`. The payment for | ||
that gas goes to contract address. As a return it puts consumed value (Wei) into the stack. | ||
|
||
The cost of the operation itself is equal to 1/4 of requested amount of Gas plus 5000 (`a/4 + 5000`). The payment for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this extra "gas" to contract paid a) at the end of the contract execution (like how miner gas works), or b) paid immediately at the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean should it be paid if transaction has failed? no, only if succeeded. but "payment" should be registered at the moment of opcode |
||
that gas is going to miner address, and supposed to compensate potential miner loss from including in a block | ||
transaction that doesn’t give all gas fee as a reward to a miner. | ||
|
||
``` | ||
Op code value: 0x3d | ||
Mnemonic: GASPAY | ||
δ: 1 | ||
α: 1 | ||
``` | ||
|
||
With the current average price of 23000 MWei per Gas, a smart contract can earn up to $1 per operation, by | ||
requesting payment for 1,048,575 of Gas. | ||
|
||
# Risks consideration | ||
|
||
## Miners don’t receive payment for all gas in a block | ||
Currently miners expect that all payment for the gas goes to coinbase. After introducing this operation part of this | ||
payment could go to smart contracts participated in block transactions. This plays a role only when we have blocks fully | ||
packed with transaction, up to the block gas limit, which is a dynamic value and can be controlled by miners. | ||
|
||
Because cost of the execution of that operation is a constant and roughly is about 5000 of Gas, then requested cost of | ||
execution as `a/4 + 5000` will be as much as profitable as including other transactions with same gas limit. With that | ||
cost it’s expected that a miner could earn 10%-20% of a requested amount, in addition to cost of actual work spent on | ||
execution of that transaction. If gas prices per opcodes are fair, then a miner could be in favour of adding a | ||
transaction with GASPAY opcode as it provides slightly more profit to a miner too. | ||
|
||
## Software must distinguish payment went to contract and to miner | ||
Most of the current 3rd party software expect that whole payment for a gas will go to a miner of the block. It includes | ||
dev tools, block explorers and nodes (protocol implementations). | ||
|
||
After introducing this new opcode, all this software must be updated according to a new way of gas payment calculation. | ||
|
||
## Smart Contract language compilers | ||
Solidity and other smart contract language compilers will need to be updated to support additional opcode |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we be more specific on this.
DELEGATECALL
happened, does the payment goes to the parent contract (which has the address field set in context), or the delegated contract?CREATE
or a contract creation transaction?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.