1

While testing in Jungle and adding signatures to a transaction with the flag -p, I see that if I add two signatures to a transaction I can see that both accounts used CPU for that transaction. Why? Also, the CPU cost is not split among accounts, both of them pay more or less the same amount, i.e., even the amount is not the same. Why?

In summary, my questions are:

  1. Why both accounts pay CPU after adding signatures with -p flag?
  2. Why the CPU cost is not split?
  3. Why the CPU cost is not exactly the same for both accounts?

To see this in action, you can use the following script:

export account1=username1
export account2=username2
alias cleos="cleos -u http://jungle2.cryptolions.io:80"


cleos get account $account1 # See the CPU used before the Tx
cleos get account $account2 # See the CPU used before the Tx

# The following Tx debts CPU from account1 only
cleos transfer $account1 $account2 "0.0001 EOS"  -p $account1

cleos get account $account1 # See the CPU used after the Tx (Changed)
cleos get account $account2 # See the CPU used after the Tx (No Change)

# The following Tx debts CPU from both accounts.
cleos transfer $account1 $account2 "0.0001 EOS"  -p $account1 -p $account2

cleos get account $account1 # See the CPU used after the Tx (Changed)
cleos get account $account2 # See the CPU used after the Tx (Changed)


# uncomment the next line to see both signatures in the not-broadcasted Tx:
# cleos transfer $account1 $account2 "0.0001 EOS"  -p $account1 -p $account2 -d 
0

After doing some digging all I could find is an issue in Github entitled "Consensus upgrade to only bill CPU and network bandwidth to first authorizer of a transaction" saying the following:

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

Showing that the devs are aware of the issue, and it might have been designed that way as a paragraph later in the same issue explains:

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() ).

Link: https://github.com/EOSIO/eos/issues/6332

Regarding the questions 1) and 2) above, all the accounts are billed because of the nested loop as explained by the issue. For question 3, I guess the difference in CPU billing is due to the machine running the code twice, and having different run times on each.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.