Skip to content

Commit d1f0b2d

Browse files
committed
update build/release files
1. fix warning
1 parent 3f8a155 commit d1f0b2d

File tree

11 files changed

+325
-79
lines changed

11 files changed

+325
-79
lines changed

build/StarcoinFramework/BuildInfo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ compiled_package_info:
55
StarcoinAssociation: "0x0000000000000000000000000a550c18"
66
StarcoinFramework: "0x00000000000000000000000000000001"
77
VMReserved: "0x00000000000000000000000000000000"
8-
source_digest: 9280A56F445BC59176E3E1323C8B6159C411D74258DCD6679977DD49BA0C45D5
8+
source_digest: 0899528282F044F9621C6B7686759D0D2AE52CF34CFAE8BF0917D02F2699ADF9
99
build_flags:
1010
dev_mode: false
1111
test_mode: false
-76 Bytes
Binary file not shown.

build/StarcoinFramework/docs/Epoch.md

Lines changed: 81 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ The module provide epoch functionality for starcoin.
3131

3232
<pre><code><b>use</b> <a href="ConsensusConfig.md#0x1_ConsensusConfig">0x1::ConsensusConfig</a>;
3333
<b>use</b> <a href="CoreAddresses.md#0x1_CoreAddresses">0x1::CoreAddresses</a>;
34-
<b>use</b> <a href="Errors.md#0x1_Errors">0x1::Errors</a>;
3534
<b>use</b> <a href="Event.md#0x1_Event">0x1::Event</a>;
3635
<b>use</b> <a href="Math.md#0x1_Math">0x1::Math</a>;
3736
<b>use</b> <a href="Option.md#0x1_Option">0x1::Option</a>;
@@ -369,13 +368,21 @@ compute next block time_target.
369368
<summary>Implementation</summary>
370369

371370

372-
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_compute_next_block_time_target">compute_next_block_time_target</a>(config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>, last_epoch_time_target: u64, epoch_start_time: u64, now_milli_second: u64, start_block_number: u64, end_block_number: u64, total_uncles: u64): u64 {
371+
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_compute_next_block_time_target">compute_next_block_time_target</a>(
372+
config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>,
373+
last_epoch_time_target: u64,
374+
epoch_start_time: u64,
375+
now_milli_second: u64,
376+
start_block_number: u64,
377+
end_block_number: u64,
378+
total_uncles: u64
379+
): u64 {
373380
<b>let</b> total_time = now_milli_second - epoch_start_time;
374381
<b>let</b> blocks = end_block_number - start_block_number;
375382
<b>let</b> avg_block_time = total_time / blocks;
376383
<b>let</b> uncles_rate = total_uncles * <a href="Epoch.md#0x1_Epoch_THOUSAND">THOUSAND</a> / blocks;
377384
<b>let</b> new_epoch_block_time_target = (<a href="Epoch.md#0x1_Epoch_THOUSAND">THOUSAND</a> + uncles_rate) * avg_block_time /
378-
(<a href="ConsensusConfig.md#0x1_ConsensusConfig_uncle_rate_target">ConsensusConfig::uncle_rate_target</a>(config) + <a href="Epoch.md#0x1_Epoch_THOUSAND">THOUSAND</a>);
385+
(<a href="ConsensusConfig.md#0x1_ConsensusConfig_uncle_rate_target">ConsensusConfig::uncle_rate_target</a>(config) + <a href="Epoch.md#0x1_Epoch_THOUSAND">THOUSAND</a>);
379386
<b>if</b> (new_epoch_block_time_target &gt; last_epoch_time_target * 2) {
380387
new_epoch_block_time_target = last_epoch_time_target * 2;
381388
};
@@ -426,26 +433,43 @@ adjust_epoch try to advance to next epoch if current epoch ends.
426433
<summary>Implementation</summary>
427434

428435

429-
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_adjust_epoch">adjust_epoch</a>(account: &signer, block_number: u64, timestamp: u64, uncles: u64, parent_gas_used:u64): u128
436+
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_adjust_epoch">adjust_epoch</a>(
437+
account: &signer,
438+
block_number: u64,
439+
timestamp: u64,
440+
uncles: u64,
441+
parent_gas_used: u64
442+
): u128
430443
<b>acquires</b> <a href="Epoch.md#0x1_Epoch">Epoch</a>, <a href="Epoch.md#0x1_Epoch_EpochData">EpochData</a> {
431444
<a href="CoreAddresses.md#0x1_CoreAddresses_assert_genesis_address">CoreAddresses::assert_genesis_address</a>(account);
432445

433446
<b>let</b> epoch_ref = <b>borrow_global_mut</b>&lt;<a href="Epoch.md#0x1_Epoch">Epoch</a>&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_GENESIS_ADDRESS">CoreAddresses::GENESIS_ADDRESS</a>());
434-
<b>assert</b>!(epoch_ref.max_uncles_per_block &gt;= uncles, <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="Epoch.md#0x1_Epoch_EINVALID_UNCLES_COUNT">EINVALID_UNCLES_COUNT</a>));
447+
// <b>assert</b>!(epoch_ref.max_uncles_per_block &gt;= uncles, <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="Epoch.md#0x1_Epoch_EINVALID_UNCLES_COUNT">EINVALID_UNCLES_COUNT</a>));
435448

