Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R4R: Consume Gas Proportional to Tx Size #3447

Merged
merged 20 commits into from
Feb 4, 2019
Merged

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Jan 30, 2019

  • Remove memo (per byte) cost
  • Introduce tx size (per byte) cost
  • Update simulation
    • BaseApp#Simulate now takes tx bytes because it needs to be set on the context

closes: #3256


  • Targeted PR against correct branch (see CONTRIBUTING.md)

  • Linked to github-issue with discussion and accepted design OR link to spec that describes this work.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added entries in PENDING.md with issue #

  • rereviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@cwgoes cwgoes mentioned this pull request Jan 30, 2019
4 tasks
@codecov
Copy link

codecov bot commented Jan 31, 2019

Codecov Report

Merging #3447 into develop will decrease coverage by 0.02%.
The diff coverage is 71.42%.

@@             Coverage Diff             @@
##           develop    #3447      +/-   ##
===========================================
- Coverage    52.97%   52.94%   -0.03%     
===========================================
  Files          137      137              
  Lines        10719    10741      +22     
===========================================
+ Hits          5678     5687       +9     
- Misses        4698     4710      +12     
- Partials       343      344       +1

@alexanderbez alexanderbez changed the title WIP: Consume Gas Proportional to Tx Size R4R: Consume Gas Proportional to Tx Size Jan 31, 2019
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions but mostly looks good.

@alexanderbez
Copy link
Contributor Author

address your comments @cwgoes -- lmk if the cost logic makes sense.

@cwgoes
Copy link
Contributor

cwgoes commented Feb 1, 2019

address your comments @cwgoes -- lmk if the cost logic makes sense.

I think that's fine; we should consider the total tx cost but in the broader context of #1008 (comment).

@jackzampolin
Copy link
Member

Hey @mossid can you take a look at this too?

x/auth/ante.go Outdated
// contain a pubkey, so we must account for tx size of including a
// StdSignature (Amino encoding) and simulate gas consumption
// (assuming a SECP256k1 simulation key).
simSig := StdSignature{PubKey: pubKey}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the multisig case, gas estimate would be wrong here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't support multi-sig for estimation afaik -- correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we with a flag or something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cwgoes multisig is tricky nonetheless - signature verification strictly depends on the signature itself, i.e. given a N-of-M multikey and a multisig signature with P sub sigs, all sub signatures get always processed/verified, even when N < P. Knowing the original N-of-M key might help obtaining a more accurate estimate (i.e. you know that you would process at least N signature), though it does not solve the problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just estimating the upper bound by default?

(I agree that the problem is tricky but we should optimize for the average use case and relatively low cost of paying a bit extra gas)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to account for multisigs.

Copy link
Contributor

@alessio alessio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gas estimate in multisig txs is controversial - approving

@jackzampolin
Copy link
Member

Looks like we are still failing some tests here.

@alexanderbez
Copy link
Contributor Author

@cwgoes @alessio @jackzampolin updated to account for multisigs and fixed CI regression.

@jackzampolin jackzampolin merged commit 0822951 into develop Feb 4, 2019
@jackzampolin jackzampolin deleted the bez/3256-gas-tx-size branch February 4, 2019 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Charge gas proportional to transaction size
4 participants