eos icon indicating copy to clipboard operation
eos copied to clipboard

Consensus upgrade to only bill CPU and network bandwidth to first authorizer of a transaction

Open arhag opened this issue 8 years ago • 8 comments

Background

Currently, the set of all unique authorizing accounts of a transaction are each billed for the total CPU and network bandwidth consumed by the transaction. From the perspective of protecting the network from abuse, the CPU and network bandwidth only needs to be billed once to some account.

By only billing one of the authorizing accounts of the transaction, less CPU and network bandwidth is expended for transactions with multiple authorizers. Furthermore, by allowing the transaction creator and signers choice over which of the authorizing accounts are billed, it becomes possible for a service to elect to pay for the costs of a transaction on a per-transaction basis in exchange for some form of compensation.

Consensus upgrade feature

The goal of this consensus upgrade feature is to only bill the first authorizing account of a transaction for the CPU and network bandwidth costs of the transaction. This enables transaction creators to craft the transaction (including, if necessary, adding a no-op action to the beginning of the transaction authorized by the account to be billed) to bill the desired account.

A new consensus protocol upgrade feature will be added to trigger the changes described in this consensus upgrade proposal. The actual digest for the feature understood at the blockchain level is to be determined. For the purposes of this proposal the codename ONLY_BILL_FIRST_AUTHORIZER will be use to stand-in for whatever the feature identifier will actually end up being.

In transaction_context::init, prior to ONLY_BILL_FIRST_AUTHORIZER activation, the current nested for loop logic that inserts into transaction_context::bill_to_accounts should be maintained. However, after ONLY_BILL_FIRST_AUTHORIZER activation, that logic should instead be replaced simply with bill_to_accounts.insert( trx.first_authorizor() ).

Note: push_transaction and/or push_scheduled_transaction may be using transaction_context::bill_to_accounts for the purposes of checking the subjective actor whitelist/blacklist under the assumption that bill_to_accounts is the set of unique accounts authorizing the transaction. To avoid breaking the actor whitelist/blacklist checks with the changes to bill_to_accounts described above, a separate (properly named) field for the set of unique accounts authorizing the transaction should be used for actor whitelist/blacklist enforcement.

arhag avatar Nov 16 '18 20:11 arhag

I think this feature is very useful, when DApp provider allows users to make some transactions (related to DApp directly) using provider's CPU and NET bandwidth.

conr2d avatar Nov 18 '18 04:11 conr2d

an awesome feature. waiting for your implementations. and I am wondering when will this feature will be implemented?

shuke0327 avatar Dec 03 '18 04:12 shuke0327

This issue depends on #6429. It will also be setup by default to be a protocol feature requiring pre-activation, thus it also depends on #6431.

arhag avatar Dec 07 '18 16:12 arhag

Resolved by #7089.

arhag avatar Apr 10 '19 14:04 arhag

Is ONLY_BILL_FIRST_AUTHORIZER also possible with an normal account (non smart-contract) in first position?

timelockdapp avatar Nov 10 '19 13:11 timelockdapp

@timelockdapp Yes. The first signer will pay the resources no matter if it has a smart contract or not.

maoueh avatar Nov 11 '19 18:11 maoueh

any instructions on how to implement this with eosiojs 20?

nelsonenzo avatar Nov 12 '19 07:11 nelsonenzo

@nelsonenzo Please see https://github.com/EOSIO/eosjs/issues/620#issuecomment-589811766 for more information, including a PoC for how this can be implemented/used.

jlamarr22 avatar Feb 21 '20 20:02 jlamarr22