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

[sip5] Implement Treasury #2465

Merged
merged 15 commits into from
May 7, 2021
Merged

[sip5] Implement Treasury #2465

merged 15 commits into from
May 7, 2021

Conversation

jolestar
Copy link
Member

@jolestar jolestar commented Apr 29, 2021

实现了 Treasury 的主要逻辑

  1. STC 一次性 mint 到 Treasury。
  2. 废弃了 LinearTimeMintKey 机制,替换为 LinearTimeWithdrawCapability。
  3. Dao 增加了 TreasuryWithdrawDaoProposal。
  4. 废弃了 Collection 的写方法。
  5. 增加了一些测试用例。

@jolestar jolestar requested review from nanne007 and guangyuz April 29, 2021 08:49
@codecov
Copy link

codecov bot commented Apr 29, 2021

Codecov Report

Merging #2465 (773fe50) into master (e63009a) will increase coverage by 0.03%.
The diff coverage is 12.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2465      +/-   ##
==========================================
+ Coverage   33.23%   33.26%   +0.03%     
==========================================
  Files         493      496       +3     
  Lines       43143    42995     -148     
  Branches    19635    19452     -183     
==========================================
- Hits        14335    14298      -37     
- Misses      13870    14015     +145     
+ Partials    14938    14682     -256     
Flag Coverage Δ
unittests 33.26% <12.25%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
config/src/lib.rs 27.06% <ø> (ø)
executor/src/stdlib_test/on_chain_config_test.rs 18.75% <0.00%> (-2.02%) ⬇️
executor/src/stdlib_test/sip_flag_test.rs 17.31% <0.00%> (-3.06%) ⬇️
genesis/src/lib.rs 24.04% <ø> (ø)
sync/src/tasks/inner_sync_task.rs 40.26% <0.00%> (-2.40%) ⬇️
vm/stdlib/src/compat.rs 0.00% <0.00%> (ø)
vm/types/src/move_resource.rs 84.22% <ø> (ø)
vm/types/src/on_chain_resource/dao/actions.rs 0.00% <0.00%> (ø)
vm/types/src/on_chain_resource/dao/mod.rs 0.00% <0.00%> (ø)
vm/types/src/on_chain_resource/treasury.rs 0.00% <0.00%> (ø)
... and 58 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 7a3a9c5...773fe50. Read the comment docs.

@github-actions
Copy link

Benchmark for 8467547

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.7±0.26ms 2.6±0.14ms +3.85%
block_apply/block_apply_10 491.0±9.89ms 477.8±11.89ms +2.76%
block_apply/block_apply_1000 50.1±0.49s 48.3±0.72s +3.73%
get_with_proof/db_store 38.4±0.34µs 38.2±0.35µs +0.52%
get_with_proof/mem_store 31.8±0.26µs 31.6±0.27µs +0.63%
put_and_commit/db_store/1 1631.5±80.80µs 1634.3±103.67µs -0.17%
put_and_commit/db_store/10 2.8±0.59ms 2.9±0.55ms -3.45%
put_and_commit/db_store/100 9.8±1.44ms 9.8±1.22ms 0.00%
put_and_commit/db_store/5 2.2±0.21ms 2.2±0.22ms 0.00%
put_and_commit/db_store/50 5.9±0.98ms 6.0±0.96ms -1.67%
put_and_commit/mem_store/1 63.4±5.63µs 63.4±5.59µs 0.00%
put_and_commit/mem_store/10 590.0±46.30µs 584.5±46.41µs +0.94%
put_and_commit/mem_store/100 5.8±0.81ms 5.7±0.81ms +1.75%
put_and_commit/mem_store/5 297.0±24.15µs 296.1±23.97µs +0.30%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.18ms 0.00%
query_block/query_block_in(10)_times(100) 2.9±0.04ms 2.8±0.02ms +3.57%
query_block/query_block_in(10)_times(1000) 29.2±0.53ms 27.1±0.41ms +7.75%
query_block/query_block_in(10)_times(10000) 294.5±4.78ms 277.1±3.73ms +6.28%
query_block/query_block_in(1000)_times(100) 917.0±6.17µs 927.4±2.80µs -1.12%
query_block/query_block_in(1000)_times(1000) 9.3±0.07ms 9.1±0.04ms +2.20%
query_block/query_block_in(1000)_times(10000) 93.1±0.44ms 93.5±0.29ms -0.43%
storage_transaction 64.2±4.59ms 63.9±4.65ms +0.47%
vm/transaction_execution/1 336.6±0.90ms 313.8±4.44ms +7.27%
vm/transaction_execution/10 112.5±1.77ms 105.5±0.57ms +6.64%
vm/transaction_execution/20 105.2±0.40ms 99.8±1.16ms +5.41%
vm/transaction_execution/5 134.5±0.95ms 126.2±0.67ms +6.58%
vm/transaction_execution/50 120.7±0.51ms 115.2±0.41ms +4.77%

@jolestar jolestar marked this pull request as ready for review April 29, 2021 15:15
@github-actions
Copy link

Benchmark for 38a47cd

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.2±0.22ms 2.2±0.21ms 0.00%
block_apply/block_apply_10 418.3±3.96ms 399.5±3.65ms +4.71%
block_apply/block_apply_1000 42.6±0.14s 41.0±0.64s +3.90%
get_with_proof/db_store 39.3±0.91µs 38.2±0.35µs +2.88%
get_with_proof/mem_store 31.5±0.26µs 31.7±0.29µs -0.63%
put_and_commit/db_store/1 1219.8±38.97µs 1216.2±56.85µs +0.30%
put_and_commit/db_store/10 2.3±0.34ms 2.3±0.33ms 0.00%
put_and_commit/db_store/100 9.2±0.59ms 9.2±0.55ms 0.00%
put_and_commit/db_store/5 1892.2±124.11µs 1863.1±151.55µs +1.56%
put_and_commit/db_store/50 5.5±0.34ms 5.5±0.39ms 0.00%
put_and_commit/mem_store/1 62.6±5.50µs 63.1±5.80µs -0.79%
put_and_commit/mem_store/10 586.1±48.67µs 585.0±46.21µs +0.19%
put_and_commit/mem_store/100 5.7±0.81ms 5.7±0.81ms 0.00%
put_and_commit/mem_store/5 296.7±25.30µs 296.1±24.09µs +0.20%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.18ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.05ms 2.8±0.04ms +7.14%
query_block/query_block_in(10)_times(1000) 29.6±0.91ms 27.7±0.66ms +6.86%
query_block/query_block_in(10)_times(10000) 298.0±5.76ms 275.2±3.47ms +8.28%
query_block/query_block_in(1000)_times(100) 933.3±5.11µs 920.8±3.51µs +1.36%
query_block/query_block_in(1000)_times(1000) 9.4±0.06ms 9.3±0.04ms +1.08%
query_block/query_block_in(1000)_times(10000) 93.9±0.43ms 92.3±0.37ms +1.73%
storage_transaction 45.5±2.61ms 46.1±2.52ms -1.30%
vm/transaction_execution/1 339.6±4.62ms 313.2±0.86ms +8.43%
vm/transaction_execution/10 113.6±1.45ms 106.1±1.15ms +7.07%
vm/transaction_execution/20 106.4±0.69ms 100.2±0.83ms +6.19%
vm/transaction_execution/5 136.5±0.88ms 126.9±1.39ms +7.57%
vm/transaction_execution/50 122.2±1.04ms 115.3±0.36ms +5.98%

@github-actions
Copy link

