This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update p2p handshake and tmp disable some validations
- Loading branch information
1 parent
9f0bd70
commit edc3580
Showing
9 changed files
with
71 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,5 @@ serde_json.workspace = true | |
[features] | ||
bsc = [ | ||
"reth-primitives/bsc", | ||
"reth-network/bsc" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,45 @@ | ||
use alloy_rlp::{RlpDecodable, RlpEncodable}; | ||
use serde::{Deserialize, Serialize}; | ||
use reth_codecs::derive_arbitrary; | ||
use reth_primitives::{Bytes, B256, hex}; | ||
|
||
/// UpdateStatus packet introduced in BSC to notify peers whether to broadcast transaction or not. | ||
/// It is used during the p2p handshake. | ||
#[derive_arbitrary(rlp)] | ||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct UpgradeStatus { | ||
pub extension : UpgradeStatusExtension | ||
pub extension: UpgradeStatusExtension, | ||
} | ||
|
||
/// The extension to define whether to enable or disable the flag. | ||
/// This flag currently is ignored, and will be supported later. | ||
#[derive_arbitrary(rlp)] | ||
#[derive(Debug, Clone, PartialEq, Eq, RlpEncodable, RlpDecodable)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct UpgradeStatusExtension { | ||
pub disable_peer_tx_broadcast: bool | ||
// TODO: support disable_peer_tx_broadcast flag | ||
pub disable_peer_tx_broadcast: bool, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use std::path::Path; | ||
use alloy_rlp::Encodable; | ||
use reth_primitives::hex; | ||
use crate::{EthMessage, ProtocolMessage}; | ||
|
||
#[test] | ||
fn test_encode_upgrade_status() { | ||
let extension = UpgradeStatusExtension{disable_peer_tx_broadcast: true}; | ||
let extension = UpgradeStatusExtension { disable_peer_tx_broadcast: true }; | ||
let mut buffer = Vec::<u8>::new(); | ||
let _ = extension.encode(&mut buffer); | ||
println!("extension hex: {}", hex::encode(buffer.clone())); | ||
assert_eq!("c101", hex::encode(buffer.clone())); | ||
|
||
let upgrade_status = UpgradeStatus{ | ||
extension: extension, | ||
let upgrade_status = UpgradeStatus { | ||
extension, | ||
}; | ||
let mut buffer = Vec::<u8>::new(); | ||
let _ = upgrade_status.encode(&mut buffer); | ||
println!("upgrade_status hex: {}", hex::encode(buffer.clone())); | ||
|
||
// let result = alloy_rlp::encode(ProtocolMessage::from(EthMessage::UpgradeStatus(UpgradeStatus{ | ||
// extension: buffer, | ||
// }))); | ||
// println!("message hex: {}", hex::encode(result)) | ||
assert_eq!("c2c101", hex::encode(buffer.clone())); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters