-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Ignore messages with duplicated nonces #2375
base: master
Are you sure you want to change the base?
Changes from all commits
ee44841
f0f34d6
3e858d9
7270cd0
fe970df
d355d48
6d1edd6
3e834c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -812,7 +812,7 @@ where | |
D: KeyValueInspect<Column = Column>, | ||
{ | ||
let forced_transactions = if self.relayer.enabled() { | ||
self.process_da( | ||
self.process_l1_events( | ||
block_height, | ||
da_block_height, | ||
data, | ||
|
@@ -875,7 +875,7 @@ where | |
} | ||
} | ||
|
||
fn process_da<D>( | ||
fn process_l1_events<D>( | ||
&mut self, | ||
block_height: BlockHeight, | ||
da_block_height: DaBlockHeight, | ||
|
@@ -916,12 +916,21 @@ where | |
if message.da_height() != da_height { | ||
return Err(ExecutorError::RelayerGivesIncorrectMessages) | ||
} | ||
block_storage_tx | ||
.storage_as_mut::<Messages>() | ||
.insert(message.nonce(), &message)?; | ||
execution_data | ||
.events | ||
.push(ExecutorEvent::MessageImported(message)); | ||
let message_nonce = message.nonce(); | ||
let message_event = if !block_storage_tx | ||
.storage_as_ref::<Messages>() | ||
.contains_key(message_nonce)? | ||
{ | ||
block_storage_tx | ||
.storage_as_mut::<Messages>() | ||
.insert(message_nonce, &message)?; | ||
ExecutorEvent::MessageImported(message) | ||
} else { | ||
let reason = | ||
"Message with the same nonce already exists".to_string(); | ||
ExecutorEvent::MessageIgnored { message, reason } | ||
}; | ||
Comment on lines
+920
to
+932
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure even how do we want to handle this case. Right now you don't handle the situation mentioned by @Voxelot .
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
You mean if a message with the same nonce gets spent before we check for nonce collisions, it will get added still. Right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. And I think it is okay behavior if L1 contracts emit the message with the same nonce. It is not our business to decide is it bad or not in this situation=D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then maybe we want a data structure that allows us to store multiple messages with colliding nonces? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, only one message should be active at the time. |
||
execution_data.events.push(message_event); | ||
} | ||
Event::Transaction(relayed_tx) => { | ||
let id = relayed_tx.id(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
//! Types related to executor service. | ||
|
||
#[cfg(feature = "alloc")] | ||
use alloc::{ | ||
string::String, | ||
vec::Vec, | ||
}; | ||
|
||
use crate::{ | ||
blockchain::{ | ||
block::Block, | ||
|
@@ -34,12 +40,6 @@ use crate::{ | |
services::Uncommitted, | ||
}; | ||
|
||
#[cfg(feature = "alloc")] | ||
use alloc::{ | ||
string::String, | ||
vec::Vec, | ||
}; | ||
|
||
/// The alias for executor result. | ||
pub type Result<T> = core::result::Result<T, Error>; | ||
/// The uncommitted result of the block production execution. | ||
|
@@ -131,6 +131,13 @@ impl<DatabaseTransaction> UncommittedResult<DatabaseTransaction> { | |
pub enum Event { | ||
/// Imported a new spendable message from the relayer. | ||
MessageImported(Message), | ||
/// Ignored a message from the relayer. | ||
MessageIgnored { | ||
/// Ignored message | ||
message: Message, | ||
/// The reason for ignoring the message | ||
reason: String, | ||
}, | ||
Comment on lines
+134
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't add a new event at the middle since it is a breaking change for the WASM interface, basically you break all nodes in the network with this update and forces them to use a new Plus, I don't think that we even need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fair. It was an afterthought and added a breaking section the the CHANGELOG to flag for this reason. |
||
/// The message was consumed by the transaction. | ||
MessageConsumed(Message), | ||
/// Created a new spendable coin, produced by the transaction. | ||
|
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.
May I ask you to rename this method please?=D
message.id()
for me meansMessageId
return type, while it is not true.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.
There is already a
nonce
method that returns the same thing asid
. Very silly.