Benchmark for f74e4bd

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.1±0.15ms 2.2±0.17ms -4.55%
block_apply/block_apply_10 418.0±5.93ms 398.2±5.14ms +4.97%
block_apply/block_apply_1000 42.5±0.19s 40.8±0.80s +4.17%
get_with_proof/db_store 38.3±0.42µs 38.2±0.31µs +0.26%
get_with_proof/mem_store 31.6±0.37µs 31.5±0.63µs +0.32%
put_and_commit/db_store/1 1232.5±75.98µs 1378.5±128.61µs -10.59%
put_and_commit/db_store/10 2.2±0.39ms 2.5±0.47ms -12.00%
put_and_commit/db_store/100 9.4±0.69ms 9.5±0.77ms -1.05%
put_and_commit/db_store/5 1866.6±180.85µs 2.0±0.24ms -6.67%
put_and_commit/db_store/50 5.6±0.80ms 5.5±0.77ms +1.82%
put_and_commit/mem_store/1 63.0±5.63µs 63.0±5.66µs 0.00%
put_and_commit/mem_store/10 585.2±48.63µs 586.2±48.44µs -0.17%
put_and_commit/mem_store/100 5.7±0.80ms 5.7±0.82ms 0.00%
put_and_commit/mem_store/5 294.6±24.48µs 298.6±25.54µs -1.34%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.18ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.07ms 2.8±0.05ms +7.14%
query_block/query_block_in(10)_times(1000) 29.6±0.36ms 27.9±0.65ms +6.09%
query_block/query_block_in(10)_times(10000) 295.2±4.67ms 277.4±3.22ms +6.42%
query_block/query_block_in(1000)_times(100) 934.4±6.09µs 930.1±4.99µs +0.46%
query_block/query_block_in(1000)_times(1000) 9.3±0.13ms 9.5±0.06ms -2.11%
query_block/query_block_in(1000)_times(10000) 93.3±0.54ms 94.9±0.51ms -1.69%
storage_transaction 43.9±2.95ms 48.9±5.04ms -10.22%
vm/transaction_execution/1 340.0±2.31ms 312.3±0.79ms +8.87%
vm/transaction_execution/10 114.3±2.19ms 105.5±0.72ms +8.34%
vm/transaction_execution/20 107.5±3.14ms 99.9±1.53ms +7.61%
vm/transaction_execution/5 135.8±0.23ms 126.4±0.66ms +7.44%
vm/transaction_execution/50 123.2±3.77ms 114.8±0.27ms +7.32%

@github-actions
Copy link

github-actions bot commented May 6, 2021

Benchmark for 71d435f

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.6±0.16ms 2.7±0.17ms -3.70%
block_apply/block_apply_10 481.0±7.52ms 454.0±13.13ms +5.95%
block_apply/block_apply_1000 48.9±0.31s 47.5±1.10s +2.95%
get_with_proof/db_store 38.2±0.30µs 37.9±0.24µs +0.79%
get_with_proof/mem_store 31.8±0.24µs 31.5±0.27µs +0.95%
put_and_commit/db_store/1 1584.9±106.33µs 1631.1±99.55µs -2.83%
put_and_commit/db_store/10 2.7±0.45ms 2.7±0.30ms 0.00%
put_and_commit/db_store/100 9.7±1.08ms 9.8±1.32ms -1.02%
put_and_commit/db_store/5 2.2±0.26ms 2.2±0.22ms 0.00%
put_and_commit/db_store/50 5.9±0.70ms 6.1±0.78ms -3.28%
put_and_commit/mem_store/1 62.8±5.62µs 62.9±5.67µs -0.16%
put_and_commit/mem_store/10 582.5±45.57µs 584.6±46.41µs -0.36%
put_and_commit/mem_store/100 5.7±0.81ms 5.7±0.82ms 0.00%
put_and_commit/mem_store/5 295.2±23.97µs 296.7±24.19µs -0.51%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.18ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.08ms 2.8±0.07ms +7.14%
query_block/query_block_in(10)_times(1000) 29.9±0.46ms 27.7±0.60ms +7.94%
query_block/query_block_in(10)_times(10000) 299.3±5.53ms 279.4±6.65ms +7.12%
query_block/query_block_in(1000)_times(100) 925.4±4.59µs 914.7±4.36µs +1.17%
query_block/query_block_in(1000)_times(1000) 9.3±0.05ms 9.2±0.06ms +1.09%
query_block/query_block_in(1000)_times(10000) 92.8±0.59ms 91.5±0.46ms +1.42%
storage_transaction 61.7±4.57ms 62.3±4.48ms -0.96%
vm/transaction_execution/1 339.3±2.26ms 313.3±1.40ms +8.30%
vm/transaction_execution/10 113.4±0.22ms 105.5±0.14ms +7.49%
vm/transaction_execution/20 106.6±0.36ms 99.7±0.27ms +6.92%
vm/transaction_execution/5 136.4±1.43ms 126.1±0.32ms +8.17%
vm/transaction_execution/50 122.0±0.21ms 115.2±0.14ms +5.90%

@github-actions
Copy link

github-actions bot commented May 6, 2021

