Skip to content
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

feat: modify protocol message #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions examples/client-cardano-transaction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ async fn main() -> MithrilResult<()> {
.unwrap();

info!(logger, "Verifying the proof…",);
info!(logger, "{}", format!("{:?}", cardano_transaction_proof),);
let verified_transactions = cardano_transaction_proof.verify().unwrap();

info!(
logger,
"verified_transactions {}",
format!("{:?}", verified_transactions),
);
info!(
logger,
"Fetching the associated certificate and verifying the certificate chain…",
Expand All @@ -67,7 +72,16 @@ async fn main() -> MithrilResult<()> {
.verify_chain(&cardano_transaction_proof.certificate_hash)
.await
.unwrap();

info!(
logger,
"certificate {}",
format!("{:?}", certificate),
);
info!(
logger,
"certificate {}",
format!("{:?}", certificate),
);
info!(
logger,
"Verify that the proof is signed in the associated certificate",
Expand Down
1 change: 1 addition & 0 deletions mithril-aggregator/src/dependency_injection/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ impl DependenciesBuilder {
Ok(self.transaction_repository.as_ref().cloned().unwrap())
}

// hadelive(pallas)
async fn build_chain_block_reader(&mut self) -> Result<Arc<Mutex<dyn ChainBlockReader>>> {
let chain_block_reader = PallasChainReader::new(
&self.configuration.cardano_node_socket_path,
Expand Down
2 changes: 1 addition & 1 deletion mithril-aggregator/src/entities/open_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct OpenMessage {
pub signed_entity_type: SignedEntityType,

/// Message used by the Mithril Protocol
pub protocol_message: ProtocolMessage,
pub protocol_message: ProtocolMessage, // TODO(hadelive): update ProtocolMessage

/// Has this message been converted into a Certificate?
pub is_certified: bool,
Expand Down
3 changes: 3 additions & 0 deletions mithril-aggregator/src/runtime/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
.with_context(|| format!("CertifierService can not get open message for signed_entity_type: '{signed_entity_type}'"))?)
}

//TODO(hadelive): update OpenMessage
async fn get_current_non_certified_open_message(
&self,
current_time_point: &TimePoint,
Expand All @@ -243,6 +244,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
.with_context(|| format!("AggregatorRunner can not get current open message for signed entity type: '{}'", &signed_entity_type))?;
match current_open_message {
None => {
// TODO(hadelive): update protocol message
let protocol_message = self.compute_protocol_message(&signed_entity_type).await.with_context(|| format!("AggregatorRunner can not compute protocol message for signed_entity_type: '{signed_entity_type}'"))?;
let open_message_new = self.create_open_message(&signed_entity_type, &protocol_message)
.await
Expand Down Expand Up @@ -315,6 +317,7 @@ impl AggregatorRunnerTrait for AggregatorRunner {
.await
}

// TODO(hadelive)
async fn compute_protocol_message(
&self,
signed_entity_type: &SignedEntityType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ impl CardanoTransactionsImporter {
.get_transactions_in_range(block_range.start..block_range.end)
.await?;

// TODO(hadelive): filter bridge transactions or attach transaction data (datum)
if transactions.is_empty() {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions mithril-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ kes-summed-ed25519 = { version = "0.2.1", features = [
mithril-stm = { path = "../mithril-stm", version = "0.3", default-features = false }
nom = "7.1.3"
pallas-addresses = { version = "0.30.2", optional = true }
pallas-codec = { version = "0.30.2", optional = true }
pallas-codec = { version = "0.30.2" }
pallas-hardano = { version = "0.30.2", optional = true }
pallas-network = { version = "0.30.2", optional = true }
pallas-primitives = { version = "0.30.2", optional = true }
pallas-primitives = { version = "0.30.2" }
pallas-traverse = { version = "0.30.2", optional = true }
rand_chacha = "0.3.1"
rand_core = "0.6.4"
Expand Down Expand Up @@ -100,10 +100,10 @@ fs = [
"tokio/fs",
"tokio/process",
"dep:pallas-addresses",
"dep:pallas-codec",
# "dep:pallas-codec",
"dep:pallas-hardano",
"dep:pallas-network",
"dep:pallas-primitives",
# "dep:pallas-primitives",
"dep:pallas-traverse",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ impl ChainReaderBlockStreamer {

#[cfg(test)]
mod tests {
use std::collections::HashMap;

use crate::cardano_block_scanner::ScannedBlock;
use crate::chain_reader::FakeChainReader;
use crate::entities::SlotNumber;
Expand All @@ -189,6 +191,7 @@ mod tests {
until_block_number,
SlotNumber(100),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -197,6 +200,7 @@ mod tests {
until_block_number,
SlotNumber(100),
Vec::<&str>::new(),
HashMap::new(),
),
},
])));
Expand Down Expand Up @@ -231,6 +235,7 @@ mod tests {
until_block_number,
SlotNumber(100),
Vec::<&str>::new(),
HashMap::new(),
)])),
scanned_blocks
);
Expand All @@ -249,6 +254,7 @@ mod tests {
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -257,6 +263,7 @@ mod tests {
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -265,6 +272,7 @@ mod tests {
BlockNumber(3),
SlotNumber(30),
Vec::<&str>::new(),
HashMap::new(),
),
},
])));
Expand All @@ -282,8 +290,20 @@ mod tests {

assert_eq!(
Some(ChainScannedBlocks::RollForwards(vec![
ScannedBlock::new("hash-1", BlockNumber(1), SlotNumber(10), Vec::<&str>::new()),
ScannedBlock::new("hash-2", BlockNumber(2), SlotNumber(20), Vec::<&str>::new())
ScannedBlock::new(
"hash-1",
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
ScannedBlock::new(
"hash-2",
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
)
])),
scanned_blocks,
);
Expand All @@ -308,6 +328,7 @@ mod tests {
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -316,6 +337,7 @@ mod tests {
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
),
},
])));
Expand All @@ -333,8 +355,20 @@ mod tests {

assert_eq!(
Some(ChainScannedBlocks::RollForwards(vec![
ScannedBlock::new("hash-1", BlockNumber(1), SlotNumber(10), Vec::<&str>::new()),
ScannedBlock::new("hash-2", BlockNumber(2), SlotNumber(20), Vec::<&str>::new())
ScannedBlock::new(
"hash-1",
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
ScannedBlock::new(
"hash-2",
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
)
])),
scanned_blocks,
);
Expand All @@ -353,6 +387,7 @@ mod tests {
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -361,6 +396,7 @@ mod tests {
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -369,6 +405,7 @@ mod tests {
BlockNumber(3),
SlotNumber(30),
Vec::<&str>::new(),
HashMap::new(),
),
},
])));
Expand All @@ -386,8 +423,20 @@ mod tests {
let scanned_blocks = block_streamer.poll_next().await.expect("poll_next failed");
assert_eq!(
Some(ChainScannedBlocks::RollForwards(vec![
ScannedBlock::new("hash-1", BlockNumber(1), SlotNumber(10), Vec::<&str>::new()),
ScannedBlock::new("hash-2", BlockNumber(2), SlotNumber(20), Vec::<&str>::new())
ScannedBlock::new(
"hash-1",
BlockNumber(1),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
ScannedBlock::new(
"hash-2",
BlockNumber(2),
SlotNumber(20),
Vec::<&str>::new(),
HashMap::new(),
)
])),
scanned_blocks,
);
Expand All @@ -402,7 +451,8 @@ mod tests {
"hash-3",
BlockNumber(3),
SlotNumber(30),
Vec::<&str>::new()
Vec::<&str>::new(),
HashMap::new(),
),])),
scanned_blocks,
);
Expand Down Expand Up @@ -488,6 +538,7 @@ mod tests {
BlockNumber(80),
SlotNumber(8),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -496,6 +547,7 @@ mod tests {
BlockNumber(90),
SlotNumber(9),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -504,6 +556,7 @@ mod tests {
BlockNumber(100),
SlotNumber(10),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollBackward {
Expand All @@ -524,8 +577,20 @@ mod tests {

assert_eq!(
Some(ChainScannedBlocks::RollForwards(vec![
ScannedBlock::new("hash-8", BlockNumber(80), SlotNumber(8), Vec::<&str>::new()),
ScannedBlock::new("hash-9", BlockNumber(90), SlotNumber(9), Vec::<&str>::new())
ScannedBlock::new(
"hash-8",
BlockNumber(80),
SlotNumber(8),
Vec::<&str>::new(),
HashMap::new(),
),
ScannedBlock::new(
"hash-9",
BlockNumber(90),
SlotNumber(9),
Vec::<&str>::new(),
HashMap::new(),
)
])),
scanned_blocks,
);
Expand All @@ -545,6 +610,7 @@ mod tests {
BlockNumber(80),
SlotNumber(8),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollForward {
Expand All @@ -553,6 +619,7 @@ mod tests {
BlockNumber(90),
SlotNumber(9),
Vec::<&str>::new(),
HashMap::new(),
),
},
ChainBlockNextAction::RollBackward {
Expand Down
Loading
Loading