From 53bf8cc7260c0358ee518fd20daecce2b693e792 Mon Sep 17 00:00:00 2001 From: Daniil Polyakov Date: Wed, 27 May 2026 00:17:26 +0300 Subject: [PATCH] feat: upgrade to new zone-sdk --- Cargo.lock | 275 ++++++++++++++++++-------- Cargo.toml | 14 +- bedrock/deployment-settings.yaml | 4 +- bedrock/docker-compose.yml | 2 +- indexer/core/src/block_store.rs | 8 +- indexer/core/src/lib.rs | 8 +- integration_tests/tests/bridge.rs | 2 +- sequencer/core/Cargo.toml | 2 + sequencer/core/src/block_publisher.rs | 67 ++++--- sequencer/core/src/lib.rs | 76 ++++++- sequencer/core/src/mock.rs | 4 +- sequencer/service/Cargo.toml | 4 - sequencer/service/src/lib.rs | 166 +--------------- 13 files changed, 340 insertions(+), 292 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58f5ad2e..a6e1867b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -733,8 +733,6 @@ checksum = "86887daca11d02e0b04f37a9cb81888aae881397fb48ff66494e356aea97554a" dependencies = [ "itertools 0.10.5", "lazy_static", - "rand 0.8.5", - "serde", ] [[package]] @@ -1056,7 +1054,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cffb0e931875b666fc4fcb20fee52e9bbd1ef836fd9e9e04ec21555f9f85f7ef" dependencies = [ "fastrand", - "gloo-timers 0.3.0", "tokio", ] @@ -2189,7 +2186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ab67060fc6b8ef687992d439ca0fa36e7ed17e9a0b16b25b601e8757df720de" dependencies = [ "data-encoding", - "syn 2.0.117", + "syn 1.0.109", ] [[package]] @@ -2673,7 +2670,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3020,7 +3017,7 @@ version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" dependencies = [ - "gloo-timers 0.2.6", + "gloo-timers", "send_wrapper 0.4.0", ] @@ -3190,18 +3187,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "gloo-timers" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" -dependencies = [ - "futures-channel", - "futures-core", - "js-sys", - "wasm-bindgen", -] - [[package]] name = "gloo-utils" version = "0.2.0" @@ -5329,7 +5314,7 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "logos-blockchain-blend-crypto" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "blake2", "logos-blockchain-groth16", @@ -5337,13 +5322,13 @@ dependencies = [ "logos-blockchain-poseidon2", "logos-blockchain-utils", "rs-merkle-tree", - "thiserror 1.0.69", + "thiserror 2.0.18", ] [[package]] name = "logos-blockchain-blend-message" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "blake2", "derivative", @@ -5354,11 +5339,12 @@ dependencies = [ "logos-blockchain-core", "logos-blockchain-groth16", "logos-blockchain-key-management-system-keys", + "logos-blockchain-log-targets", "logos-blockchain-utils", "serde", "serde-big-array", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.18", "tracing", "zeroize", ] @@ -5366,7 +5352,7 @@ dependencies = [ [[package]] name = "logos-blockchain-blend-proofs" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ed25519-dalek", "generic-array 1.3.5", @@ -5375,17 +5361,18 @@ dependencies = [ "logos-blockchain-groth16", "logos-blockchain-pol", "logos-blockchain-poq", + "logos-blockchain-poseidon2", "logos-blockchain-utils", "num-bigint 0.4.6", "serde", - "thiserror 1.0.69", + "thiserror 2.0.18", "zeroize", ] [[package]] name = "logos-blockchain-chain-broadcast-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "derivative", @@ -5401,7 +5388,7 @@ dependencies = [ [[package]] name = "logos-blockchain-chain-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "bytes", @@ -5423,7 +5410,8 @@ dependencies = [ "serde", "serde_with", "strum", - "thiserror 1.0.69", + "thiserror 2.0.18", + "time", "tokio", "tracing", "tracing-futures", @@ -5432,7 +5420,7 @@ dependencies = [ [[package]] name = "logos-blockchain-circuits-prover" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "logos-blockchain-circuits-utils", "tempfile", @@ -5441,7 +5429,7 @@ dependencies = [ [[package]] name = "logos-blockchain-circuits-utils" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "dirs", ] @@ -5449,10 +5437,11 @@ dependencies = [ [[package]] name = "logos-blockchain-common-http-client" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "futures", "hex", + "log", "logos-blockchain-chain-broadcast-service", "logos-blockchain-chain-service", "logos-blockchain-core", @@ -5462,14 +5451,15 @@ dependencies = [ "reqwest", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.18", + "tokio-util", "url", ] [[package]] name = "logos-blockchain-core" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ark-ff 0.4.2", "bincode", @@ -5494,20 +5484,21 @@ dependencies = [ "rpds", "serde", "strum", - "thiserror 1.0.69", + "thiserror 2.0.18", + "time", "tracing", ] [[package]] name = "logos-blockchain-cryptarchia-engine" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "logos-blockchain-pol", "logos-blockchain-utils", "serde", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.18", "time", "tokio", "tracing", @@ -5516,7 +5507,7 @@ dependencies = [ [[package]] name = "logos-blockchain-cryptarchia-sync" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "bytes", "futures", @@ -5527,7 +5518,7 @@ dependencies = [ "rand 0.8.5", "serde", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.18", "tokio", "tracing", ] @@ -5535,7 +5526,7 @@ dependencies = [ [[package]] name = "logos-blockchain-groth16" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ark-bn254 0.4.0", "ark-ec 0.4.2", @@ -5553,7 +5544,7 @@ dependencies = [ [[package]] name = "logos-blockchain-http-api-common" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "axum 0.7.9", "logos-blockchain-core", @@ -5561,14 +5552,19 @@ dependencies = [ "logos-blockchain-tracing", "serde", "serde_json", + "serde_urlencoded", "serde_with", + "time", "tracing", + "url", + "utoipa", + "validator", ] [[package]] name = "logos-blockchain-key-management-system-keys" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "bytes", @@ -5594,7 +5590,7 @@ dependencies = [ [[package]] name = "logos-blockchain-key-management-system-macros" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "proc-macro2", "quote", @@ -5604,7 +5600,7 @@ dependencies = [ [[package]] name = "logos-blockchain-key-management-system-operators" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "logos-blockchain-blend-proofs", @@ -5620,7 +5616,7 @@ dependencies = [ [[package]] name = "logos-blockchain-key-management-system-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "log", @@ -5637,7 +5633,7 @@ dependencies = [ [[package]] name = "logos-blockchain-ledger" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "derivative", "logos-blockchain-blend-crypto", @@ -5656,14 +5652,14 @@ dependencies = [ "rpds", "serde", "serde_arrays", - "thiserror 1.0.69", + "thiserror 2.0.18", "tracing", ] [[package]] name = "logos-blockchain-libp2p" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "backon", @@ -5674,6 +5670,7 @@ dependencies = [ "igd-next 0.16.2", "libp2p", "logos-blockchain-cryptarchia-sync", + "logos-blockchain-log-targets", "logos-blockchain-utils", "multiaddr", "natpmp", @@ -5682,16 +5679,34 @@ dependencies = [ "rand 0.8.5", "serde", "serde_with", - "thiserror 1.0.69", + "thiserror 2.0.18", "tokio", "tracing", "zerocopy", ] +[[package]] +name = "logos-blockchain-log-targets" +version = "0.1.2" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" +dependencies = [ + "logos-blockchain-log-targets-macros", +] + +[[package]] +name = "logos-blockchain-log-targets-macros" +version = "0.1.2" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "logos-blockchain-mmr" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ark-ff 0.4.2", "logos-blockchain-groth16", @@ -5704,13 +5719,14 @@ dependencies = [ [[package]] name = "logos-blockchain-network-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "futures", "logos-blockchain-core", "logos-blockchain-cryptarchia-sync", "logos-blockchain-libp2p", + "logos-blockchain-log-targets", "logos-blockchain-tracing", "overwatch", "rand 0.8.5", @@ -5724,47 +5740,48 @@ dependencies = [ [[package]] name = "logos-blockchain-poc" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "logos-blockchain-circuits-prover", "logos-blockchain-circuits-utils", "logos-blockchain-groth16", + "logos-blockchain-proofs-error", "logos-blockchain-witness-generator", "num-bigint 0.4.6", "serde", "serde_json", - "thiserror 2.0.18", "tracing", ] [[package]] name = "logos-blockchain-pol" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "astro-float", "logos-blockchain-circuits-prover", "logos-blockchain-circuits-utils", "logos-blockchain-groth16", + "logos-blockchain-proofs-error", "logos-blockchain-utils", "logos-blockchain-witness-generator", "num-bigint 0.4.6", "num-traits", "serde", "serde_json", - "thiserror 2.0.18", "tracing", ] [[package]] name = "logos-blockchain-poq" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "logos-blockchain-circuits-prover", "logos-blockchain-circuits-utils", "logos-blockchain-groth16", "logos-blockchain-pol", + "logos-blockchain-proofs-error", "logos-blockchain-witness-generator", "num-bigint 0.4.6", "serde", @@ -5776,7 +5793,7 @@ dependencies = [ [[package]] name = "logos-blockchain-poseidon2" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ark-bn254 0.4.0", "ark-ff 0.4.2", @@ -5784,10 +5801,20 @@ dependencies = [ "num-bigint 0.4.6", ] +[[package]] +name = "logos-blockchain-proofs-error" +version = "0.1.2" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" +dependencies = [ + "logos-blockchain-groth16", + "serde_json", + "thiserror 2.0.18", +] + [[package]] name = "logos-blockchain-services-utils" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "futures", @@ -5795,24 +5822,25 @@ dependencies = [ "overwatch", "serde", "serde_json", - "thiserror 1.0.69", + "thiserror 2.0.18", "tracing", ] [[package]] name = "logos-blockchain-storage-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "bytes", "futures", "logos-blockchain-core", "logos-blockchain-cryptarchia-engine", + "logos-blockchain-log-targets", "logos-blockchain-tracing", "overwatch", "serde", - "thiserror 1.0.69", + "thiserror 2.0.18", "tokio", "tracing", ] @@ -5820,12 +5848,13 @@ dependencies = [ [[package]] name = "logos-blockchain-time-service" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "futures", "log", "logos-blockchain-cryptarchia-engine", + "logos-blockchain-log-targets", "logos-blockchain-tracing", "logos-blockchain-utils", "overwatch", @@ -5842,8 +5871,10 @@ dependencies = [ [[package]] name = "logos-blockchain-tracing" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ + "flate2", + "logos-blockchain-log-targets", "opentelemetry", "opentelemetry-appender-tracing", "opentelemetry-http", @@ -5866,7 +5897,7 @@ dependencies = [ [[package]] name = "logos-blockchain-utils" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "blake2", @@ -5877,13 +5908,15 @@ dependencies = [ "rand 0.8.5", "serde", "serde_with", + "serde_yaml", + "thiserror 2.0.18", "time", ] [[package]] name = "logos-blockchain-utxotree" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "ark-ff 0.4.2", "logos-blockchain-groth16", @@ -5891,13 +5924,13 @@ dependencies = [ "num-bigint 0.4.6", "rpds", "serde", - "thiserror 1.0.69", + "thiserror 2.0.18", ] [[package]] name = "logos-blockchain-witness-generator" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "tempfile", ] @@ -5905,12 +5938,13 @@ dependencies = [ [[package]] name = "logos-blockchain-zksign" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "logos-blockchain-circuits-prover", "logos-blockchain-circuits-utils", "logos-blockchain-groth16", "logos-blockchain-poseidon2", + "logos-blockchain-proofs-error", "logos-blockchain-witness-generator", "num-bigint 0.4.6", "serde", @@ -5922,13 +5956,15 @@ dependencies = [ [[package]] name = "logos-blockchain-zone-sdk" version = "0.1.2" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=ee281a447d95a951752461ee0a6e88eb4a0f17cf#ee281a447d95a951752461ee0a6e88eb4a0f17cf" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git?rev=dd055cc1ef7c130f710a52a190edd97bc7b0f71b#dd055cc1ef7c130f710a52a190edd97bc7b0f71b" dependencies = [ "async-trait", "futures", + "hex", "logos-blockchain-common-http-client", "logos-blockchain-core", "logos-blockchain-groth16", + "logos-blockchain-http-api-common", "logos-blockchain-key-management-system-service", "rand 0.8.5", "reqwest", @@ -7258,6 +7294,30 @@ dependencies = [ "toml_edit 0.25.4+spec-1.1.0", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro-error-attr2" version = "2.0.0" @@ -7606,7 +7666,7 @@ dependencies = [ "once_cell", "socket2 0.6.3", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -8525,7 +8585,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -8583,7 +8643,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs 0.26.11", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -8793,11 +8853,13 @@ version = "0.1.0" dependencies = [ "anyhow", "borsh", + "bridge_core", "bytesize", "chrono", "common", "faucet_core", "futures", + "hex", "humantime-serde", "log", "logos-blockchain-core", @@ -8824,7 +8886,6 @@ version = "0.1.0" dependencies = [ "anyhow", "borsh", - "bridge_core", "bytesize", "clap", "common", @@ -8832,8 +8893,6 @@ dependencies = [ "futures", "jsonrpsee", "log", - "logos-blockchain-core", - "logos-blockchain-zone-sdk", "mempool", "nssa", "sequencer_core", @@ -8841,7 +8900,6 @@ dependencies = [ "sequencer_service_rpc", "tokio", "tokio-util", - "vault_core", ] [[package]] @@ -9360,6 +9418,12 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "symlink" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" + [[package]] name = "syn" version = "1.0.109" @@ -9506,7 +9570,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -10083,11 +10147,12 @@ dependencies = [ [[package]] name = "tracing-appender" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786d480bce6247ab75f005b14ae1624ad978d3029d9113f0a22fa1ac773faeaf" +checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" dependencies = [ "crossbeam-channel", + "symlink", "thiserror 2.0.18", "time", "tracing-subscriber 0.3.23", @@ -10501,6 +10566,30 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" +[[package]] +name = "utoipa" +version = "4.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5afb1a60e207dca502682537fefcfd9921e71d0b83e9576060f09abc6efab23" +dependencies = [ + "indexmap 2.13.0", + "serde", + "serde_json", + "utoipa-gen", +] + +[[package]] +name = "utoipa-gen" +version = "4.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20c24e8ab68ff9ee746aad22d39b5535601e6416d1b0feeabf78be986a5c4392" +dependencies = [ + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "uuid" version = "1.22.0" @@ -10512,6 +10601,36 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "validator" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43fb22e1a008ece370ce08a3e9e4447a910e92621bb49b85d6e48a45397e7cfa" +dependencies = [ + "idna", + "once_cell", + "regex", + "serde", + "serde_derive", + "serde_json", + "url", + "validator_derive", +] + +[[package]] +name = "validator_derive" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7df16e474ef958526d1205f6dda359fdfab79d9aa6d54bafcb92dcd07673dca" +dependencies = [ + "darling 0.20.11", + "once_cell", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "valuable" version = "0.1.1" @@ -10867,7 +10986,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 19f4c066..ca9880ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -137,13 +137,13 @@ schemars = "1.2" async-stream = "0.3.6" criterion = { version = "0.8", features = ["html_reports"] } -logos-blockchain-common-http-client = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-key-management-system-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-core = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-chain-broadcast-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-chain-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-zone-sdk = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } -logos-blockchain-http-api-common = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "ee281a447d95a951752461ee0a6e88eb4a0f17cf" } +logos-blockchain-common-http-client = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-key-management-system-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-core = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-chain-broadcast-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-chain-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-zone-sdk = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } +logos-blockchain-http-api-common = { git = "https://github.com/logos-blockchain/logos-blockchain.git", rev = "dd055cc1ef7c130f710a52a190edd97bc7b0f71b" } rocksdb = { version = "0.24.0", default-features = false, features = [ "snappy", diff --git a/bedrock/deployment-settings.yaml b/bedrock/deployment-settings.yaml index 7ef63f03..de58f12a 100644 --- a/bedrock/deployment-settings.yaml +++ b/bedrock/deployment-settings.yaml @@ -67,7 +67,9 @@ cryptarchia: - opcode: 17 payload: channel_id: '0000000000000000000000000000000000000000000000000000000000000000' - inscription: '67656e65736973' + # chain_id_len=12 (u64_le), chain_id=logos-devnet (utf-8), + # genesis_time=2026-01-10T07:47:56Z (u64_le), epoch_nonce=[0u8; 32] + inscription: '0c000000000000006c6f676f732d6465766e65742c046269000000000000000000000000000000000000000000000000000000000000000000000000' parent: '0000000000000000000000000000000000000000000000000000000000000000' signer: '0000000000000000000000000000000000000000000000000000000000000000' execution_gas_price: 0 diff --git a/bedrock/docker-compose.yml b/bedrock/docker-compose.yml index e16e505b..356c6df8 100644 --- a/bedrock/docker-compose.yml +++ b/bedrock/docker-compose.yml @@ -1,7 +1,7 @@ services: logos-blockchain-node-0: - image: ghcr.io/logos-blockchain/logos-blockchain@sha256:9f1829dea335c56f6ff68ae37ea872ed5313b96b69e8ffe143c02b7217de85fc + image: ghcr.io/logos-blockchain/logos-blockchain@sha256:f160cfbf898a06554451cc066d84cfd0f8ab62d59bd3e62d9cde3bd5582c12ab ports: - "${PORT:-8080}:18080/tcp" volumes: diff --git a/indexer/core/src/block_store.rs b/indexer/core/src/block_store.rs index b66b778f..323f5ff3 100644 --- a/indexer/core/src/block_store.rs +++ b/indexer/core/src/block_store.rs @@ -6,7 +6,7 @@ use common::{ transaction::{NSSATransaction, clock_invocation}, }; use log::info; -use logos_blockchain_core::{header::HeaderId, mantle::ops::channel::MsgId}; +use logos_blockchain_core::header::HeaderId; use logos_blockchain_zone_sdk::Slot; use nssa::{Account, AccountId, V03State}; use nssa_core::BlockId; @@ -97,16 +97,16 @@ impl IndexerStore { Ok(self.dbio.calculate_state_for_id(block_id)?) } - pub fn get_zone_cursor(&self) -> Result> { + pub fn get_zone_cursor(&self) -> Result> { let Some(bytes) = self.dbio.get_zone_sdk_indexer_cursor_bytes()? else { return Ok(None); }; - let cursor: (MsgId, Slot) = serde_json::from_slice(&bytes) + let cursor: Slot = serde_json::from_slice(&bytes) .context("Failed to deserialize stored zone-sdk indexer cursor")?; Ok(Some(cursor)) } - pub fn set_zone_cursor(&self, cursor: &(MsgId, Slot)) -> Result<()> { + pub fn set_zone_cursor(&self, cursor: &Slot) -> Result<()> { let bytes = serde_json::to_vec(cursor).context("Failed to serialize zone-sdk indexer cursor")?; self.dbio.put_zone_sdk_indexer_cursor_bytes(&bytes)?; diff --git a/indexer/core/src/lib.rs b/indexer/core/src/lib.rs index 400d0a9d..b0416905 100644 --- a/indexer/core/src/lib.rs +++ b/indexer/core/src/lib.rs @@ -81,8 +81,8 @@ impl IndexerCore { error!("Failed to deserialize L2 block from zone-sdk: {e}"); // Advance past the broken inscription so we don't // re-process it on restart. - cursor = Some((zone_block.id, slot)); - if let Err(err) = self.store.set_zone_cursor(&(zone_block.id, slot)) { + cursor = Some(slot); + if let Err(err) = self.store.set_zone_cursor(&slot) { warn!("Failed to persist indexer cursor: {err:#}"); } continue; @@ -98,8 +98,8 @@ impl IndexerCore { error!("Failed to store block {}: {err:#}", block.header.block_id); } - cursor = Some((zone_block.id, slot)); - if let Err(err) = self.store.set_zone_cursor(&(zone_block.id, slot)) { + cursor = Some(slot); + if let Err(err) = self.store.set_zone_cursor(&slot) { warn!("Failed to persist indexer cursor: {err:#}"); } yield Ok(block); diff --git a/integration_tests/tests/bridge.rs b/integration_tests/tests/bridge.rs index cc4042ba..7cb63b22 100644 --- a/integration_tests/tests/bridge.rs +++ b/integration_tests/tests/bridge.rs @@ -27,7 +27,7 @@ use nssa_core::{InputAccountIdentity, account::AccountWithMetadata}; use sequencer_service_rpc::RpcClient as _; use tokio::test; -const TIME_TO_FINALIZE_DEPOSIT_EVENT_ON_BEDROCK: Duration = Duration::from_mins(6); +const TIME_TO_FINALIZE_DEPOSIT_EVENT_ON_BEDROCK: Duration = Duration::from_mins(2); #[test] async fn public_bridge_deposit_invocation_is_dropped() -> anyhow::Result<()> { diff --git a/sequencer/core/Cargo.toml b/sequencer/core/Cargo.toml index 5f74fbde..985fc969 100644 --- a/sequencer/core/Cargo.toml +++ b/sequencer/core/Cargo.toml @@ -16,6 +16,7 @@ mempool.workspace = true logos-blockchain-zone-sdk.workspace = true testnet_initial_state.workspace = true faucet_core.workspace = true +bridge_core.workspace = true vault_core.workspace = true anyhow.workspace = true @@ -31,6 +32,7 @@ logos-blockchain-core.workspace = true rand.workspace = true borsh.workspace = true bytesize.workspace = true +hex.workspace = true url.workspace = true [features] diff --git a/sequencer/core/src/block_publisher.rs b/sequencer/core/src/block_publisher.rs index 9f4c8235..62cd7259 100644 --- a/sequencer/core/src/block_publisher.rs +++ b/sequencer/core/src/block_publisher.rs @@ -1,6 +1,6 @@ -use std::{sync::Arc, time::Duration}; +use std::{pin::Pin, sync::Arc, time::Duration}; -use anyhow::{Context as _, Result, anyhow}; +use anyhow::{Context as _, Result}; use common::block::Block; use log::warn; pub use logos_blockchain_core::mantle::ops::channel::MsgId; @@ -10,7 +10,7 @@ use logos_blockchain_zone_sdk::{ CommonHttpClient, adapter::NodeHttpClient, sequencer::{Event, SequencerConfig as ZoneSdkSequencerConfig, SequencerHandle, ZoneSequencer}, - state::InscriptionInfo, + state::{DepositInfo, FinalizedOp, InscriptionInfo}, }; use tokio::task::JoinHandle; @@ -18,12 +18,16 @@ use crate::config::BedrockConfig; /// Sink for `Event::Published` checkpoints emitted by the drive task. /// Caller is responsible for persistence (e.g. writing to rocksdb). -pub type CheckpointSink = Box; +pub type CheckpointSink = Box; /// Sink for finalized L2 block ids derived from `Event::TxsFinalized` and /// `Event::FinalizedInscriptions`. Caller is responsible for cleanup /// (e.g. marking pending blocks as finalized in storage). -pub type FinalizedBlockSink = Box; +pub type FinalizedBlockSink = Box; + +/// Sink for finalized Bedrock deposit events. +pub type OnDepositEventSink = + Box Pin + Send>> + Send + 'static>; #[expect(async_fn_in_trait, reason = "We don't care about Send/Sync here")] pub trait BlockPublisherTrait: Clone { @@ -34,6 +38,7 @@ pub trait BlockPublisherTrait: Clone { initial_checkpoint: Option, on_checkpoint: CheckpointSink, on_finalized_block: FinalizedBlockSink, + on_deposit_event: OnDepositEventSink, ) -> Result; /// Fire-and-forget publish. Zone-sdk drives the actual submission and @@ -65,6 +70,7 @@ impl BlockPublisherTrait for ZoneSdkPublisher { initial_checkpoint: Option, on_checkpoint: CheckpointSink, on_finalized_block: FinalizedBlockSink, + on_deposit_event: OnDepositEventSink, ) -> Result { let basic_auth = config.auth.clone().map(Into::into); let node = NodeHttpClient::new(CommonHttpClient::new(basic_auth), config.node_url.clone()); @@ -89,10 +95,20 @@ impl BlockPublisherTrait for ZoneSdkPublisher { }; match event { Event::Published { checkpoint, .. } => on_checkpoint(checkpoint), - Event::TxsFinalized { inscriptions, .. } - | Event::FinalizedInscriptions { inscriptions } => { - if let Some(max_block_id) = max_block_id_from_inscriptions(&inscriptions) { - on_finalized_block(max_block_id); + Event::TxsFinalized { items } => { + for op in items.into_iter().flat_map(|item| item.ops) { + match op { + FinalizedOp::Inscription(inscription) => { + if let Some(block_id) = block_id_from_inscription(&inscription) + { + on_finalized_block(block_id); + } + } + FinalizedOp::Deposit(deposit) => { + on_deposit_event(deposit).await; + } + FinalizedOp::Withdraw(_) => {} + } } } Event::ChannelUpdate { .. } | Event::Ready => {} @@ -110,27 +126,26 @@ impl BlockPublisherTrait for ZoneSdkPublisher { async fn publish_block(&self, block: &Block) -> Result<()> { let data = borsh::to_vec(block).context("Failed to serialize block")?; + let data_bounded = data + .try_into() + .context("Block data exceeds maximum allowed size")?; + self.handle - .publish_message(data) + .publish_message(data_bounded) .await - .map_err(|e| anyhow!("zone-sdk publish failed: {e}"))?; + .context("Failed to publish block")?; + Ok(()) } } -/// Deserialize each inscription payload as a `Block` and return the highest -/// `block_id`. Bad payloads are logged and skipped. -fn max_block_id_from_inscriptions(inscriptions: &[InscriptionInfo]) -> Option { - inscriptions - .iter() - .filter_map( - |inscription| match borsh::from_slice::(&inscription.payload) { - Ok(block) => Some(block.header.block_id), - Err(err) => { - warn!("Failed to deserialize finalized inscription as Block: {err:#}"); - None - } - }, - ) - .max() +/// Deserialize inscription payload as a `Block` and return it's`block_id`. +/// Bad payloads are logged and skipped. +fn block_id_from_inscription(inscription: &InscriptionInfo) -> Option { + borsh::from_slice::(&inscription.payload) + .inspect_err(|err| { + warn!("Failed to deserialize block from inscription: {err:?}"); + }) + .ok() + .map(|block| block.header.block_id) } diff --git a/sequencer/core/src/lib.rs b/sequencer/core/src/lib.rs index 3425db2a..6de57806 100644 --- a/sequencer/core/src/lib.rs +++ b/sequencer/core/src/lib.rs @@ -1,6 +1,7 @@ use std::{path::Path, time::Instant}; use anyhow::{Context as _, Result, anyhow}; +use borsh::BorshDeserialize; use common::{ HashType, block::{BedrockStatus, Block, HashableBlockData}, @@ -36,6 +37,17 @@ pub enum TransactionOrigin { Sequencer, } +#[derive(Clone, Debug, BorshDeserialize)] +struct DepositMetadata { + recipient_id: nssa::AccountId, +} + +impl DepositMetadata { + fn decode(bytes: &[u8]) -> Result { + Self::try_from_slice(bytes) + } +} + pub struct SequencerCore { state: nssa::V03State, store: SequencerStore, @@ -140,6 +152,37 @@ impl SequencerCore { } }); + let (mempool, mempool_handle) = MemPool::new(config.mempool_max_size); + + let mempool_handle_for_deposit = mempool_handle.clone(); + let on_deposit_event: block_publisher::OnDepositEventSink = Box::new(move |deposit| { + let mempool_handle_for_deposit = mempool_handle_for_deposit.clone(); + Box::pin(async move { + info!( + "Observed Bedrock Deposit event with id: {:?}", + hex::encode(deposit.op_id) + ); + let tx = match build_bridge_deposit_tx(&deposit) { + Ok(tx) => tx, + Err(err) => { + warn!( + "Skipping finalized Bedrock deposit event due to tx build failure: {err:#}" + ); + return; + } + }; + + if let Err(err) = mempool_handle_for_deposit + .push((TransactionOrigin::Sequencer, tx)) + .await + { + error!( + "Failed to queue sequencer transaction built from finalized Bedrock event: {err:#}" + ); + } + }) + }); + let block_publisher = BP::new( &config.bedrock_config, bedrock_signing_key, @@ -147,6 +190,7 @@ impl SequencerCore { initial_checkpoint, on_checkpoint, on_finalized_block, + on_deposit_event, ) .await .expect("Failed to initialize Block Publisher"); @@ -159,8 +203,6 @@ impl SequencerCore { error!("Failed to publish genesis block: {err:#}"); } - let (mempool, mempool_handle) = MemPool::new(config.mempool_max_size); - let sequencer_core = Self { state, store, @@ -443,6 +485,36 @@ fn build_supply_bridge_account_genesis_transaction(balance: u128) -> PublicTrans PublicTransaction::new(message, witness_set) } +fn build_bridge_deposit_tx( + deposit: &logos_blockchain_zone_sdk::state::DepositInfo, +) -> Result { + let metadata = DepositMetadata::decode(&deposit.metadata) + .context("Failed to decode finalized Bedrock deposit metadata")?; + + let bridge_program_id = Program::bridge().id(); + let vault_program_id = Program::vault().id(); + let recipient_vault_id = + vault_core::compute_vault_account_id(vault_program_id, metadata.recipient_id); + + let message = Message::try_new( + bridge_program_id, + vec![nssa::system_bridge_account_id(), recipient_vault_id], + vec![], + bridge_core::Instruction::Deposit { + vault_program_id, + recipient_id: metadata.recipient_id, + amount: u128::from(deposit.amount), + }, + ) + .context("Failed to build bridge deposit message")?; + + let witness_set = nssa::public_transaction::WitnessSet::from_raw_parts(vec![]); + Ok(NSSATransaction::Public(PublicTransaction::new( + message, + witness_set, + ))) +} + /// Load signing key from file or generate a new one if it doesn't exist. fn load_or_create_signing_key(path: &Path) -> Result { if path.exists() { diff --git a/sequencer/core/src/mock.rs b/sequencer/core/src/mock.rs index ebe6ea5d..e041269a 100644 --- a/sequencer/core/src/mock.rs +++ b/sequencer/core/src/mock.rs @@ -6,7 +6,8 @@ use logos_blockchain_key_management_system_service::keys::Ed25519Key; use crate::{ block_publisher::{ - BlockPublisherTrait, CheckpointSink, FinalizedBlockSink, SequencerCheckpoint, + BlockPublisherTrait, CheckpointSink, FinalizedBlockSink, OnDepositEventSink, + SequencerCheckpoint, }, config::BedrockConfig, }; @@ -24,6 +25,7 @@ impl BlockPublisherTrait for MockBlockPublisher { _initial_checkpoint: Option, _on_checkpoint: CheckpointSink, _on_finalized_block: FinalizedBlockSink, + _on_deposit_event: OnDepositEventSink, ) -> Result { Ok(Self) } diff --git a/sequencer/service/Cargo.toml b/sequencer/service/Cargo.toml index 26a32d5c..beed6be2 100644 --- a/sequencer/service/Cargo.toml +++ b/sequencer/service/Cargo.toml @@ -11,13 +11,9 @@ workspace = true common.workspace = true nssa.workspace = true mempool.workspace = true -bridge_core.workspace = true -vault_core.workspace = true sequencer_core = { workspace = true, features = ["testnet"] } sequencer_service_protocol.workspace = true sequencer_service_rpc = { workspace = true, features = ["server"] } -logos-blockchain-zone-sdk.workspace = true -logos-blockchain-core.workspace = true clap = { workspace = true, features = ["derive", "env"] } anyhow.workspace = true diff --git a/sequencer/service/src/lib.rs b/sequencer/service/src/lib.rs index 81e3c50c..416822ac 100644 --- a/sequencer/service/src/lib.rs +++ b/sequencer/service/src/lib.rs @@ -1,23 +1,11 @@ use std::{net::SocketAddr, sync::Arc, time::Duration}; use anyhow::{Context as _, Result, anyhow}; -#[cfg(not(feature = "standalone"))] -use borsh::BorshDeserialize; use bytesize::ByteSize; use common::transaction::NSSATransaction; -#[cfg(not(feature = "standalone"))] -use futures::StreamExt as _; use futures::never::Never; use jsonrpsee::server::ServerHandle; -#[cfg(not(feature = "standalone"))] -use log::warn; use log::{error, info}; -#[cfg(not(feature = "standalone"))] -use logos_blockchain_core::mantle::ops::channel::MsgId; -#[cfg(not(feature = "standalone"))] -use logos_blockchain_zone_sdk::{ - CommonHttpClient, Slot, ZoneMessage, adapter::NodeHttpClient, indexer::ZoneIndexer, -}; use mempool::MemPoolHandle; #[cfg(not(feature = "standalone"))] use sequencer_core::SequencerCore; @@ -32,19 +20,6 @@ pub mod service; const REQUEST_BODY_MAX_SIZE: ByteSize = ByteSize::mib(10); -#[cfg(not(feature = "standalone"))] -#[derive(Clone, Debug, BorshDeserialize)] -struct DepositMetadata { - recipient_id: nssa::AccountId, -} - -#[cfg(not(feature = "standalone"))] -impl DepositMetadata { - fn decode(bytes: &[u8]) -> Result { - Self::try_from_slice(bytes) - } -} - /// Handle to manage the sequencer and its tasks. /// /// Implements `Drop` to ensure all tasks are aborted and the RPC server is stopped when dropped. @@ -53,7 +28,6 @@ pub struct SequencerHandle { /// Option because of `Drop` which forbids to simply move out of `self` in `stopped()`. server_handle: Option, main_loop_handle: JoinHandle>, - bedrock_deposit_loop_handle: Option>>, } impl SequencerHandle { @@ -61,13 +35,11 @@ impl SequencerHandle { addr: SocketAddr, server_handle: ServerHandle, main_loop_handle: JoinHandle>, - bedrock_deposit_loop_handle: Option>>, ) -> Self { Self { addr, server_handle: Some(server_handle), main_loop_handle, - bedrock_deposit_loop_handle, } } @@ -81,12 +53,9 @@ impl SequencerHandle { addr: _, server_handle, main_loop_handle, - bedrock_deposit_loop_handle, } = &mut self; let server_handle = server_handle.take().expect("Server handle is set"); - let deposit_opt_fut = - futures::future::OptionFuture::from(bedrock_deposit_loop_handle.take()); tokio::select! { () = server_handle.stopped() => { Err(anyhow!("RPC Server stopped")) @@ -96,11 +65,6 @@ impl SequencerHandle { .context("Main loop task panicked")? .context("Main loop exited unexpectedly") } - Some(res) = deposit_opt_fut => { - res - .context("Bedrock deposit loop task panicked")? - .context("Bedrock deposit loop exited unexpectedly") - } } } @@ -114,14 +78,10 @@ impl SequencerHandle { addr: _, server_handle, main_loop_handle, - bedrock_deposit_loop_handle, } = self; let stopped = server_handle.as_ref().is_none_or(ServerHandle::is_stopped) - || main_loop_handle.is_finished() - || bedrock_deposit_loop_handle - .as_ref() - .is_some_and(JoinHandle::is_finished); + || main_loop_handle.is_finished(); !stopped } @@ -137,13 +97,9 @@ impl Drop for SequencerHandle { addr: _, server_handle, main_loop_handle, - bedrock_deposit_loop_handle, } = self; main_loop_handle.abort(); - if let Some(handle) = bedrock_deposit_loop_handle { - handle.abort(); - } let Some(handle) = server_handle else { return; @@ -158,8 +114,6 @@ impl Drop for SequencerHandle { pub async fn run(config: SequencerConfig, port: u16) -> Result { let block_timeout = config.block_create_timeout; let max_block_size = config.max_block_size; - #[cfg(not(feature = "standalone"))] - let bedrock_config = config.bedrock_config.clone(); let (sequencer_core, mempool_handle) = SequencerCore::start_from_config(config).await; @@ -180,26 +134,9 @@ pub async fn run(config: SequencerConfig, port: u16) -> Result info!("Starting main sequencer loop"); let main_loop_handle = tokio::spawn(main_loop(seq_core_wrapped, block_timeout)); - #[cfg(not(feature = "standalone"))] - let bedrock_deposit_loop_handle = { - info!("Starting Bedrock deposit listener loop"); - Some(tokio::spawn(bedrock_deposit_loop( - bedrock_config, - mempool_handle, - ))) - }; - #[cfg(feature = "standalone")] - let bedrock_deposit_loop_handle = { - let _ = mempool_handle; - None - }; + let _ = mempool_handle; - Ok(SequencerHandle::new( - addr, - server_handle, - main_loop_handle, - bedrock_deposit_loop_handle, - )) + Ok(SequencerHandle::new(addr, server_handle, main_loop_handle)) } async fn run_server( @@ -248,100 +185,3 @@ async fn main_loop(seq_core: Arc>, block_timeout: Duration) info!("Waiting for new transactions"); } } - -#[cfg(not(feature = "standalone"))] -async fn bedrock_deposit_loop( - bedrock_config: BedrockConfig, - mempool_handle: MemPoolHandle<(TransactionOrigin, NSSATransaction)>, -) -> Result { - let basic_auth = bedrock_config.auth.map(Into::into); - let node = NodeHttpClient::new(CommonHttpClient::new(basic_auth), bedrock_config.node_url); - let zone_indexer = ZoneIndexer::new(bedrock_config.channel_id, node); - - let mut cursor: Option<(MsgId, Slot)> = None; - let poll_interval = Duration::from_secs(1); - - // Short-term fix: dummy MsgId so zone-sdk skips the whole slot on re-poll. - // TODO: drop once zone-sdk indexer API is updated to take only `Slot`. - let dummy_msg_id = MsgId::from([0xff_u8; 32]); - - loop { - let stream = match zone_indexer.next_messages(cursor).await { - Ok(stream) => stream, - Err(err) => { - error!("Failed to start Bedrock deposit stream: {err}"); - tokio::time::sleep(poll_interval).await; - continue; - } - }; - - let mut stream = std::pin::pin!(stream); - while let Some((msg, slot)) = stream.next().await { - cursor = Some((dummy_msg_id, slot)); - match msg { - ZoneMessage::Block(block) => { - info!("Observed Bedrock channel block id {:?}", block.id); - } - ZoneMessage::Deposit(deposit) => { - let metadata = match DepositMetadata::decode(&deposit.metadata) { - Ok(metadata) => metadata, - Err(err) => { - warn!("Skipping Bedrock Deposit with invalid metadata: {err}"); - continue; - } - }; - - let tx = match build_bridge_deposit_tx(&metadata) { - Ok(tx) => tx, - Err(err) => { - warn!("Skipping Bedrock Deposit due to tx build failure: {err:#}"); - continue; - } - }; - - info!( - "Observed Bedrock Deposit for recipient {recipient_id}, pushing to mempool", - recipient_id = metadata.recipient_id - ); - mempool_handle - .push((TransactionOrigin::Sequencer, tx)) - .await - .context("Mempool is closed while pushing Bedrock Deposit transaction")?; - } - ZoneMessage::Withdraw(_) => {} - } - } - - tokio::time::sleep(poll_interval).await; - } -} - -#[cfg(not(feature = "standalone"))] -fn build_bridge_deposit_tx(metadata: &DepositMetadata) -> Result { - // TODO: Remove this constant once we have a way to get the deposit amount from Bedrock deposit - // inputs. - const TEMPORARY_BRIDGE_DEPOSIT_AMOUNT: u128 = 1; - - let bridge_program_id = nssa::program::Program::bridge().id(); - let vault_program_id = nssa::program::Program::vault().id(); - let recipient_vault_id = - vault_core::compute_vault_account_id(vault_program_id, metadata.recipient_id); - - let message = nssa::public_transaction::Message::try_new( - bridge_program_id, - vec![nssa::system_bridge_account_id(), recipient_vault_id], - vec![], - bridge_core::Instruction::Deposit { - vault_program_id, - recipient_id: metadata.recipient_id, - amount: TEMPORARY_BRIDGE_DEPOSIT_AMOUNT, - }, - ) - .context("Failed to build bridge deposit message")?; - - let witness_set = nssa::public_transaction::WitnessSet::from_raw_parts(vec![]); - Ok(NSSATransaction::Public(nssa::PublicTransaction::new( - message, - witness_set, - ))) -}