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

[stdlib] Implement a generic Oracle data protocol #2732

Merged
merged 7 commits into from
Jul 31, 2021
Merged

Conversation

jolestar
Copy link
Member

#2727 的基础上进行重构

  1. Oracle 的数据通过泛型表达,并不绑定在 price。PriceOracle 基于 Oracle 实现。
  2. 提供了默认的 STCUSDOracle 定义,提供了 PriceOracle 的一些 script function。
  3. Genesis 初始化的时候自动注册 STCUSDOracle 。

@codecov
Copy link

codecov bot commented Jul 22, 2021

Codecov Report

Merging #2732 (2d37292) into master (6d2a64f) will decrease coverage by 0.24%.
The diff coverage is n/a.

❗ Current head 2d37292 differs from pull request most recent head cbdef00. Consider uploading reports for the commit cbdef00 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2732      +/-   ##
==========================================
- Coverage   31.93%   31.70%   -0.23%     
==========================================
  Files         508      508              
  Lines       44774    44774              
  Branches    19930    19930              
==========================================
- Hits        14295    14189     -106     
- Misses      16500    16810     +310     
+ Partials    13979    13775     -204     
Flag Coverage Δ
unittests 31.70% <ø> (-0.23%) ⬇️

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

Impacted Files Coverage Δ
block-relayer/src/metrics.rs 0.00% <0.00%> (-38.46%) ⬇️
sync/api/src/lib.rs 9.31% <0.00%> (-20.93%) ⬇️
executor/src/readonly_function_call_test.rs 2.99% <0.00%> (-10.44%) ⬇️
block-relayer/src/block_relayer.rs 15.25% <0.00%> (-10.36%) ⬇️
sync/src/block_connector/write_block_chain.rs 26.57% <0.00%> (-7.81%) ⬇️
sync/src/block_connector/test_write_block_chain.rs 15.89% <0.00%> (-7.47%) ⬇️
network-rpc/core/src/lib.rs 23.53% <0.00%> (-5.88%) ⬇️
types/src/system_events.rs 57.90% <0.00%> (-5.26%) ⬇️
...ync/src/block_connector/block_connector_service.rs 27.59% <0.00%> (-4.59%) ⬇️
chain/src/chain.rs 30.83% <0.00%> (-3.08%) ⬇️
... and 19 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 6d2a64f...cbdef00. Read the comment docs.

@github-actions
Copy link

Benchmark for cd2c6a0

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.8±0.12ms 2.7±0.38ms +3.70%
block_apply/block_apply_10 499.8±8.89ms 507.9±5.45ms -1.59%
block_apply/block_apply_1000 51.0±0.76s 51.0±0.61s 0.00%
get_with_proof/db_store 38.5±0.43µs 38.3±0.23µs +0.52%
get_with_proof/mem_store 31.8±0.44µs 31.6±0.32µs +0.63%
put_and_commit/db_store/1 1764.2±140.65µs 1656.0±106.05µs +6.53%
put_and_commit/db_store/10 2.8±0.35ms 2.8±0.33ms 0.00%
put_and_commit/db_store/100 9.8±0.80ms 9.8±0.86ms 0.00%
put_and_commit/db_store/5 2.2±0.11ms 2.2±0.14ms 0.00%
put_and_commit/db_store/50 6.1±0.48ms 6.0±0.63ms +1.67%
put_and_commit/mem_store/1 62.6±5.52µs 63.1±5.88µs -0.79%
put_and_commit/mem_store/10 585.2±46.15µs 588.2±47.54µs -0.51%
put_and_commit/mem_store/100 5.8±0.80ms 5.8±0.81ms 0.00%
put_and_commit/mem_store/5 294.7±24.05µs 296.2±23.61µs -0.51%
put_and_commit/mem_store/50 2.9±0.19ms 2.9±0.19ms 0.00%
query_block/query_block_in(10)_times(100) 3.1±0.08ms 2.9±0.05ms +6.90%
query_block/query_block_in(10)_times(1000) 30.7±0.90ms 29.4±0.47ms +4.42%
query_block/query_block_in(10)_times(10000) 305.9±6.14ms 293.8±6.03ms +4.12%
query_block/query_block_in(1000)_times(100) 909.5±4.73µs 899.4±8.35µs +1.12%
query_block/query_block_in(1000)_times(1000) 9.0±0.07ms 9.0±0.04ms 0.00%
query_block/query_block_in(1000)_times(10000) 90.9±0.30ms 92.1±0.38ms -1.30%
storage_transaction 66.2±3.84ms 65.4±3.95ms +1.22%
vm/transaction_execution/1 330.8±0.85ms 326.8±0.95ms +1.22%
vm/transaction_execution/10 109.7±0.54ms 106.5±0.17ms +3.00%
vm/transaction_execution/20 102.5±0.21ms 99.7±0.33ms +2.81%
vm/transaction_execution/5 131.7±0.30ms 128.8±0.36ms +2.25%
vm/transaction_execution/50 117.8±0.74ms 114.5±0.89ms +2.88%

}