436449
<b>let</b> epoch_data = <b>borrow_global_mut</b>&lt;<a href="Epoch.md#0x1_Epoch_EpochData">EpochData</a>&gt;(<a href="CoreAddresses.md#0x1_CoreAddresses_GENESIS_ADDRESS">CoreAddresses::GENESIS_ADDRESS</a>());
437450
<b>let</b> (new_epoch, reward_per_block) = <b>if</b> (block_number &lt; epoch_ref.end_block_number) {
438451
(<b>false</b>, epoch_ref.reward_per_block)
439452
} <b>else</b> <b>if</b> (block_number == epoch_ref.end_block_number) {
440453
//start a new epoch
441-
<b>assert</b>!(uncles == 0, <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="Epoch.md#0x1_Epoch_EINVALID_UNCLES_COUNT">EINVALID_UNCLES_COUNT</a>));
454+
// <b>assert</b>!(uncles == 0, <a href="Errors.md#0x1_Errors_invalid_argument">Errors::invalid_argument</a>(<a href="Epoch.md#0x1_Epoch_EINVALID_UNCLES_COUNT">EINVALID_UNCLES_COUNT</a>));
442455
// block time target unit is milli_seconds.
443456
<b>let</b> now_milli_seconds = timestamp;
444457

445458
<b>let</b> config = <a href="ConsensusConfig.md#0x1_ConsensusConfig_get_config">ConsensusConfig::get_config</a>();
446459
<b>let</b> last_epoch_time_target = epoch_ref.block_time_target;
447-
<b>let</b> new_epoch_block_time_target = <a href="Epoch.md#0x1_Epoch_compute_next_block_time_target">compute_next_block_time_target</a>(&config, last_epoch_time_target, epoch_ref.start_time, now_milli_seconds, epoch_ref.start_block_number, epoch_ref.end_block_number, epoch_data.uncles);
448-
<b>let</b> new_reward_per_block = <a href="ConsensusConfig.md#0x1_ConsensusConfig_do_compute_reward_per_block">ConsensusConfig::do_compute_reward_per_block</a>(&config, new_epoch_block_time_target);
460+
<b>let</b> new_epoch_block_time_target = <a href="Epoch.md#0x1_Epoch_compute_next_block_time_target">compute_next_block_time_target</a>(
461+
&config,
462+
last_epoch_time_target,
463+
epoch_ref.start_time,
464+
now_milli_seconds,
465+
epoch_ref.start_block_number,
466+
epoch_ref.end_block_number,
467+
epoch_data.uncles
468+
);
469+
<b>let</b> new_reward_per_block = <a href="ConsensusConfig.md#0x1_ConsensusConfig_do_compute_reward_per_block">ConsensusConfig::do_compute_reward_per_block</a>(
470+
&config,
471+
new_epoch_block_time_target
472+
);
449473

