Skip to content

Commit

Permalink
freeze kumquat elfs for devnet (#1695)
Browse files Browse the repository at this point in the history
Co-authored-by: yaziciahmet <yaziciahmet991@gmail.com>
  • Loading branch information
eyusufatik and yaziciahmet authored Jan 11, 2025
1 parent 00c4d3b commit f442a88
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 11 deletions.
2 changes: 2 additions & 0 deletions bin/citrea/src/guests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ lazy_static! {
let mut m = HashMap::new();

m.insert(SpecId::Genesis, guest!("../../../resources/guests/risc0/devnet/batch-0.elf"));
m.insert(SpecId::Kumquat, guest!("../../../resources/guests/risc0/devnet/batch-1.elf"));

m
};
pub(crate) static ref LIGHT_CLIENT_MAINNET_GUESTS: HashMap<SpecId, (Digest, Vec<u8>)> = {
Expand Down
21 changes: 15 additions & 6 deletions crates/bitcoin-da/src/network_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,21 @@ pub const INITIAL_TESTNET4_STATE: LatestDaState = LatestDaState {
};

pub const INITIAL_SIGNET_STATE: LatestDaState = LatestDaState {
block_hash: [0; 32],
block_height: 0,
total_work: [0; 32],
current_target_bits: 0,
epoch_start_time: 0,
prev_11_timestamps: [0; 11],
block_hash: [
0, 0, 0, 0, 205, 48, 242, 114, 146, 69, 136, 38, 244, 175, 53, 131, 85, 232, 204, 5, 105,
182, 13, 206, 145, 123, 119, 143, 218, 93, 176, 244,
],
block_height: 17583,
total_work: [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 26, 194, 148,
96, 108, 27,
],
current_target_bits: 0x1d00e6bb,
epoch_start_time: 1735751321,
prev_11_timestamps: [
1736599665, 1736599872, 1736600266, 1736600656, 1736601001, 1736601561, 1736597417,
1736597589, 1736597617, 1736599403, 1736599498,
],
};

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/forks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub const TESTNET_FORKS: [Fork; 2] = [

pub const DEVNET_FORKS: [Fork; 2] = [
Fork::new(SpecId::Genesis, 0),
Fork::new(SpecId::Kumquat, u64::MAX),
Fork::new(SpecId::Kumquat, 1921835),
];

pub const NIGHTLY_FORKS: [Fork; 1] = [Fork::new(SpecId::Kumquat, 0)];
Expand Down
1 change: 1 addition & 0 deletions guests/risc0/batch-proof/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ fn get_guest_options() -> HashMap<&'static str, risc0_build::GuestOptions> {
let mut features = Vec::new();

if std::env::var("CARGO_FEATURE_TESTING").is_ok() {
println!("cargo:warning=Building with testing feature");
features.push("testing".to_string());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const L2_GENESIS_ROOT: [u8; 32] = {
Network::Mainnet => "0000000000000000000000000000000000000000000000000000000000000000",
// TODO: Update this after finding out the first batch prover output of the next release
Network::Testnet => "05183faf24857f0fa6d4a7738fe5ef14b7ebe88be0f66e6f87f461485554d531",
Network::Devnet => "c23eb4eec08765750400f6e98567ef1977dc86334318f5424b7783c4080c0a36",
Network::Devnet => "c6584931466a25793f7f4d6d512d0ce53af4067d3ac61af20df968f5835d3743",
Network::Nightly | Network::TestNetworkWithForks => match option_env!("L2_GENESIS_ROOT") {
Some(hex_root) => hex_root,
None => "dacb59b0ff5d16985a8418235133eee37758a3ac1b76ab6d1f87c6df20e4d4da",
Expand Down Expand Up @@ -62,8 +62,20 @@ const INITIAL_BATCH_PROOF_METHOD_IDS: &[(u64, [u32; 8])] = {
),
),
],
// TODO: Update
Network::Devnet => &[(0, [0; 8])],
Network::Devnet => &[
(
0,
decode_to_u32_array(
"3631d90630a3f0deb47f3a3411fe6e7ede1b0d86ad4216c75041e1a2020f009f",
),
),
(
1921835,
decode_to_u32_array(
"b44b5a78d60714131e02829fe5f7575cbaff7586d6d4a7346bd495ea41ccb481",
),
),
],
Network::Nightly | Network::TestNetworkWithForks => {
match option_env!("BATCH_PROOF_METHOD_ID") {
Some(hex_method_id) => &[(0, decode_to_u32_array(hex_method_id))],
Expand Down Expand Up @@ -104,7 +116,7 @@ pub const METHOD_ID_UPGRADE_AUTHORITY_DA_PUBLIC_KEY: [u8; 33] = {
let hex_pub_key = match NETWORK {
Network::Mainnet => "000000000000000000000000000000000000000000000000000000000000000000",
Network::Testnet => "000000000000000000000000000000000000000000000000000000000000000000",
Network::Devnet => "000000000000000000000000000000000000000000000000000000000000000000",
Network::Devnet => "0388e988066db18e19750fa92aa0fbf9c85104be2b5b507ce0aa7f30f3fe24b1ac",
Network::Nightly | Network::TestNetworkWithForks => {
match option_env!("METHOD_ID_UPGRADE_AUTHORITY_DA_PUBLIC_KEY") {
Some(hex_pub_key) => hex_pub_key,
Expand Down
Binary file added resources/guests/risc0/devnet/batch-1.elf
Binary file not shown.
Binary file modified resources/guests/risc0/devnet/light-0.elf
Binary file not shown.
63 changes: 63 additions & 0 deletions resources/scripts/fork1-data-pull.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# script used for devnet fork1 data pull for setting constants in guests

import requests
import json

def json_rpc_req(method, params):
url = "https://rpc.devnet.citrea.xyz"
payload = json.dumps({
"jsonrpc": "2.0",
"id": 1,
"method": method,
"params": params
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
return response.json()["result"]

# Get head soft confirmation
def get_head_soft_confirmation():
return json_rpc_req("ledger_getHeadSoftConfirmation", [])

# Get soft confirmation by height
def get_soft_confirmation_by_height(height):
return json_rpc_req("ledger_getSoftConfirmationByNumber", [height])

# Get Sequencer commitments on DA slot by number
def get_sequencer_commitments_on_slot_by_number(number):
return json_rpc_req("ledger_getSequencerCommitmentsOnSlotByNumber", [number])


print("Initializing data pull...")

head_l2 = get_head_soft_confirmation()

print("Head soft confirmation height:\t", head_l2['l2Height'], "\nL1 height:\t", head_l2['daSlotHeight'])

print("Fetching latest sequencer commitment")

start = head_l2['daSlotHeight']

for i in range(start, 0, -1):
sequencer_commitments = get_sequencer_commitments_on_slot_by_number(i)

if sequencer_commitments is not None:
print("Found sequencer commitment(s) on slot:\t", i, "using first one.")
sequencer_commitment = sequencer_commitments[0]

print("Sequencer commitment start:\t", sequencer_commitment['l2StartBlockNumber'], "\tend:\t", sequencer_commitment['l2EndBlockNumber'])

fork1_genesis_state_root_height = sequencer_commitment['l2StartBlockNumber'] - 1

print("Genesis state root height:\t", fork1_genesis_state_root_height)

genesis_soft_conf = get_soft_confirmation_by_height(fork1_genesis_state_root_height)

print("Genesis state root:\t", genesis_soft_conf['stateRoot'])
print("Batch prover start proving at DA height:\t", i)
print("Light client prover start proving at DA height:\t", i, "\t Fill its constants with:\t", i-1)

break

0 comments on commit f442a88

Please sign in to comment.