-
Notifications
You must be signed in to change notification settings - Fork 5
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
SYS-4002: Fix primary validator for summary operations #385
SYS-4002: Fix primary validator for summary operations #385
Conversation
…or_summary_operations' into SYS-4002_Fix_primary_validator_for_summary_operations
pallets/avn/src/lib.rs
Outdated
@@ -181,20 +175,14 @@ pub mod pallet { | |||
|
|||
#[pallet::storage] | |||
#[pallet::getter(fn get_primary_collator)] | |||
pub type PrimaryCollator<T: Config> = StorageValue<_, PrimaryCollatorData, ValueQuery>; | |||
pub type PrimaryCollator<T: Config> = StorageValue<_, u8, ValueQuery>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this to make it more explicit? Something like primaryCollatorIndexForEth
? I also think we should use a large type for the value. u8 give 255 only and its possible we will end up sending more than that. Perhaps a u32
?
pallets/ethereum-events/src/lib.rs
Outdated
let is_primary = | ||
AVN::<T>::is_primary(OperationType::Ethereum, &this_validator.account_id); | ||
if is_primary.is_err() { | ||
let is_primary_validator_for_sending = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let is_primary_validator_for_sending = | |
let is_primary = |
pallets/ethereum-events/src/lib.rs
Outdated
@@ -836,7 +835,7 @@ pub mod pallet { | |||
return InvalidTransaction::Custom(ERROR_CODE_INVALID_EVENT_DATA).into() | |||
} | |||
|
|||
if AVN::<T>::is_primary(OperationType::Ethereum, &result.checked_by) | |||
if AVN::<T>::is_primary_validator_for_sending(&result.checked_by) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if AVN::<T>::is_primary_validator_for_sending(&result.checked_by) | |
if AVN::<T>::is_primary_for_block(&result.checked_by) |
pallets/ethereum-events/src/mock.rs
Outdated
validator: &AccountId, | ||
) -> Result<bool, avn_error<TestRuntime>> { | ||
return AVN::is_primary(op_type, validator) | ||
return AVN::is_primary_validator_for_sending(validator) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return AVN::is_primary_validator_for_sending(validator) | |
return AVN::is_primary_for_block(validator) |
@@ -190,7 +190,7 @@ fn test_is_primary_blocknumber_3() { | |||
ext.execute_with(|| { | |||
let block_number = 3; | |||
let expected_primary = account_id_1(); | |||
let result = EthereumEvents::is_primary(OperationType::Ethereum, &expected_primary); | |||
let result = EthereumEvents::is_primary_validator_for_sending(&expected_primary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let result = EthereumEvents::is_primary_validator_for_sending(&expected_primary); | |
let result = EthereumEvents::is_primary_for_block(&expected_primary); |
@@ -312,7 +312,7 @@ fn is_primary_fails_with_no_validators() { | |||
let mut ext = ExtBuilder::build_default().as_externality(); | |||
ext.execute_with(|| { | |||
let block_number = 1; | |||
let result = EthereumEvents::is_primary(OperationType::Ethereum, &account_id_1()); | |||
let result = EthereumEvents::is_primary_validator_for_sending(&account_id_1()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let result = EthereumEvents::is_primary_validator_for_sending(&account_id_1()); | |
let result = EthereumEvents::is_primary_for_block(&account_id_1()); |
pallets/summary/src/lib.rs
Outdated
@@ -751,7 +751,7 @@ pub mod pallet { | |||
safe_add_block_numbers::<BlockNumberFor<T>>(Self::current_slot(), 1u32.into()) | |||
.map_err(|_| Error::<T>::Overflow)?; | |||
|
|||
let new_validator_account_id = AVN::<T>::advance_primary_validator(OperationType::Avn)?; | |||
let new_validator_account_id = AVN::<T>::advance_primary_validator_for_sending()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be doing that here. The index is only incremented when sending I think.
@@ -152,19 +159,20 @@ mod challenge_slot_if_required { | |||
assert!(pool_state.read().transactions.is_empty()); | |||
|
|||
System::set_block_number(context.block_after_grace_period); | |||
// let challenge = get_valid_challenge(&context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// let challenge = get_valid_challenge(&context); |
@@ -897,7 +897,7 @@ mod end_voting_period { | |||
Summary::set_previous_summary_slot(5); | |||
|
|||
let primary_validator_id = | |||
AVN::<TestRuntime>::advance_primary_validator(OperationType::Avn) | |||
AVN::<TestRuntime>::advance_primary_validator_for_sending() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to advance here? I think only sending should advance.
@@ -131,13 +58,13 @@ mod calling_is_primary_validator_for_ethereum { | |||
let mut ext = ExtBuilder::build_default().with_validators().as_externality(); | |||
ext.execute_with(|| { | |||
let expected_primary = 1; | |||
let eth_index_before: u8 = get_index_based_on_operation_type(&OperationType::Ethereum); | |||
let eth_index_before: u8 = AVN::get_primary_collator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its the getter for the primary collator storage index.
@@ -143,7 +141,7 @@ fn generate_msg_hash<T: pallet::Config>( | |||
} | |||
|
|||
fn assign_sender<T: Config>() -> Result<T::AccountId, Error<T>> { | |||
match AVN::<T>::advance_primary_validator(OperationType::Ethereum) { | |||
match AVN::<T>::advance_primary_validator_for_sending() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Cargo.toml
Outdated
@@ -12,7 +12,7 @@ lto = "fat" | |||
codegen-units = 1 | |||
|
|||
[workspace.package] | |||
version = "5.2.3" | |||
version = "5.2.4" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this
runtime/avn/src/lib.rs
Outdated
@@ -174,7 +174,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |||
spec_name: create_runtime_str!("avn-parachain"), | |||
impl_name: create_runtime_str!("avn-parachain"), | |||
authoring_version: 1, | |||
spec_version: 62, | |||
spec_version: 63, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we revert this change please?
runtime/test/src/lib.rs
Outdated
@@ -169,7 +169,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { | |||
spec_name: create_runtime_str!("avn-test-parachain"), | |||
impl_name: create_runtime_str!("avn-test-parachain"), | |||
authoring_version: 1, | |||
spec_version: 62, | |||
spec_version: 63, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and this too
Proposed changes
Type of change/Merge
🚨What type of change is this PR?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR.Further comments