450474
//<b>update</b> epoch by adjust result or config, because <a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a> may be updated.
451475
epoch_ref.number = epoch_ref.number + 1;
@@ -461,15 +485,21 @@ adjust_epoch try to advance to next epoch if current epoch ends.
461485

462486
epoch_data.uncles = 0;
463487
<b>let</b> last_epoch_total_gas = epoch_data.total_gas + (parent_gas_used <b>as</b> u128);
464-
<a href="Epoch.md#0x1_Epoch_adjust_gas_limit">adjust_gas_limit</a>(&config, epoch_ref, last_epoch_time_target, new_epoch_block_time_target, last_epoch_total_gas);
488+
<a href="Epoch.md#0x1_Epoch_adjust_gas_limit">adjust_gas_limit</a>(
489+
&config,
490+
epoch_ref,
491+
last_epoch_time_target,
492+
new_epoch_block_time_target,
493+
last_epoch_total_gas
494+
);
465495
<a href="Epoch.md#0x1_Epoch_emit_epoch_event">emit_epoch_event</a>(epoch_ref, epoch_data.total_reward);
466496
(<b>true</b>, new_reward_per_block)
467497
} <b>else</b> {
468498
//This should never happened.
469499
<b>abort</b> <a href="Epoch.md#0x1_Epoch_EUNREACHABLE">EUNREACHABLE</a>
470500
};
471501
<b>let</b> reward = reward_per_block +
472-
reward_per_block * (epoch_ref.reward_per_uncle_percent <b>as</b> u128) * (uncles <b>as</b> u128) / (<a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> <b>as</b> u128);
502+
reward_per_block * (epoch_ref.reward_per_uncle_percent <b>as</b> u128) * (uncles <b>as</b> u128) / (<a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> <b>as</b> u128);
473503
<a href="Epoch.md#0x1_Epoch_update_epoch_data">update_epoch_data</a>(epoch_data, new_epoch, reward, uncles, parent_gas_used);
474504
reward
475505
}
@@ -511,8 +541,20 @@ adjust_epoch try to advance to next epoch if current epoch ends.
511541
<summary>Implementation</summary>
512542

513543

