From f0171b5d1a021b15db4ad79d00b88ef14ceb81cc Mon Sep 17 00:00:00 2001 From: Tejas Badadare Date: Thu, 7 Aug 2025 15:03:06 -0700 Subject: [PATCH 1/4] fix(fortuna): migrate timestamp columns integer -> bigint --- Cargo.lock | 2 +- .../migrations/20250707000000_init.down.sql | 1 - .../migrations/20250707000000_init.up.sql | 36 ------------------- ...0250801232728_add_callback_fields.down.sql | 4 --- .../20250801232728_add_callback_fields.up.sql | 4 --- 5 files changed, 1 insertion(+), 46 deletions(-) delete mode 100644 apps/fortuna/migrations/20250707000000_init.down.sql delete mode 100644 apps/fortuna/migrations/20250707000000_init.up.sql delete mode 100644 apps/fortuna/migrations/20250801232728_add_callback_fields.down.sql delete mode 100644 apps/fortuna/migrations/20250801232728_add_callback_fields.up.sql diff --git a/Cargo.lock b/Cargo.lock index 48ed36f567..88ead5a220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3071,7 +3071,7 @@ dependencies = [ [[package]] name = "fortuna" -version = "9.1.1" +version = "9.1.2" dependencies = [ "anyhow", "axum 0.6.20", diff --git a/apps/fortuna/migrations/20250707000000_init.down.sql b/apps/fortuna/migrations/20250707000000_init.down.sql deleted file mode 100644 index b02621d63a..0000000000 --- a/apps/fortuna/migrations/20250707000000_init.down.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE IF EXISTS request; diff --git a/apps/fortuna/migrations/20250707000000_init.up.sql b/apps/fortuna/migrations/20250707000000_init.up.sql deleted file mode 100644 index 609351b70f..0000000000 --- a/apps/fortuna/migrations/20250707000000_init.up.sql +++ /dev/null @@ -1,36 +0,0 @@ -CREATE TABLE request( - chain_id VARCHAR(20) NOT NULL, - network_id INTEGER NOT NULL, - provider VARCHAR(40) NOT NULL, - sequence INTEGER NOT NULL, - created_at INTEGER NOT NULL, - last_updated_at INTEGER NOT NULL, - state VARCHAR(10) NOT NULL, - request_block_number INTEGER NOT NULL, - request_tx_hash VARCHAR(64) NOT NULL, - user_random_number VARCHAR(64) NOT NULL, - sender VARCHAR(40) NOT NULL, - reveal_block_number INTEGER, - reveal_tx_hash VARCHAR(64), - provider_random_number VARCHAR(64), - info TEXT, - gas_used VARCHAR(100), - gas_limit VARCHAR(100) NOT NULL, - PRIMARY KEY (network_id, sequence, provider, request_tx_hash) -); - -CREATE INDEX request__network_id__state__created_at ON request(network_id, state, created_at); -CREATE INDEX request__network_id__created_at ON request(network_id, created_at); -CREATE INDEX request__sender__network_id__state__created_at ON request(sender, network_id, state, created_at); -CREATE INDEX request__sender__network_id__created_at ON request(sender, network_id, created_at); -CREATE INDEX request__sender__state__created_at ON request(sender, state, created_at); -CREATE INDEX request__sender__created_at ON request(sender, created_at); -CREATE INDEX request__sequence__network_id__state__created_at ON request(sequence, network_id, state, created_at); -CREATE INDEX request__sequence__network_id__created_at ON request(sequence, network_id, created_at); -CREATE INDEX request__sequence__state__created_at ON request(sequence, state, created_at); -CREATE INDEX request__sequence__created_at ON request(sequence, created_at); -CREATE INDEX request__state__created_at ON request(state, created_at); -CREATE INDEX request__created_at ON request(created_at); - -CREATE INDEX request__request_tx_hash ON request (request_tx_hash) WHERE request_tx_hash IS NOT NULL; -CREATE INDEX request__reveal_tx_hash ON request (reveal_tx_hash) WHERE reveal_tx_hash IS NOT NULL; diff --git a/apps/fortuna/migrations/20250801232728_add_callback_fields.down.sql b/apps/fortuna/migrations/20250801232728_add_callback_fields.down.sql deleted file mode 100644 index 28e9082af4..0000000000 --- a/apps/fortuna/migrations/20250801232728_add_callback_fields.down.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Remove callback_failed, callback_return_value, and callback_gas_used from the requests table. -ALTER TABLE request DROP COLUMN callback_failed; -ALTER TABLE request DROP COLUMN callback_return_value; -ALTER TABLE request DROP COLUMN callback_gas_used; diff --git a/apps/fortuna/migrations/20250801232728_add_callback_fields.up.sql b/apps/fortuna/migrations/20250801232728_add_callback_fields.up.sql deleted file mode 100644 index 113b43f9ad..0000000000 --- a/apps/fortuna/migrations/20250801232728_add_callback_fields.up.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Add callback_failed, callback_return_value, and callback_gas_used to the requests table. -ALTER TABLE request ADD COLUMN callback_failed INTEGER; -ALTER TABLE request ADD COLUMN callback_return_value VARCHAR; -ALTER TABLE request ADD COLUMN callback_gas_used VARCHAR(100); From 3a44cf7226acccee31b55f612bc5f9bcffc69254 Mon Sep 17 00:00:00 2001 From: Tejas Badadare Date: Thu, 7 Aug 2025 15:04:07 -0700 Subject: [PATCH 2/4] fix(fortuna): migrate timestamp columns integer -> bigint --- .../migrations/20250807000000_init.down.sql | 1 + .../migrations/20250807000000_init.up.sql | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 apps/fortuna/migrations/20250807000000_init.down.sql create mode 100644 apps/fortuna/migrations/20250807000000_init.up.sql diff --git a/apps/fortuna/migrations/20250807000000_init.down.sql b/apps/fortuna/migrations/20250807000000_init.down.sql new file mode 100644 index 0000000000..b02621d63a --- /dev/null +++ b/apps/fortuna/migrations/20250807000000_init.down.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS request; diff --git a/apps/fortuna/migrations/20250807000000_init.up.sql b/apps/fortuna/migrations/20250807000000_init.up.sql new file mode 100644 index 0000000000..4ec14695fe --- /dev/null +++ b/apps/fortuna/migrations/20250807000000_init.up.sql @@ -0,0 +1,39 @@ +CREATE TABLE request( + chain_id VARCHAR(20) NOT NULL, + network_id INTEGER NOT NULL, + provider VARCHAR(40) NOT NULL, + sequence INTEGER NOT NULL, + created_at BIGINT NOT NULL, + last_updated_at BIGINT NOT NULL, + state VARCHAR(10) NOT NULL, + request_block_number INTEGER NOT NULL, + request_tx_hash VARCHAR(64) NOT NULL, + user_random_number VARCHAR(64) NOT NULL, + sender VARCHAR(40) NOT NULL, + reveal_block_number INTEGER, + reveal_tx_hash VARCHAR(64), + provider_random_number VARCHAR(64), + info TEXT, + gas_used VARCHAR(100), + gas_limit VARCHAR(100) NOT NULL, + callback_failed INTEGER, + callback_return_value VARCHAR, + callback_gas_used VARCHAR(100), + PRIMARY KEY (network_id, sequence, provider, request_tx_hash) +); +CREATE INDEX request__network_id__state__created_at ON request(network_id, state, created_at); +CREATE INDEX request__network_id__created_at ON request(network_id, created_at); +CREATE INDEX request__sender__network_id__state__created_at ON request(sender, network_id, state, created_at); +CREATE INDEX request__sender__network_id__created_at ON request(sender, network_id, created_at); +CREATE INDEX request__sender__state__created_at ON request(sender, state, created_at); +CREATE INDEX request__sender__created_at ON request(sender, created_at); +CREATE INDEX request__sequence__network_id__state__created_at ON request(sequence, network_id, state, created_at); +CREATE INDEX request__sequence__network_id__created_at ON request(sequence, network_id, created_at); +CREATE INDEX request__sequence__state__created_at ON request(sequence, state, created_at); +CREATE INDEX request__sequence__created_at ON request(sequence, created_at); +CREATE INDEX request__state__created_at ON request(state, created_at); +CREATE INDEX request__created_at ON request(created_at); +CREATE INDEX request__request_tx_hash ON request (request_tx_hash) +WHERE request_tx_hash IS NOT NULL; +CREATE INDEX request__reveal_tx_hash ON request (reveal_tx_hash) +WHERE reveal_tx_hash IS NOT NULL; From 1b79a7560ae897db910f3e6e731a0af04cbc35f5 Mon Sep 17 00:00:00 2001 From: Tejas Badadare Date: Thu, 7 Aug 2025 15:20:56 -0700 Subject: [PATCH 3/4] bump ver --- Cargo.lock | 2 +- apps/fortuna/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 88ead5a220..25fc1df504 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3071,7 +3071,7 @@ dependencies = [ [[package]] name = "fortuna" -version = "9.1.2" +version = "9.2.0" dependencies = [ "anyhow", "axum 0.6.20", diff --git a/apps/fortuna/Cargo.toml b/apps/fortuna/Cargo.toml index 1f45ee12ca..0f4024ad9e 100644 --- a/apps/fortuna/Cargo.toml +++ b/apps/fortuna/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fortuna" -version = "9.1.2" +version = "9.2.0" edition = "2021" [lib] From 914b198a9b1d04d2a8d0909131794c6ca5e9e325 Mon Sep 17 00:00:00 2001 From: Tejas Badadare Date: Thu, 7 Aug 2025 15:34:48 -0700 Subject: [PATCH 4/4] fix(fortuna): add Bytes utoipa schema --- apps/fortuna/src/history.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/fortuna/src/history.rs b/apps/fortuna/src/history.rs index a278af9208..af00b58a70 100644 --- a/apps/fortuna/src/history.rs +++ b/apps/fortuna/src/history.rs @@ -51,6 +51,7 @@ pub enum RequestEntryState { /// the error code and any additional returned data. Note that "" often indicates an out-of-gas error. /// If the callback returns more than 256 bytes, only the first 256 bytes of the callback return value are included. /// NOTE: This field is the raw bytes returned from the callback, not hex-decoded. The client should decode it as needed. + #[schema(example = "0x4e487b710000000000000000000000000000000000000000000000000000000000000011", value_type = String)] callback_return_value: Bytes, /// How much gas the callback used. #[schema(example = "567890", value_type = String)]