Skip to content

Commit 56a4389

Browse files
committed
wip
1 parent 1c3f5cc commit 56a4389

8 files changed

Lines changed: 24 additions & 18 deletions

File tree

golem-api-grpc/proto/golem/worker/public_oplog.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ message QueuedCardEventCard {
298298

299299
enum CardInstallFailure {
300300
CARD_INSTALL_FAILURE_UNSPECIFIED = 0;
301+
CARD_INSTALL_FAILURE_CARD_REVOKED = 1;
301302
CARD_INSTALL_FAILURE_NOT_FOUND = 2;
302303
CARD_INSTALL_FAILURE_RECIPIENT_MISMATCH = 3;
303304
CARD_INSTALL_FAILURE_NOT_PERMITTED = 4;

golem-api-grpc/proto/golem/worker/raw_oplog.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ message RawQueuedCardEventCard {
336336

337337
enum RawCardInstallFailure {
338338
RAW_CARD_INSTALL_FAILURE_UNSPECIFIED = 0;
339+
RAW_CARD_INSTALL_FAILURE_CARD_REVOKED = 1;
339340
RAW_CARD_INSTALL_FAILURE_NOT_FOUND = 2;
340341
RAW_CARD_INSTALL_FAILURE_RECIPIENT_MISMATCH = 3;
341342
RAW_CARD_INSTALL_FAILURE_NOT_PERMITTED = 4;

golem-common/src/base_model/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ impl From<QueuedCardEvent> for PublicQueuedCardEvent {
10121012
#[cfg_attr(feature = "full", derive(desert_rust::BinaryCodec))]
10131013
#[cfg_attr(feature = "full", desert(evolution()))]
10141014
pub enum CardInstallFailure {
1015+
CardRevoked,
10151016
NotFound,
10161017
RecipientMismatch,
10171018
NotPermitted,

golem-common/src/model/oplog/protobuf.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ fn card_install_failure_from_proto(
187187
golem_api_grpc::proto::golem::worker::CardInstallFailure::Unspecified => {
188188
Err("Unspecified card install failure".to_string())
189189
}
190+
golem_api_grpc::proto::golem::worker::CardInstallFailure::CardRevoked => {
191+
Ok(CardInstallFailure::CardRevoked)
192+
}
190193
golem_api_grpc::proto::golem::worker::CardInstallFailure::NotFound => {
191194
Ok(CardInstallFailure::NotFound)
192195
}
@@ -203,6 +206,9 @@ fn card_install_failure_to_proto(
203206
value: CardInstallFailure,
204207
) -> golem_api_grpc::proto::golem::worker::CardInstallFailure {
205208
match value {
209+
CardInstallFailure::CardRevoked => {
210+
golem_api_grpc::proto::golem::worker::CardInstallFailure::CardRevoked
211+
}
206212
CardInstallFailure::NotFound => {
207213
golem_api_grpc::proto::golem::worker::CardInstallFailure::NotFound
208214
}
@@ -222,6 +228,9 @@ fn raw_card_install_failure_from_proto(
222228
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::Unspecified => {
223229
Err("Unspecified raw card install failure".to_string())
224230
}
231+
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::CardRevoked => {
232+
Ok(CardInstallFailure::CardRevoked)
233+
}
225234
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::NotFound => {
226235
Ok(CardInstallFailure::NotFound)
227236
}
@@ -238,6 +247,9 @@ fn raw_card_install_failure_to_proto(
238247
value: CardInstallFailure,
239248
) -> golem_api_grpc::proto::golem::worker::RawCardInstallFailure {
240249
match value {
250+
CardInstallFailure::CardRevoked => {
251+
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::CardRevoked
252+
}
241253
CardInstallFailure::NotFound => {
242254
golem_api_grpc::proto::golem::worker::RawCardInstallFailure::NotFound
243255
}

golem-worker-executor/src/durable_host/golem/v1x.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ fn card_install_failure_to_wit(
106106
failure: CardInstallFailure,
107107
) -> golem_api_1_x::host::CardInstallError {
108108
match failure {
109+
CardInstallFailure::CardRevoked => golem_api_1_x::host::CardInstallError::Revoked,
109110
CardInstallFailure::NotFound => golem_api_1_x::host::CardInstallError::NotFound,
110111
CardInstallFailure::RecipientMismatch | CardInstallFailure::NotPermitted => {
111112
golem_api_1_x::host::CardInstallError::NotPermitted

golem-worker-executor/src/durable_host/mod.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,10 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
797797
.set_card_interest(self.owned_agent_id.clone(), &wallet_card_ids)
798798
.await;
799799

800-
let reason = CardInstallFailure::NotFound;
800+
let reason = match card_state {
801+
Some(CardState::Revoked) => CardInstallFailure::CardRevoked,
802+
_ => CardInstallFailure::NotFound,
803+
};
801804

802805
if let Some(queued_event_index) = queued_event_index {
803806
self.public_state
@@ -845,10 +848,6 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
845848
}
846849

847850
if is_live {
848-
self.state
849-
.card_service
850-
.record_revoked_cards(&[card_id])
851-
.await;
852851
let wallet_card_ids = self
853852
.state
854853
.agent_wallet_cards
@@ -2707,7 +2706,7 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
27072706
Ok(())
27082707
}
27092708

2710-
pub async fn update_state_to_new_component_revision(
2709+
async fn update_state_to_new_component_revision(
27112710
&mut self,
27122711
new_revision: ComponentRevision,
27132712
) -> Result<(), WorkerExecutorError> {
@@ -2797,16 +2796,6 @@ impl<Ctx: WorkerCtx> DurableWorkerCtx<Ctx> {
27972796
self.state.cached_agent_config_retry_policies = None;
27982797
self.state.agent_effective_surface = agent_effective_surface;
27992798
self.state.agent_wallet_cards = initial_wallet_cards;
2800-
let wallet_card_ids = self
2801-
.state
2802-
.agent_wallet_cards
2803-
.keys()
2804-
.copied()
2805-
.collect::<Vec<_>>();
2806-
self.state
2807-
.card_service
2808-
.set_card_interest(self.owned_agent_id.clone(), &wallet_card_ids)
2809-
.await;
28102799
};
28112800

28122801
self.state.component_metadata = new_metadata;

golem-worker-executor/src/model/public_oplog/wit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ fn raw_queued_card_event_to_wit(value: QueuedCardEvent) -> oplog::QueuedCardEven
109109

110110
fn card_install_failure_to_wit(value: CardInstallFailure) -> oplog::CardInstallFailure {
111111
match value {
112+
CardInstallFailure::CardRevoked => oplog::CardInstallFailure::CardRevoked,
112113
CardInstallFailure::NotFound => oplog::CardInstallFailure::NotFound,
113114
CardInstallFailure::RecipientMismatch => oplog::CardInstallFailure::RecipientMismatch,
114115
CardInstallFailure::NotPermitted => oplog::CardInstallFailure::NotPermitted,
@@ -117,7 +118,7 @@ fn card_install_failure_to_wit(value: CardInstallFailure) -> oplog::CardInstallF
117118

118119
fn card_install_failure_from_wit(value: oplog::CardInstallFailure) -> CardInstallFailure {
119120
match value {
120-
oplog::CardInstallFailure::CardRevoked => CardInstallFailure::NotFound,
121+
oplog::CardInstallFailure::CardRevoked => CardInstallFailure::CardRevoked,
121122
oplog::CardInstallFailure::NotFound => CardInstallFailure::NotFound,
122123
oplog::CardInstallFailure::RecipientMismatch => CardInstallFailure::RecipientMismatch,
123124
oplog::CardInstallFailure::NotPermitted => CardInstallFailure::NotPermitted,

golem-worker-executor/src/worker/status.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3372,7 +3372,7 @@ mod test {
33723372
OplogEntry::card_install_failed(
33733373
OplogIndex::from_u64(1),
33743374
card_id,
3375-
CardInstallFailure::NotFound,
3375+
CardInstallFailure::CardRevoked,
33763376
),
33773377
),
33783378
]);

0 commit comments

Comments
 (0)