514-
<pre><code><b>fun</b> <a href="Epoch.md#0x1_Epoch_adjust_gas_limit">adjust_gas_limit</a>(config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>, epoch_ref: &<b>mut</b> <a href="Epoch.md#0x1_Epoch">Epoch</a>, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_total_gas:u128) {
515-
<b>let</b> new_gas_limit = <a href="Epoch.md#0x1_Epoch_compute_gas_limit">compute_gas_limit</a>(config, last_epoch_time_target, new_epoch_time_target, epoch_ref.block_gas_limit, last_epoch_total_gas);
544+
<pre><code><b>fun</b> <a href="Epoch.md#0x1_Epoch_adjust_gas_limit">adjust_gas_limit</a>(
545+
config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>,
546+
epoch_ref: &<b>mut</b> <a href="Epoch.md#0x1_Epoch">Epoch</a>,
547+
last_epoch_time_target: u64,
548+
new_epoch_time_target: u64,
549+
last_epoch_total_gas: u128
550+
) {
551+
<b>let</b> new_gas_limit = <a href="Epoch.md#0x1_Epoch_compute_gas_limit">compute_gas_limit</a>(
552+
config,
553+
last_epoch_time_target,
554+
new_epoch_time_target,
555+
epoch_ref.block_gas_limit,
556+
last_epoch_total_gas
557+
);
516558
<b>if</b> (<a href="Option.md#0x1_Option_is_some">Option::is_some</a>(&new_gas_limit)) {
517559
epoch_ref.block_gas_limit = <a href="Option.md#0x1_Option_destroy_some">Option::destroy_some</a>(new_gas_limit);
518560
}
@@ -551,17 +593,31 @@ Compute block's gas limit of next epoch.
551593
<summary>Implementation</summary>
552594

553595

554-
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_compute_gas_limit">compute_gas_limit</a>(config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>, last_epoch_time_target: u64, new_epoch_time_target: u64, last_epoch_block_gas_limit: u64, last_epoch_total_gas: u128) : <a href="Option.md#0x1_Option_Option">Option::Option</a>&lt;u64&gt; {
596+
<pre><code><b>public</b> <b>fun</b> <a href="Epoch.md#0x1_Epoch_compute_gas_limit">compute_gas_limit</a>(
597+
config: &<a href="ConsensusConfig.md#0x1_ConsensusConfig">ConsensusConfig</a>,
598+
last_epoch_time_target: u64,
599+
new_epoch_time_target: u64,
600+
last_epoch_block_gas_limit: u64,
601+
last_epoch_total_gas: u128
602+
): <a href="Option.md#0x1_Option_Option">Option::Option</a>&lt;u64&gt; {
555603
<b>let</b> epoch_block_count = (<a href="ConsensusConfig.md#0x1_ConsensusConfig_epoch_block_count">ConsensusConfig::epoch_block_count</a>(config) <b>as</b> u128);
556-
<b>let</b> gas_limit_threshold = (last_epoch_total_gas &gt;= <a href="Math.md#0x1_Math_mul_div">Math::mul_div</a>((last_epoch_block_gas_limit <b>as</b> u128) * epoch_block_count, (80 <b>as</b> u128), (<a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> <b>as</b> u128)));
604+
<b>let</b> gas_limit_threshold = (last_epoch_total_gas &gt;= <a href="Math.md#0x1_Math_mul_div">Math::mul_div</a>(
605+
(last_epoch_block_gas_limit <b>as</b> u128) * epoch_block_count,
606+
(80 <b>as</b> u128),
607+
(<a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> <b>as</b> u128)
608+
));
557609
<b>let</b> new_gas_limit = <a href="Option.md#0x1_Option_none">Option::none</a>&lt;u64&gt;();
558610

559611
<b>let</b> min_block_time_target = <a href="ConsensusConfig.md#0x1_ConsensusConfig_min_block_time_target">ConsensusConfig::min_block_time_target</a>(config);
560612
<b>let</b> max_block_time_target = <a href="ConsensusConfig.md#0x1_ConsensusConfig_max_block_time_target">ConsensusConfig::max_block_time_target</a>(config);
561-
<b>let</b> base_block_gas_limit = <a href="ConsensusConfig.md#0x1_ConsensusConfig_base_block_gas_limit">ConsensusConfig::base_block_gas_limit</a>(config);
613+
<b>let</b> base_block_gas_limit = <a href="ConsensusConfig.md#0x1_ConsensusConfig_base_block_gas_limit">ConsensusConfig::base_block_gas_limit</a>(config);
562614
<b>if</b> (last_epoch_time_target == new_epoch_time_target) {
563615
<b>if</b> (new_epoch_time_target == min_block_time_target && gas_limit_threshold) {
564-
<b>let</b> increase_gas_limit = <a href="Epoch.md#0x1_Epoch_in_or_decrease_gas_limit">in_or_decrease_gas_limit</a>(last_epoch_block_gas_limit, 110, base_block_gas_limit);
616+
<b>let</b> increase_gas_limit = <a href="Epoch.md#0x1_Epoch_in_or_decrease_gas_limit">in_or_decrease_gas_limit</a>(
617+
last_epoch_block_gas_limit,
618+
110,
619+
base_block_gas_limit
620+
);
565621
new_gas_limit = <a href="Option.md#0x1_Option_some">Option::some</a>(increase_gas_limit);
566622
} <b>else</b> <b>if</b> (new_epoch_time_target == max_block_time_target && !gas_limit_threshold) {
567623
<b>let</b> decrease_gas_limit = <a href="Epoch.md#0x1_Epoch_in_or_decrease_gas_limit">in_or_decrease_gas_limit</a>(last_epoch_block_gas_limit, 90, base_block_gas_limit);
@@ -606,7 +662,7 @@ Compute block's gas limit of next epoch.
606662

607663
<pre><code><b>fun</b> <a href="Epoch.md#0x1_Epoch_in_or_decrease_gas_limit">in_or_decrease_gas_limit</a>(last_epoch_block_gas_limit: u64, percent: u64, min_block_gas_limit: u64): u64 {
608664
<b>let</b> tmp_gas_limit = <a href="Math.md#0x1_Math_mul_div">Math::mul_div</a>((last_epoch_block_gas_limit <b>as</b> u128), (percent <b>as</b> u128), (<a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> <b>as</b> u128));
609-
<b>let</b> new_gas_limit = <b>if</b> (tmp_gas_limit &gt; (min_block_gas_limit <b>as</b> u128)) {
665+
<b>let</b> new_gas_limit = <b>if</b> (tmp_gas_limit &gt; (min_block_gas_limit <b>as</b> u128)) {
610666
(tmp_gas_limit <b>as</b> u64)
611667
} <b>else</b> {
612668
min_block_gas_limit
@@ -625,7 +681,7 @@ Compute block's gas limit of next epoch.
625681

626682

627683

628-
<pre><code><b>include</b> <a href="Math.md#0x1_Math_MulDivAbortsIf">Math::MulDivAbortsIf</a>{x: last_epoch_block_gas_limit, y: percent, z: <a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a>};
684+
<pre><code><b>include</b> <a href="Math.md#0x1_Math_MulDivAbortsIf">Math::MulDivAbortsIf</a> { x: last_epoch_block_gas_limit, y: percent, z: <a href="Epoch.md#0x1_Epoch_HUNDRED">HUNDRED</a> };
629685
<b>aborts_if</b> <a href="Math.md#0x1_Math_spec_mul_div">Math::spec_mul_div</a>() &gt; MAX_U64;
630686
</code></pre>
631687

@@ -648,7 +704,13 @@ Compute block's gas limit of next epoch.
648704
<summary>Implementation</summary>
649705

650706

651-
<pre><code><b>fun</b> <a href="Epoch.md#0x1_Epoch_update_epoch_data">update_epoch_data</a>(epoch_data: &<b>mut</b> <a href="Epoch.md#0x1_Epoch_EpochData">EpochData</a>, new_epoch: bool, reward: u128, uncles: u64, parent_gas_used:u64) {
707+
<pre><code><b>fun</b> <a href="Epoch.md#0x1_Epoch_update_epoch_data">update_epoch_data</a>(
708+
epoch_data: &<b>mut</b> <a href="Epoch.md#0x1_Epoch_EpochData">EpochData</a>,
709+
new_epoch: bool,
710+
reward: u128,
711+
uncles: u64,
712+
parent_gas_used: u64
713+
) {
652714
<b>if</b> (new_epoch) {
653715
epoch_data.total_reward = reward;
654716
epoch_data.uncles = uncles;
-630 Bytes
Binary file not shown.

release/StarcoinFramework.v0.1.0.blob

-77 Bytes
Binary file not shown.

release/v13/BuildInfo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ compiled_package_info:
55
StarcoinAssociation: "0x0000000000000000000000000a550c18"
66
StarcoinFramework: "0x00000000000000000000000000000001"
77
VMReserved: "0x00000000000000000000000000000000"
8-
source_digest: 9280A56F445BC59176E3E1323C8B6159C411D74258DCD6679977DD49BA0C45D5
8+
source_digest: 0899528282F044F9621C6B7686759D0D2AE52CF34CFAE8BF0917D02F2699ADF9
99
build_flags:
1010
dev_mode: false
1111
test_mode: false

release/v13/bytecode_modules/Epoch.mv

-76 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)