Benchmark for 585cb05

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.3±0.15ms 2.2±0.10ms +4.55%
block_apply/block_apply_10 450.9±6.55ms 402.8±3.69ms +11.94%
block_apply/block_apply_1000 44.8±0.70s 41.4±0.20s +8.21%
get_with_proof/db_store 38.0±0.34µs 38.2±0.34µs -0.52%
get_with_proof/mem_store 31.5±0.20µs 32.0±0.26µs -1.56%
put_and_commit/db_store/1 1324.8±89.85µs 1278.3±81.87µs +3.64%
put_and_commit/db_store/10 2.4±0.74ms 2.3±0.41ms +4.35%
put_and_commit/db_store/100 9.3±0.62ms 9.5±0.58ms -2.11%
put_and_commit/db_store/5 1912.4±178.20µs 1915.1±167.14µs -0.14%
put_and_commit/db_store/50 5.6±0.67ms 5.6±0.74ms 0.00%
put_and_commit/mem_store/1 63.3±5.70µs 63.1±5.62µs +0.32%
put_and_commit/mem_store/10 593.7±48.25µs 587.2±46.53µs +1.11%
put_and_commit/mem_store/100 5.8±0.80ms 5.8±0.84ms 0.00%
put_and_commit/mem_store/5 298.0±25.49µs 295.5±24.25µs +0.85%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.19ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.06ms 2.8±0.05ms +7.14%
query_block/query_block_in(10)_times(1000) 29.9±0.43ms 27.9±0.22ms +7.17%
query_block/query_block_in(10)_times(10000) 300.8±5.35ms 276.0±8.15ms +8.99%
query_block/query_block_in(1000)_times(100) 939.0±32.16µs 932.2±4.27µs +0.73%
query_block/query_block_in(1000)_times(1000) 9.5±0.07ms 9.3±0.06ms +2.15%
query_block/query_block_in(1000)_times(10000) 92.8±0.56ms 92.6±0.33ms +0.22%
storage_transaction 50.4±3.94ms 47.2±3.52ms +6.78%
vm/transaction_execution/1 340.0±1.68ms 315.0±4.00ms +7.94%
vm/transaction_execution/10 114.0±0.74ms 105.8±0.14ms +7.75%
vm/transaction_execution/20 107.2±0.46ms 100.2±0.44ms +6.99%
vm/transaction_execution/5 136.5±0.71ms 126.6±0.46ms +7.82%
vm/transaction_execution/50 123.1±0.47ms 115.8±0.72ms +6.30%

@github-actions
Copy link

github-actions bot commented May 6, 2021

Benchmark for 02e2c55

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.9±0.13ms 2.9±0.22ms 0.00%
block_apply/block_apply_10 525.3±8.40ms 514.9±26.86ms +2.02%
block_apply/block_apply_1000 54.1±0.69s 51.0±0.48s +6.08%
get_with_proof/db_store 38.3±0.64µs 38.4±0.53µs -0.26%
get_with_proof/mem_store 31.9±0.36µs 31.4±0.38µs +1.59%
put_and_commit/db_store/1 1894.9±125.63µs 1869.1±62.22µs +1.38%
put_and_commit/db_store/10 3.0±0.72ms 3.0±0.75ms 0.00%
put_and_commit/db_store/100 29.1±18.35ms 10.1±1.87ms +188.12%
put_and_commit/db_store/5 2.4±0.32ms 2.4±0.31ms 0.00%
put_and_commit/db_store/50 6.3±1.31ms 6.3±1.50ms 0.00%
put_and_commit/mem_store/1 62.7±5.57µs 62.7±5.52µs 0.00%
put_and_commit/mem_store/10 582.4±45.63µs 587.3±45.86µs -0.83%
put_and_commit/mem_store/100 5.7±0.80ms 5.7±0.80ms 0.00%
put_and_commit/mem_store/5 295.3±24.14µs 298.3±23.81µs -1.01%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.19ms 0.00%
query_block/query_block_in(10)_times(100) 3.1±0.12ms 2.8±0.04ms +10.71%
query_block/query_block_in(10)_times(1000) 30.2±0.43ms 27.9±0.56ms +8.24%
query_block/query_block_in(10)_times(10000) 302.7±6.53ms 273.9±6.33ms +10.51%
query_block/query_block_in(1000)_times(100) 932.5±5.65µs 917.4±7.91µs +1.65%
query_block/query_block_in(1000)_times(1000) 9.3±0.03ms 9.2±0.05ms +1.09%
query_block/query_block_in(1000)_times(10000) 93.1±0.79ms 92.0±0.59ms +1.20%
storage_transaction 72.2±4.37ms 70.1±3.28ms +3.00%
vm/transaction_execution/1 339.2±0.92ms 313.1±1.00ms +8.34%
vm/transaction_execution/10 113.4±0.29ms 105.9±0.28ms +7.08%
vm/transaction_execution/20 106.6±0.20ms 99.9±0.42ms +6.71%
vm/transaction_execution/5 137.3±2.80ms 126.2±0.21ms +8.80%
vm/transaction_execution/50 122.7±0.70ms 115.2±0.21ms +6.51%

