diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 38161a0f..a8efedd9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,7 +99,7 @@ jobs: run: rustup install - name: Install nextest - run: cargo install cargo-nextest + run: cargo install --locked cargo-nextest - name: Run tests env: diff --git a/Cargo.lock b/Cargo.lock index 75f1877b..82889f14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,18 +376,6 @@ dependencies = [ "triomphe", ] -[[package]] -name = "ark-bls12-381" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c775f0d12169cba7aae4caeb547bb6a50781c7449a8aa53793827c9ec4abf488" -dependencies = [ - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-serialize 0.4.2", - "ark-std 0.4.0", -] - [[package]] name = "ark-bn254" version = "0.4.0" @@ -644,23 +632,6 @@ dependencies = [ "hashbrown 0.15.5", ] -[[package]] -name = "ark-poly-commit" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a741492629ffcd228337676dc223a28551aa6792eedb8a2a22c767f00df6c89" -dependencies = [ - "ark-crypto-primitives 0.4.0", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-poly 0.4.2", - "ark-relations 0.4.0", - "ark-serialize 0.4.2", - "ark-std 0.4.0", - "derivative", - "digest", -] - [[package]] name = "ark-r1cs-std" version = "0.5.0" @@ -956,11 +927,8 @@ name = "bedrock_client" version = "0.1.0" dependencies = [ "anyhow", - "broadcast-service", - "common-http-client", - "futures", - "log", - "nomos-core", + "logos-blockchain-common-http-client", + "logos-blockchain-core", "reqwest", "tokio-retry", "url", @@ -1062,18 +1030,6 @@ dependencies = [ "generic-array 0.14.7", ] -[[package]] -name = "blst" -version = "0.3.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcdb4c7013139a150f9fc55d123186dbfaba0d912817466282c73ac49e71fb45" -dependencies = [ - "cc", - "glob", - "threadpool", - "zeroize", -] - [[package]] name = "bonsai-sdk" version = "1.4.1" @@ -1110,22 +1066,6 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "broadcast-service" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "derivative", - "futures", - "nomos-core", - "overwatch", - "serde", - "tokio", - "tokio-stream", - "tracing", -] - [[package]] name = "bs58" version = "0.5.1" @@ -1282,35 +1222,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "chain-service" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "broadcast-service", - "bytes", - "cryptarchia-engine", - "cryptarchia-sync", - "futures", - "groth16", - "nomos-core", - "nomos-ledger", - "nomos-network", - "nomos-storage", - "nomos-utils", - "num-bigint", - "overwatch", - "serde", - "serde_with", - "services-utils", - "strum", - "thiserror 1.0.69", - "tokio", - "tracing", - "tracing-futures", -] - [[package]] name = "chrono" version = "0.4.43" @@ -1335,23 +1246,6 @@ dependencies = [ "inout", ] -[[package]] -name = "circuits-prover" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "circuits-utils", - "tempfile", -] - -[[package]] -name = "circuits-utils" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "dirs", -] - [[package]] name = "clang-sys" version = "1.8.1" @@ -1436,24 +1330,6 @@ dependencies = [ "thiserror 2.0.17", ] -[[package]] -name = "common-http-client" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "broadcast-service", - "chain-service", - "futures", - "nomos-core", - "nomos-da-messages", - "nomos-http-api-common", - "reqwest", - "serde", - "serde_json", - "thiserror 1.0.69", - "url", -] - [[package]] name = "console" version = "0.16.2" @@ -1581,37 +1457,6 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "cryptarchia-engine" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "cfg_eval", - "nomos-utils", - "serde", - "serde_with", - "thiserror 1.0.69", - "time", - "tracing", -] - -[[package]] -name = "cryptarchia-sync" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "bytes", - "cryptarchia-engine", - "futures", - "nomos-core", - "rand 0.8.5", - "serde", - "serde_with", - "thiserror 1.0.69", - "tokio", - "tracing", -] - [[package]] name = "crypto-bigint" version = "0.5.5" @@ -2412,24 +2257,6 @@ dependencies = [ "spinning_top", ] -[[package]] -name = "groth16" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-bn254 0.4.0", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-groth16 0.4.0", - "ark-serialize 0.4.2", - "generic-array 1.3.5", - "hex", - "num-bigint", - "serde", - "serde_json", - "thiserror 2.0.17", -] - [[package]] name = "group" version = "0.13.0" @@ -2999,15 +2826,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -3101,56 +2919,6 @@ dependencies = [ "cpufeatures", ] -[[package]] -name = "key-management-system-keys" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "bytes", - "ed25519-dalek", - "generic-array 1.3.5", - "groth16", - "key-management-system-macros", - "nomos-blend-proofs", - "nomos-utils", - "num-bigint", - "poseidon2", - "rand_core 0.6.4", - "serde", - "subtle", - "thiserror 2.0.17", - "tokio", - "tracing", - "zeroize", - "zksign", -] - -[[package]] -name = "key-management-system-macros" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.114", -] - -[[package]] -name = "key-management-system-service" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "key-management-system-keys", - "log", - "overwatch", - "serde", - "thiserror 2.0.17", - "tokio", - "tracing", -] - [[package]] name = "key_protocol" version = "0.1.0" @@ -3172,41 +2940,6 @@ dependencies = [ "thiserror 2.0.17", ] -[[package]] -name = "kzgrs" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-bls12-381", - "ark-ec 0.4.2", - "ark-ff 0.4.2", - "ark-poly 0.4.2", - "ark-poly-commit", - "ark-serialize 0.4.2", - "blake2", - "blst", - "num-bigint", - "num-traits", - "rand 0.8.5", - "thiserror 1.0.69", -] - -[[package]] -name = "kzgrs-backend" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-ff 0.4.2", - "ark-poly 0.4.2", - "ark-serialize 0.4.2", - "blake2", - "itertools 0.12.1", - "kzgrs", - "nomos-core", - "rand 0.8.5", - "serde", -] - [[package]] name = "language-tags" version = "0.3.2" @@ -3276,7 +3009,6 @@ dependencies = [ "bs58", "hkdf", "multihash", - "serde", "sha2", "thiserror 2.0.17", "tracing", @@ -3372,6 +3104,483 @@ version = "0.4.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +[[package]] +name = "logos-blockchain-blend-crypto" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "blake2", + "logos-blockchain-groth16", + "logos-blockchain-poq", + "logos-blockchain-poseidon2", + "logos-blockchain-utils", + "rs-merkle-tree", + "thiserror 1.0.69", +] + +[[package]] +name = "logos-blockchain-blend-message" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "blake2", + "derivative", + "itertools 0.14.0", + "logos-blockchain-blend-crypto", + "logos-blockchain-blend-proofs", + "logos-blockchain-core", + "logos-blockchain-groth16", + "logos-blockchain-key-management-system-keys", + "logos-blockchain-utils", + "serde", + "serde-big-array", + "serde_with", + "thiserror 1.0.69", + "tracing", + "zeroize", +] + +[[package]] +name = "logos-blockchain-blend-proofs" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ed25519-dalek", + "generic-array 1.3.5", + "logos-blockchain-blend-crypto", + "logos-blockchain-groth16", + "logos-blockchain-poq", + "num-bigint", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "logos-blockchain-chain-broadcast-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "derivative", + "futures", + "logos-blockchain-core", + "overwatch", + "serde", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "logos-blockchain-chain-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "bytes", + "futures", + "logos-blockchain-chain-broadcast-service", + "logos-blockchain-core", + "logos-blockchain-cryptarchia-engine", + "logos-blockchain-cryptarchia-sync", + "logos-blockchain-groth16", + "logos-blockchain-ledger", + "logos-blockchain-network-service", + "logos-blockchain-services-utils", + "logos-blockchain-storage-service", + "logos-blockchain-time-service", + "logos-blockchain-utils", + "num-bigint", + "overwatch", + "serde", + "serde_with", + "strum", + "thiserror 1.0.69", + "tokio", + "tracing", + "tracing-futures", +] + +[[package]] +name = "logos-blockchain-circuits-prover" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "logos-blockchain-circuits-utils", + "tempfile", +] + +[[package]] +name = "logos-blockchain-circuits-utils" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "dirs", +] + +[[package]] +name = "logos-blockchain-common-http-client" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "futures", + "logos-blockchain-chain-broadcast-service", + "logos-blockchain-chain-service", + "logos-blockchain-core", + "logos-blockchain-http-api-common", + "reqwest", + "serde", + "serde_json", + "thiserror 1.0.69", + "url", +] + +[[package]] +name = "logos-blockchain-core" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ark-ff 0.4.2", + "bincode", + "blake2", + "bytes", + "const-hex", + "futures", + "generic-array 1.3.5", + "hex", + "logos-blockchain-blend-proofs", + "logos-blockchain-cryptarchia-engine", + "logos-blockchain-groth16", + "logos-blockchain-key-management-system-keys", + "logos-blockchain-pol", + "logos-blockchain-poseidon2", + "logos-blockchain-utils", + "multiaddr", + "nom 8.0.0", + "num-bigint", + "serde", + "strum", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "logos-blockchain-cryptarchia-engine" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "cfg_eval", + "logos-blockchain-utils", + "serde", + "serde_with", + "thiserror 1.0.69", + "time", + "tokio", + "tracing", +] + +[[package]] +name = "logos-blockchain-cryptarchia-sync" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "bytes", + "futures", + "logos-blockchain-core", + "logos-blockchain-cryptarchia-engine", + "rand 0.8.5", + "serde", + "serde_with", + "thiserror 1.0.69", + "tokio", + "tracing", +] + +[[package]] +name = "logos-blockchain-groth16" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ark-bn254 0.4.0", + "ark-ec 0.4.2", + "ark-ff 0.4.2", + "ark-groth16 0.4.0", + "ark-serialize 0.4.2", + "generic-array 1.3.5", + "hex", + "num-bigint", + "serde", + "serde_json", + "thiserror 2.0.17", +] + +[[package]] +name = "logos-blockchain-http-api-common" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "axum", + "governor", + "logos-blockchain-core", + "logos-blockchain-key-management-system-keys", + "serde", + "serde_json", + "serde_with", + "tower_governor", +] + +[[package]] +name = "logos-blockchain-key-management-system-keys" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "bytes", + "ed25519-dalek", + "generic-array 1.3.5", + "logos-blockchain-blend-proofs", + "logos-blockchain-groth16", + "logos-blockchain-key-management-system-macros", + "logos-blockchain-poseidon2", + "logos-blockchain-utils", + "logos-blockchain-zksign", + "num-bigint", + "rand_core 0.6.4", + "serde", + "subtle", + "thiserror 2.0.17", + "tokio", + "tracing", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "logos-blockchain-key-management-system-macros" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.111", +] + +[[package]] +name = "logos-blockchain-key-management-system-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "log", + "logos-blockchain-key-management-system-keys", + "overwatch", + "serde", + "thiserror 2.0.17", + "tokio", + "tracing", +] + +[[package]] +name = "logos-blockchain-ledger" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "derivative", + "logos-blockchain-blend-crypto", + "logos-blockchain-blend-message", + "logos-blockchain-blend-proofs", + "logos-blockchain-core", + "logos-blockchain-cryptarchia-engine", + "logos-blockchain-groth16", + "logos-blockchain-key-management-system-keys", + "logos-blockchain-mmr", + "logos-blockchain-utils", + "logos-blockchain-utxotree", + "num-bigint", + "rand 0.8.5", + "rpds", + "serde", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "logos-blockchain-mmr" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ark-ff 0.4.2", + "logos-blockchain-groth16", + "logos-blockchain-poseidon2", + "rpds", + "serde", +] + +[[package]] +name = "logos-blockchain-network-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "futures", + "logos-blockchain-core", + "logos-blockchain-cryptarchia-sync", + "overwatch", + "serde", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "logos-blockchain-pol" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "logos-blockchain-circuits-prover", + "logos-blockchain-circuits-utils", + "logos-blockchain-groth16", + "logos-blockchain-witness-generator", + "num-bigint", + "num-traits", + "serde", + "serde_json", + "thiserror 2.0.17", +] + +[[package]] +name = "logos-blockchain-poq" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "logos-blockchain-circuits-prover", + "logos-blockchain-circuits-utils", + "logos-blockchain-groth16", + "logos-blockchain-pol", + "logos-blockchain-witness-generator", + "num-bigint", + "serde", + "serde_json", + "thiserror 2.0.17", +] + +[[package]] +name = "logos-blockchain-poseidon2" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ark-bn254 0.4.0", + "ark-ff 0.4.2", + "jf-poseidon2", + "num-bigint", +] + +[[package]] +name = "logos-blockchain-services-utils" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "futures", + "log", + "overwatch", + "serde", + "serde_json", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "logos-blockchain-storage-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "bytes", + "futures", + "logos-blockchain-core", + "logos-blockchain-cryptarchia-engine", + "overwatch", + "serde", + "thiserror 1.0.69", + "tokio", + "tracing", +] + +[[package]] +name = "logos-blockchain-time-service" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "futures", + "log", + "logos-blockchain-cryptarchia-engine", + "overwatch", + "sntpc", + "thiserror 2.0.17", + "time", + "tokio", + "tokio-stream", + "tracing", +] + +[[package]] +name = "logos-blockchain-utils" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "async-trait", + "blake2", + "cipher", + "const-hex", + "humantime", + "overwatch", + "rand 0.8.5", + "serde", + "serde_with", + "time", +] + +[[package]] +name = "logos-blockchain-utxotree" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "ark-ff 0.4.2", + "logos-blockchain-core", + "logos-blockchain-groth16", + "logos-blockchain-poseidon2", + "num-bigint", + "rpds", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "logos-blockchain-witness-generator" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "tempfile", +] + +[[package]] +name = "logos-blockchain-zksign" +version = "0.1.0" +source = "git+https://github.com/logos-blockchain/logos-blockchain.git#451df112f8574aea2840d04fffb7e16e76d24f42" +dependencies = [ + "logos-blockchain-circuits-prover", + "logos-blockchain-circuits-utils", + "logos-blockchain-groth16", + "logos-blockchain-poseidon2", + "logos-blockchain-witness-generator", + "num-bigint", + "serde", + "serde_json", + "thiserror 2.0.17", +] + [[package]] name = "lru-slab" version = "0.1.2" @@ -3479,18 +3688,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "mmr" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-ff 0.4.2", - "groth16", - "poseidon2", - "rpds", - "serde", -] - [[package]] name = "multiaddr" version = "0.18.2" @@ -3597,194 +3794,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "nomos-blend-crypto" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "blake2", - "groth16", - "nomos-utils", - "poq", - "poseidon2", - "rs-merkle-tree", - "serde", - "subtle", - "thiserror 1.0.69", - "x25519-dalek", - "zeroize", -] - -[[package]] -name = "nomos-blend-message" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "blake2", - "derivative", - "groth16", - "itertools 0.14.0", - "key-management-system-keys", - "nomos-blend-crypto", - "nomos-blend-proofs", - "nomos-core", - "nomos-utils", - "serde", - "serde-big-array", - "serde_with", - "thiserror 1.0.69", - "tracing", - "zeroize", -] - -[[package]] -name = "nomos-blend-proofs" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ed25519-dalek", - "generic-array 1.3.5", - "groth16", - "nomos-blend-crypto", - "num-bigint", - "poq", - "serde", - "thiserror 1.0.69", -] - -[[package]] -name = "nomos-core" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-ff 0.4.2", - "async-trait", - "bincode", - "blake2", - "bytes", - "const-hex", - "cryptarchia-engine", - "futures", - "generic-array 1.3.5", - "groth16", - "hex", - "key-management-system-keys", - "multiaddr", - "nom 8.0.0", - "nomos-blend-proofs", - "nomos-utils", - "num-bigint", - "pol", - "poseidon2", - "serde", - "strum", - "thiserror 1.0.69", - "tracing", -] - -[[package]] -name = "nomos-da-messages" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "blake2", - "futures", - "kzgrs-backend", - "nomos-core", - "serde", - "tokio", -] - -[[package]] -name = "nomos-http-api-common" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "axum", - "governor", - "key-management-system-keys", - "nomos-core", - "serde", - "serde_json", - "serde_with", - "tower_governor", -] - -[[package]] -name = "nomos-ledger" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "cryptarchia-engine", - "groth16", - "key-management-system-keys", - "mmr", - "nomos-blend-crypto", - "nomos-blend-message", - "nomos-blend-proofs", - "nomos-core", - "nomos-utils", - "num-bigint", - "rand 0.8.5", - "rpds", - "serde", - "thiserror 1.0.69", - "tracing", - "utxotree", -] - -[[package]] -name = "nomos-network" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "cryptarchia-sync", - "futures", - "nomos-core", - "overwatch", - "serde", - "tokio", - "tokio-stream", - "tracing", -] - -[[package]] -name = "nomos-storage" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "bytes", - "cryptarchia-engine", - "futures", - "libp2p-identity", - "multiaddr", - "nomos-core", - "overwatch", - "serde", - "thiserror 1.0.69", - "tokio", - "tracing", -] - -[[package]] -name = "nomos-utils" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "blake2", - "cipher", - "const-hex", - "humantime", - "overwatch", - "rand 0.8.5", - "serde", - "serde_with", - "time", -] - [[package]] name = "nonempty" version = "0.7.0" @@ -3898,16 +3907,6 @@ dependencies = [ "libm", ] -[[package]] -name = "num_cpus" -version = "1.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" -dependencies = [ - "hermit-abi", - "libc", -] - [[package]] name = "num_enum" version = "0.7.5" @@ -4147,22 +4146,6 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" -[[package]] -name = "pol" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "circuits-prover", - "circuits-utils", - "groth16", - "num-bigint", - "num-traits", - "serde", - "serde_json", - "thiserror 2.0.17", - "witness-generator", -] - [[package]] name = "polyval" version = "0.6.2" @@ -4175,39 +4158,12 @@ dependencies = [ "universal-hash", ] -[[package]] -name = "poq" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "circuits-prover", - "circuits-utils", - "groth16", - "num-bigint", - "pol", - "serde", - "serde_json", - "thiserror 2.0.17", - "witness-generator", -] - [[package]] name = "portable-atomic" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f89776e4d69bb58bc6993e99ffa1d11f228b839984854c7daeb5d37f87cbe950" -[[package]] -name = "poseidon2" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-bn254 0.4.0", - "ark-ff 0.4.2", - "jf-poseidon2", - "num-bigint", -] - [[package]] name = "postcard" version = "1.1.3" @@ -5186,10 +5142,10 @@ dependencies = [ "chrono", "common", "futures", - "key-management-system-service", "log", + "logos-blockchain-core", + "logos-blockchain-key-management-system-service", "mempool", - "nomos-core", "nssa", "nssa_core", "rand 0.8.5", @@ -5366,21 +5322,6 @@ dependencies = [ "serde", ] -[[package]] -name = "services-utils" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "async-trait", - "futures", - "log", - "overwatch", - "serde", - "serde_json", - "thiserror 1.0.69", - "tracing", -] - [[package]] name = "sha1" version = "0.10.6" @@ -5441,6 +5382,16 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "sntpc" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78f778a0f82b3cf5d75f858eceee38e84d5292f1d03415e88cc4ec45ca6ba8a2" +dependencies = [ + "cfg-if", + "tokio", +] + [[package]] name = "socket2" version = "0.4.10" @@ -5734,15 +5685,6 @@ dependencies = [ "syn 2.0.114", ] -[[package]] -name = "threadpool" -version = "1.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" -dependencies = [ - "num_cpus", -] - [[package]] name = "time" version = "0.3.45" @@ -6197,21 +6139,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" -[[package]] -name = "utxotree" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "ark-ff 0.4.2", - "groth16", - "nomos-core", - "num-bigint", - "poseidon2", - "rpds", - "serde", - "thiserror 1.0.69", -] - [[package]] name = "valuable" version = "0.1.1" @@ -6657,15 +6584,6 @@ version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" -[[package]] -name = "witness-generator" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "circuits-utils", - "tempfile", -] - [[package]] name = "writeable" version = "0.6.2" @@ -6811,25 +6729,3 @@ dependencies = [ "quote", "syn 2.0.114", ] - -[[package]] -name = "zksign" -version = "0.1.0" -source = "git+https://github.com/logos-blockchain/logos-blockchain.git#044259f74527bffb2724e132203f10253de58541" -dependencies = [ - "circuits-prover", - "circuits-utils", - "groth16", - "num-bigint", - "poseidon2", - "serde", - "serde_json", - "thiserror 2.0.17", - "witness-generator", -] - -[[package]] -name = "zmij" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" diff --git a/Cargo.toml b/Cargo.toml index d5a0682e..dcc765d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -82,10 +82,9 @@ itertools = "0.14.0" url = "2.5.4" tokio-retry = "0.3.0" -common-http-client = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } -key-management-system-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } -nomos-core = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } -broadcast-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } +logos-blockchain-common-http-client = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } +logos-blockchain-key-management-system-service = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } +logos-blockchain-core = { git = "https://github.com/logos-blockchain/logos-blockchain.git" } rocksdb = { version = "0.24.0", default-features = false, features = [ "snappy", diff --git a/bedrock_client/Cargo.toml b/bedrock_client/Cargo.toml index 8ed7fd24..50a54815 100644 --- a/bedrock_client/Cargo.toml +++ b/bedrock_client/Cargo.toml @@ -6,10 +6,5 @@ edition = "2024" [dependencies] reqwest.workspace = true anyhow.workspace = true -common-http-client.workspace = true -nomos-core.workspace = true -broadcast-service.workspace = true -url.workspace = true -futures.workspace = true -tokio-retry.workspace = true -log.workspace = true +logos-blockchain-common-http-client.workspace = true +logos-blockchain-core.workspace = true diff --git a/bedrock_client/src/lib.rs b/bedrock_client/src/lib.rs index e22446f7..154b6bfe 100644 --- a/bedrock_client/src/lib.rs +++ b/bedrock_client/src/lib.rs @@ -1,28 +1,33 @@ use anyhow::Result; -use broadcast_service::BlockInfo; -use common_http_client::CommonHttpClient; -pub use common_http_client::{BasicAuthCredentials, Error}; -use futures::{Stream, TryFutureExt}; -use log::warn; -use nomos_core::{block::Block, header::HeaderId, mantle::SignedMantleTx}; -use reqwest::Client; -use tokio_retry::Retry; -use url::Url; +pub use logos_blockchain_common_http_client::{BasicAuthCredentials, CommonHttpClient, Error}; +use logos_blockchain_core::mantle::SignedMantleTx; +use reqwest::{Client, Url}; // Simple wrapper // maybe extend in the future for our purposes -pub struct BedrockClient(pub CommonHttpClient); +pub struct BedrockClient { + http_client: CommonHttpClient, + node_url: Url, +} impl BedrockClient { - pub fn new(auth: Option) -> Result { + pub fn new(auth: Option, node_url: Url) -> Result { let client = Client::builder() - //Add more fiedls if needed + //Add more fields if needed .timeout(std::time::Duration::from_secs(60)) .build()?; - Ok(BedrockClient(CommonHttpClient::new_with_client( - client, auth, - ))) + let http_client = CommonHttpClient::new_with_client(client, auth); + Ok(Self { + http_client, + node_url, + }) + } + + pub async fn post_transaction(&self, tx: SignedMantleTx) -> Result<(), Error> { + self.http_client + .post_transaction(self.node_url.clone(), tx) + .await } pub async fn get_lib_stream(&self, url: Url) -> Result, Error> { diff --git a/common/src/block.rs b/common/src/block.rs index 8cc5be89..98b1afb3 100644 --- a/common/src/block.rs +++ b/common/src/block.rs @@ -23,7 +23,7 @@ pub type BlockHash = [u8; 32]; pub type BlockId = u64; pub type TimeStamp = u64; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] pub struct BlockHeader { pub block_id: BlockId, pub prev_block_hash: BlockHash, @@ -32,15 +32,23 @@ pub struct BlockHeader { pub signature: nssa::Signature, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] pub struct BlockBody { pub transactions: Vec, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, BorshSerialize, BorshDeserialize)] +pub enum BedrockStatus { + Pending, + Safe, + Finalized, +} + +#[derive(Debug, BorshSerialize, BorshDeserialize)] pub struct Block { pub header: BlockHeader, pub body: BlockBody, + pub bedrock_status: BedrockStatus, } #[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)] @@ -52,7 +60,7 @@ pub struct HashableBlockData { } impl HashableBlockData { - pub fn into_block(self, signing_key: &nssa::PrivateKey) -> Block { + pub fn into_pending_block(self, signing_key: &nssa::PrivateKey) -> Block { let data_bytes = borsh::to_vec(&self).unwrap(); let signature = nssa::Signature::new(signing_key, &data_bytes); let hash = OwnHasher::hash(&data_bytes); @@ -67,6 +75,7 @@ impl HashableBlockData { body: BlockBody { transactions: self.transactions, }, + bedrock_status: BedrockStatus::Pending, } } diff --git a/common/src/test_utils.rs b/common/src/test_utils.rs index 7e3c0ba8..1125b86e 100644 --- a/common/src/test_utils.rs +++ b/common/src/test_utils.rs @@ -30,7 +30,7 @@ pub fn produce_dummy_block( transactions, }; - block_data.into_block(&sequencer_sign_key_for_testing()) + block_data.into_pending_block(&sequencer_sign_key_for_testing()) } pub fn produce_dummy_empty_transaction() -> EncodedTransaction { diff --git a/sequencer_core/Cargo.toml b/sequencer_core/Cargo.toml index 58d7a9b8..528fa16f 100644 --- a/sequencer_core/Cargo.toml +++ b/sequencer_core/Cargo.toml @@ -19,8 +19,8 @@ chrono.workspace = true log.workspace = true tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } bedrock_client.workspace = true -key-management-system-service.workspace = true -nomos-core.workspace = true +logos-blockchain-key-management-system-service.workspace = true +logos-blockchain-core.workspace = true rand.workspace = true reqwest.workspace = true borsh.workspace = true diff --git a/sequencer_core/src/block_settlement_client.rs b/sequencer_core/src/block_settlement_client.rs index 16b33107..0aa22420 100644 --- a/sequencer_core/src/block_settlement_client.rs +++ b/sequencer_core/src/block_settlement_client.rs @@ -1,20 +1,20 @@ use std::{fs, path::Path}; -use anyhow::Result; +use anyhow::{Context, Result, anyhow}; use bedrock_client::BedrockClient; use common::block::HashableBlockData; -use key_management_system_service::keys::{ED25519_SECRET_KEY_SIZE, Ed25519Key, Ed25519PublicKey}; -use nomos_core::mantle::{ +use logos_blockchain_core::mantle::{ MantleTx, Op, OpProof, SignedMantleTx, Transaction, TxHash, ledger, ops::channel::{ChannelId, MsgId, inscribe::InscriptionOp}, }; -use reqwest::Url; +use logos_blockchain_key_management_system_service::keys::{ + ED25519_SECRET_KEY_SIZE, Ed25519Key, Ed25519PublicKey, +}; use crate::config::BedrockConfig; /// A component that posts block data to logos blockchain pub struct BlockSettlementClient { - bedrock_node_url: Url, bedrock_client: BedrockClient, bedrock_signing_key: Ed25519Key, bedrock_channel_id: ChannelId, @@ -22,25 +22,23 @@ pub struct BlockSettlementClient { } impl BlockSettlementClient { - pub fn new(home: &Path, config: &BedrockConfig) -> Self { + pub fn try_new(home: &Path, config: &BedrockConfig) -> Result { let bedrock_signing_key = load_or_create_signing_key(&home.join("bedrock_signing_key")) - .expect("Signing key should load or be created successfully"); - let bedrock_node_url = - Url::parse(&config.node_url).expect("Bedrock URL should be a valid URL"); - let bedrock_channel_id = config.channel_id; - let bedrock_client = - BedrockClient::new(None).expect("Bedrock client should be able to initialize"); - Self { - bedrock_node_url, + .context("Failed to load or create signing key")?; + let bedrock_channel_id = ChannelId::from(config.channel_id); + let bedrock_client = BedrockClient::new(None, config.node_url.clone()) + .context("Failed to initialize bedrock client")?; + let channel_genesis_msg = MsgId::from([0; 32]); + Ok(Self { bedrock_client, bedrock_signing_key, bedrock_channel_id, - last_message_id: MsgId::from([0; 32]), - } + last_message_id: channel_genesis_msg, + }) } /// Create and sign a transaction for inscribing data - pub fn create_inscribe_tx(&self, data: Vec) -> SignedMantleTx { + pub fn create_inscribe_tx(&self, data: Vec) -> (SignedMantleTx, MsgId) { let verifying_key_bytes = self.bedrock_signing_key.public_key().to_bytes(); let verifying_key = Ed25519PublicKey::from_bytes(&verifying_key_bytes).expect("valid ed25519 public key"); @@ -51,12 +49,14 @@ impl BlockSettlementClient { parent: self.last_message_id, signer: verifying_key, }; + let inscribe_op_id = inscribe_op.id(); let ledger_tx = ledger::Tx::new(vec![], vec![]); let inscribe_tx = MantleTx { ops: vec![Op::ChannelInscribe(inscribe_op)], ledger_tx, + // Altruistic test config storage_gas_price: 0, execution_gas_price: 0, }; @@ -67,54 +67,51 @@ impl BlockSettlementClient { .sign_payload(tx_hash.as_signing_bytes().as_ref()) .to_bytes(); let signature = - key_management_system_service::keys::Ed25519Signature::from_bytes(&signature_bytes); + logos_blockchain_key_management_system_service::keys::Ed25519Signature::from_bytes( + &signature_bytes, + ); - SignedMantleTx { + let signed_mantle_tx = SignedMantleTx { ops_proofs: vec![OpProof::Ed25519Sig(signature)], ledger_tx_proof: empty_ledger_signature(&tx_hash), mantle_tx: inscribe_tx, - } + }; + (signed_mantle_tx, inscribe_op_id) } /// Post a transaction to the node and wait for inclusion pub async fn post_and_wait(&mut self, block_data: &HashableBlockData) -> Result { let inscription_data = borsh::to_vec(&block_data)?; - let tx = self.create_inscribe_tx(inscription_data); + let (tx, new_msg_id) = self.create_inscribe_tx(inscription_data); // Post the transaction - self.bedrock_client - .0 - .post_transaction(self.bedrock_node_url.clone(), tx.clone()) - .await?; + self.bedrock_client.post_transaction(tx).await?; - if let Some(Op::ChannelInscribe(inscribe)) = tx.mantle_tx.ops.first() { - self.last_message_id = inscribe.id() - } + self.last_message_id = new_msg_id; Ok(block_data.block_id) } } /// Load signing key from file or generate a new one if it doesn't exist -fn load_or_create_signing_key(path: &Path) -> Result { +fn load_or_create_signing_key(path: &Path) -> Result { if path.exists() { - let key_bytes = fs::read(path).map_err(|_| ())?; - if key_bytes.len() != ED25519_SECRET_KEY_SIZE { - // TODO: proper error - return Err(()); - } - let key_array: [u8; ED25519_SECRET_KEY_SIZE] = - key_bytes.try_into().expect("length already checked"); + let key_bytes = fs::read(path)?; + let key_array: [u8; ED25519_SECRET_KEY_SIZE] = key_bytes + .try_into() + .map_err(|_| anyhow!("Found key with incorrect length"))?; Ok(Ed25519Key::from_bytes(&key_array)) } else { let mut key_bytes = [0u8; ED25519_SECRET_KEY_SIZE]; rand::RngCore::fill_bytes(&mut rand::thread_rng(), &mut key_bytes); - fs::write(path, key_bytes).map_err(|_| ())?; + fs::write(path, key_bytes)?; Ok(Ed25519Key::from_bytes(&key_bytes)) } } -fn empty_ledger_signature(tx_hash: &TxHash) -> key_management_system_service::keys::ZkSignature { - key_management_system_service::keys::ZkKey::multi_sign(&[], tx_hash.as_ref()) +fn empty_ledger_signature( + tx_hash: &TxHash, +) -> logos_blockchain_key_management_system_service::keys::ZkSignature { + logos_blockchain_key_management_system_service::keys::ZkKey::multi_sign(&[], tx_hash.as_ref()) .expect("multi-sign with empty key set works") } diff --git a/sequencer_core/src/block_store.rs b/sequencer_core/src/block_store.rs index 67535022..cd9aa194 100644 --- a/sequencer_core/src/block_store.rs +++ b/sequencer_core/src/block_store.rs @@ -46,7 +46,7 @@ impl SequencerBlockStore { } pub fn get_block_at_id(&self, id: u64) -> Result { - Ok(self.dbio.get_block(id)?.into_block(&self.signing_key)) + Ok(self.dbio.get_block(id)?) } pub fn put_block_at_id(&mut self, block: Block) -> Result<()> { @@ -113,7 +113,7 @@ mod tests { transactions: vec![], }; - let genesis_block = genesis_block_hashable_data.into_block(&signing_key); + let genesis_block = genesis_block_hashable_data.into_pending_block(&signing_key); // Start an empty node store let mut node_store = SequencerBlockStore::open_db_with_genesis(path, Some(genesis_block), signing_key) diff --git a/sequencer_core/src/config.rs b/sequencer_core/src/config.rs index a7eecc6c..7307d43c 100644 --- a/sequencer_core/src/config.rs +++ b/sequencer_core/src/config.rs @@ -5,7 +5,7 @@ use std::{ }; use anyhow::Result; -use nomos_core::mantle::ops::channel::ChannelId; +use reqwest::Url; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] @@ -57,11 +57,7 @@ pub struct BedrockConfig { /// Bedrock channel ID pub channel_id: ChannelId, /// Bedrock Url - pub node_url: String, - /// Bedrock user - pub user: String, - /// Bedrock password(optional) - pub password: Option, + pub node_url: Url, } impl SequencerConfig { diff --git a/sequencer_core/src/lib.rs b/sequencer_core/src/lib.rs index 561f5ef6..89cafc4c 100644 --- a/sequencer_core/src/lib.rs +++ b/sequencer_core/src/lib.rs @@ -53,7 +53,7 @@ impl SequencerCore { }; let signing_key = nssa::PrivateKey::try_new(config.signing_key).unwrap(); - let genesis_block = hashable_data.into_block(&signing_key); + let genesis_block = hashable_data.into_pending_block(&signing_key); // Sequencer should panic if unable to open db, // as fixing this issue may require actions non-native to program scope @@ -89,10 +89,10 @@ impl SequencerCore { state.add_pinata_program(PINATA_BASE58.parse().unwrap()); let (mempool, mempool_handle) = MemPool::new(config.mempool_max_size); - let block_settlement = config - .bedrock_config - .as_ref() - .map(|bedrock_config| BlockSettlementClient::new(&config.home, bedrock_config)); + let block_settlement_client = config.bedrock_config.as_ref().map(|bedrock_config| { + BlockSettlementClient::try_new(&config.home, bedrock_config) + .expect("Block settlement client should be constructible") + }); let mut this = Self { state, @@ -100,7 +100,7 @@ impl SequencerCore { mempool, chain_height: config.genesis_id, sequencer_config: config, - block_settlement_client: block_settlement, + block_settlement_client, }; this.sync_state_with_stored_blocks(); @@ -196,14 +196,14 @@ impl SequencerCore { let block = hashable_data .clone() - .into_block(self.block_store.signing_key()); + .into_pending_block(self.block_store.signing_key()); self.block_store.put_block_at_id(block)?; self.chain_height = new_block_height; // TODO: Consider switching to `tracing` crate to have more structured and consistent logs - // // e.g. + // e.g. // // ``` // info!( diff --git a/storage/src/lib.rs b/storage/src/lib.rs index 87b78705..883684c2 100644 --- a/storage/src/lib.rs +++ b/storage/src/lib.rs @@ -1,6 +1,6 @@ use std::{path::Path, sync::Arc}; -use common::block::{Block, HashableBlockData}; +use common::block::Block; use error::DbError; use rocksdb::{ BoundColumnFamily, ColumnFamilyDescriptor, DBWithThreadMode, MultiThreaded, Options, @@ -26,6 +26,8 @@ pub const DB_META_FIRST_BLOCK_IN_DB_KEY: &str = "first_block_in_db"; pub const DB_META_LAST_BLOCK_IN_DB_KEY: &str = "last_block_in_db"; /// Key base for storing metainformation which describe if first block has been set pub const DB_META_FIRST_BLOCK_SET_KEY: &str = "first_block_set"; +/// Key base for storing metainformation about the last finalized block on Bedrock +pub const DB_META_LAST_FINALIZED_BLOCK_ID: &str = "last_finalized_block_id"; /// Key base for storing snapshot which describe block id pub const DB_SNAPSHOT_BLOCK_ID_KEY: &str = "block_id"; @@ -75,6 +77,7 @@ impl RocksDBIO { dbio.put_meta_first_block_in_db(block)?; dbio.put_meta_is_first_block_set()?; dbio.put_meta_last_block_in_db(block_id)?; + dbio.put_meta_last_finalized_block_id(None)?; Ok(dbio) } else { @@ -232,6 +235,28 @@ impl RocksDBIO { Ok(()) } + pub fn put_meta_last_finalized_block_id(&self, block_id: Option) -> DbResult<()> { + let cf_meta = self.meta_column(); + self.db + .put_cf( + &cf_meta, + borsh::to_vec(&DB_META_LAST_FINALIZED_BLOCK_ID).map_err(|err| { + DbError::borsh_cast_message( + err, + Some("Failed to serialize DB_META_LAST_FINALIZED_BLOCK_ID".to_string()), + ) + })?, + borsh::to_vec(&block_id).map_err(|err| { + DbError::borsh_cast_message( + err, + Some("Failed to serialize last block id".to_string()), + ) + })?, + ) + .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; + Ok(()) + } + pub fn put_meta_is_first_block_set(&self) -> DbResult<()> { let cf_meta = self.meta_column(); self.db @@ -269,7 +294,7 @@ impl RocksDBIO { Some("Failed to serialize block id".to_string()), ) })?, - borsh::to_vec(&HashableBlockData::from(block)).map_err(|err| { + borsh::to_vec(&block).map_err(|err| { DbError::borsh_cast_message( err, Some("Failed to serialize block data".to_string()), @@ -280,7 +305,7 @@ impl RocksDBIO { Ok(()) } - pub fn get_block(&self, block_id: u64) -> DbResult { + pub fn get_block(&self, block_id: u64) -> DbResult { let cf_block = self.block_column(); let res = self .db @@ -296,14 +321,12 @@ impl RocksDBIO { .map_err(|rerr| DbError::rocksdb_cast_message(rerr, None))?; if let Some(data) = res { - Ok( - borsh::from_slice::(&data).map_err(|serr| { - DbError::borsh_cast_message( - serr, - Some("Failed to deserialize block data".to_string()), - ) - })?, - ) + Ok(borsh::from_slice::(&data).map_err(|serr| { + DbError::borsh_cast_message( + serr, + Some("Failed to deserialize block data".to_string()), + ) + })?) } else { Err(DbError::db_interaction_error( "Block on this id not found".to_string(), diff --git a/wallet/src/cli/chain.rs b/wallet/src/cli/chain.rs index 419fa5e2..17ecd020 100644 --- a/wallet/src/cli/chain.rs +++ b/wallet/src/cli/chain.rs @@ -19,7 +19,7 @@ pub enum ChainSubcommand { /// Get transaction at hash from sequencer Transaction { /// hash - valid 32 byte hex string - #[arg(short, long)] + #[arg(short = 't', long)] hash: String, }, }