Skip to content

Commit

Permalink
move pegout graphs from config to state
Browse files Browse the repository at this point in the history
  • Loading branch information
ProofOfKeags committed Mar 6, 2025
1 parent bfb80c2 commit 90ca13c
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 117 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/duty-tracker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ musig2.workspace = true
serde.workspace = true
sqlx.workspace = true
strata-bridge-primitives.workspace = true
strata-bridge-stake-chain.workspace = true
strata-bridge-tx-graph.workspace = true
strata-btcio.workspace = true
strata-p2p.workspace = true
Expand Down
6 changes: 3 additions & 3 deletions crates/duty-tracker/src/contract_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,16 @@ impl ContractManagerCtx {
})
.collect::<Result<BTreeMap<OperatorIdx, PegOutGraphSummary>, TxGraphError>>()?;
let (sm, duty) = ContractSM::new(
self.build_context.own_index(),
todo!(), // TODO(proofofkeags): We need to get our own operator pubkey.
self.build_context.pubkey_table().clone(),
height,
height + REFUND_DELAY,
deposit_tx,
peg_out_graphs,
);

self.contract_persister.init(sm.cfg(), sm.state()).await?;

self.active_contracts.insert(txid, sm);

self.execute_duty(duty);

// It's impossible for this transaction to be routable to another CSM so we move on
Expand Down
17 changes: 6 additions & 11 deletions crates/duty-tracker/src/contract_persister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl ContractPersister {
deposit_txid CHAR(64) NOT NULL UNIQUE,
deposit_tx VARBINARY NOT NULL,
operator_set VARBINARY NOT NULL,
perspective SMALLINT NOT NULL,
perspective CHAR(64) NOT NULL,
peg_out_graphs VARBINARY NOT NULL,
state VARBINARY NOT NULL,
);
Expand All @@ -64,8 +64,7 @@ impl ContractPersister {
.bind(cfg.deposit_tx.compute_txid().to_string())
.bind(bincode::serialize(&cfg.deposit_tx)?)
.bind(bincode::serialize(&cfg.operator_set)?)
.bind(cfg.perspective)
.bind(bincode::serialize(&cfg.peg_out_graphs)?)
.bind(bincode::serialize(&cfg.perspective)?)
.bind(bincode::serialize(&state)?)
.execute(&self.pool)
.await
Expand Down Expand Up @@ -103,18 +102,16 @@ impl ContractPersister {
"#
).bind(deposit_txid.to_string()).fetch_one(&self.pool).await.map_err(|_|PersistErr)?;
let deposit_tx = bincode::deserialize(row.try_get("deposit_tx").map_err(|_| PersistErr)?)?;
let perspective = row.try_get("perspective").map_err(|_| PersistErr)?;
let perspective =
bincode::deserialize(row.try_get("perspective").map_err(|_| PersistErr)?)?;
let operator_set =
bincode::deserialize(row.try_get("operator_set").map_err(|_| PersistErr)?)?;
let peg_out_graphs =
bincode::deserialize(row.try_get("peg_out_graphs").map_err(|_| PersistErr)?)?;
let state = bincode::deserialize(row.try_get("state").map_err(|_| PersistErr)?)?;
Ok((
ContractCfg {
perspective,
operator_set,
deposit_tx,
peg_out_graphs,
},
state,
))
Expand All @@ -132,18 +129,16 @@ impl ContractPersister {
.map(|row| {
let deposit_tx =
bincode::deserialize(row.try_get("deposit_tx").map_err(|_| PersistErr)?)?;
let perspective = row.try_get("perspective").map_err(|_| PersistErr)?;
let perspective =
bincode::deserialize(row.try_get("perspective").map_err(|_| PersistErr)?)?;
let operator_set =
bincode::deserialize(row.try_get("operator_set").map_err(|_| PersistErr)?)?;
let peg_out_graphs =
bincode::deserialize(row.try_get("peg_out_graphs").map_err(|_| PersistErr)?)?;
let state = bincode::deserialize(row.try_get("state").map_err(|_| PersistErr)?)?;
Ok((
ContractCfg {
perspective,
operator_set,
deposit_tx,
peg_out_graphs,
},
state,
))
Expand Down
Loading

0 comments on commit 90ca13c

Please sign in to comment.