Skip to content

Commit

Permalink
fix: Fix LocalTransactionExecutionV1 sbor assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhedey committed Aug 22, 2024
1 parent 0c51979 commit 8317342
Show file tree
Hide file tree
Showing 11 changed files with 451 additions and 187 deletions.
2 changes: 1 addition & 1 deletion radix-engine/src/kernel/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ where
}
}

#[deprecated = "Remove when implemented with threads"]
#[deprecated = "Deprecated as a reminder to remove this when threads are implemented"]
fn single_intent_index() -> usize {
0
}
Expand Down
2 changes: 1 addition & 1 deletion radix-engine/src/transaction/transaction_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,7 @@ mod tests {
#[derive(ScryptoSbor, ScryptoSborAssertion)]
#[sbor_assert(
backwards_compatible(
bottlenose = "FILE:node_local_transaction_execution_v1_bottlenose.txt",
bottlenose = "FILE:node_local_transaction_execution_v1_bottlenose.txt"
),
settings(allow_name_changes)
)]
Expand Down
40 changes: 30 additions & 10 deletions radix-sbor-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ pub fn scrypto_sbor(input: TokenStream) -> TokenStream {
/// }
/// ```
///
/// Other supported options are `fixed("INLINE:<hex>")` and `fixed("CONST:<Constant>")`.
/// Instead of `"FILE:X"`, you can also use `"INLINE:<hex>"`, `"CONST:<Constant>"` or `"EXPR:<Expression>"`
/// where the expression (such as `generate_schema()`) has to generate a `SingleTypeSchema<NoCustomSchema>`.
///
/// ## Backwards compatibility verification
///
Expand All @@ -228,17 +229,32 @@ pub fn scrypto_sbor(input: TokenStream) -> TokenStream {
/// }
/// ```
///
/// Instead of `"FILE:X"`, you can also use `"INLINE:<hex>"` and `"CONST:<Constant>"`.
/// Instead of `"FILE:X"`, you can also use `"INLINE:<hex>"`, `"CONST:<Constant>"` or `"EXPR:<Expression>"`
/// where the expression (such as `generate_schema()`) has to generate a `SingleTypeSchema<ScryptoCustomSchema>`.
///
/// If you wish to configure exactly which schemas are used for comparison of the current schema with
/// the latest named schema; and each named schema with its predecessor, you can use:
///
/// ```ignore
/// #[sbor_assert(backwards_compatible("EXPR:<Expression>"))
/// ```
/// Where the expression (such as `params_builder()`) has to generate a `SingleTypeSchemaCompatibilityParameters<ScryptoCustomSchema>`.
///
/// ## Custom settings
/// By default, the `fixed` mode will use `SchemaComparisonSettings::require_equality()` and
/// the `backwards_compatible` mode will use `SchemaComparisonSettings::allow_extension()`.
/// the `backwards_compatible` mode will use `SchemaComparisonSettings::require_equality()` for the check
/// of `current` aginst the latest version, and `SchemaComparisonSettings::allow_extension()` for the
/// checks between consecutive versions.
///
/// You may wish to change these:
/// * If you just wish to ignore the equality of metadata such as names, you can use the
/// `allow_name_changes` flag.
/// * If you wish to override any settings, you can provide a constant containing your
/// * If you wish to override all settings, you can provide a constant containing your
/// own SchemaComparisonSettings.
/// * If you wish to specify a builder for settings, you can provide `"EXPR:|builder| builder.<stuff>"`
/// * If for `backwards_compatible`, you wish to provide a separate configuration for the "latest" and
/// "named versions" checks, you can use `settings(comparison_between_versions = \"EXPR:F1\", comparison_between_current_and_latest = \"EXPR:F2\") `
///
///
/// For example:
/// ```no_run
Expand All @@ -251,17 +267,21 @@ pub fn scrypto_sbor(input: TokenStream) -> TokenStream {
/// // ...
/// }
///
/// const CUSTOM_COMPARISON_SETTINGS: sbor::schema::SchemaComparisonSettings = sbor::schema::SchemaComparisonSettings::require_equality();
///
/// #[derive(ScryptoSbor, ScryptoSborAssertion)]
/// #[sbor_assert(
/// backwards_compatible(
/// version1 = "FILE:MyType-schema-v1.txt",
/// version2 = "FILE:MyType-schema-v2.txt",
/// v1 = "FILE:MyType-schema-v1.txt",
/// v2 = "FILE:MyType-schema-v2.txt",
/// ),
/// settings(
/// // We allow name changes between versions, but require the current schema to exactly match
/// // the latest version (v2 in this case).
/// // This could be useful to e.g. ensure that we have a fixed schema with the latest naming available.
/// comparison_between_versions = "EXPR: |s| s.allow_all_name_changes()",
/// comparison_between_current_and_latest = "EXPR: |s| s",
/// ),
/// settings(CUSTOM_COMPARISON_SETTINGS),
/// )]
/// struct MyOtherType {
/// struct MyType {
/// // ...
/// }
/// ```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl TipSpecifier {
Decimal::ONE + self.proportion()
}

#[deprecated = "Need to remove this function before releasing bottlenose; once we can change the receipt"]
#[deprecated = "Need to remove this function before releasing cuttlefish; once we can change the receipt"]
pub fn truncate_to_percentage_u16(&self) -> u16 {
match self {
TipSpecifier::None => 0,
Expand Down
Loading

0 comments on commit 8317342

Please sign in to comment.