Переглянути джерело

event_graph: add a special tier and bootstrap genesis events

dasman 2 місяців тому
батько
коміт
c5bba7e6ce

+ 21 - 0
Cargo.lock

@@ -2113,6 +2113,7 @@ dependencies = [
  "smol",
  "structopt",
  "structopt-toml",
+ "tikv-jemallocator",
  "toml 0.9.12+spec-1.1.0",
  "tracing",
  "tracing-appender",
@@ -7384,6 +7385,26 @@ dependencies = [
  "cfg-if",
 ]
 
+[[package]]
+name = "tikv-jemalloc-sys"
+version = "0.5.4+5.3.0-patched"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9402443cb8fd499b6f327e40565234ff34dbda27460c5b47db0db77443dd85d1"
+dependencies = [
+ "cc",
+ "libc",
+]
+
+[[package]]
+name = "tikv-jemallocator"
+version = "0.5.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "965fe0c26be5c56c94e38ba547249074803efd52adfb66de62107d95aab3eaca"
+dependencies = [
+ "libc",
+ "tikv-jemalloc-sys",
+]
+
 [[package]]
 name = "time"
 version = "0.3.47"

+ 2 - 0
bin/darkirc/Cargo.toml

@@ -27,6 +27,8 @@ darkfi-sdk = {path = "../../src/sdk", features = ["async"]}
 darkfi-serial = {path = "../../src/serial", features = ["async"]}
 libc = "0.2.186"
 
+tikv-jemallocator = "0.5.4"
+
 # Event Graph DB
 sled-overlay = "0.1.20"
 

+ 30 - 1
bin/darkirc/src/irc/services/nickserv.rs

@@ -60,7 +60,8 @@ use std::{str::SplitAsciiWhitespace, sync::Arc};
 
 use darkfi::{
     event_graph::{
-        rln::{create_slash_proof, RLNNode, SlashBlob},
+        genesis_commits::GENESIS_COMMITMENTS_REPR,
+        rln::{create_slash_proof, RLNNode, SlashBlob, GENESIS_USER_MSG_LIMIT},
         Event,
     },
     Result,
@@ -506,6 +507,34 @@ impl NickServ {
             *self.server.rln_identity.write().await = Some(new_rln_identity);
         }
 
+        let is_genesis =
+            GENESIS_COMMITMENTS_REPR.contains(&new_rln_identity.commitment().to_repr());
+
+        if is_genesis {
+            if user_msg_limit != GENESIS_USER_MSG_LIMIT {
+                let mut replies = vec![notice(
+                    nick,
+                    format!("Genesis account must use user_msg_limit={}", GENESIS_USER_MSG_LIMIT),
+                )];
+                replies.push(notice(
+                    nick,
+                    format!("Use `DEREGISTER {account_name}` to remove this account."),
+                ));
+            }
+            let mut replies =
+                vec![notice(nick, format!("Successfully registered account \"{account_name}\""))];
+            if became_active {
+                replies
+                    .push(notice(nick, format!("\"{account_name}\" is now the active identity.")));
+            } else {
+                replies.push(notice(
+                    nick,
+                    format!("Use `SET {account_name}` to make this the active identity."),
+                ));
+            }
+            return Ok(replies)
+        }
+
         // Build the static-DAG event and the registration blob.
         // The blob format is `RegistrationBlob` (proof +
         // user_message_limit + max_message_limit + attestation),

+ 6 - 6
bin/darkirc/src/main.rs

@@ -177,12 +177,12 @@ struct Args {
     rpc: RpcSettingsOpt,
 }
 
-// #[global_allocator]
-// static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
+#[global_allocator]
+static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
 
-// #[allow(non_upper_case_globals)]
-// #[export_name = "malloc_conf"]
-// pub static malloc_conf: &[u8] = b"dirty_decay_ms:1000,muzzy_decay_ms:1000\0";
+#[allow(non_upper_case_globals)]
+#[export_name = "malloc_conf"]
+pub static malloc_conf: &[u8] = b"dirty_decay_ms:1000,muzzy_decay_ms:1000\0";
 
 async_daemonize!(realmain);
 async fn realmain(args: Args, ex: Arc<Executor<'static>>) -> Result<()> {
@@ -676,7 +676,7 @@ async fn sync_task(
                 Err(e) => {
                     error!("Failed syncing static graph: {e}");
                     p2p.stop().await;
-                    return Err(Error::DagSyncFailed)
+                    return Err(Error::StaticDagSyncFailed)
                 }
             }
             info!("Syncing event DAG");

+ 2 - 2
contrib/localnet/darkirc-four-nodes/darkirc_full_node2.toml

@@ -52,9 +52,9 @@ active_profiles = ["tcp"]
 ## Seed nodes to connect to
 seeds = ["tcp://127.0.0.1:25551"]
 
-# inbound = ["tcp://127.0.0.1:25553"]
+inbound = ["tcp://127.0.0.1:25553"]
 
-# external_addrs = ["tcp://127.0.0.1:25553"]
+external_addrs = ["tcp://127.0.0.1:25553"]
 
 # peers = ["tcp://127.0.0.1:25552"]
 

+ 416 - 0
src/event_graph/genesis_commits.rs

@@ -0,0 +1,416 @@
+/* This file is part of DarkFi (https://dark.fi)
+ *
+ * Copyright (C) 2020-2026 Dyne.org foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ */
+
+pub const GENESIS_COMMITMENTS_REPR: &[[u8; 32]] = &[
+    [
+        174, 24, 82, 252, 164, 38, 217, 34, 167, 197, 190, 21, 91, 140, 238, 27, 33, 23, 110, 88,
+        113, 177, 97, 244, 158, 212, 63, 158, 3, 239, 59, 63,
+    ],
+    [
+        95, 47, 141, 238, 104, 199, 133, 192, 221, 216, 224, 186, 230, 16, 29, 94, 189, 64, 14,
+        148, 129, 34, 109, 124, 29, 201, 202, 134, 53, 90, 73, 38,
+    ],
+    [
+        232, 193, 102, 129, 230, 35, 63, 121, 243, 144, 79, 8, 250, 43, 183, 38, 195, 142, 239, 96,
+        138, 126, 251, 9, 121, 69, 196, 253, 248, 218, 177, 10,
+    ],
+    [
+        121, 32, 214, 197, 16, 224, 124, 45, 71, 22, 110, 208, 132, 100, 133, 135, 212, 98, 208,
+        232, 181, 172, 96, 210, 61, 108, 15, 247, 151, 197, 176, 38,
+    ],
+    [
+        88, 63, 232, 8, 67, 194, 164, 92, 121, 187, 150, 6, 0, 183, 168, 204, 230, 49, 178, 190,
+        104, 16, 56, 17, 15, 118, 120, 93, 252, 76, 112, 25,
+    ],
+    [
+        36, 49, 89, 20, 231, 58, 230, 141, 66, 175, 85, 80, 191, 158, 133, 96, 246, 165, 23, 75,
+        83, 51, 90, 134, 94, 156, 77, 1, 98, 155, 76, 21,
+    ],
+    [
+        36, 215, 221, 180, 110, 206, 46, 235, 67, 169, 68, 128, 64, 162, 13, 98, 247, 191, 106, 90,
+        179, 113, 214, 6, 119, 1, 12, 164, 0, 210, 106, 32,
+    ],
+    [
+        199, 55, 22, 165, 79, 111, 205, 113, 91, 31, 89, 61, 107, 61, 16, 15, 187, 199, 237, 97,
+        207, 53, 212, 99, 208, 45, 78, 105, 7, 199, 116, 40,
+    ],
+    [
+        66, 128, 40, 170, 136, 222, 254, 30, 117, 111, 116, 220, 98, 75, 32, 203, 116, 255, 0, 122,
+        65, 24, 95, 122, 2, 102, 100, 181, 4, 125, 120, 34,
+    ],
+    [
+        235, 27, 208, 32, 40, 189, 218, 206, 226, 93, 238, 160, 66, 145, 195, 31, 125, 185, 225,
+        145, 182, 8, 170, 41, 216, 40, 230, 102, 139, 101, 196, 56,
+    ],
+    [
+        8, 8, 168, 24, 103, 188, 35, 238, 242, 227, 76, 136, 117, 73, 152, 182, 61, 118, 64, 0, 78,
+        57, 140, 213, 159, 55, 223, 239, 13, 151, 65, 61,
+    ],
+    [
+        177, 229, 15, 242, 148, 9, 76, 23, 190, 219, 4, 110, 180, 27, 37, 78, 57, 206, 118, 231,
+        19, 161, 186, 254, 89, 73, 30, 191, 136, 150, 141, 5,
+    ],
+    [
+        131, 220, 102, 66, 155, 36, 25, 126, 5, 75, 36, 42, 60, 129, 89, 37, 195, 87, 179, 191,
+        109, 181, 4, 123, 117, 122, 221, 68, 233, 228, 44, 61,
+    ],
+    [
+        208, 89, 138, 138, 10, 247, 185, 132, 250, 126, 233, 91, 156, 137, 16, 99, 113, 32, 39,
+        172, 229, 92, 41, 214, 145, 136, 55, 29, 138, 156, 236, 35,
+    ],
+    [
+        235, 196, 181, 0, 38, 60, 132, 120, 43, 68, 128, 63, 177, 214, 180, 82, 90, 56, 24, 253,
+        239, 171, 244, 65, 189, 221, 87, 109, 156, 81, 158, 53,
+    ],
+    [
+        181, 3, 158, 245, 220, 198, 95, 65, 60, 180, 77, 138, 78, 87, 1, 41, 2, 128, 178, 15, 242,
+        57, 159, 117, 59, 21, 200, 210, 17, 239, 144, 11,
+    ],
+    [
+        109, 254, 243, 205, 228, 183, 33, 16, 95, 72, 181, 127, 184, 78, 25, 45, 42, 222, 81, 63,
+        37, 205, 199, 211, 64, 166, 105, 36, 41, 27, 222, 42,
+    ],
+    [
+        6, 157, 104, 104, 2, 140, 243, 128, 75, 199, 209, 76, 212, 13, 237, 163, 80, 0, 245, 96,
+        213, 226, 145, 159, 28, 27, 178, 24, 77, 254, 105, 33,
+    ],
+    [
+        209, 95, 218, 88, 181, 202, 12, 21, 215, 124, 92, 229, 173, 72, 155, 27, 227, 9, 78, 72,
+        98, 226, 109, 145, 165, 10, 106, 228, 83, 207, 161, 38,
+    ],
+    [
+        172, 75, 166, 133, 234, 88, 253, 132, 130, 88, 97, 231, 224, 207, 50, 116, 163, 74, 73, 51,
+        24, 60, 143, 104, 226, 79, 125, 243, 199, 192, 124, 35,
+    ],
+    [
+        127, 93, 63, 255, 52, 195, 56, 207, 130, 199, 151, 96, 0, 104, 23, 108, 166, 44, 127, 86,
+        139, 143, 136, 152, 107, 74, 199, 8, 10, 57, 162, 29,
+    ],
+    [
+        169, 76, 25, 37, 55, 44, 142, 222, 72, 136, 39, 200, 248, 101, 116, 142, 67, 246, 125, 73,
+        218, 43, 254, 217, 164, 246, 48, 85, 229, 64, 225, 6,
+    ],
+    [
+        26, 209, 32, 216, 73, 67, 219, 73, 224, 79, 203, 151, 223, 95, 74, 250, 212, 107, 107, 31,
+        100, 149, 82, 7, 11, 154, 233, 167, 137, 232, 157, 42,
+    ],
+    [
+        68, 113, 165, 109, 144, 226, 94, 207, 73, 186, 163, 105, 135, 220, 242, 143, 191, 143, 83,
+        131, 50, 150, 71, 187, 178, 60, 199, 206, 164, 6, 254, 9,
+    ],
+    [
+        104, 25, 141, 151, 48, 179, 238, 188, 8, 89, 122, 43, 119, 231, 246, 222, 85, 111, 98, 114,
+        58, 22, 5, 73, 94, 27, 64, 109, 59, 7, 232, 21,
+    ],
+    [
+        205, 72, 142, 15, 45, 155, 97, 216, 167, 83, 153, 255, 97, 212, 97, 34, 14, 75, 86, 145,
+        136, 31, 89, 99, 252, 189, 48, 176, 85, 208, 14, 4,
+    ],
+    [
+        232, 130, 162, 103, 68, 36, 99, 161, 2, 184, 30, 210, 94, 84, 76, 116, 184, 210, 223, 39,
+        90, 148, 170, 14, 80, 30, 86, 55, 98, 142, 43, 50,
+    ],
+    [
+        99, 21, 1, 150, 190, 88, 104, 67, 232, 176, 191, 194, 86, 135, 28, 108, 31, 33, 137, 192,
+        30, 2, 174, 168, 170, 237, 106, 87, 178, 178, 239, 46,
+    ],
+    [
+        145, 220, 24, 143, 5, 16, 10, 87, 163, 130, 11, 16, 99, 228, 34, 235, 53, 252, 89, 86, 150,
+        82, 168, 153, 105, 175, 142, 224, 44, 66, 1, 37,
+    ],
+    [
+        91, 17, 84, 201, 239, 54, 48, 164, 102, 111, 150, 113, 189, 22, 210, 172, 62, 199, 192,
+        219, 178, 141, 213, 152, 211, 227, 184, 127, 212, 11, 106, 4,
+    ],
+    [
+        253, 31, 31, 202, 112, 46, 140, 82, 195, 129, 23, 136, 113, 134, 16, 57, 18, 112, 68, 3,
+        125, 211, 177, 116, 237, 225, 16, 239, 67, 24, 81, 58,
+    ],
+    [
+        34, 117, 130, 49, 229, 51, 19, 39, 184, 78, 81, 217, 128, 249, 252, 234, 233, 33, 158, 194,
+        250, 252, 247, 251, 147, 135, 53, 34, 77, 180, 155, 24,
+    ],
+    [
+        145, 219, 183, 211, 126, 24, 168, 118, 78, 83, 212, 210, 187, 78, 222, 15, 61, 176, 47,
+        208, 227, 250, 108, 162, 75, 25, 9, 159, 115, 228, 236, 14,
+    ],
+    [
+        150, 166, 207, 0, 181, 165, 75, 33, 5, 58, 255, 175, 240, 57, 218, 203, 153, 154, 116, 16,
+        47, 198, 92, 209, 38, 240, 141, 74, 119, 140, 235, 18,
+    ],
+    [
+        122, 37, 32, 40, 249, 184, 104, 135, 139, 72, 234, 196, 220, 208, 151, 151, 97, 15, 130,
+        190, 168, 112, 43, 218, 221, 7, 233, 202, 79, 253, 28, 36,
+    ],
+    [
+        81, 44, 241, 81, 132, 167, 218, 134, 239, 94, 249, 71, 74, 189, 71, 27, 207, 99, 58, 187,
+        39, 170, 194, 220, 191, 203, 229, 253, 210, 44, 134, 20,
+    ],
+    [
+        121, 148, 185, 6, 102, 59, 152, 112, 168, 208, 160, 171, 214, 30, 72, 17, 210, 87, 221,
+        210, 168, 80, 215, 222, 122, 12, 78, 60, 226, 112, 190, 52,
+    ],
+    [
+        145, 206, 187, 109, 174, 120, 4, 166, 107, 239, 230, 208, 240, 32, 102, 101, 10, 87, 137,
+        114, 211, 186, 197, 6, 160, 73, 17, 167, 161, 38, 134, 59,
+    ],
+    [
+        191, 234, 164, 248, 93, 193, 252, 173, 134, 73, 71, 46, 77, 206, 149, 131, 45, 221, 142,
+        147, 200, 155, 58, 72, 3, 246, 70, 156, 202, 101, 39, 18,
+    ],
+    [
+        222, 58, 215, 166, 150, 255, 106, 236, 32, 170, 172, 17, 238, 108, 186, 84, 68, 100, 74,
+        245, 170, 9, 204, 98, 182, 160, 105, 210, 21, 72, 56, 48,
+    ],
+    [
+        87, 142, 120, 119, 179, 171, 92, 73, 248, 93, 106, 244, 201, 177, 15, 21, 151, 153, 160,
+        173, 32, 182, 220, 15, 86, 21, 16, 140, 116, 147, 110, 11,
+    ],
+    [
+        37, 41, 30, 21, 201, 62, 118, 65, 151, 148, 21, 139, 66, 85, 124, 166, 159, 72, 38, 177,
+        65, 4, 38, 195, 191, 45, 207, 187, 168, 34, 59, 29,
+    ],
+    [
+        214, 131, 221, 173, 139, 166, 62, 231, 154, 175, 118, 193, 231, 131, 165, 178, 250, 99, 10,
+        169, 163, 233, 230, 119, 212, 52, 94, 130, 238, 189, 154, 58,
+    ],
+    [
+        23, 19, 117, 54, 162, 107, 0, 8, 190, 239, 186, 232, 223, 90, 27, 189, 244, 66, 46, 204,
+        228, 99, 114, 42, 208, 149, 245, 97, 223, 227, 248, 57,
+    ],
+    [
+        243, 118, 37, 128, 37, 165, 138, 106, 41, 167, 4, 174, 6, 188, 186, 155, 209, 250, 201,
+        243, 40, 43, 181, 224, 89, 124, 218, 103, 59, 37, 18, 32,
+    ],
+    [
+        190, 207, 243, 234, 100, 188, 172, 135, 38, 93, 223, 76, 15, 50, 31, 79, 141, 250, 83, 135,
+        185, 236, 215, 190, 162, 131, 169, 203, 235, 67, 167, 27,
+    ],
+    [
+        61, 239, 107, 22, 68, 31, 101, 132, 140, 51, 113, 61, 129, 82, 137, 123, 229, 231, 137, 11,
+        78, 199, 205, 147, 49, 200, 81, 184, 8, 131, 129, 54,
+    ],
+    [
+        224, 215, 242, 21, 216, 45, 159, 114, 246, 6, 152, 133, 9, 57, 1, 80, 87, 209, 110, 237,
+        224, 109, 150, 70, 126, 131, 89, 28, 98, 5, 194, 33,
+    ],
+    [
+        229, 248, 171, 177, 36, 132, 98, 208, 196, 137, 187, 130, 149, 15, 157, 182, 227, 28, 138,
+        114, 81, 43, 213, 39, 243, 54, 173, 22, 14, 155, 169, 35,
+    ],
+    [
+        162, 14, 52, 11, 130, 201, 135, 50, 126, 74, 190, 222, 252, 151, 117, 13, 189, 72, 233,
+        186, 191, 112, 97, 252, 237, 223, 161, 80, 57, 143, 9, 1,
+    ],
+    [
+        234, 138, 235, 17, 189, 11, 198, 128, 197, 242, 180, 134, 215, 211, 254, 139, 47, 149, 232,
+        126, 39, 238, 33, 191, 38, 31, 61, 181, 127, 115, 48, 14,
+    ],
+    [
+        14, 124, 242, 151, 164, 239, 201, 185, 21, 228, 130, 57, 36, 148, 47, 221, 3, 29, 67, 54,
+        155, 20, 8, 97, 217, 91, 92, 84, 14, 133, 145, 51,
+    ],
+    [
+        196, 61, 9, 20, 124, 244, 87, 146, 87, 60, 139, 9, 207, 5, 50, 5, 118, 251, 48, 30, 143,
+        38, 89, 170, 189, 35, 136, 93, 119, 235, 5, 2,
+    ],
+    [
+        96, 13, 80, 22, 169, 123, 183, 111, 238, 26, 35, 131, 92, 186, 144, 39, 49, 222, 239, 7,
+        143, 8, 79, 107, 176, 175, 204, 161, 127, 121, 215, 48,
+    ],
+    [
+        126, 198, 102, 97, 74, 177, 14, 51, 81, 58, 16, 173, 172, 159, 224, 186, 134, 85, 86, 106,
+        20, 254, 98, 216, 187, 71, 37, 186, 112, 120, 177, 28,
+    ],
+    [
+        209, 9, 7, 219, 126, 132, 159, 110, 254, 152, 55, 228, 251, 66, 118, 116, 117, 178, 124,
+        154, 156, 72, 247, 203, 245, 156, 91, 162, 23, 204, 178, 49,
+    ],
+    [
+        187, 162, 176, 40, 42, 191, 74, 67, 177, 140, 83, 187, 198, 22, 46, 173, 84, 59, 130, 204,
+        101, 181, 95, 90, 199, 246, 190, 108, 211, 184, 253, 29,
+    ],
+    [
+        224, 183, 206, 65, 217, 6, 41, 91, 235, 179, 245, 239, 9, 130, 223, 214, 138, 122, 93, 160,
+        133, 225, 217, 9, 253, 129, 127, 227, 251, 229, 226, 44,
+    ],
+    [
+        119, 251, 83, 142, 109, 163, 25, 62, 245, 106, 206, 230, 109, 221, 116, 157, 120, 200, 56,
+        57, 210, 104, 13, 84, 14, 167, 118, 60, 24, 36, 117, 34,
+    ],
+    [
+        223, 9, 4, 55, 195, 159, 106, 116, 246, 6, 38, 212, 217, 97, 49, 4, 48, 18, 1, 69, 216,
+        189, 193, 129, 13, 250, 112, 61, 81, 167, 227, 34,
+    ],
+    [
+        26, 69, 249, 10, 167, 187, 61, 126, 255, 154, 188, 119, 236, 229, 234, 7, 248, 185, 165,
+        39, 222, 72, 206, 16, 82, 38, 198, 234, 26, 191, 20, 24,
+    ],
+    [
+        231, 143, 3, 169, 139, 249, 130, 67, 92, 211, 44, 228, 10, 180, 28, 244, 31, 123, 176, 87,
+        69, 133, 198, 102, 163, 44, 131, 24, 112, 232, 146, 56,
+    ],
+    [
+        62, 6, 17, 44, 33, 82, 89, 56, 193, 197, 118, 120, 40, 9, 236, 105, 250, 219, 220, 158, 39,
+        118, 129, 233, 83, 212, 220, 222, 36, 179, 209, 35,
+    ],
+    [
+        240, 165, 145, 179, 255, 241, 222, 241, 92, 230, 86, 3, 175, 145, 164, 123, 238, 159, 191,
+        224, 164, 154, 62, 217, 207, 19, 16, 147, 121, 217, 125, 50,
+    ],
+    [
+        45, 116, 216, 216, 95, 218, 213, 181, 86, 72, 220, 254, 251, 46, 184, 57, 135, 131, 27, 94,
+        148, 48, 84, 158, 118, 218, 230, 132, 210, 112, 132, 37,
+    ],
+    [
+        248, 221, 249, 24, 184, 80, 236, 164, 19, 212, 143, 29, 189, 181, 101, 245, 161, 167, 121,
+        83, 150, 84, 245, 175, 126, 137, 200, 161, 230, 50, 70, 46,
+    ],
+    [
+        27, 105, 219, 17, 167, 127, 120, 147, 102, 117, 169, 171, 151, 247, 194, 168, 102, 131,
+        128, 10, 132, 112, 58, 216, 69, 27, 58, 104, 64, 243, 92, 55,
+    ],
+    [
+        98, 166, 193, 125, 151, 184, 136, 178, 55, 187, 240, 189, 139, 246, 79, 135, 221, 126, 1,
+        126, 215, 196, 229, 96, 77, 199, 34, 18, 190, 42, 187, 21,
+    ],
+    [
+        86, 234, 45, 60, 141, 241, 14, 157, 207, 62, 205, 6, 30, 177, 179, 122, 94, 243, 105, 69,
+        155, 38, 139, 53, 60, 188, 87, 47, 113, 200, 163, 36,
+    ],
+    [
+        18, 241, 99, 176, 169, 204, 62, 216, 255, 8, 134, 12, 169, 139, 91, 240, 122, 228, 25, 111,
+        155, 174, 46, 198, 22, 131, 252, 90, 31, 111, 226, 24,
+    ],
+    [
+        217, 62, 151, 180, 105, 211, 150, 240, 173, 58, 20, 151, 94, 170, 72, 89, 198, 238, 148,
+        241, 237, 189, 56, 248, 242, 126, 15, 110, 243, 117, 1, 7,
+    ],
+    [
+        1, 82, 122, 52, 88, 105, 159, 237, 229, 240, 99, 213, 114, 30, 162, 9, 157, 91, 52, 245,
+        111, 74, 80, 175, 80, 51, 211, 192, 204, 147, 172, 44,
+    ],
+    [
+        98, 73, 7, 38, 11, 116, 238, 132, 82, 187, 127, 245, 185, 38, 253, 188, 161, 11, 39, 131,
+        44, 164, 21, 222, 245, 138, 163, 238, 165, 169, 160, 57,
+    ],
+    [
+        127, 32, 167, 148, 62, 255, 0, 74, 30, 253, 46, 81, 56, 244, 45, 37, 69, 94, 53, 106, 23,
+        47, 123, 189, 28, 102, 73, 105, 66, 63, 95, 17,
+    ],
+    [
+        190, 222, 178, 52, 24, 0, 51, 204, 111, 84, 215, 77, 46, 59, 97, 98, 130, 165, 224, 119,
+        198, 185, 167, 224, 209, 84, 184, 60, 49, 191, 219, 57,
+    ],
+    [
+        217, 35, 80, 59, 176, 161, 221, 55, 156, 56, 40, 114, 108, 181, 205, 91, 195, 202, 239,
+        235, 252, 248, 75, 34, 171, 185, 33, 115, 186, 244, 48, 48,
+    ],
+    [
+        61, 148, 91, 72, 197, 240, 50, 54, 190, 45, 40, 206, 249, 60, 187, 159, 21, 152, 47, 252,
+        52, 55, 144, 199, 187, 170, 177, 196, 4, 195, 59, 52,
+    ],
+    [
+        87, 249, 252, 199, 52, 139, 47, 121, 77, 126, 200, 171, 6, 226, 185, 137, 7, 159, 245, 206,
+        47, 85, 72, 159, 135, 82, 211, 59, 80, 117, 72, 56,
+    ],
+    [
+        149, 96, 169, 68, 158, 97, 191, 236, 180, 116, 223, 13, 211, 170, 32, 136, 148, 119, 58,
+        195, 216, 233, 71, 213, 49, 192, 101, 98, 138, 211, 202, 23,
+    ],
+    [
+        75, 57, 111, 161, 23, 82, 45, 41, 126, 47, 115, 28, 96, 75, 3, 178, 222, 238, 104, 152, 76,
+        165, 40, 253, 255, 89, 109, 152, 247, 184, 78, 33,
+    ],
+    [
+        149, 26, 14, 0, 82, 44, 206, 134, 125, 167, 239, 234, 226, 223, 223, 140, 16, 37, 201, 62,
+        155, 197, 225, 147, 216, 176, 110, 30, 201, 163, 202, 34,
+    ],
+    [
+        24, 135, 122, 98, 53, 237, 40, 218, 117, 218, 88, 33, 92, 199, 15, 115, 210, 230, 104, 150,
+        213, 45, 89, 251, 243, 158, 48, 141, 72, 141, 57, 12,
+    ],
+    [
+        197, 245, 45, 0, 216, 161, 126, 99, 90, 215, 172, 237, 235, 53, 155, 193, 86, 239, 126, 48,
+        200, 101, 245, 65, 62, 74, 149, 73, 94, 88, 140, 43,
+    ],
+    [
+        156, 143, 165, 18, 181, 132, 53, 211, 109, 30, 39, 53, 161, 207, 225, 27, 228, 2, 91, 69,
+        68, 129, 81, 200, 151, 233, 38, 127, 109, 168, 46, 0,
+    ],
+    [
+        48, 189, 222, 54, 186, 158, 234, 124, 154, 115, 79, 31, 228, 83, 136, 229, 124, 181, 13,
+        192, 64, 198, 219, 146, 232, 122, 177, 205, 101, 80, 202, 4,
+    ],
+    [
+        163, 218, 208, 177, 76, 18, 177, 150, 224, 15, 151, 66, 182, 188, 231, 72, 47, 16, 19, 169,
+        76, 5, 169, 238, 5, 145, 124, 14, 202, 92, 148, 42,
+    ],
+    [
+        201, 12, 98, 69, 109, 130, 244, 104, 227, 12, 217, 177, 61, 223, 20, 93, 27, 165, 12, 166,
+        129, 229, 221, 187, 78, 43, 243, 212, 228, 13, 172, 50,
+    ],
+    [
+        72, 66, 83, 240, 11, 236, 42, 201, 4, 65, 42, 26, 68, 228, 104, 101, 222, 73, 121, 183,
+        222, 55, 13, 34, 153, 153, 190, 101, 204, 77, 194, 23,
+    ],
+    [
+        107, 189, 58, 229, 33, 69, 3, 168, 252, 70, 160, 92, 101, 164, 88, 65, 88, 249, 49, 43, 51,
+        42, 155, 132, 119, 172, 103, 248, 43, 55, 143, 52,
+    ],
+    [
+        41, 53, 206, 79, 231, 93, 118, 136, 109, 78, 38, 212, 219, 114, 134, 234, 45, 189, 141, 78,
+        58, 48, 19, 156, 218, 146, 29, 225, 53, 35, 206, 38,
+    ],
+    [
+        86, 68, 53, 32, 121, 46, 242, 165, 123, 247, 235, 45, 249, 182, 5, 165, 89, 254, 242, 79,
+        180, 84, 247, 243, 127, 146, 184, 100, 8, 51, 141, 35,
+    ],
+    [
+        90, 103, 91, 22, 44, 190, 53, 240, 75, 132, 136, 133, 65, 19, 83, 172, 216, 242, 126, 56,
+        125, 196, 80, 227, 16, 10, 192, 158, 32, 100, 143, 38,
+    ],
+    [
+        107, 237, 142, 196, 146, 23, 37, 160, 218, 220, 166, 144, 130, 18, 173, 176, 254, 98, 56,
+        128, 48, 113, 229, 172, 254, 45, 129, 50, 139, 97, 91, 36,
+    ],
+    [
+        97, 238, 102, 252, 196, 29, 220, 62, 129, 202, 148, 228, 59, 203, 46, 156, 137, 82, 110,
+        107, 4, 147, 250, 18, 182, 244, 242, 16, 208, 5, 74, 56,
+    ],
+    [
+        131, 236, 235, 23, 245, 152, 82, 127, 44, 17, 151, 244, 244, 60, 219, 141, 162, 92, 240,
+        97, 16, 63, 118, 227, 242, 240, 144, 147, 70, 123, 103, 53,
+    ],
+    [
+        39, 112, 172, 37, 77, 126, 110, 88, 106, 102, 193, 225, 39, 72, 74, 106, 111, 69, 32, 219,
+        132, 68, 158, 120, 200, 217, 198, 223, 241, 212, 171, 51,
+    ],
+    [
+        179, 226, 252, 77, 217, 210, 173, 60, 106, 229, 89, 133, 28, 122, 28, 31, 214, 24, 34, 29,
+        248, 240, 27, 219, 56, 188, 46, 71, 241, 55, 180, 62,
+    ],
+    [
+        44, 141, 71, 226, 164, 202, 24, 177, 94, 123, 162, 68, 111, 189, 1, 194, 157, 42, 186, 188,
+        47, 71, 6, 193, 206, 177, 111, 45, 18, 64, 76, 44,
+    ],
+    [
+        165, 51, 130, 87, 22, 185, 98, 170, 47, 52, 169, 73, 143, 133, 150, 224, 148, 81, 187, 239,
+        124, 146, 150, 42, 241, 166, 219, 175, 25, 16, 142, 23,
+    ],
+];

+ 65 - 2
src/event_graph/mod.rs

@@ -41,6 +41,7 @@ use tracing::{error, info, warn};
 use url::Url;
 
 use crate::{
+    event_graph::rln::genesis_commitments,
     net::{channel::Channel, P2pPtr},
     system::{msleep, Publisher, PublisherPtr, StoppableTask, StoppableTaskPtr, Subscription},
     Error, Result,
@@ -55,6 +56,9 @@ use proto::{EventRep, EventReq, HeaderRep, HeaderReq, StaticPut, SyncDirection,
 pub mod rln;
 use rln::{IdentityState, RlnState, ZkKeys};
 
+pub mod genesis_commits;
+use genesis_commits::GENESIS_COMMITMENTS_REPR;
+
 pub mod util;
 use util::{
     generate_genesis, millis_until_next_rotation, next_hour_timestamp, next_rotation_timestamp,
@@ -549,6 +553,9 @@ impl EventGraph {
             rln_app_id,
         });
 
+        // Init genesis registration events
+        self_.bootstrap_genesis_identities().await?;
+
         if need_prune {
             info!(
                 target: "event_graph::new",
@@ -1701,8 +1708,6 @@ impl EventGraph {
         compute_unreferenced_tips(&self.static_dag).await
     }
 
-    /// Persist the original RLN blob for a static-DAG event. The
-    /// blob is the wire payload from the originating `StaticPut` -
     /// Persist the original RLN blob for a static-DAG event. The
     /// blob is the wire payload from the originating `StaticPut` -
     /// proof + public inputs + attestation - needed to re-verify
@@ -2266,6 +2271,22 @@ impl EventGraph {
 
         match rln_node {
             RLNNode::Registration(commitment) => {
+                // No ZK proofs, only commitments in the hardcoded genesis set
+                // are accepted this way, anything else falls through to
+                // normal proof verification.
+                if blob == rln::GENESIS_BLOB_GUARD {
+                    let repr = commitment.to_repr();
+                    if GENESIS_COMMITMENTS_REPR.contains(&repr) {
+                        if self.identity_state.read().await.contains(commitment) {
+                            return StaticEventCheck::Rejected
+                        }
+                        return StaticEventCheck::AcceptedRegistration(*commitment)
+                    } else {
+                        // Guard blob with unknown commitment = malicious
+                        return StaticEventCheck::Malicious
+                    }
+                }
+
                 let reg: RegistrationBlob = match deserialize_async_partial(blob).await {
                     Ok((v, _)) => v,
                     Err(_) => return StaticEventCheck::Rejected,
@@ -2344,6 +2365,48 @@ impl EventGraph {
             }
         }
     }
+
+    /// Insert proof-less genesis registration events commitments into
+    /// the static DAG, called once at startup after the genesis event
+    /// itself is inserted. Idempotent - skips any commitment already
+    /// present in the identity tree.
+    pub async fn bootstrap_genesis_identities(&self) -> Result<()> {
+        let genesis_event = generate_genesis(&self.config);
+        let genesis_id = genesis_event.id();
+
+        let genesis_commitments = genesis_commitments();
+        for commitment in genesis_commitments.iter() {
+            if self.identity_state.read().await.contains(commitment) {
+                continue
+            }
+
+            let rln_node = rln::RLNNode::Registration(*commitment);
+            let content = serialize_async(&rln_node).await;
+
+            // Inserted at layer 1
+            let mut parents = [NULL_ID; N_EVENT_PARENTS];
+            parents[0] = genesis_id;
+
+            let header = Header {
+                timestamp: genesis_event.header.timestamp + 1,
+                parents,
+                layer: 1,
+                content_hash: blake3::hash(&content),
+            };
+            let event = Event { header, content };
+
+            if self.static_dag.contains_key(event.id().as_bytes())? {
+                continue
+            }
+
+            let blob = rln::GENESIS_BLOB_GUARD.to_vec();
+            self.static_blob_store(&event.id(), &blob)?;
+            self.apply_rln_static_event(&event, &rln_node).await?;
+            self.static_insert(&event).await?;
+        }
+
+        Ok(())
+    }
 }
 
 async fn request_tips(

+ 15 - 0
src/event_graph/rln.rs

@@ -46,6 +46,7 @@ use tracing::info;
 
 use super::Event;
 use crate::{
+    event_graph::genesis_commits::GENESIS_COMMITMENTS_REPR,
     zk::{empty_witnesses, Proof, ProvingKey, VerifyingKey, Witness, ZkCircuit},
     zkas::ZkBinary,
     Error, Result,
@@ -55,6 +56,9 @@ pub const RLN2_REGISTER_ZKBIN: &[u8] = include_bytes!("proof/rlnv2-diff-register
 pub const RLN2_SIGNAL_ZKBIN: &[u8] = include_bytes!("proof/rlnv2-diff-signal.zk.bin");
 pub const RLN2_SLASH_ZKBIN: &[u8] = include_bytes!("proof/rlnv2-diff-slash.zk.bin");
 
+pub const GENESIS_BLOB_GUARD: &[u8] = b"darkfi-rln-genesis-v1";
+pub const GENESIS_USER_MSG_LIMIT: u64 = MAX_MSG_LIMIT;
+
 /// RLN epoch genesis in millis.
 /// Used as the time-zero reference for epoch numbering.
 pub const RLN_GENESIS: u64 = 1_738_688_400_000;
@@ -123,6 +127,7 @@ pub enum RegistrationAttestation {
     /// No external attestation. The user_message_limit must be
     /// at most [`Self::FREE_TIER_LIMIT`].
     Free,
+    SPECIAL,
     /// Reserved for the future staking integration.
     Staked(Vec<u8>),
 }
@@ -130,11 +135,14 @@ pub enum RegistrationAttestation {
 impl RegistrationAttestation {
     /// In free-tier mode, hard cap on `user_message_limit`.
     pub const FREE_TIER_LIMIT: u64 = 10;
+    /// In special-tier mode.
+    pub const SPECIAL_TIER_LIMIT: u64 = 100;
 
     /// Validate the attestation against a claimed limit.
     pub fn permits(&self, user_message_limit: u64) -> bool {
         match self {
             Self::Free => user_message_limit <= Self::FREE_TIER_LIMIT,
+            Self::SPECIAL => user_message_limit <= Self::SPECIAL_TIER_LIMIT,
             // Until staking is implemented, refuse to honor any
             // "Staked" attestation
             Self::Staked(_) => false,
@@ -700,3 +708,10 @@ fn read_pk(sled_db: &sled::Db, key: &str, zkbin_bytes: &[u8]) -> Result<ProvingK
     let circuit = ZkCircuit::new(empty_witnesses(&zkbin)?, &zkbin);
     Ok(ProvingKey::read(&mut Cursor::new(bytes), circuit)?)
 }
+
+pub fn genesis_commitments() -> Vec<pallas::Base> {
+    GENESIS_COMMITMENTS_REPR
+        .iter()
+        .filter_map(|repr| pallas::Base::from_repr(*repr).into())
+        .collect()
+}