massa icon indicating copy to clipboard operation
massa copied to clipboard

Max operation size in protocol

Open damip opened this issue 2 years ago • 2 comments

If an operation is strictly bigger than MAX_BLOCK_SIZE, it is considered invalid => ignore and ban sender

damip avatar Sep 28 '22 09:09 damip

In protocol, we receive a Vec of operations from a node identified with it's NodeID. if only one operation is invalid, we'll ban this node ? and ignore all remaining operations ?

I found this in the current codebase:

https://github.com/massalabs/massa/blob/1863a5348f451af144438d7276858a296b7806d2/massa-protocol-worker/src/protocol_network.rs#L362-L374

Is it already done ? cc @AurelienFT

aoudiamoncef avatar Oct 28 '22 08:10 aoudiamoncef

@aoudiamoncef that's when operations are included in blocks: their total size cannot exceed the max block size. This issue should focus on "free" operations propagating outside of a block.

damip avatar Oct 28 '22 10:10 damip

@aoudiamoncef i think in your case you can do it like this :

.any() stop iter() if one respect the condition :


                if operations.iter().any(|operation| {
                    operation.serialized_size() > self.config.max_serialized_operations_size_per_block
                }) {
                    warn!(
                        "Node id {} sent us an operation which exceed max block size.",
                        node
                    );
                    let _ = self.ban_node(&node).await;
                } else {
                    self.on_operations_received(node, operations, op_timer)
                        .await;
                }

modship avatar Nov 08 '22 13:11 modship

Good catch, any fit better our usecase. Thank you

aoudiamoncef avatar Nov 08 '22 13:11 aoudiamoncef