-
Notifications
You must be signed in to change notification settings - Fork 0
Core: доверенный сертификат допускается только к спрошенному региону (V5b2d-5b) #561
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ce1944d
Core: bind the trusted family certificate to the asked region (V5b2d-5b)
f5d4d71
Core: compare the whole definition address and keep the refusal quiet…
c8376f9
Merge origin/main into v5b2d-5b-definition-binding
3ead2f4
Core: the transport contract is asserted on both failure branches
b6d2087
Merge remote-tracking branch 'origin/main' into v5b2d-5b-definition-b…
0c989be
Core: one helper owns the coherence recomputation the mutators need
d6dc0c8
Merge branch 'main' into v5b2d-5b-definition-binding
lemone112 b00f9e5
Merge branch 'main' into v5b2d-5b-definition-binding
lemone112 9540ac9
Merge branch 'main' into v5b2d-5b-definition-binding
lemone112 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
crates/labcolors-core/contracts/clean-set-srgb8-v1/receipt-v1.sha256
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| a27604c3306a3a40818594c173b09e7feda925653eb9658d64c9b9784526c48e receipt-v1.json | ||
| 959f1b235e4a08004c0632c87678622b4b688ded4fd507cd28f9d41072fd3ac0 receipt-v1.json |
2 changes: 1 addition & 1 deletion
2
crates/labcolors-core/contracts/point-support-reference-surplus-q55-bps-proof-v1.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| //! Связывание доверенного certificate с адресом спрошенного определения. | ||
| //! | ||
| //! `contextual_region` отвечает, какой content address имеет спрошенный регион. | ||
| //! `family_artifact` отвечает, что байты точно соответствуют доверенному | ||
| //! certificate. Ни одна из границ не отвечает на вопрос «а этот certificate | ||
| //! вообще про спрошенный регион?»: целый artifact ДРУГОГО региона проходит обе | ||
| //! проверки. Модуль замыкает цепь одним сравнением двух адресов. | ||
|
|
||
| #![cfg_attr( | ||
| not(test), | ||
| expect( | ||
| dead_code, | ||
| reason = "V5b2b keeps the definition-bound admission private until the public family provider cutover" | ||
| ) | ||
| )] | ||
|
|
||
| use core::fmt; | ||
|
|
||
| use crate::contextual_region::{ | ||
| ContextualRegionFamilyProviderV1, ContextualRegionPipelineV1, PiecewiseLinearCartesianTubeV1, | ||
| }; | ||
| use crate::family::FamilyDefinitionDigestV2; | ||
| use crate::family_artifact::{ | ||
| AdmittedFamilyArtifactV2, EncodedFamilyArtifactV2, FamilyArtifactLoadErrorV1, | ||
| FamilyArtifactLoaderV1, FamilyImageCertificateV2, | ||
| }; | ||
|
|
||
| /// Причина, по которой artifact не допущен как образ спрошенного региона. | ||
| #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| pub(crate) enum DefinitionBoundFamilyLoadErrorV1 { | ||
| /// Certificate доверен и цел, но адресует другое определение. | ||
| ForeignDefinition { | ||
| asked: FamilyDefinitionDigestV2, | ||
| certified: FamilyDefinitionDigestV2, | ||
| }, | ||
| /// Certificate про спрошенное определение, но transport его не подтвердил. | ||
| Artifact(FamilyArtifactLoadErrorV1), | ||
| } | ||
|
|
||
| /// Неуспех возвращает те же owned bytes: диагностика, исправление или повтор | ||
| /// не требуют refetch и clone. | ||
| pub(crate) struct DefinitionBoundFamilyLoadFailureV1 { | ||
| cause: DefinitionBoundFamilyLoadErrorV1, | ||
| encoded: EncodedFamilyArtifactV2, | ||
| } | ||
|
|
||
| impl fmt::Debug for DefinitionBoundFamilyLoadFailureV1 { | ||
| fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| formatter | ||
| .debug_struct("DefinitionBoundFamilyLoadFailureV1") | ||
| .field("cause", &self.cause) | ||
| .finish_non_exhaustive() | ||
| } | ||
| } | ||
|
|
||
| impl DefinitionBoundFamilyLoadFailureV1 { | ||
| pub(crate) const fn cause(&self) -> DefinitionBoundFamilyLoadErrorV1 { | ||
| self.cause | ||
| } | ||
|
|
||
| pub(crate) fn into_parts(self) -> (DefinitionBoundFamilyLoadErrorV1, EncodedFamilyArtifactV2) { | ||
| (self.cause, self.encoded) | ||
| } | ||
| } | ||
|
|
||
| /// Единственный вход, допускающий artifact к тому определению, которое | ||
| /// потребитель действительно спросил. | ||
| pub(crate) struct DefinitionBoundFamilyLoaderV1; | ||
|
|
||
| impl DefinitionBoundFamilyLoaderV1 { | ||
| /// Спрошенный регион задаётся `pipeline` и `region`; семейство приходит | ||
| /// извне как доверенный `certificate` и его `encoded` bytes. | ||
| /// | ||
| /// Сравнение адресов идёт по двум записям и завершается до parse envelope, | ||
| /// хеширования payload и decode образа: чужое определение стоит одного | ||
| /// content address, а не мегабайтов. | ||
| pub(crate) fn load( | ||
| pipeline: ContextualRegionPipelineV1, | ||
| region: &PiecewiseLinearCartesianTubeV1, | ||
| certificate: FamilyImageCertificateV2, | ||
| encoded: EncodedFamilyArtifactV2, | ||
| ) -> Result<AdmittedFamilyArtifactV2, DefinitionBoundFamilyLoadFailureV1> { | ||
| let asked = ContextualRegionFamilyProviderV1::definition_digest(pipeline, region); | ||
| let certified = certificate.definition_digest(); | ||
| if asked != certified { | ||
| return Err(DefinitionBoundFamilyLoadFailureV1 { | ||
| cause: DefinitionBoundFamilyLoadErrorV1::ForeignDefinition { asked, certified }, | ||
| encoded, | ||
| }); | ||
| } | ||
| FamilyArtifactLoaderV1::load(certificate, encoded).map_err(|failure| { | ||
| let (cause, encoded) = failure.into_parts(); | ||
| DefinitionBoundFamilyLoadFailureV1 { | ||
| cause: DefinitionBoundFamilyLoadErrorV1::Artifact(cause), | ||
| encoded, | ||
| } | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.