struct OracleFeed<OracleT: copy+store+drop, ValueT: copy+store+drop> has key {
record: DataRecord<ValueT>,
Copy link
Member

Choose a reason for hiding this comment

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

oraclefeed 里建议加上 data source id

Copy link
Member Author

Choose a reason for hiding this comment

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

是在 DataRecord 里还是 OracleFeed?如果是 OracleFeed 的话感觉没必要,OracleFeed 和 DataSource 都在同一个账号下,只有一份

@github-actions
Copy link

Benchmark for b323712

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.3±0.13ms 2.2±0.14ms +4.55%
block_apply/block_apply_10 412.6±2.58ms 408.5±4.65ms +1.00%
block_apply/block_apply_1000 42.3±0.15s 42.3±0.90s 0.00%
get_with_proof/db_store 38.5±0.31µs 38.3±0.31µs +0.52%
get_with_proof/mem_store 31.7±0.22µs 31.7±0.35µs 0.00%
put_and_commit/db_store/1 1219.8±47.18µs 1247.0±42.18µs -2.18%
put_and_commit/db_store/10 2.3±0.34ms 2.3±0.37ms 0.00%
put_and_commit/db_store/100 9.7±0.95ms 9.6±0.86ms +1.04%
put_and_commit/db_store/5 1879.9±213.68µs 1944.0±142.58µs -3.30%
put_and_commit/db_store/50 5.7±0.75ms 5.8±0.67ms -1.72%
put_and_commit/mem_store/1 63.1±5.62µs 63.5±5.81µs -0.63%
put_and_commit/mem_store/10 587.0±48.07µs 589.3±49.12µs -0.39%
put_and_commit/mem_store/100 5.8±0.82ms 5.8±0.82ms 0.00%
put_and_commit/mem_store/5 298.2±24.60µs 299.2±25.00µs -0.33%
put_and_commit/mem_store/50 2.9±0.19ms 2.9±0.19ms 0.00%
query_block/query_block_in(10)_times(100) 3.1±0.04ms 3.0±0.05ms +3.33%
query_block/query_block_in(10)_times(1000) 30.8±0.56ms 29.2±0.47ms +5.48%
query_block/query_block_in(10)_times(10000) 307.6±6.12ms 292.5±7.55ms +5.16%
query_block/query_block_in(1000)_times(100) 910.8±3.17µs 921.4±6.64µs -1.15%
query_block/query_block_in(1000)_times(1000) 9.1±0.08ms 9.3±0.04ms -2.15%
query_block/query_block_in(1000)_times(10000) 94.2±0.42ms 91.7±0.59ms +2.73%
storage_transaction 45.6±4.76ms 44.7±2.50ms +2.01%
vm/transaction_execution/1 331.6±1.23ms 326.6±0.84ms +1.53%
vm/transaction_execution/10 110.3±0.44ms 106.8±0.29ms +3.28%
vm/transaction_execution/20 103.0±0.72ms 99.8±0.70ms +3.21%
vm/transaction_execution/5 132.4±0.77ms 128.8±0.78ms +2.80%
vm/transaction_execution/50 117.5±1.28ms 113.9±0.26ms +3.16%

@github-actions
Copy link

Benchmark for 2b7b27e

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.4±0.12ms 2.4±0.22ms 0.00%
block_apply/block_apply_10 454.0±3.91ms 471.4±9.33ms -3.69%
block_apply/block_apply_1000 46.4±0.70s 45.6±0.49s +1.75%
get_with_proof/db_store 38.3±0.35µs 38.1±0.33µs +0.52%
get_with_proof/mem_store 31.4±0.20µs 31.6±0.24µs -0.63%
put_and_commit/db_store/1 1448.2±64.16µs 1402.9±28.38µs +3.23%
put_and_commit/db_store/10 2.5±0.32ms 2.5±0.34ms 0.00%
put_and_commit/db_store/100 9.8±0.89ms 9.8±0.87ms 0.00%
put_and_commit/db_store/5 2.0±0.13ms 2.0±0.12ms 0.00%
put_and_commit/db_store/50 5.9±0.58ms 5.9±0.60ms 0.00%
put_and_commit/mem_store/1 63.5±5.61µs 63.0±5.62µs +0.79%
put_and_commit/mem_store/10 583.8±46.08µs 587.2±46.58µs -0.58%
put_and_commit/mem_store/100 5.7±0.83ms 5.7±0.82ms 0.00%
put_and_commit/mem_store/5 297.0±23.75µs 295.9±24.16µs +0.37%
put_and_commit/mem_store/50 2.9±0.19ms 2.9±0.20ms 0.00%
query_block/query_block_in(10)_times(100) 3.1±0.07ms 2.9±0.06ms +6.90%
query_block/query_block_in(10)_times(1000) 30.7±0.52ms 29.2±0.72ms +5.14%
query_block/query_block_in(10)_times(10000) 307.9±4.05ms 294.3±4.96ms +4.62%
query_block/query_block_in(1000)_times(100) 902.6±4.06µs 940.9±6.65µs -4.07%
query_block/query_block_in(1000)_times(1000) 9.2±0.05ms 9.4±0.05ms -2.13%
query_block/query_block_in(1000)_times(10000) 90.5±0.59ms 93.9±0.44ms -3.62%
storage_transaction 52.9±2.52ms 52.5±2.69ms +0.76%
vm/transaction_execution/1 332.9±1.79ms 326.4±0.84ms +1.99%
vm/transaction_execution/10 109.8±0.60ms 106.7±1.34ms +2.91%
vm/transaction_execution/20 102.8±0.44ms 99.6±0.37ms +3.21%
vm/transaction_execution/5 132.7±0.80ms 128.7±0.85ms +3.11%
vm/transaction_execution/50 117.1±0.33ms 114.0±0.40ms +2.72%

@github-actions
Copy link

Benchmark for 6acf1ef

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.4±0.12ms 2.4±0.12ms 0.00%
block_apply/block_apply_10 455.2±4.90ms 448.5±9.27ms +1.49%
block_apply/block_apply_1000 45.6±0.24s 45.5±0.33s +0.22%
get_with_proof/db_store 38.2±0.36µs 38.9±0.56µs -1.80%
get_with_proof/mem_store 31.7±0.28µs 31.7±0.31µs 0.00%
put_and_commit/db_store/1 1387.3±101.87µs 1356.7±39.45µs +2.26%
put_and_commit/db_store/10 2.5±0.53ms 2.5±0.54ms 0.00%
put_and_commit/db_store/100 10.1±1.56ms 10.0±1.49ms +1.00%
put_and_commit/db_store/5 2.0±0.17ms 2.0±0.30ms 0.00%
put_and_commit/db_store/50 6.2±1.19ms 6.1±1.08ms +1.64%
put_and_commit/mem_store/1 62.9±5.56µs 63.7±5.66µs -1.26%
put_and_commit/mem_store/10 584.7±46.34µs 590.9±47.03µs -1.05%
put_and_commit/mem_store/100 5.7±0.81ms 5.8±0.81ms -1.72%
put_and_commit/mem_store/5 295.9±24.33µs 301.0±24.36µs -1.69%
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.06ms 3.0±0.06ms +3.33%
query_block/query_block_in(10)_times(1000) 31.4±0.63ms 29.5±0.33ms +6.44%
query_block/query_block_in(10)_times(10000) 308.8±5.12ms 297.8±5.39ms +3.69%
query_block/query_block_in(1000)_times(100) 908.2±3.95µs 915.3±6.56µs -0.78%
query_block/query_block_in(1000)_times(1000) 9.1±0.04ms 9.2±0.05ms -1.09%
query_block/query_block_in(1000)_times(10000) 90.7±0.65ms 91.7±0.41ms -1.09%
storage_transaction 52.5±3.53ms 51.4±3.37ms +2.14%
vm/transaction_execution/1 341.9±4.81ms 333.4±1.13ms +2.55%
vm/transaction_execution/10 112.9±1.34ms 109.0±0.23ms +3.58%
vm/transaction_execution/20 105.5±0.26ms 102.3±0.37ms +3.13%
vm/transaction_execution/5 135.6±0.44ms 131.5±0.15ms +3.12%
vm/transaction_execution/50 120.2±0.65ms 116.5±0.38ms +3.18%

@github-actions
Copy link

Benchmark for 46bfbe0

Click to view benchmark
Test PR Benchmark Master Benchmark %
accumulator_append 2.4±0.14ms 2.4±0.11ms 0.00%
block_apply/block_apply_10 444.5±3.96ms 444.0±9.88ms +0.11%
block_apply/block_apply_1000 45.1±0.44s 45.2±0.39s -0.22%
get_with_proof/db_store 38.2±0.41µs 38.4±0.38µs -0.52%
get_with_proof/mem_store 31.6±0.21µs 31.7±0.30µs -0.32%
put_and_commit/db_store/1 1359.2±53.59µs 1400.4±71.33µs -2.94%
put_and_commit/db_store/10 2.5±0.54ms 2.6±0.49ms -3.85%
put_and_commit/db_store/100 10.0±1.36ms 10.0±1.52ms 0.00%
put_and_commit/db_store/5 2.0±0.19ms 2.0±0.22ms 0.00%
put_and_commit/db_store/50 6.0±0.90ms 6.1±0.68ms -1.64%
put_and_commit/mem_store/1 63.5±5.56µs 63.4±5.64µs +0.16%
put_and_commit/mem_store/10 588.7±46.99µs 588.7±45.14µs 0.00%
put_and_commit/mem_store/100 5.8±0.81ms 5.8±0.81ms 0.00%
put_and_commit/mem_store/5 296.7±24.54µs 297.3±24.44µ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.1±0.06ms 3.0±0.06ms +3.33%
query_block/query_block_in(10)_times(1000) 31.1±0.72ms 29.9±0.67ms +4.01%
query_block/query_block_in(10)_times(10000) 314.7±5.21ms 296.2±2.96ms +6.25%
query_block/query_block_in(1000)_times(100) 925.5±5.60µs 904.7±5.62µs +2.30%
query_block/query_block_in(1000)_times(1000) 9.2±0.06ms 9.1±0.08ms +1.10%
query_block/query_block_in(1000)_times(10000) 91.2±0.65ms 90.7±0.44ms +0.55%
storage_transaction 49.9±2.74ms 53.4±4.18ms -6.55%
vm/transaction_execution/1 340.2±2.03ms 334.9±3.50ms +1.58%
vm/transaction_execution/10 113.1±1.49ms 109.7±1.04ms +3.10%
vm/transaction_execution/20 106.2±2.19ms 102.8±1.58ms +3.31%
vm/transaction_execution/5 135.7±0.91ms 131.9±0.49ms +2.88%
vm/transaction_execution/50 119.9±0.44ms 116.8±0.91ms +2.65%

@jolestar jolestar merged commit 3285430 into master Jul 31, 2021
@jolestar jolestar deleted the oracle_v2 branch July 31, 2021 07:55
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