@@ -1147,6 +1147,7 @@ impl ContractSM {
1147
1147
// TODO(proofofkeags): thoroughly review this code it is ALMOST CERTAINLY WRONG IN SOME
1148
1148
// SUBTLE WAY.
1149
1149
1150
+ let deposit_txid = self . deposit_txid ( ) ;
1150
1151
match & mut self . state . state {
1151
1152
ContractState :: Requested {
1152
1153
peg_out_graph_inputs,
@@ -1156,14 +1157,6 @@ impl ContractSM {
1156
1157
graph_partials,
1157
1158
..
1158
1159
} => {
1159
- if peg_out_graph_inputs. contains_key ( & signer) {
1160
- let deposit_txid = self . deposit_txid ( ) ;
1161
- warn ! ( "already received operator's ({signer}) deposit setup for contract {deposit_txid}" ) ;
1162
-
1163
- // FIXME: (@Rajil1213) this should return an error
1164
- return Ok ( vec ! [ ] ) ;
1165
- }
1166
-
1167
1160
let pog_input = PegOutGraphInput {
1168
1161
stake_outpoint : OutPoint :: new ( new_stake_tx. compute_txid ( ) , STAKE_VOUT ) ,
1169
1162
withdrawal_fulfillment_outpoint : OutPoint :: new (
@@ -1174,6 +1167,20 @@ impl ContractSM {
1174
1167
wots_public_keys : new_wots_keys. clone ( ) ,
1175
1168
operator_pubkey,
1176
1169
} ;
1170
+
1171
+ if let Some ( existing) = peg_out_graph_inputs. get ( & signer) {
1172
+ warn ! (
1173
+ "already received deposit setup from {signer} for contract {deposit_txid}"
1174
+ ) ;
1175
+ debug_assert_eq ! (
1176
+ & pog_input, existing,
1177
+ "conflicting deposit setup from {signer} for contract {deposit_txid}"
1178
+ ) ;
1179
+
1180
+ // FIXME: (@Rajil1213) this should return an error
1181
+ return Ok ( vec ! [ ] ) ;
1182
+ }
1183
+
1177
1184
peg_out_graph_inputs. insert ( signer, pog_input. clone ( ) ) ;
1178
1185
1179
1186
if peg_out_graph_inputs. len ( ) != self . cfg . operator_table . cardinality ( ) {
@@ -1311,8 +1318,14 @@ impl ContractSM {
1311
1318
) ) ) ;
1312
1319
} ;
1313
1320
1314
- if session_nonces. contains_key ( & signer) {
1321
+ if let Some ( existing ) = session_nonces. get ( & signer) {
1315
1322
warn ! ( %claim_txid, %signer, "already received nonces for graph" ) ;
1323
+ debug_assert_eq ! (
1324
+ & unpacked, existing,
1325
+ "conflicting graph nonces received from {} for claim {}" ,
1326
+ signer, claim_txid
1327
+ ) ;
1328
+
1316
1329
// FIXME: (@Rajil1213) this should return an error
1317
1330
return Ok ( None ) ;
1318
1331
}
@@ -1413,8 +1426,14 @@ impl ContractSM {
1413
1426
) ) ) ;
1414
1427
} ;
1415
1428
1416
- if session_partials. contains_key ( & signer) {
1429
+ if let Some ( existing ) = session_partials. get ( & signer) {
1417
1430
warn ! ( %claim_txid, %signer, "already received signatures for graph" ) ;
1431
+ debug_assert_eq ! (
1432
+ & unpacked, existing,
1433
+ "conflicting graph signatures received from {} for claim {}" ,
1434
+ & signer, & claim_txid
1435
+ ) ;
1436
+
1418
1437
// FIXME: (@Rajil1213) this should return an error
1419
1438
return Ok ( None ) ;
1420
1439
}
@@ -1460,10 +1479,17 @@ impl ContractSM {
1460
1479
signer : P2POperatorPubKey ,
1461
1480
nonce : PubNonce ,
1462
1481
) -> Result < Option < OperatorDuty > , TransitionErr > {
1482
+ let deposit_txid = self . deposit_txid ( ) ;
1463
1483
match & mut self . state . state {
1464
1484
ContractState :: Requested { root_nonces, .. } => {
1465
- if root_nonces. contains_key ( & signer) {
1485
+ if let Some ( existing ) = root_nonces. get ( & signer) {
1466
1486
warn ! ( %signer, "already received nonce for root" ) ;
1487
+ debug_assert_eq ! (
1488
+ & nonce, existing,
1489
+ "conflicting root nonce received from {} for contract {}" ,
1490
+ signer, deposit_txid,
1491
+ ) ;
1492
+
1467
1493
// FIXME: (@Rajil1213) this should return an error
1468
1494
return Ok ( None ) ;
1469
1495
}
@@ -1527,10 +1553,17 @@ impl ContractSM {
1527
1553
signer : P2POperatorPubKey ,
1528
1554
sig : PartialSignature ,
1529
1555
) -> Result < Option < OperatorDuty > , TransitionErr > {
1556
+ let deposit_txid = self . deposit_txid ( ) ;
1530
1557
match & mut self . state . state {
1531
1558
ContractState :: Requested { root_partials, .. } => {
1532
- if root_partials. contains_key ( & signer) {
1559
+ if let Some ( existing ) = root_partials. get ( & signer) {
1533
1560
warn ! ( %signer, "already received signature for root" ) ;
1561
+ debug_assert_eq ! (
1562
+ & sig, existing,
1563
+ "conflicting root signature received from {} for contract {}" ,
1564
+ signer, deposit_txid
1565
+ ) ;
1566
+
1534
1567
// FIXME: (@Rajil1213) this should return an error
1535
1568
return Ok ( None ) ;
1536
1569
}
0 commit comments