vm/stdlib/modules/Genesis.move Outdated Show resolved Hide resolved
amount: u128,
}

const ERR_INVALID_PERIOD: u64 = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

error code 1~4 is already used by other errors. It's suggested to use 101, 102, 103, 104 instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

当前 error 有点乱,有的从 1 开始,有的从 101 开始,有的从 1401 开始,我们用 category 来区分 error code type后,1~4 实际上也不会冲突,是不是没必要跳号了?

@github-actions
Copy link

github-actions bot commented May 7, 2021

Benchmark for 38b3093

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 3.1±0.21ms 3.0±0.22ms +3.33%
block_apply/block_apply_10 524.6±14.20ms 519.8±18.39ms +0.92%
block_apply/block_apply_1000 56.1±1.46s 54.4±0.88s +3.13%
get_with_proof/db_store 38.0±0.44µs 37.9±0.45µs +0.26%
get_with_proof/mem_store 31.7±0.36µs 31.9±0.32µs -0.63%
put_and_commit/db_store/1 1988.5±136.33µs 1998.2±178.01µs -0.49%
put_and_commit/db_store/10 3.4±1.12ms 3.1±0.31ms +9.68%
put_and_commit/db_store/100 10.6±2.25ms 10.6±1.72ms 0.00%
put_and_commit/db_store/5 2.6±0.27ms 2.6±0.34ms 0.00%
put_and_commit/db_store/50 6.6±2.16ms 6.6±1.56ms 0.00%
put_and_commit/mem_store/1 63.0±5.61µs 63.0±5.62µs 0.00%
put_and_commit/mem_store/10 589.4±46.24µs 586.2±48.60µs +0.55%
put_and_commit/mem_store/100 5.7±0.80ms 5.7±0.80ms 0.00%
put_and_commit/mem_store/5 298.4±23.55µs 297.5±25.15µs +0.30%
put_and_commit/mem_store/50 2.9±0.19ms 2.9±0.18ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.06ms 2.8±0.04ms +7.14%
query_block/query_block_in(10)_times(1000) 29.8±0.56ms 27.7±0.53ms +7.58%
query_block/query_block_in(10)_times(10000) 296.8±6.05ms 278.3±2.39ms +6.65%
query_block/query_block_in(1000)_times(100) 919.8±4.54µs 926.5±7.29µs -0.72%
query_block/query_block_in(1000)_times(1000) 9.2±0.05ms 9.3±0.05ms -1.08%
query_block/query_block_in(1000)_times(10000) 92.4±0.34ms 92.7±0.30ms -0.32%
storage_transaction 80.7±12.01ms 78.1±8.53ms +3.33%
vm/transaction_execution/1 335.1±0.77ms 312.9±1.51ms +7.09%
vm/transaction_execution/10 113.1±0.68ms 106.6±1.66ms +6.10%
vm/transaction_execution/20 106.6±1.02ms 100.0±0.29ms +6.60%
vm/transaction_execution/5 135.5±0.69ms 126.5±0.78ms +7.11%
vm/transaction_execution/50 121.8±0.34ms 115.5±0.38ms +5.45%

@@ -25,6 +26,8 @@ module Collection {
items: Option<vector<T>>,
}

const EDEPRECATED_FUNCTION: u64 = 11;
Copy link
Contributor

Choose a reason for hiding this comment

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

19 is used in another module, it's better use same one.

@github-actions
Copy link

github-actions bot commented May 7, 2021

