Compare commits
No commits in common. "main" and "main-test" have entirely different histories.
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1186,7 +1186,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "casper-runtime"
|
name = "casper-runtime"
|
||||||
version = "3.5.36"
|
version = "3.5.35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"casper-runtime-constants",
|
"casper-runtime-constants",
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
@ -3837,7 +3837,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.7"
|
version = "0.4.5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"frame-benchmarking",
|
"frame-benchmarking",
|
||||||
"frame-support",
|
"frame-support",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ghost-slow-clap"
|
name = "ghost-slow-clap"
|
||||||
version = "0.4.7"
|
version = "0.4.5"
|
||||||
description = "Applause protocol for the EVM bridge"
|
description = "Applause protocol for the EVM bridge"
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
|
|||||||
@ -725,12 +725,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
let (current_commits, current_last_updated) = current_commitments
|
let (current_commits, current_last_updated) = current_commitments
|
||||||
.get(&authority_index)
|
.get(&authority_index)
|
||||||
.map(|details| {
|
.map(|details| (details.commits + 1, details.last_updated))
|
||||||
(
|
|
||||||
details.commits.saturating_add(1),
|
|
||||||
details.last_updated.saturating_add(COMMITMENT_DELAY_MILLIS),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.unwrap_or((1, 0));
|
.unwrap_or((1, 0));
|
||||||
|
|
||||||
ensure!(
|
ensure!(
|
||||||
@ -788,18 +783,34 @@ impl<T: Config> Pallet<T> {
|
|||||||
|
|
||||||
fn start_slow_clapping(block_number: BlockNumberFor<T>) -> OffchainResult<T, ()> {
|
fn start_slow_clapping(block_number: BlockNumberFor<T>) -> OffchainResult<T, ()> {
|
||||||
let session_index = T::ValidatorSet::session_index();
|
let session_index = T::ValidatorSet::session_index();
|
||||||
let networks = T::NetworkDataHandler::iter().collect::<Vec<_>>();
|
let networks_len = T::NetworkDataHandler::iter().count();
|
||||||
let network_index = block_number
|
let network_in_use = T::NetworkDataHandler::iter()
|
||||||
.into()
|
.nth(
|
||||||
.as_usize()
|
block_number
|
||||||
.checked_rem(networks.len())
|
.into()
|
||||||
.unwrap_or_default();
|
.as_usize()
|
||||||
|
.checked_rem(networks_len)
|
||||||
let network_in_use = networks
|
.unwrap_or_default(),
|
||||||
.iter()
|
)
|
||||||
.nth(network_index)
|
|
||||||
.ok_or(OffchainErr::NoStoredNetworks)?;
|
.ok_or(OffchainErr::NoStoredNetworks)?;
|
||||||
|
|
||||||
|
let network_id_encoded = network_in_use.0.encode();
|
||||||
|
|
||||||
|
let rate_limit_delay_key = Self::create_storage_key(b"rate-limit-", &network_id_encoded);
|
||||||
|
let rate_limit_delay = Self::read_persistent_offchain_storage(
|
||||||
|
&rate_limit_delay_key,
|
||||||
|
network_in_use.1.rate_limit_delay,
|
||||||
|
);
|
||||||
|
|
||||||
|
let network_lock_key = Self::create_storage_key(b"network-lock-", &network_id_encoded);
|
||||||
|
let block_until =
|
||||||
|
rt_offchain::Duration::from_millis(rate_limit_delay.max(MIN_LOCK_GUARD_PERIOD));
|
||||||
|
let mut network_lock = StorageLock::<Time>::with_deadline(&network_lock_key, block_until);
|
||||||
|
|
||||||
|
let _lock_guard = network_lock
|
||||||
|
.try_lock()
|
||||||
|
.map_err(|_| OffchainErr::OffchainTimeoutPeriod(network_in_use.0))?;
|
||||||
|
|
||||||
log::info!(
|
log::info!(
|
||||||
target: LOG_TARGET,
|
target: LOG_TARGET,
|
||||||
"👻 Offchain worker started for network #{:?} at block #{:?}",
|
"👻 Offchain worker started for network #{:?} at block #{:?}",
|
||||||
@ -807,15 +818,6 @@ impl<T: Config> Pallet<T> {
|
|||||||
block_number,
|
block_number,
|
||||||
);
|
);
|
||||||
|
|
||||||
let network_id_encoded = network_in_use.0.encode();
|
|
||||||
let network_lock_key = Self::create_storage_key(b"network-lock-", &network_id_encoded);
|
|
||||||
let lock_until = rt_offchain::Duration::from_millis(MIN_LOCK_GUARD_PERIOD);
|
|
||||||
let mut network_lock = StorageLock::<Time>::with_deadline(&network_lock_key, lock_until);
|
|
||||||
|
|
||||||
let _lock_guard = network_lock
|
|
||||||
.try_lock()
|
|
||||||
.map_err(|_| OffchainErr::OffchainTimeoutPeriod(network_in_use.0))?;
|
|
||||||
|
|
||||||
Self::do_evm_claps_or_save_block(session_index, network_in_use.0, &network_in_use.1)
|
Self::do_evm_claps_or_save_block(session_index, network_in_use.0, &network_in_use.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1008,8 +1008,8 @@ fn should_disable_on_commitment_inactivity() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// two block commitments
|
// two block commitments
|
||||||
for extra_time in 1..=3 {
|
for extra_time in 0..=2 {
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS + extra_time;
|
block_commitment.last_updated += extra_time;
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
assert_ok!(do_block_commitment(
|
assert_ok!(do_block_commitment(
|
||||||
session_index,
|
session_index,
|
||||||
@ -1066,9 +1066,9 @@ fn should_disable_on_commitment_block_deviation() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// two block commitments
|
// two block commitments
|
||||||
for extra_time in 1..=3 {
|
for extra_time in 0..=2 {
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS + extra_time;
|
block_commitment.last_updated += extra_time;
|
||||||
bad_block_commitment.last_updated += COMMITMENT_DELAY_MILLIS + extra_time;
|
bad_block_commitment.last_updated += extra_time;
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
assert_ok!(do_block_commitment(
|
assert_ok!(do_block_commitment(
|
||||||
session_index,
|
session_index,
|
||||||
@ -1093,73 +1093,6 @@ fn should_disable_on_commitment_block_deviation() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn should_throw_error_on_fast_commitments() {
|
|
||||||
let (network_id, _, _) = generate_unique_hash(None, None, None, None, None);
|
|
||||||
|
|
||||||
new_test_ext().execute_with(|| {
|
|
||||||
let session_index = advance_session_and_get_index();
|
|
||||||
prepare_evm_network(None, None);
|
|
||||||
|
|
||||||
let timestamp = SystemTime::now()
|
|
||||||
.duration_since(UNIX_EPOCH)
|
|
||||||
.expect("Time went backwards")
|
|
||||||
.as_millis() as u64;
|
|
||||||
|
|
||||||
let mut block_commitment = CommitmentDetails {
|
|
||||||
last_stored_block: 9_500_000,
|
|
||||||
commits: 420,
|
|
||||||
last_updated: timestamp,
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_ok!(do_block_commitment(
|
|
||||||
session_index,
|
|
||||||
network_id,
|
|
||||||
0,
|
|
||||||
&block_commitment
|
|
||||||
));
|
|
||||||
assert_err!(
|
|
||||||
do_block_commitment(session_index, network_id, 0, &block_commitment),
|
|
||||||
Error::<Runtime>::TimeWentBackwards,
|
|
||||||
);
|
|
||||||
|
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS / 2;
|
|
||||||
assert_err!(
|
|
||||||
do_block_commitment(session_index, network_id, 0, &block_commitment),
|
|
||||||
Error::<Runtime>::TimeWentBackwards,
|
|
||||||
);
|
|
||||||
|
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS / 2;
|
|
||||||
assert_err!(
|
|
||||||
do_block_commitment(session_index, network_id, 0, &block_commitment),
|
|
||||||
Error::<Runtime>::TimeWentBackwards,
|
|
||||||
);
|
|
||||||
|
|
||||||
block_commitment.last_updated += 1;
|
|
||||||
assert_ok!(do_block_commitment(
|
|
||||||
session_index,
|
|
||||||
network_id,
|
|
||||||
0,
|
|
||||||
&block_commitment
|
|
||||||
));
|
|
||||||
|
|
||||||
block_commitment.last_updated = timestamp;
|
|
||||||
assert_err!(
|
|
||||||
do_block_commitment(session_index, network_id, 0, &block_commitment),
|
|
||||||
Error::<Runtime>::TimeWentBackwards,
|
|
||||||
);
|
|
||||||
|
|
||||||
for commitment_details in BlockCommitments::<Runtime>::get(network_id).values() {
|
|
||||||
assert_eq!(commitment_details.last_stored_block, 9_500_000);
|
|
||||||
assert_eq!(
|
|
||||||
commitment_details.last_updated,
|
|
||||||
timestamp + COMMITMENT_DELAY_MILLIS + 1
|
|
||||||
);
|
|
||||||
assert_eq!(commitment_details.commits, 2);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_not_offend_disabled_authorities() {
|
fn should_not_offend_disabled_authorities() {
|
||||||
let (network_id, _, _) = generate_unique_hash(None, None, None, None, None);
|
let (network_id, _, _) = generate_unique_hash(None, None, None, None, None);
|
||||||
@ -1186,8 +1119,8 @@ fn should_not_offend_disabled_authorities() {
|
|||||||
Session::disable_index(3);
|
Session::disable_index(3);
|
||||||
|
|
||||||
// two block commitments
|
// two block commitments
|
||||||
for extra_time in 1..=3 {
|
for extra_time in 0..=2 {
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS + extra_time;
|
block_commitment.last_updated += extra_time;
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
assert_ok!(do_block_commitment(
|
assert_ok!(do_block_commitment(
|
||||||
session_index,
|
session_index,
|
||||||
@ -1231,8 +1164,8 @@ fn should_not_slash_by_applause_if_disabled_by_commitment() {
|
|||||||
Session::disable_index(3);
|
Session::disable_index(3);
|
||||||
|
|
||||||
// two block commitments
|
// two block commitments
|
||||||
for extra_time in 1..=3 {
|
for extra_time in 0..=2 {
|
||||||
block_commitment.last_updated += COMMITMENT_DELAY_MILLIS + extra_time;
|
block_commitment.last_updated += extra_time;
|
||||||
for i in 0..3 {
|
for i in 0..3 {
|
||||||
assert_ok!(do_block_commitment(
|
assert_ok!(do_block_commitment(
|
||||||
session_index,
|
session_index,
|
||||||
@ -1270,18 +1203,20 @@ fn should_not_nullify_on_incorrect_block_commitment() {
|
|||||||
|
|
||||||
for i in 0..4 {
|
for i in 0..4 {
|
||||||
assert_ok!(do_block_commitment(
|
assert_ok!(do_block_commitment(
|
||||||
session_index,
|
session_index,
|
||||||
network_id,
|
network_id,
|
||||||
i,
|
i,
|
||||||
&block_commitment
|
&block_commitment
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
block_commitment.last_updated = 0;
|
block_commitment.last_updated = 0;
|
||||||
assert_err!(
|
assert_err!(do_block_commitment(
|
||||||
do_block_commitment(session_index, network_id, 3, &block_commitment),
|
session_index,
|
||||||
Error::<Runtime>::TimeWentBackwards
|
network_id,
|
||||||
);
|
3,
|
||||||
|
&block_commitment),
|
||||||
|
Error::<Runtime>::TimeWentBackwards);
|
||||||
|
|
||||||
for commitment_details in BlockCommitments::<Runtime>::get(network_id).values() {
|
for commitment_details in BlockCommitments::<Runtime>::get(network_id).values() {
|
||||||
assert_eq!(commitment_details.last_stored_block, 9_500_000);
|
assert_eq!(commitment_details.last_stored_block, 9_500_000);
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "casper-runtime"
|
name = "casper-runtime"
|
||||||
version = "3.5.36"
|
version = "3.5.35"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
description = "Runtime of the Casper Network"
|
description = "Runtime of the Casper Network"
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|||||||
@ -118,7 +118,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
impl_name: create_runtime_str!("casper-svengali"),
|
impl_name: create_runtime_str!("casper-svengali"),
|
||||||
authoring_version: 0,
|
authoring_version: 0,
|
||||||
spec_version: 3,
|
spec_version: 3,
|
||||||
impl_version: 2,
|
impl_version: 1,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
transaction_version: 1,
|
transaction_version: 1,
|
||||||
state_version: 1,
|
state_version: 1,
|
||||||
|
|||||||
@ -227,7 +227,6 @@ if [[ $HARD_RESET = true ]]; then
|
|||||||
sudo rm -rf "$BASE_PATH/chains/casper_staging_testnet"
|
sudo rm -rf "$BASE_PATH/chains/casper_staging_testnet"
|
||||||
|
|
||||||
cd $PROJECT_FOLDER
|
cd $PROJECT_FOLDER
|
||||||
git switch main
|
|
||||||
git pull origin main
|
git pull origin main
|
||||||
echo "[+] starting build in 3 seconds..."
|
echo "[+] starting build in 3 seconds..."
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user