From 10d1691730e1300ccdddafe369042387185976ca Mon Sep 17 00:00:00 2001 From: Sylvain Ribstein Date: Tue, 16 Apr 2024 11:02:17 +0200 Subject: [PATCH] sdk: introduce proto-oxford feature flag --- src/kernel_sdk/CHANGES.md | 1 + src/kernel_sdk/core/Cargo.toml | 1 + src/kernel_sdk/encoding/Cargo.toml | 1 + src/kernel_sdk/encoding/src/outbox.rs | 30 +++++++++++----------- src/kernel_sdk/host/Cargo.toml | 1 + src/kernel_sdk/installer-client/Cargo.toml | 4 +-- src/kernel_sdk/mock/Cargo.toml | 1 + src/kernel_sdk/sdk/Cargo.toml | 1 + 8 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/kernel_sdk/CHANGES.md b/src/kernel_sdk/CHANGES.md index fc545073fdfc..ebb6eeac2eae 100644 --- a/src/kernel_sdk/CHANGES.md +++ b/src/kernel_sdk/CHANGES.md @@ -9,6 +9,7 @@ - Add `From OutboxMessageTransaction`, `From OutboxMessageTransactionBatch` for `OutboxMessage` to simplify construction. - Fix the incomplete inbox on the first level of using `MockHost::default()`. - Add support for new michelson `Ticket` constructor. +- Add uses of `proto-oxford` feature flag. - Add michelson `nat`. ### Installer client/kernel diff --git a/src/kernel_sdk/core/Cargo.toml b/src/kernel_sdk/core/Cargo.toml index 411209e54f79..66a50a5653aa 100644 --- a/src/kernel_sdk/core/Cargo.toml +++ b/src/kernel_sdk/core/Cargo.toml @@ -27,4 +27,5 @@ path = "../constants" [features] "testing" = ["mockall"] "proto-nairobi" = [] +"proto-oxford" = [] "proto-alpha" = [] diff --git a/src/kernel_sdk/encoding/Cargo.toml b/src/kernel_sdk/encoding/Cargo.toml index 4b5b7d1b3c5a..a458718bdaec 100644 --- a/src/kernel_sdk/encoding/Cargo.toml +++ b/src/kernel_sdk/encoding/Cargo.toml @@ -51,4 +51,5 @@ crypto = ["tezos_crypto_rs"] bls = ["tezos_crypto_rs/bls"] alloc = ["crypto", "thiserror", "hex", "num-traits", "num-bigint", "regex"] tezos-encoding = ["tezos_data_encoding", "tezos_data_encoding_derive", "time"] +proto-oxford = ["tezos-smart-rollup-core/proto-oxford", "tezos-smart-rollup-host/proto-oxford"] proto-alpha = ["tezos-smart-rollup-core/proto-alpha", "tezos-smart-rollup-host/proto-alpha"] diff --git a/src/kernel_sdk/encoding/src/outbox.rs b/src/kernel_sdk/encoding/src/outbox.rs index c7e291f6342d..64147f271875 100644 --- a/src/kernel_sdk/encoding/src/outbox.rs +++ b/src/kernel_sdk/encoding/src/outbox.rs @@ -20,7 +20,7 @@ use tezos_data_encoding::nom::NomReader; use crate::contract::Contract; use crate::entrypoint::Entrypoint; use crate::michelson::Michelson; -#[cfg(feature = "proto-alpha")] +#[cfg(feature = "proto-oxford")] use crate::public_key_hash::PublicKeyHash; /// Outbox message, sent by the kernel as tezos-encoded bytes. @@ -32,7 +32,7 @@ pub enum OutboxMessage { #[encoding(tag = 0)] AtomicTransactionBatch(OutboxMessageTransactionBatch), /// Only keys in the whitelist are allowed to stake and publish a commitment. - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] #[encoding(tag = 2)] WhitelistUpdate(OutboxMessageWhitelistUpdate), } @@ -115,7 +115,7 @@ pub struct OutboxMessageTransaction { /// `(opt "whitelist" Sc_rollup_whitelist_repr.encoding)` /// where /// `encoding = Data_encoding.(list Signature.Public_key_hash.encoding)` -#[cfg(feature = "proto-alpha")] +#[cfg(feature = "proto-oxford")] #[derive(Debug, PartialEq, Eq, HasEncoding, BinWriter, NomReader)] pub struct OutboxMessageWhitelistUpdate { /// The new contents of the whitelist @@ -124,7 +124,7 @@ pub struct OutboxMessageWhitelistUpdate { } /// Kinds of invalid whitelists -#[cfg(feature = "proto-alpha")] +#[cfg(feature = "proto-oxford")] #[derive(Debug, PartialEq, Eq)] pub enum InvalidWhitelist { /// If the provided whitelist is the empty list @@ -133,7 +133,7 @@ pub enum InvalidWhitelist { DuplicatedKeys, } -#[cfg(feature = "proto-alpha")] +#[cfg(feature = "proto-oxford")] fn has_unique_elements(iter: T) -> bool where T: IntoIterator, @@ -145,7 +145,7 @@ where /// Returns `Err` on empty list, to not accidentally set the whitelist to /// None, thereby making the rollup public. -#[cfg(feature = "proto-alpha")] +#[cfg(feature = "proto-oxford")] impl TryFrom>> for OutboxMessageWhitelistUpdate { type Error = InvalidWhitelist; @@ -178,7 +178,7 @@ mod test { const ENCODED_OUTBOX_MESSAGE_PREFIX: [u8; 5] = [0, 0, 0, 0, 152]; // first byte is union tag (currently always `2`) - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] const ENCODED_OUTBOX_MESSAGE_WHITELIST_PREFIX: [u8; 1] = [2]; const ENCODED_TRANSACTION_ONE: [u8; 74] = [ @@ -223,7 +223,7 @@ mod test { // Format.asprintf "%a" // Binary_schema.pp // (Binary.describe (list Tezos_crypto.Signature.Public_key_hash.encoding)) - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] const ENCODED_WHITELIST_UPDATE: [u8; 47] = [ 0xff, // provide whitelist (0x0 for none) 0x0, 0x0, 0x0, 0x2a, // # bytes in next field @@ -246,7 +246,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn encode_whitelist_update() { let mut bin = vec![]; whitelist().bin_write(&mut bin).unwrap(); @@ -264,7 +264,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn decode_whitelist_update() { let (remaining, decoded) = OutboxMessageWhitelistUpdate::nom_read(ENCODED_WHITELIST_UPDATE.as_slice()) @@ -290,7 +290,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn encode_outbox_message_whitelist() { let mut expected = ENCODED_OUTBOX_MESSAGE_WHITELIST_PREFIX.to_vec(); expected.extend_from_slice(ENCODED_WHITELIST_UPDATE.as_slice()); @@ -321,7 +321,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn decode_outbox_message_whitelist() { let mut bytes = ENCODED_OUTBOX_MESSAGE_WHITELIST_PREFIX.to_vec(); bytes.extend_from_slice(ENCODED_WHITELIST_UPDATE.as_slice()); @@ -347,7 +347,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn decode_outbox_message_whitelist_err_on_invalid_prefix() { let mut bytes = ENCODED_OUTBOX_MESSAGE_PREFIX.to_vec(); // prefix too long, missing message @@ -394,7 +394,7 @@ mod test { } } - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn whitelist() -> OutboxMessageWhitelistUpdate { let whitelist = Some(vec![ PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx").unwrap(), @@ -404,7 +404,7 @@ mod test { } #[test] - #[cfg(feature = "proto-alpha")] + #[cfg(feature = "proto-oxford")] fn tryfrom_whitelist() { let addr = PublicKeyHash::from_b58check("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx").unwrap(); diff --git a/src/kernel_sdk/host/Cargo.toml b/src/kernel_sdk/host/Cargo.toml index da1e708f94cd..4b6dfffb631a 100644 --- a/src/kernel_sdk/host/Cargo.toml +++ b/src/kernel_sdk/host/Cargo.toml @@ -44,6 +44,7 @@ crypto = ["tezos_crypto_rs"] alloc = ["thiserror", "tezos_data_encoding"] testing = ["crypto", "mockall", "tezos-smart-rollup-core/testing"] proto-nairobi = ["tezos-smart-rollup-core/proto-nairobi"] +proto-oxford = ["tezos-smart-rollup-core/proto-oxford"] proto-alpha = ["tezos-smart-rollup-core/proto-alpha"] # Required for 'impl Error for RuntimeError' std = [] diff --git a/src/kernel_sdk/installer-client/Cargo.toml b/src/kernel_sdk/installer-client/Cargo.toml index 3abab9846ade..531f9fb8689c 100644 --- a/src/kernel_sdk/installer-client/Cargo.toml +++ b/src/kernel_sdk/installer-client/Cargo.toml @@ -53,5 +53,5 @@ version = "0.9" # For tests [dev-dependencies] installer-kernel = { path = "../installer-kernel", default-features = false } -tezos-smart-rollup = { path = "../sdk", features = ["proto-nairobi"], default-features = false } -tezos-smart-rollup-mock = { path = "../mock", features = ["proto-nairobi"] } +tezos-smart-rollup = { path = "../sdk", features = ["proto-oxford"], default-features = false } +tezos-smart-rollup-mock = { path = "../mock", features = ["proto-oxford"] } diff --git a/src/kernel_sdk/mock/Cargo.toml b/src/kernel_sdk/mock/Cargo.toml index e0bd167fb086..40b5941f8b13 100644 --- a/src/kernel_sdk/mock/Cargo.toml +++ b/src/kernel_sdk/mock/Cargo.toml @@ -39,4 +39,5 @@ features = ["default"] [features] proto-nairobi = ["tezos-smart-rollup-core/proto-nairobi", "tezos-smart-rollup-host/proto-nairobi"] +proto-oxford = ["tezos-smart-rollup-core/proto-oxford", "tezos-smart-rollup-host/proto-oxford"] proto-alpha = ["tezos-smart-rollup-core/proto-alpha", "tezos-smart-rollup-host/proto-alpha"] diff --git a/src/kernel_sdk/sdk/Cargo.toml b/src/kernel_sdk/sdk/Cargo.toml index d9107fe4ab0a..fe30f5ae6132 100644 --- a/src/kernel_sdk/sdk/Cargo.toml +++ b/src/kernel_sdk/sdk/Cargo.toml @@ -83,5 +83,6 @@ storage = ["tezos-smart-rollup-storage"] std = ["alloc", "debug_alloc", "tezos-smart-rollup-entrypoint/std"] testing = ["crypto", "tezos-smart-rollup-mock"] proto-nairobi = ["tezos-smart-rollup-core/proto-nairobi", "tezos-smart-rollup-host/proto-nairobi", "tezos-smart-rollup-mock/proto-nairobi"] +proto-oxford = ["tezos-smart-rollup-core/proto-oxford", "tezos-smart-rollup-host/proto-oxford", "tezos-smart-rollup-mock/proto-oxford"] proto-alpha = ["tezos-smart-rollup-core/proto-alpha", "tezos-smart-rollup-host/proto-alpha", "tezos-smart-rollup-mock/proto-alpha"] experimental-host-in-memory-store = ["tezos-smart-rollup-entrypoint/proto-alpha", "tezos-smart-rollup-entrypoint/experimental-host-in-memory-store"] -- GitLab