Benchmark for bdb77d4

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.8±0.56ms 2.7±0.14ms +3.70%
block_apply/block_apply_10 491.8±7.48ms 495.8±67.32ms -0.81%
block_apply/block_apply_1000 50.8±1.74s 48.1±1.27s +5.61%
get_with_proof/db_store 39.1±0.69µs 38.8±0.32µs +0.77%
get_with_proof/mem_store 31.5±0.28µs 31.7±0.26µs -0.63%
put_and_commit/db_store/1 1758.1±117.70µs 1555.1±68.84µs +13.05%
put_and_commit/db_store/10 2.7±0.36ms 2.6±0.27ms +3.85%
put_and_commit/db_store/100 10.0±1.07ms 9.9±0.91ms +1.01%
put_and_commit/db_store/5 2.3±0.15ms 2.1±0.20ms +9.52%
put_and_commit/db_store/50 5.8±0.70ms 5.9±0.67ms -1.69%
put_and_commit/mem_store/1 63.1±5.59µs 63.3±5.68µs -0.32%
put_and_commit/mem_store/10 584.4±46.95µs 584.4±47.05µs 0.00%
put_and_commit/mem_store/100 5.7±0.81ms 5.7±0.81ms 0.00%
put_and_commit/mem_store/5 295.9±24.13µs 295.6±24.09µs +0.10%
put_and_commit/mem_store/50 2.9±0.18ms 2.9±0.19ms 0.00%
query_block/query_block_in(10)_times(100) 3.0±0.04ms 2.8±0.05ms +7.14%
query_block/query_block_in(10)_times(1000) 29.7±0.71ms 27.6±0.82ms +7.61%
query_block/query_block_in(10)_times(10000) 295.9±7.14ms 277.4±3.88ms +6.67%
query_block/query_block_in(1000)_times(100) 910.5±4.19µs 918.9±4.02µs -0.91%
query_block/query_block_in(1000)_times(1000) 9.1±0.05ms 9.3±0.04ms -2.15%
query_block/query_block_in(1000)_times(10000) 91.4±0.77ms 92.6±0.60ms -1.30%
storage_transaction 69.3±5.80ms 69.8±5.24ms -0.72%
vm/transaction_execution/1 335.8±1.35ms 312.8±0.60ms +7.35%
vm/transaction_execution/10 112.9±0.32ms 105.9±0.86ms +6.61%
vm/transaction_execution/20 107.3±2.18ms 99.8±0.46ms +7.52%
vm/transaction_execution/5 135.2±0.33ms 126.1±0.29ms +7.22%
vm/transaction_execution/50 122.4±1.32ms 115.2±0.23ms +6.25%

/// Provider a port for get block reward STC from Treasury, only genesis account can invoke this function.
/// The TreasuryWithdrawCapability is locked in TreasuryWithdrawDaoProposal, and only can withdraw by DAO proposal.
/// This approach is not graceful, but restricts the operation to genesis accounts only, so there are no security issues either.
public fun withdraw_for_block_reward<TokenT: store>(signer: &signer, reward: u128):Token<TokenT> acquires WrappedWithdrawCapability {
Copy link
Member

Choose a reason for hiding this comment

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

这里的设计确实有点奇怪。
withdraw block reward 不属于 dao proposal的范畴,却需要放在这个 module 里。另外方法也不应该有范型,链发币只发 stc,不会涉及其他 token。

Copy link
Member

Choose a reason for hiding this comment

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

其他的看起来没啥问题。

Copy link
Member Author

Choose a reason for hiding this comment

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

嗯,没想到更好的办法。本来想给 BlockReward 设置一个 capability,但 block reward 的额度不固定,也没法用 LinearCap,最后和 WithdrawCap 类似了。这里的 TokenT 如果直接写 STC,会有依赖顺序问题,所以只能先保持泛型。

@jolestar jolestar merged commit 2834636 into master May 7, 2021
@jolestar jolestar deleted the feature/sip_5 branch May 7, 2021 12:14
naughtyvenom pushed a commit to naughtyvenom/starcoin that referenced this pull request Jul 19, 2021
* [stdlib] Implement Treasury module.

* [stdib] Impl load upgrade package between version and enhancement upgrade test

* [statedb] Implement get token info function for state reader.

* [stdlib] Release stdlib v3

* [stdlib] Deprecated MintKey and Collection.

* [stdlib] Check compat with previous latest stable version.

* [types] Define more on chain resource in rust.
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.

[stdlib] Check the compatibility between latest stdlib and previous stable stdlib.
3 participants