Skip to content

Commit

Permalink
Adding substate and partition delete support to FlashLedgerTransactio…
Browse files Browse the repository at this point in the history
…n in Core API (#810)

An omission reported at
https://rdxworks.slack.com/archives/C01M90Y2448/p1705913560366799

Intuitively, the `FlashTransaction` could be represented as
`StateUpdates`.
However, our existing `StateUpdates` Core API output is very
receipt-focused (e.g. it includes previous value for substate updates)
and it is hard to render for `FlashTransaction`. So I had to re-create a
similar structure.
  • Loading branch information
dhedey authored Jan 22, 2024
2 parents 89ff7e5 + 6fc6f18 commit 77ffe35
Show file tree
Hide file tree
Showing 24 changed files with 686 additions and 378 deletions.
80 changes: 40 additions & 40 deletions core-rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions core-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ members = [
# $ git push origin "release_name-BLAH"
# * Then use tag="release_name-BLAH" in the below dependencies.
#
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
transaction-scenarios = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
radix-engine-stores = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29" }
utils = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ab03ea29", features = ["serde"] }
sbor = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188", features = ["serde"] }
transaction = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
transaction-scenarios = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
radix-engine-common = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188", features = ["serde"] }
radix-engine-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
radix-engine = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
radix-engine-stores = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
radix-engine-store-interface = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
radix-engine-queries = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188" }
utils = { git = "https://github.com/radixdlt/radixdlt-scrypto", tag = "anemone-ea13991188", features = ["serde"] }

itertools = { version = "0.11.0" }
jni = { version = "0.19.0" }
Expand Down
50 changes: 28 additions & 22 deletions core-rust/core-api-server/core-api-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7416,10 +7416,14 @@ components:
- $ref: "#/components/schemas/LedgerTransaction"
- type: object
required:
- flash_transaction
- name
- flashed_state_updates
properties:
flash_transaction:
$ref: "#/components/schemas/FlashTransaction"
name:
type: string
description: Human-readable identifier of the flash transaction.
flashed_state_updates:
$ref: "#/components/schemas/FlashedStateUpdates"
RoundUpdateTransaction:
type: object
required:
Expand Down Expand Up @@ -7447,35 +7451,37 @@ components:
leader_proposal_history:
$ref: '#/components/schemas/LeaderProposalHistory'
description: A recent history (i.e. since the previous `RoundUpdateValidatorTransaction`) of consensus round leaders' reliability. Used for validator emissions calculation.
FlashTransaction:
FlashedStateUpdates:
type: object
description: Direct state updates performed by a Flash Transaction.
required:
- flashed_substates
- deleted_partitions
- set_substates
- deleted_substates
properties:
flashed_substates:
deleted_partitions:
type: array
items:
$ref: "#/components/schemas/PartitionId"
set_substates:
type: array
items:
$ref: "#/components/schemas/FlashSetSubstate"
deleted_substates:
type: array
items:
$ref: "#/components/schemas/FlashedSubstate"
FlashedSubstate:
$ref: "#/components/schemas/SubstateId"
FlashSetSubstate:
type: object
required:
- entity_address
- partition_number
- substate_key
- substate_id
- value
properties:
entity_address:
$ref: "#/components/schemas/EntityAddress"
partition_number:
type: integer
format: int32
minimum: 0
maximum: 255
substate_key:
$ref: "#/components/schemas/SubstateKey"
substate_id:
$ref: "#/components/schemas/SubstateId"
value:
type: string
description: The hex-encoded, SBOR-encoded substate data bytes.
$ref: "#/components/schemas/SubstateValue"
description: The new value set on the substate.
LeaderProposalHistory:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ pub struct FlashLedgerTransaction {
/// The hex-encoded full ledger transaction payload. Only returned if enabled in TransactionFormatOptions on your request.
#[serde(rename = "payload_hex", skip_serializing_if = "Option::is_none")]
pub payload_hex: Option<String>,
#[serde(rename = "flash_transaction")]
pub flash_transaction: Box<crate::core_api::generated::models::FlashTransaction>,
/// Human-readable identifier of the flash transaction.
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "flashed_state_updates")]
pub flashed_state_updates: Box<crate::core_api::generated::models::FlashedStateUpdates>,
}

impl FlashLedgerTransaction {
pub fn new(_type: crate::core_api::generated::models::LedgerTransactionType, flash_transaction: crate::core_api::generated::models::FlashTransaction) -> FlashLedgerTransaction {
pub fn new(_type: crate::core_api::generated::models::LedgerTransactionType, name: String, flashed_state_updates: crate::core_api::generated::models::FlashedStateUpdates) -> FlashLedgerTransaction {
FlashLedgerTransaction {
_type,
payload_hex: None,
flash_transaction: Box::new(flash_transaction),
name,
flashed_state_updates: Box::new(flashed_state_updates),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@

#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
pub struct FlashLedgerTransactionAllOf {
#[serde(rename = "flash_transaction")]
pub flash_transaction: Box<crate::core_api::generated::models::FlashTransaction>,
/// Human-readable identifier of the flash transaction.
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "flashed_state_updates")]
pub flashed_state_updates: Box<crate::core_api::generated::models::FlashedStateUpdates>,
}

impl FlashLedgerTransactionAllOf {
pub fn new(flash_transaction: crate::core_api::generated::models::FlashTransaction) -> FlashLedgerTransactionAllOf {
pub fn new(name: String, flashed_state_updates: crate::core_api::generated::models::FlashedStateUpdates) -> FlashLedgerTransactionAllOf {
FlashLedgerTransactionAllOf {
flash_transaction: Box::new(flash_transaction),
name,
flashed_state_updates: Box::new(flashed_state_updates),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@


#[derive(Clone, Debug, PartialEq, Default, serde::Serialize, serde::Deserialize)]
pub struct FlashTransaction {
#[serde(rename = "flashed_substates")]
pub flashed_substates: Vec<crate::core_api::generated::models::FlashedSubstate>,
pub struct FlashSetSubstate {
#[serde(rename = "substate_id")]
pub substate_id: Box<crate::core_api::generated::models::SubstateId>,
#[serde(rename = "value")]
pub value: Box<crate::core_api::generated::models::SubstateValue>,
}

impl FlashTransaction {
pub fn new(flashed_substates: Vec<crate::core_api::generated::models::FlashedSubstate>) -> FlashTransaction {
FlashTransaction {
flashed_substates,
impl FlashSetSubstate {
pub fn new(substate_id: crate::core_api::generated::models::SubstateId, value: crate::core_api::generated::models::SubstateValue) -> FlashSetSubstate {
FlashSetSubstate {
substate_id: Box::new(substate_id),
value: Box::new(value),
}
}
}
Expand Down
Loading

0 comments on commit 77ffe35

Please sign in to comment.