diff --git a/actors/market/src/lib.rs b/actors/market/src/lib.rs index c1cc47960..2c3b73f74 100644 --- a/actors/market/src/lib.rs +++ b/actors/market/src/lib.rs @@ -745,6 +745,13 @@ impl Actor { // No continue below here, to ensure state changes are consistent. activated_deals.insert(deal_id); + emit::deal_activated( + rt, + deal_id, + proposal.client.id().unwrap(), + proposal.provider.id().unwrap(), + )?; + // Remove any verified allocation ID for the pending deal. pending_deal_allocation_ids.delete(&deal_id)?; diff --git a/actors/market/tests/sector_content_changed.rs b/actors/market/tests/sector_content_changed.rs index 2366ba485..59439d38b 100644 --- a/actors/market/tests/sector_content_changed.rs +++ b/actors/market/tests/sector_content_changed.rs @@ -73,6 +73,15 @@ fn simple_one_sector() { minimum_commitment_epoch: END_EPOCH + 10, added: pieces, }]; + for deal_id in deal_ids.iter().rev() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } let ret = sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); assert_eq!(1, ret.sectors.len()); assert_eq!(3, ret.sectors[0].added.len()); @@ -117,6 +126,15 @@ fn simple_multiple_sectors() { added: pieces[2..3].to_vec(), }, ]; + for deal_id in deal_ids.iter() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } let ret = sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); assert_eq!(3, ret.sectors.len()); assert_eq!(vec![PieceReturn { accepted: true }], ret.sectors[0].added); @@ -142,6 +160,15 @@ fn new_deal_existing_sector() { minimum_commitment_epoch: END_EPOCH + 10, added: pieces[1..3].to_vec(), }]; + for deal_id in deal_ids[1..3].iter() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); let changes = vec![SectorChanges { @@ -149,6 +176,15 @@ fn new_deal_existing_sector() { minimum_commitment_epoch: END_EPOCH + 10, added: pieces[0..1].to_vec(), }]; + for deal_id in deal_ids[0..1].iter() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); // All deal IDs are stored under the right sector, in correct order. @@ -244,6 +280,16 @@ fn failures_isolated() { }, ]; + // only first and last pieces emit an event + for deal_id in [deal_ids.first().unwrap(), deal_ids.last().unwrap()] { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } let ret = sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); assert_eq!(3, ret.sectors.len()); // Broken second piece still allows first piece in same sector to activate. @@ -278,6 +324,15 @@ fn rejects_duplicates_in_same_sector() { added: vec![pieces[0].clone(), pieces[0].clone(), pieces[1].clone()], }, ]; + for deal_id in deal_ids.iter() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } let ret = sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); assert_eq!(1, ret.sectors.len()); // The first piece succeeds just once, the second piece succeeds too. @@ -323,6 +378,15 @@ fn rejects_duplicates_across_sectors() { added: vec![pieces[0].clone(), pieces[1].clone(), pieces[2].clone()], }, ]; + for deal_id in deal_ids.iter() { + harness::expect_emitted( + &rt, + "deal-activated", + *deal_id, + CLIENT_ADDR.id().unwrap(), + MINER_ADDRESSES.provider.id().unwrap(), + ); + } let ret = sector_content_changed(&rt, PROVIDER_ADDR, changes).unwrap(); assert_eq!(3, ret.sectors.len()); // Succeeds in the first time. diff --git a/integration_tests/src/tests/prove_commit3_test.rs b/integration_tests/src/tests/prove_commit3_test.rs index 17e5c4d47..ab94e0b89 100644 --- a/integration_tests/src/tests/prove_commit3_test.rs +++ b/integration_tests/src/tests/prove_commit3_test.rs @@ -323,6 +323,13 @@ pub fn prove_commit_sectors2_test(v: &dyn VM) { ), value: Some(TokenAmount::zero()), subinvocs: Some(vec![]), + events: deal_ids_s3 + .iter() + .chain(deal_ids_s4.iter()) + .map(|deal_id| { + Expect::build_market_event("deal-activated", *deal_id, client_id, miner_id) + }) + .collect::>(), ..Default::default() }, ]), diff --git a/integration_tests/src/tests/replica_update3_test.rs b/integration_tests/src/tests/replica_update3_test.rs index 321512bc6..de31f6e2a 100644 --- a/integration_tests/src/tests/replica_update3_test.rs +++ b/integration_tests/src/tests/replica_update3_test.rs @@ -387,6 +387,14 @@ pub fn prove_replica_update2_test(v: &dyn VM) { ), value: Some(TokenAmount::zero()), subinvocs: Some(vec![]), + events: deal_ids_s3 + .iter() + .chain(deal_ids_s4.iter()) + .map(|deal_id| { + Expect::build_market_event("deal-activated", *deal_id, client_id, miner_id) + }) + .collect::>(), + ..Default::default() }, ]),