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

[vm] check gas when execute readonly function #3627

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

jolestar
Copy link
Member

@jolestar jolestar commented Aug 8, 2022

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Execute readonly function do not check gas

What is the new behavior?

Check gas when calling a readonly function, and avoid malicious use of call readonly function.

@jolestar jolestar requested a review from nkysg August 8, 2022 16:52
@jolestar jolestar requested a review from nanne007 as a code owner August 8, 2022 16:52
@codecov
Copy link

codecov bot commented Aug 8, 2022

Codecov Report

Merging #3627 (3614266) into master (f3c9687) will increase coverage by 0.10%.
The diff coverage is 35.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3627      +/-   ##
==========================================
+ Coverage   28.73%   28.83%   +0.10%     
==========================================
  Files         591      591              
  Lines       50413    50428      +15     
  Branches    23757    23766       +9     
==========================================
+ Hits        14482    14535      +53     
- Misses      21743    21898     +155     
+ Partials    14188    13995     -193     
Flag Coverage Δ
unittests 28.83% <35.30%> (+0.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
vm/vm-runtime/src/starcoin_vm.rs 35.10% <35.30%> (+0.47%) ⬆️
rpc/server/src/module/mod.rs 0.00% <0.00%> (-16.66%) ⬇️
state/state-tree/src/mock/mod.rs 39.14% <0.00%> (-8.69%) ⬇️
...ccount_config/resources/module_upgrade_strategy.rs 25.72% <0.00%> (-8.57%) ⬇️
vm/types/src/transaction/error.rs 3.58% <0.00%> (-7.14%) ⬇️
vm/natives/src/account.rs 18.75% <0.00%> (-6.25%) ⬇️
types/src/system_events.rs 65.22% <0.00%> (-4.34%) ⬇️
chain/api/src/errors.rs 25.00% <0.00%> (-3.57%) ⬇️
vm/types/src/token/token_value.rs 55.56% <0.00%> (-2.77%) ⬇️
cmd/starcoin/src/dev/tests.rs 11.56% <0.00%> (-2.64%) ⬇️
... and 77 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f3c9687...3614266. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Aug 8, 2022

Benchmark for 2858c55

Click to view benchmark
Test Base PR %
accumulator_append 608.7±34.04µs 607.9±27.51µs -0.13%
block_apply/block_apply_10 637.8±7.52ms 636.0±1.03ms -0.28%
block_apply/block_apply_1000 64.7±0.05s 64.8±0.06s +0.15%
get_with_proof/db_store 37.2±0.36µs 36.7±0.23µs -1.34%
get_with_proof/mem_store 31.8±0.23µs 31.5±0.17µs -0.94%
put_and_commit/db_store/1 96.9±4.80µs 97.3±6.21µs +0.41%
put_and_commit/db_store/10 867.4±44.46µs 863.7±51.66µs -0.43%
put_and_commit/db_store/100 7.4±0.30ms 7.3±0.29ms -1.35%
put_and_commit/db_store/5 442.6±22.06µs 444.2±22.33µs +0.36%
put_and_commit/db_store/50 3.8±0.16ms 3.8±0.17ms 0.00%
put_and_commit/mem_store/1 61.8±5.72µs 61.6±5.74µs -0.32%
put_and_commit/mem_store/10 581.0±47.48µs 577.9±47.36µs -0.53%
put_and_commit/mem_store/100 5.7±0.84ms 5.7±0.36ms 0.00%
put_and_commit/mem_store/5 293.6±24.67µs 291.2±25.09µs -0.82%
put_and_commit/mem_store/50 2.9±0.19ms 2.8±0.18ms -3.45%
query_block/query_block_in(10)_times(100) 5.5±0.12ms 5.4±0.15ms -1.82%
query_block/query_block_in(10)_times(1000) 53.7±1.91ms 54.5±1.40ms +1.49%
query_block/query_block_in(10)_times(10000) 534.7±15.30ms 535.8±14.24ms +0.21%
query_block/query_block_in(1000)_times(100) 999.2±13.47µs 991.4±7.30µs -0.78%
query_block/query_block_in(1000)_times(1000) 10.0±0.10ms 9.9±0.16ms -1.00%
query_block/query_block_in(1000)_times(10000) 102.3±3.28ms 98.7±0.92ms -3.52%
storage_transaction 1102.5±274.15µs 1137.2±352.76µs +3.15%
vm/transaction_execution/1 711.1±2.26ms 711.8±1.03ms +0.10%
vm/transaction_execution/10 177.1±0.43ms 177.7±1.15ms +0.34%
vm/transaction_execution/20 152.7±0.30ms 153.1±0.41ms +0.26%
vm/transaction_execution/5 234.3±1.16ms 234.4±0.66ms +0.04%
vm/transaction_execution/50 167.8±1.10ms 167.7±0.51ms -0.06%

@nanne007 nanne007 merged commit 38e141e into master Aug 9, 2022
@nanne007 nanne007 deleted the fix_readonly_function_gas branch August 9, 2022 01:50
jolestar added a commit that referenced this pull request Aug 9, 2022
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.

2 participants