-
Notifications
You must be signed in to change notification settings - Fork 9
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
Table change check #80
Conversation
b586b67
to
ab6162f
Compare
ab6162f
to
12311bc
Compare
9074bfc
to
a25f479
Compare
.v1_state | ||
.contract_verifiers | ||
.check(&update, *table_uuid, &response.previous_table_metadata) | ||
.await? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be quite a few updates here - I would prefer concurrent execution and try_join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't quite fit here, but I am also a bit hesitant about awaiting the emit_change_event block.
We currently implement a "send and forget" approach. But right now, if the event queue is offline, we are blocking the client response until the event queue gets a timeout.
What's your feeling about emitting events non-blocking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect this endpoint to be called a lot? How many changes do we expect per call?
We could separate it out via a channel and have some background task shoveling it into nats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be quite a few updates here - I would prefer concurrent execution and try_join
made it futures + try_join_all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we expect this endpoint to be called a lot? How many changes do we expect per call?
We could separate it out via a channel and have some background task shoveling it into nats.
@@ -819,6 +842,19 @@ impl<C: Catalog, A: AuthZHandler, S: SecretStore> | |||
)); | |||
} | |||
|
|||
for ((update, (_, table_uuid)), response) in updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should push the whole block up to right after C::commit_table_transaction.
There is no need to load storage secret if the contract check fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -929,3 +965,65 @@ fn maybe_body_to_json(request: impl Serialize) -> serde_json::Value { | |||
serde_json::Value::Null | |||
} | |||
} | |||
|
|||
// TableUpdate is not clone but all containing fields are so we use this function to clone.. | |||
fn copy_updates(updates: &[TableUpdate]) -> Vec<TableUpdate> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe rename to clone_updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
async fn check( | ||
&self, | ||
table_updates: &[TableUpdate], | ||
table_ident_uuid: TableIdentUuid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we send the current_metadata
, we might want to skip the table_ident_uuid.
The table-uuid is already part of TableMetadata
and might change during updates.
If we specify it here additionally, we should rename it to current_table_ident_uuid to make sure it is the UUID before updates.
I think removing it is fine though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, missed it in table-metadata, removed!
Ok(ContractVerificationOutcome::Clear {}) => {} | ||
Ok(block_result @ ContractVerificationOutcome::Violation { error_model: _ }) => { | ||
tracing::info!( | ||
"Checker {} blocked change on table '{}'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets reflect the trait in the log - maybe ContractValidator {} blocked change on table ..
Also for other logs here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
#58