diff --git a/Cargo.lock b/Cargo.lock index dc8fa43..f28c307 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -286,7 +286,7 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4057f2c32adbb2fc158e22fb38433c8e9bbf76b75a4732c7c0cbaf695fb65568" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-sink", "futures-util", "memchr", @@ -299,7 +299,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a860072022177f903e59730004fb5dc13db9275b79bb2aef7ba8ce831956c233" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-sink", "futures-util", "memchr", @@ -332,7 +332,7 @@ dependencies = [ "async-trait", "axum-core 0.3.4", "bitflags 1.3.2", - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 0.2.12", "http-body 0.4.6", @@ -346,20 +346,20 @@ dependencies = [ "rustversion", "serde", "sync_wrapper 0.1.2", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", ] [[package]] name = "axum" -version = "0.7.5" +version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" +checksum = "8f43644eed690f5374f1af436ecd6aea01cd201f6fbdf0178adaf6907afb2cec" dependencies = [ "async-trait", - "axum-core 0.4.3", - "bytes 1.7.1", + "axum-core 0.4.4", + "bytes 1.7.2", "futures-util", "http 1.1.0", "http-body 1.0.1", @@ -379,7 +379,7 @@ dependencies = [ "serde_urlencoded", "sync_wrapper 1.0.1", "tokio", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", "tracing", @@ -392,7 +392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" dependencies = [ "async-trait", - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 0.2.12", "http-body 0.4.6", @@ -404,12 +404,12 @@ dependencies = [ [[package]] name = "axum-core" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" +checksum = "5e6b8ba012a258d63c9adfa28b9ddcf66149da6f986c5b5452e629d5ee64bf00" dependencies = [ "async-trait", - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 1.1.0", "http-body 1.0.1", @@ -417,7 +417,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", "tracing", @@ -630,9 +630,9 @@ checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" dependencies = [ "serde", ] @@ -648,9 +648,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.19" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "shlex", ] @@ -758,9 +758,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -768,9 +768,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -780,9 +780,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -1602,7 +1602,7 @@ version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "futures-core", "futures-sink", @@ -1793,7 +1793,7 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "itoa", ] @@ -1804,7 +1804,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "fnv", "itoa", ] @@ -1815,7 +1815,7 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "http 0.2.12", "pin-project-lite", ] @@ -1826,7 +1826,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "http 1.1.0", ] @@ -1836,7 +1836,7 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 1.1.0", "http-body 1.0.1", @@ -1867,7 +1867,7 @@ version = "0.14.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-channel", "futures-core", "futures-util", @@ -1891,7 +1891,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-channel", "futures-util", "http 1.1.0", @@ -1922,20 +1922,22 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-util", "http 1.1.0", "http-body 1.0.1", "hyper 1.4.1", "pin-project-lite", "tokio", + "tower 0.4.13", + "tower-service", ] [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2028,7 +2030,7 @@ checksum = "064d90fec10d541084e7b39ead8875a5a80d9114a2b18791565253bae25f49e4" dependencies = [ "async-trait", "attohttpc", - "bytes 1.7.1", + "bytes 1.7.2", "futures 0.3.30", "http 0.2.12", "hyper 0.14.30", @@ -2221,7 +2223,7 @@ version = "0.53.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681fb3f183edfbedd7a57d32ebe5dcdc0b9f94061185acf3c30249349cc6fc99" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "either", "futures 0.3.30", "futures-timer", @@ -2247,7 +2249,7 @@ dependencies = [ "libp2p-tcp", "libp2p-upnp", "libp2p-yamux", - "multiaddr 0.18.1", + "multiaddr 0.18.2", "pin-project 1.1.5", "rw-stream-sink", "thiserror", @@ -2309,7 +2311,7 @@ dependencies = [ "futures 0.3.30", "futures-timer", "libp2p-identity", - "multiaddr 0.18.1", + "multiaddr 0.18.2", "multihash 0.19.1", "multistream-select", "once_cell", @@ -2375,7 +2377,7 @@ dependencies = [ "asynchronous-codec 0.7.0", "base64 0.21.7", "byteorder", - "bytes 1.7.1", + "bytes 1.7.2", "either", "fnv", "futures 0.3.30", @@ -2448,7 +2450,7 @@ checksum = "5cc5767727d062c4eac74dd812c998f0e488008e82cce9c33b463d38423f9ad2" dependencies = [ "arrayvec", "asynchronous-codec 0.7.0", - "bytes 1.7.1", + "bytes 1.7.2", "either", "fnv", "futures 0.3.30", @@ -2518,12 +2520,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecd0545ce077f6ea5434bcb76e8d0fe942693b4380aaad0d34a358c2bd05793" dependencies = [ "asynchronous-codec 0.7.0", - "bytes 1.7.1", + "bytes 1.7.2", "curve25519-dalek", "futures 0.3.30", "libp2p-core", "libp2p-identity", - "multiaddr 0.18.1", + "multiaddr 0.18.2", "multihash 0.19.1", "once_cell", "quick-protobuf", @@ -2543,7 +2545,7 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c67296ad4e092e23f92aea3d2bdb6f24eab79c0929ed816dfb460ea2f4567d2b" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures 0.3.30", "futures-timer", "if-watch", @@ -2568,7 +2570,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d1c667cfabf3dd675c8e3cea63b7b98434ecf51721b7894cbb01d29983a6a9b" dependencies = [ "asynchronous-codec 0.7.0", - "bytes 1.7.1", + "bytes 1.7.2", "either", "futures 0.3.30", "futures-bounded", @@ -2916,8 +2918,8 @@ dependencies = [ [[package]] name = "minotari_app_grpc" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "argon2", "base64 0.13.1", @@ -2946,8 +2948,8 @@ dependencies = [ [[package]] name = "minotari_ledger_wallet_common" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "bs58 0.5.1", ] @@ -2955,7 +2957,7 @@ dependencies = [ [[package]] name = "minotari_node_grpc_client" version = "0.1.0" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "minotari_app_grpc", ] @@ -3033,9 +3035,9 @@ dependencies = [ [[package]] name = "multiaddr" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b852bc02a2da5feed68cd14fa50d0774b92790a5bdbfa932a813926c8472070" +checksum = "fe6351f60b488e04c1d21bc69e56b89cb3f5e8f5d22557d6e8031bdfd79b6961" dependencies = [ "arrayref", "byteorder", @@ -3046,7 +3048,7 @@ dependencies = [ "percent-encoding", "serde", "static_assertions", - "unsigned-varint 0.7.2", + "unsigned-varint 0.8.0", "url", ] @@ -3109,7 +3111,7 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures 0.3.30", "log", "pin-project 1.1.5", @@ -3161,7 +3163,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65b4b14489ab424703c092062176d52ba55485a89c076b4f9db05092b7223aa6" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures 0.3.30", "log", "netlink-packet-core", @@ -3176,7 +3178,7 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "416060d346fbaf1f23f9512963e3e878f1a78e707cb699ba9215761754244307" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures 0.3.30", "libc", "log", @@ -3358,9 +3360,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" dependencies = [ "critical-section", "portable-atomic", @@ -3555,9 +3557,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polling" @@ -3599,12 +3601,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" -dependencies = [ - "critical-section", -] +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" [[package]] name = "powerfmt" @@ -3724,7 +3723,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "prost-derive", ] @@ -3734,7 +3733,7 @@ version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "119533552c9a7ffacc21e099c24a0ac8bb19c2a2a3f363de84cd9b844feab270" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "heck 0.4.1", "itertools 0.10.5", "lazy_static", @@ -3809,7 +3808,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ededb1cd78531627244d51dd0c7139fbe736c7d57af0092a76f0ffb2f56e98" dependencies = [ "asynchronous-codec 0.6.2", - "bytes 1.7.1", + "bytes 1.7.2", "quick-protobuf", "thiserror", "unsigned-varint 0.7.2", @@ -3822,7 +3821,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15a0580ab32b169745d7a39db2ba969226ca16738931be152a3209b409de2474" dependencies = [ "asynchronous-codec 0.7.0", - "bytes 1.7.1", + "bytes 1.7.2", "quick-protobuf", "thiserror", "unsigned-varint 0.8.0", @@ -3834,7 +3833,7 @@ version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-io", "pin-project-lite", "quinn-proto", @@ -3853,7 +3852,7 @@ version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "rand", "ring 0.17.8", "rustc-hash", @@ -4411,9 +4410,9 @@ version = "0.1.8" dependencies = [ "anyhow", "async-trait", - "axum 0.7.5", + "axum 0.7.6", "blake2", - "clap 4.5.17", + "clap 4.5.18", "convert_case", "digest", "dirs", @@ -4764,8 +4763,8 @@ dependencies = [ [[package]] name = "tari_common" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "anyhow", "config", @@ -4788,8 +4787,8 @@ dependencies = [ [[package]] name = "tari_common_sqlite" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "diesel", "diesel_migrations", @@ -4802,8 +4801,8 @@ dependencies = [ [[package]] name = "tari_common_types" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "base64 0.21.7", "bitflags 2.6.0", @@ -4828,14 +4827,14 @@ dependencies = [ [[package]] name = "tari_comms" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "anyhow", "async-trait", "bitflags 2.6.0", "blake2", - "bytes 1.7.1", + "bytes 1.7.2", "chrono", "cidr", "data-encoding", @@ -4864,7 +4863,7 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util 0.6.10", - "tower", + "tower 0.4.13", "tracing", "yamux 0.13.3", "zeroize", @@ -4872,8 +4871,8 @@ dependencies = [ [[package]] name = "tari_comms_dht" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "anyhow", "bitflags 2.6.0", @@ -4901,14 +4900,14 @@ dependencies = [ "tari_utilities", "thiserror", "tokio", - "tower", + "tower 0.4.13", "zeroize", ] [[package]] name = "tari_comms_rpc_macros" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "proc-macro2", "quote", @@ -4917,8 +4916,8 @@ dependencies = [ [[package]] name = "tari_core" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "async-trait", "bincode", @@ -5008,13 +5007,13 @@ dependencies = [ [[package]] name = "tari_features" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" [[package]] name = "tari_hashing" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "borsh", "digest", @@ -5023,8 +5022,8 @@ dependencies = [ [[package]] name = "tari_key_manager" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "argon2", "async-trait", @@ -5056,8 +5055,8 @@ dependencies = [ [[package]] name = "tari_max_size" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "borsh", "serde", @@ -5067,8 +5066,8 @@ dependencies = [ [[package]] name = "tari_mmr" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "borsh", "digest", @@ -5081,8 +5080,8 @@ dependencies = [ [[package]] name = "tari_p2p" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "anyhow", "fs2", @@ -5104,15 +5103,15 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "trust-dns-client", "webpki", ] [[package]] name = "tari_script" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "blake2", "borsh", @@ -5129,8 +5128,8 @@ dependencies = [ [[package]] name = "tari_service_framework" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "anyhow", "async-trait", @@ -5144,16 +5143,16 @@ dependencies = [ [[package]] name = "tari_shutdown" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "futures 0.3.30", ] [[package]] name = "tari_storage" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "bincode", "lmdb-zero", @@ -5164,8 +5163,8 @@ dependencies = [ [[package]] name = "tari_test_utils" -version = "1.4.2-pre.2" -source = "git+https://github.com/tari-project/tari.git#8728c4e468525e07efaf5ab03a06da2584e5727e" +version = "1.5.0-pre.0" +source = "git+https://github.com/ksrichard/tari.git?branch=feature/p2pool-coinbase-extra#4ad63cd5b17e43682c9cf990099eebc9133bb38e" dependencies = [ "futures 0.3.30", "rand", @@ -5218,18 +5217,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -5328,7 +5327,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", - "bytes 1.7.1", + "bytes 1.7.2", "libc", "mio", "parking_lot", @@ -5399,7 +5398,7 @@ version = "0.6.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36943ee01a6d67977dd3f84a5a1d2efeb4ada3a1ae771cadfaa535d9d9fc6507" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-io", "futures-sink", @@ -5414,7 +5413,7 @@ version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-sink", "pin-project-lite", @@ -5453,9 +5452,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap 2.5.0", "serde", @@ -5474,7 +5473,7 @@ dependencies = [ "async-trait", "axum 0.6.20", "base64 0.13.1", - "bytes 1.7.1", + "bytes 1.7.2", "futures-core", "futures-util", "h2", @@ -5491,7 +5490,7 @@ dependencies = [ "tokio-rustls 0.23.4", "tokio-stream", "tokio-util 0.7.12", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -5532,6 +5531,22 @@ dependencies = [ "tracing", ] +[[package]] +name = "tower" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "tower-layer" version = "0.3.3" @@ -5692,9 +5707,9 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -5707,15 +5722,15 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" @@ -5749,7 +5764,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" dependencies = [ "asynchronous-codec 0.6.2", - "bytes 1.7.1", + "bytes 1.7.2", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index be3a6da..0c8b0a8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,12 +4,19 @@ version = "0.1.8" edition = "2021" [dependencies] -minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } -minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } -tari_common_types = { git = "https://github.com/tari-project/tari.git" } -tari_common = { git = "https://github.com/tari-project/tari.git" } -tari_core = { git = "https://github.com/tari-project/tari.git" } -tari_shutdown = { git = "https://github.com/tari-project/tari.git" } +#minotari_app_grpc = { git = "https://github.com/tari-project/tari.git" } +#minotari_node_grpc_client = { git = "https://github.com/tari-project/tari.git" } +#tari_common_types = { git = "https://github.com/tari-project/tari.git" } +#tari_common = { git = "https://github.com/tari-project/tari.git" } +#tari_core = { git = "https://github.com/tari-project/tari.git" } +#tari_shutdown = { git = "https://github.com/tari-project/tari.git" } + +minotari_app_grpc = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } +minotari_node_grpc_client = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } +tari_common_types = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } +tari_common = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } +tari_core = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } +tari_shutdown = { git = "https://github.com/ksrichard/tari.git", branch = "feature/p2pool-coinbase-extra" } tari_crypto = "0.20.1" tari_utilities = { version = "0.7", features = ["borsh"] } diff --git a/src/cli/commands/util.rs b/src/cli/commands/util.rs index a0c7ef6..79982e2 100644 --- a/src/cli/commands/util.rs +++ b/src/cli/commands/util.rs @@ -1,7 +1,7 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use std::{env, sync::Arc}; +use std::{collections::HashMap, env, sync::Arc}; use libp2p::identity::Keypair; use log::info; @@ -12,6 +12,7 @@ use tari_core::{ }; use tari_shutdown::ShutdownSignal; use tari_utilities::hex::Hex; +use tokio::sync::RwLock; use crate::{ cli::args::{Cli, StartArgs}, @@ -99,14 +100,28 @@ genesis_block_hash.to_hex()); consensus_manager.clone(), genesis_block_hash, )); - let share_chain_sha3x = - InMemoryShareChain::new(MAX_BLOCKS_COUNT, PowAlgorithm::Sha3x, None, consensus_manager.clone())?; + let coinbase_extras = Arc::new(RwLock::new(HashMap::>::new())); + let share_chain_sha3x = InMemoryShareChain::new( + MAX_BLOCKS_COUNT, + PowAlgorithm::Sha3x, + None, + consensus_manager.clone(), + coinbase_extras.clone(), + )?; let share_chain_random_x = InMemoryShareChain::new( MAX_BLOCKS_COUNT, PowAlgorithm::RandomX, Some(block_validation_params.clone()), consensus_manager, + coinbase_extras.clone(), )?; - Ok(Server::new(config, share_chain_sha3x, share_chain_random_x, shutdown_signal).await?) + Ok(Server::new( + config, + share_chain_sha3x, + share_chain_random_x, + coinbase_extras.clone(), + shutdown_signal, + ) + .await?) } diff --git a/src/server/grpc/p2pool.rs b/src/server/grpc/p2pool.rs index 0b4b845..6f2b1e0 100644 --- a/src/server/grpc/p2pool.rs +++ b/src/server/grpc/p2pool.rs @@ -1,7 +1,7 @@ // Copyright 2024 The Tari Project // SPDX-License-Identifier: BSD-3-Clause -use std::{collections::HashMap, sync::Arc, time::Instant}; +use std::{collections::HashMap, str::FromStr, sync::Arc, time::Instant}; use log::{debug, error, info, warn}; use minotari_app_grpc::tari_rpc::{ @@ -16,7 +16,7 @@ use minotari_app_grpc::tari_rpc::{ SubmitBlockResponse, }; use num_format::{Locale, ToFormattedString}; -use tari_common_types::types::FixedHash; +use tari_common_types::{tari_address::TariAddress, types::FixedHash}; use tari_core::{ consensus::ConsensusManager, proof_of_work::{randomx_difficulty, randomx_factory::RandomXFactory, sha3x_difficulty, Difficulty, PowAlgorithm}, @@ -37,6 +37,7 @@ use crate::{ P2POOL_STAT_REJECTED_BLOCKS_COUNT, }, p2p, + p2p::Tribe, stats_store::StatsStore, }, sharechain::{block::Block, BlockValidationParams, ShareChain, SHARE_COUNT}, @@ -77,6 +78,8 @@ where S: ShareChain stats_max_difficulty_since_last_success: Arc>, consensus_manager: ConsensusManager, submit_block_semaphore: Arc, + tribe: Tribe, + coinbase_extras: Arc>>>, } impl ShaP2PoolGrpc @@ -92,6 +95,8 @@ where S: ShareChain random_x_factory: RandomXFactory, consensus_manager: ConsensusManager, genesis_block_hash: FixedHash, + tribe: Tribe, + coinbase_extras: Arc>>>, ) -> Result { Ok(Self { client: Arc::new(RwLock::new( @@ -111,6 +116,8 @@ where S: ShareChain stats_max_difficulty_since_last_success: Arc::new(RwLock::new(Difficulty::min())), consensus_manager, submit_block_semaphore: Arc::new(Semaphore::new(1)), + tribe, + coinbase_extras: coinbase_extras.clone(), }) } @@ -158,11 +165,10 @@ where S: ShareChain request: Request, ) -> Result, Status> { let timer = Instant::now(); + let grpc_req = request.into_inner(); + // extract pow algo - let grpc_block_header_pow = request - .into_inner() - .pow - .ok_or(Status::invalid_argument("missing pow in request"))?; + let grpc_block_header_pow = grpc_req.pow.ok_or(Status::invalid_argument("missing pow in request"))?; let grpc_pow_algo = PowAlgos::from_i32(grpc_block_header_pow.pow_algo) .ok_or_else(|| Status::internal("invalid block header pow algo in request"))?; let pow_algo = match grpc_pow_algo { @@ -187,12 +193,22 @@ where S: ShareChain .ok_or_else(|| Status::internal("missing miner data"))?; // let reward = miner_data.reward; + // update coinbase extras cache + let wallet_payment_address = TariAddress::from_str(grpc_req.wallet_payment_address.as_str()) + .map_err(|error| Status::failed_precondition(format!("Invalid wallet payment address: {}", error)))?; + let mut coinbase_extras_lock = self.coinbase_extras.write().await; + coinbase_extras_lock.insert( + wallet_payment_address.to_base58(), + util::convert_coinbase_extra(self.tribe.clone(), grpc_req.coinbase_extra), + ); + drop(coinbase_extras_lock); + // request new block template with shares as coinbases let share_chain = match pow_algo { PowAlgorithm::RandomX => self.share_chain_random_x.clone(), PowAlgorithm::Sha3x => self.share_chain_sha3x.clone(), }; - let shares = share_chain.generate_shares().await; + let shares = share_chain.generate_shares(self.tribe.clone()).await; let mut response = self .client @@ -257,6 +273,7 @@ where S: ShareChain if timer.elapsed() > MAX_ACCEPTABLE_GRPC_TIMEOUT { warn!(target: LOG_TARGET, "get_new_block took {}ms", timer.elapsed().as_millis()); } + Ok(Response::new(GetNewBlockResponse { block: Some(response), target_difficulty: target_difficulty.as_u64(), @@ -307,7 +324,7 @@ where S: ShareChain PowAlgorithm::Sha3x => self.share_chain_sha3x.clone(), }; let mut block = share_chain - .new_block(grpc_block) + .new_block(grpc_block, self.tribe.clone()) .await .map_err(|error| Status::internal(error.to_string()))?; diff --git a/src/server/grpc/util.rs b/src/server/grpc/util.rs index f69d8f4..d24676f 100644 --- a/src/server/grpc/util.rs +++ b/src/server/grpc/util.rs @@ -10,7 +10,10 @@ use tari_shutdown::ShutdownSignal; use tokio::select; use tonic::transport::Channel; -use crate::server::grpc::error::{Error, TonicError}; +use crate::server::{ + grpc::error::{Error, TonicError}, + p2p::Tribe, +}; /// Utility function to connect to a Base node and try infinitely when it fails until gets connected. pub async fn connect_base_node( @@ -49,3 +52,17 @@ pub async fn connect_base_node( Ok(client) } + +pub fn convert_coinbase_extra(tribe: Tribe, custom_coinbase_extra: String) -> Vec { + let type_length_value_marker = 0xFFu8; + let tribe_type_marker = 0x02u8; + let custom_message_type_marker = 0x01u8; + let mut current_tribe = tribe.as_string().into_bytes(); + let mut result = vec![type_length_value_marker, tribe_type_marker, current_tribe.len() as u8]; + result.append(&mut current_tribe); + let mut coinbase_extra_bytes = custom_coinbase_extra.into_bytes(); + result.append(&mut vec![custom_message_type_marker, coinbase_extra_bytes.len() as u8]); + result.append(&mut coinbase_extra_bytes); + + result +} diff --git a/src/server/http/stats/handlers.rs b/src/server/http/stats/handlers.rs index a58ee92..a24a29a 100644 --- a/src/server/http/stats/handlers.rs +++ b/src/server/http/stats/handlers.rs @@ -81,17 +81,25 @@ pub(crate) async fn handle_miners_with_shares( let mut result = HashMap::with_capacity(2); result.insert( PowAlgorithm::Sha3x.to_string().to_lowercase(), - state.share_chain_sha3x.miners_with_shares().await.map_err(|error| { - error!(target: LOG_TARGET, "Failed to get Sha3x miners with shares: {error:?}"); - StatusCode::INTERNAL_SERVER_ERROR - })?, + state + .share_chain_sha3x + .miners_with_shares(state.tribe.clone()) + .await + .map_err(|error| { + error!(target: LOG_TARGET, "Failed to get Sha3x miners with shares: {error:?}"); + StatusCode::INTERNAL_SERVER_ERROR + })?, ); result.insert( PowAlgorithm::RandomX.to_string().to_lowercase(), - state.share_chain_random_x.miners_with_shares().await.map_err(|error| { - error!(target: LOG_TARGET, "Failed to get RandomX miners with shares: {error:?}"); - StatusCode::INTERNAL_SERVER_ERROR - })?, + state + .share_chain_random_x + .miners_with_shares(state.tribe.clone()) + .await + .map_err(|error| { + error!(target: LOG_TARGET, "Failed to get RandomX miners with shares: {error:?}"); + StatusCode::INTERNAL_SERVER_ERROR + })?, ); if timer.elapsed() > MAX_ACCEPTABLE_HTTP_TIMEOUT { @@ -140,10 +148,13 @@ async fn get_stats(state: AppState, algo: PowAlgorithm) -> Result 0; - let shares = share_chain.miners_with_shares().await.map_err(|error| { - error!(target: LOG_TARGET, "Failed to get miners with shares: {error:?}"); - StatusCode::INTERNAL_SERVER_ERROR - })?; + let shares = share_chain + .miners_with_shares(state.tribe.clone()) + .await + .map_err(|error| { + error!(target: LOG_TARGET, "Failed to get miners with shares: {error:?}"); + StatusCode::INTERNAL_SERVER_ERROR + })?; // collect number of miners // let num_of_miners = chain // .iter() diff --git a/src/server/p2p/network.rs b/src/server/p2p/network.rs index 5e732dd..d42012b 100644 --- a/src/server/p2p/network.rs +++ b/src/server/p2p/network.rs @@ -111,6 +111,10 @@ impl Tribe { pub fn formatted(&self) -> String { self.inner.to_case(Case::Lower).replace("_", " ").to_case(Case::Title) } + + pub fn as_string(&self) -> String { + self.inner.to_case(Case::Lower) + } } impl ToValue for Tribe { diff --git a/src/server/server.rs b/src/server/server.rs index 6e0d55e..0025b60 100644 --- a/src/server/server.rs +++ b/src/server/server.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: BSD-3-Clause use std::{ + collections::HashMap, net::{AddrParseError, SocketAddr}, str::FromStr, sync::{atomic::AtomicBool, Arc}, @@ -13,6 +14,7 @@ use tari_common::configuration::Network; use tari_core::{consensus::ConsensusManager, proof_of_work::randomx_factory::RandomXFactory}; use tari_shutdown::ShutdownSignal; use thiserror::Error; +use tokio::sync::RwLock; use crate::{ server::{ @@ -60,6 +62,7 @@ where S: ShareChain config: config::Config, share_chain_sha3x: S, share_chain_random_x: S, + coinbase_extras: Arc>>>, shutdown_signal: ShutdownSignal, ) -> Result { let share_chain_sha3x = Arc::new(share_chain_sha3x); @@ -103,6 +106,8 @@ where S: ShareChain randomx_factory, consensus_manager, genesis_block_hash, + config.p2p_service.tribe.clone(), + coinbase_extras.clone(), ) .await .map_err(Error::Grpc)?; diff --git a/src/sharechain/block.rs b/src/sharechain/block.rs index 7bb113e..8cd4f76 100644 --- a/src/sharechain/block.rs +++ b/src/sharechain/block.rs @@ -36,6 +36,7 @@ pub(crate) struct Block { pub miner_wallet_address: Option, pub sent_to_main_chain: bool, pub achieved_difficulty: Difficulty, + pub miner_coinbase_extra: Vec, } impl_conversions!(Block); @@ -76,6 +77,7 @@ impl BlockBuilder { miner_wallet_address: Default::default(), sent_to_main_chain: false, achieved_difficulty: Difficulty::min(), + miner_coinbase_extra: vec![], }, } } @@ -100,6 +102,11 @@ impl BlockBuilder { self } + pub fn with_miner_coinbase_extra(&mut self, coinbase_extra: Vec) -> &mut Self { + self.block.miner_coinbase_extra = coinbase_extra; + self + } + pub fn with_miner_wallet_address(&mut self, miner_wallet_address: TariAddress) -> &mut Self { self.block.miner_wallet_address = Some(miner_wallet_address); self diff --git a/src/sharechain/in_memory.rs b/src/sharechain/in_memory.rs index aeafacd..576211f 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -2,13 +2,14 @@ // SPDX-License-Identifier: BSD-3-Clause use std::{ - collections::{HashMap, VecDeque}, + collections::{vec_deque, HashMap, VecDeque}, slice::Iter, str::FromStr, sync::Arc, }; use async_trait::async_trait; +use itertools::Itertools; use log::*; use minotari_app_grpc::tari_rpc::{NewBlockCoinbase, SubmitBlockRequest}; use num::{BigUint, Zero}; @@ -23,7 +24,10 @@ use tokio::sync::{RwLock, RwLockWriteGuard}; use super::MAX_BLOCKS_COUNT; use crate::{ - server::grpc::p2pool::min_difficulty, + server::{ + grpc::{p2pool::min_difficulty, util::convert_coinbase_extra}, + p2p::Tribe, + }, sharechain::{ error::{BlockConvertError, Error}, Block, @@ -63,6 +67,7 @@ pub(crate) struct InMemoryShareChain { pow_algo: PowAlgorithm, block_validation_params: Option>, consensus_manager: ConsensusManager, + coinbase_extras: Arc>>>, } /// A collection of blocks with the same height. @@ -117,6 +122,7 @@ impl InMemoryShareChain { pow_algo: PowAlgorithm, block_validation_params: Option>, consensus_manager: ConsensusManager, + coinbase_extras: Arc>>>, ) -> Result { if pow_algo == PowAlgorithm::RandomX && block_validation_params.is_none() { return Err(Error::MissingBlockValidationParams); @@ -133,6 +139,7 @@ impl InMemoryShareChain { pow_algo, block_validation_params, consensus_manager, + coinbase_extras, }) } @@ -453,6 +460,38 @@ impl InMemoryShareChain { Ok(()) } + + async fn find_coinbase_extra( + &self, + block_level_iter: vec_deque::Iter<'_, BlockLevel>, + miner_wallet_address: TariAddress, + ) -> Option> { + // check if we have coinbase in cache (it is the newest, since miner sent it recently) + let coinbase_extras_lock = self.coinbase_extras.read().await; + if let Some(found_coinbase_extras) = coinbase_extras_lock.get(&miner_wallet_address.to_base58()) { + return Some(found_coinbase_extras.clone()); + } + drop(coinbase_extras_lock); + + Some( + block_level_iter + .map(|level| { + level + .blocks + .as_slice() + .iter() + .cloned() + .filter(|block| block.miner_wallet_address == Some(miner_wallet_address.clone())) + .sorted_by(|block1, block2| block1.timestamp.cmp(&block2.timestamp)) + .last() + }) + .filter(|block_option| block_option.is_some()) + .map(|block_option| block_option.unwrap()) + .sorted_by(|block1, block2| block1.timestamp.cmp(&block2.timestamp)) + .last()? + .miner_coinbase_extra, + ) + } } #[async_trait] @@ -493,7 +532,7 @@ impl ShareChain for InMemoryShareChain { Ok(tip_level) } - async fn generate_shares(&self) -> Vec { + async fn generate_shares(&self, tribe: Tribe) -> Vec { let bl = self.block_levels.read().await; if let Some(ref cached_shares) = bl.cached_shares { return cached_shares.clone(); @@ -563,12 +602,24 @@ impl ShareChain for InMemoryShareChain { } for (key, value) in miners_to_shares { + // find coinbase extra for wallet address + let mut coinbase_extra = convert_coinbase_extra(tribe.clone(), String::new()); + if let Ok(miner_wallet_address) = TariAddress::from_str(key.as_str()) { + if let Some(coinbase_extra_found) = + self.find_coinbase_extra(bl.levels.iter(), miner_wallet_address).await + { + coinbase_extra = coinbase_extra_found; + } + } + + info!(target: LOG_TARGET, "Current coinbase extra: {:?}", coinbase_extra.to_hex()); // TODO: remove + res.push(NewBlockCoinbase { address: key, value, stealth_payment: false, revealed_value_proof: true, - coinbase_extra: vec![], + coinbase_extra, }); } @@ -577,7 +628,7 @@ impl ShareChain for InMemoryShareChain { res } - async fn new_block(&self, request: &SubmitBlockRequest) -> ShareChainResult { + async fn new_block(&self, request: &SubmitBlockRequest, tribe: Tribe) -> ShareChainResult { let origin_block_grpc = request .block .as_ref() @@ -595,14 +646,25 @@ impl ShareChain for InMemoryShareChain { .block_in_main_chain() .ok_or_else(|| Error::Empty)?; + let miner_wallet_address = + TariAddress::from_str(request.wallet_payment_address.as_str()).map_err(Error::TariAddress)?; + + // coinbase extra + let coinbase_extras_lock = self.coinbase_extras.read().await; + let coinbase_extra = + if let Some(found_coinbase_extra) = coinbase_extras_lock.get(&miner_wallet_address.to_base58()) { + found_coinbase_extra.clone() + } else { + convert_coinbase_extra(tribe, String::new()) + }; + Ok(Block::builder() .with_timestamp(EpochTime::now()) .with_prev_hash(last_block.hash) .with_height(last_block.height + 1) + .with_miner_coinbase_extra(coinbase_extra) .with_original_block_header(origin_block.header.clone()) - .with_miner_wallet_address( - TariAddress::from_str(request.wallet_payment_address.as_str()).map_err(Error::TariAddress)?, - ) + .with_miner_wallet_address(miner_wallet_address) .build()) } @@ -682,14 +744,14 @@ impl ShareChain for InMemoryShareChain { // Ok(hash_rates_sum.div(hash_rates_count)) } - async fn miners_with_shares(&self) -> ShareChainResult> { + async fn miners_with_shares(&self, tribe: Tribe) -> ShareChainResult> { let bl = self.block_levels.read().await; if let Some(ref shares) = bl.cached_shares { return Ok(shares.iter().map(|s| (s.address.clone(), s.value)).collect()); } drop(bl); - let shares = self.generate_shares().await; + let shares = self.generate_shares(tribe).await; Ok(shares.iter().map(|s| (s.address.clone(), s.value)).collect()) } } diff --git a/src/sharechain/mod.rs b/src/sharechain/mod.rs index 239aa33..947da80 100644 --- a/src/sharechain/mod.rs +++ b/src/sharechain/mod.rs @@ -9,11 +9,14 @@ use num::BigUint; use tari_common_types::types::FixedHash; use tari_core::{consensus::ConsensusManager, proof_of_work::randomx_factory::RandomXFactory}; -use crate::sharechain::{block::Block, error::Error}; +use crate::{ + server::p2p::Tribe, + sharechain::{block::Block, error::Error}, +}; /// Chain ID is an identifier which makes sure we apply the same rules to blocks. /// Note: This must be updated when new logic applied to blocks handling. -pub const CHAIN_ID: usize = 1; +pub const CHAIN_ID: usize = 2; /// How many blocks to keep overall. pub const MAX_BLOCKS_COUNT: usize = 2001; @@ -83,10 +86,10 @@ pub(crate) trait ShareChain: Send + Sync + 'static { async fn tip_height(&self) -> ShareChainResult; /// Generate shares based on the previous blocks. - async fn generate_shares(&self) -> Vec; + async fn generate_shares(&self, tribe: Tribe) -> Vec; /// Return a new block that could be added via `submit_block`. - async fn new_block(&self, request: &SubmitBlockRequest) -> ShareChainResult; + async fn new_block(&self, request: &SubmitBlockRequest, tribe: Tribe) -> ShareChainResult; /// Returns blocks from the given height (`from_height`, exclusive). async fn blocks(&self, from_height: u64) -> ShareChainResult>; @@ -97,5 +100,5 @@ pub(crate) trait ShareChain: Send + Sync + 'static { async fn hash_rate(&self) -> ShareChainResult; /// Returns the current miners with all the current shares in the current blocks window. - async fn miners_with_shares(&self) -> ShareChainResult>; + async fn miners_with_shares(&self, tribe: Tribe) -> ShareChainResult>; }