diff --git a/.env b/.env index 128a6994d..9b81e297b 100644 --- a/.env +++ b/.env @@ -57,9 +57,10 @@ ESPRESSO_BUILDER_ETH_ACCOUNT_INDEX=8 ESPRESSO_DEPLOYER_ACCOUNT_INDEX=9 # Contracts -ESPRESSO_SEQUENCER_LIGHT_CLIENT_PROXY_ADDRESS=0x0c8e79f3534b00d9a3d4a856b665bf4ebc22f2ba +ESPRESSO_SEQUENCER_LIGHT_CLIENT_PROXY_ADDRESS=0xf7cd8fa9b94db2aa972023b379c7f72c65e4de9d ESPRESSO_SEQUENCER_LIGHTCLIENT_ADDRESS=$ESPRESSO_SEQUENCER_LIGHT_CLIENT_PROXY_ADDRESS ESPRESSO_SEQUENCER_PERMISSIONED_PROVER=0x14dc79964da2c08b23698b3d3cc7ca32193d9955 +SPRESSO_SEQUENCER_PERMISSIONED_STAKE_TABLE_ADDRESS=0x8ce361602b935680e8dec218b820ff5056beb7af # Example sequencer demo private keys ESPRESSO_DEMO_SEQUENCER_STAKING_PRIVATE_KEY_0=BLS_SIGNING_KEY~lNDh4Pn-pTAyzyprOAFdXHwhrKhEwqwtMtkD3CZF4x3o diff --git a/.typos.toml b/.typos.toml index d80b10dae..01a0775fb 100644 --- a/.typos.toml +++ b/.typos.toml @@ -1,5 +1,6 @@ [files] extend-exclude = [ + "data/initial_stake_table.toml", ".env", "*.json", "**/*.pdf", diff --git a/data/initial_stake_table.toml b/data/initial_stake_table.toml new file mode 100644 index 000000000..59384a650 --- /dev/null +++ b/data/initial_stake_table.toml @@ -0,0 +1,30 @@ +[[public_keys]] +stake_table_key = "BLS_VER_KEY~bQszS-QKYvUij2g20VqS8asttGSb95NrTu2PUj0uMh1CBUxNy1FqyPDjZqB29M7ZbjWqj79QkEOWkpga84AmDYUeTuWmy-0P1AdKHD3ehc-dKvei78BDj5USwXPJiDUlCxvYs_9rWYhagaq-5_LXENr78xel17spftNd5MA1Mw5U" +state_ver_key = "SCHNORR_VER_KEY~ibJCbfPOhDoURqiGLe683TDJ_KOLQCx8_Hdq43dOviSuL6WJJ_2mARKO3xA2k5zpXE3iiq4_z7mzvA-V1VXvIWw" +da = true +stake = 1 + +[[public_keys]] +stake_table_key = "BLS_VER_KEY~4zQnaCOFJ7m95OjxeNls0QOOwWbz4rfxaL3NwmN2zSdnf8t5Nw_dfmMHq05ee8jCegw6Bn5T8inmrnGGAsQJMMWLv77nd7FJziz2ViAbXg-XGGF7o4HyzELCmypDOIYF3X2UWferFE_n72ZX0iQkUhOvYZZ7cfXToXxRTtb_mwRR" +state_ver_key = "SCHNORR_VER_KEY~lNCMqH5qLthH5OXxW_Z25tLXJUqmzzhsuQ6oVuaPWhtRPmgIKSqcBoJTaEbmGZL2VfTyQNguaoQL4U_4tCA_HmI" +da = true +stake = 1 + +[[public_keys]] +stake_table_key = "BLS_VER_KEY~IBRoz_Q1EXvcm1pNZcmVlyYZU8hZ7qmy337ePAjEMhz8Hl2q8vWPFOd3BaLwgRS1UzAPW3z4E-XIgRDGcRBTAMZX9b_0lKYjlyTlNF2EZfNnKmvv-xJ0yurkfjiveeYEsD2l5d8q_rJJbH1iZdXy-yPEbwI0SIvQfwdlcaKw9po4" +state_ver_key = "SCHNORR_VER_KEY~nkFKzpLhJAafJ3LBkY_0h9OzxSyTu95Z029EUFPO4QNkeUo6DHQGTTVjxmprTA5H8jRSn73i0slJvig6dZ5kLX4" +da = true +stake = 1 + +[[public_keys]] +stake_table_key = "BLS_VER_KEY~rO2PIjyY30HGfapFcloFe3mNDKMIFi6JlOLkH5ZWBSYoRm5fE2-Rm6Lp3EvmAcB5r7KFJ0c1Uor308x78r04EY_sfjcsDCWt7RSJdL4cJoD_4fSTCv_bisO8k98hs_8BtqQt8BHlPeJohpUXvcfnK8suXJETiJ6Er97pfxRbzgAL" +state_ver_key = "SCHNORR_VER_KEY~NwYhzlWarlZHxTNvChWuf74O3fP7zIt5NdC7V8gV6w2W92JOBDkrNmKQeMGxMUke-G5HHxUjHlZEWr1m1xLjEaI" +da = false +stake = 1 + + +[[public_keys]] +stake_table_key = "BLS_VER_KEY~r6b-Cwzp-b3czlt0MHmYPJIow5kMsXbrNmZsLSYg9RV49oCCO4WEeCRFR02x9bqLCa_sgNFMrIeNdEa11qNiBAohApYFIvrSa-zP5QGj3xbZaMOCrshxYit6E2TR-XsWvv6gjOrypmugjyTAth-iqQzTboSfmO9DD1-gjJIdCaD7" +state_ver_key = "SCHNORR_VER_KEY~qMfMj1c1hRVTnugvz3MKNnVC5JA9jvZcV3ZCLL_J4Ap-u0i6ulGWveTk3OOelZj2-kd_WD5ojtYGWV1jHx9wCaA" +da = true +stake = 1 \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index bac902af8..1618480f4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -17,7 +17,7 @@ services: deploy-sequencer-contracts: image: ghcr.io/espressosystems/espresso-sequencer/deploy:main - command: deploy --only sequencer,permissioned-stake-table + command: deploy --only fee-contract,permissioned-stake-table environment: - ESPRESSO_SEQUENCER_ETH_MULTISIG_ADDRESS - ESPRESSO_SEQUENCER_L1_PROVIDER diff --git a/process-compose.yaml b/process-compose.yaml index 6b3a1fdfd..ff57120a7 100644 --- a/process-compose.yaml +++ b/process-compose.yaml @@ -7,6 +7,7 @@ environment: - ESPRESSO_SEQUENCER_L1_PROVIDER=http://localhost:$ESPRESSO_SEQUENCER_L1_PORT - ESPRESSO_SEQUENCER_GENESIS_FILE=data/genesis/demo.toml - ESPRESSO_BUILDER_GENESIS_FILE=data/genesis/demo.toml + - ESPRESSO_SEQUENCER_INITIAL_PERMISSIONED_STAKE_TABLE_PATH=data/initial_stake_table.toml - ESPRESSO_STATE_RELAY_SERVER_URL=http://localhost:$ESPRESSO_STATE_RELAY_SERVER_PORT - QUERY_SERVICE_URI=http://localhost:$ESPRESSO_SEQUENCER1_API_PORT/v0/ - NODE_VALIDATOR_URI=ws://localhost:$ESPRESSO_NODE_VALIDATOR_PORT/v0/ diff --git a/sequencer-sqlite/Cargo.lock b/sequencer-sqlite/Cargo.lock index ad03aad19..fe749395e 100644 --- a/sequencer-sqlite/Cargo.lock +++ b/sequencer-sqlite/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "Inflector" @@ -2752,15 +2752,18 @@ dependencies = [ "committable", "contract-bindings", "derive_more 1.0.0", + "diff-test-bn254", "dyn-clone", "ethers", "fluent-asserter", "futures", "hotshot", + "hotshot-contract-adapter", "hotshot-query-service", "hotshot-types", "itertools 0.12.1", "jf-merkle-tree", + "jf-signature 0.2.0", "jf-utils", "jf-vid", "lru 0.12.5", @@ -3960,11 +3963,14 @@ version = "0.1.0" dependencies = [ "anyhow", "ark-bn254", + "ark-ec", + "ark-ed-on-bn254", "ark-ff", "ark-poly", "ark-serialize", "ark-std", "contract-bindings", + "derive_more 1.0.0", "diff-test-bn254", "ethers", "hotshot-types", @@ -3974,6 +3980,7 @@ dependencies = [ "libp2p", "num-bigint", "num-traits", + "serde", ] [[package]] @@ -4083,7 +4090,7 @@ dependencies = [ [[package]] name = "hotshot-query-service" version = "0.1.75" -source = "git+https://github.com/EspressoSystems/hotshot-query-service?branch=hotshot/0.5.82#5e2c984d19da3826f4cc8d80c5cf1a84dcd377f7" +source = "git+https://github.com/EspressoSystems/hotshot-query-service?tag=v0.1.75#dffefa160f441a663723a67bc54efedb11a88b02" dependencies = [ "anyhow", "ark-serialize", @@ -8409,6 +8416,7 @@ dependencies = [ "futures", "hotshot", "hotshot-contract-adapter", + "hotshot-types", "log-panics", "portpicker", "reqwest 0.11.27", @@ -8417,6 +8425,7 @@ dependencies = [ "surf", "tempfile", "tokio", + "toml 0.8.19", "tracing", "url", ] diff --git a/utils/src/stake_table.rs b/utils/src/stake_table.rs index 1f5dbda0b..0b3236083 100644 --- a/utils/src/stake_table.rs +++ b/utils/src/stake_table.rs @@ -6,6 +6,7 @@ use contract_bindings::permissioned_stake_table::NodeInfo; use hotshot::types::BLSPubKey; use hotshot_contract_adapter::stake_table::NodeInfoJf; use hotshot_types::network::PeerConfigKeys; + use std::{fs, path::Path}; /// A stake table config stored in a file @@ -46,3 +47,92 @@ impl From for Vec { .collect() } } + +#[cfg(test)] +mod test { + use crate::stake_table::PermissionedStakeTableConfig; + use crate::test_utils::setup_test; + use hotshot::types::{BLSPubKey, SignatureKey}; + use hotshot_types::{light_client::StateKeyPair, network::PeerConfigKeys}; + use toml::toml; + #[test] + fn test_permissioned_stake_table_from_toml() { + setup_test(); + + let mut keys = Vec::new(); + for i in 0..3 { + let (pubkey, _) = BLSPubKey::generated_from_seed_indexed([0; 32], i); + let state_kp = StateKeyPair::generate_from_seed_indexed([0; 32], i).0; + let ver_key = state_kp.ver_key(); + keys.push(PeerConfigKeys { + stake_table_key: pubkey, + state_ver_key: ver_key, + stake: 1, + da: i == 0, + }); + } + + let st_key_1 = keys[0].stake_table_key.to_string(); + let verkey_1 = keys[0].state_ver_key.to_string(); + let da_1 = keys[0].da; + + let st_key_2 = keys[1].stake_table_key.to_string(); + let verkey_2 = keys[1].state_ver_key.to_string(); + let da_2 = keys[1].da; + + let st_key_3 = keys[2].stake_table_key.to_string(); + let verkey_3 = keys[2].state_ver_key.to_string(); + let da_3 = keys[2].da; + + let toml = toml! { + [[public_keys]] + stake_table_key = st_key_1 + state_ver_key = verkey_1 + stake = 1 + da = da_1 + + [[public_keys]] + stake_table_key = st_key_2 + state_ver_key = verkey_2 + stake = 1 + da = da_2 + + [[public_keys]] + stake_table_key = st_key_3 + state_ver_key = verkey_3 + stake = 2 + da = da_3 + + } + .to_string(); + + let toml_st: PermissionedStakeTableConfig = toml::from_str(&toml).unwrap(); + + assert_eq!(toml_st.public_keys.len(), 3); + + // TODO: add `PartialEq` to PeerConfigKeys + assert_eq!(toml_st.public_keys[0].state_ver_key, keys[0].state_ver_key); + assert_eq!( + toml_st.public_keys[0].stake_table_key, + keys[0].stake_table_key + ); + assert_eq!(toml_st.public_keys[0].da, da_1); + assert_eq!(toml_st.public_keys[0].stake, 1); + + assert_eq!(toml_st.public_keys[1].state_ver_key, keys[1].state_ver_key); + assert_eq!( + toml_st.public_keys[1].stake_table_key, + keys[1].stake_table_key + ); + assert_eq!(toml_st.public_keys[1].da, da_2); + assert_eq!(toml_st.public_keys[1].stake, 1); + + assert_eq!(toml_st.public_keys[2].state_ver_key, keys[2].state_ver_key); + assert_eq!( + toml_st.public_keys[2].stake_table_key, + keys[2].stake_table_key + ); + assert_eq!(toml_st.public_keys[2].da, da_3); + assert_eq!(toml_st.public_keys[2].stake, 2); + } +}