From 621cef6a970228158f62d7f59fb173d573d1da4a Mon Sep 17 00:00:00 2001 From: popcnt <142196625+popcnt1@users.noreply.github.com> Date: Sat, 21 Sep 2024 16:43:42 +0800 Subject: [PATCH] fix(da): rm open-da(gcs) for mainnet deploy workflow (#2665) 1. rm open-da(gcs) for mainnet deploy workflow 2. switch to save last block instead of a map: Replaced BTreeMap with an Option to store only the last block in StateCommitmentChain. Updated methods for adding and retrieving the last block accordingly, streamlining state management. --- .github/workflows/deploy_mainnet.yml | 4 +--- crates/rooch-proposer/src/scc/mod.rs | 18 ++++++++---------- scripts/deploy_rooch_mainnet.sh | 5 +---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/deploy_mainnet.yml b/.github/workflows/deploy_mainnet.yml index cfddcd1d37..d49b3e15a0 100644 --- a/.github/workflows/deploy_mainnet.yml +++ b/.github/workflows/deploy_mainnet.yml @@ -72,6 +72,4 @@ jobs: "cd /root/rooch && git fetch origin && git checkout -B $BRANCH origin/$BRANCH || git checkout $BRANCH && bash scripts/deploy_rooch_mainnet.sh \ '${{ env.REF }}' \ '${{ secrets.BTC_MAIN_RPC_URL }}' \ - '${{ secrets.BTC_MAIN_RPC_PWD }}' \ - '${{ secrets.OPENDA_GCP_MAINNET_BUCKET }}' \ - '${{ secrets.OPENDA_GCP_MAINNET_CREDENTIAL }}'" + '${{ secrets.BTC_MAIN_RPC_PWD }}'" diff --git a/crates/rooch-proposer/src/scc/mod.rs b/crates/rooch-proposer/src/scc/mod.rs index 02d23796c1..e59a8e8a5c 100644 --- a/crates/rooch-proposer/src/scc/mod.rs +++ b/crates/rooch-proposer/src/scc/mod.rs @@ -1,8 +1,6 @@ // Copyright (c) RoochNetwork // SPDX-License-Identifier: Apache-2.0 -use std::collections::BTreeMap; - use crate::actor::messages::TransactionProposeMessage; use moveos_types::h256; use moveos_types::h256::H256; @@ -14,7 +12,7 @@ use rooch_types::block::Block; /// This SCC is a mirror of the on-chain SCC pub struct StateCommitmentChain { //TODO save to the storage - blocks: BTreeMap, + last_block: Option, buffer: Vec, da: DAProxy, } @@ -23,7 +21,7 @@ impl StateCommitmentChain { /// Create a new SCC pub fn new(da_proxy: DAProxy) -> Self { Self { - blocks: BTreeMap::new(), + last_block: None, buffer: Vec::new(), da: da_proxy, } @@ -33,19 +31,19 @@ impl StateCommitmentChain { self.buffer.push(tx); } - /// Append a new block to the SCC - fn append_block(&mut self, block: Block) { - self.blocks.insert(block.block_number, block); + /// Update last block of the SCC + fn update_last_block(&mut self, block: Block) { + self.last_block = Some(block); } /// Get the last block of the SCC pub fn last_block(&self) -> Option<&Block> { - self.blocks.values().last() + self.last_block.as_ref() } /// Get the last block number of the SCC pub fn last_block_number(&self) -> Option { - self.blocks.keys().last().copied() + self.last_block.as_ref().map(|block| block.block_number) } /// Trigger the proposer to propose a new block @@ -104,7 +102,7 @@ impl StateCommitmentChain { tx_accumulator_root, state_roots, ); - self.append_block(new_block); + self.update_last_block(new_block); self.buffer.clear(); self.last_block() } diff --git a/scripts/deploy_rooch_mainnet.sh b/scripts/deploy_rooch_mainnet.sh index e611a30998..9736676880 100644 --- a/scripts/deploy_rooch_mainnet.sh +++ b/scripts/deploy_rooch_mainnet.sh @@ -5,8 +5,6 @@ REF="$1" BTC_MAIN_RPC_URL="$2" BTC_MAIN_RPC_PWD="$3" -OPENDA_GCP_MAINNET_BUCKET="$4" -OPENDA_GCP_MAINNET_CREDENTIAL="$5" sleep 30 docker image prune -a -f @@ -17,5 +15,4 @@ docker run -d --name rooch-mainnet --restart unless-stopped -v /data:/root -p 67 server start -n main \ --btc-rpc-url "$BTC_MAIN_RPC_URL" \ --btc-rpc-username rooch-main \ - --btc-rpc-password "$BTC_MAIN_RPC_PWD" \ - --da "{\"internal-da-server\": {\"servers\": [{\"open-da\": {\"scheme\": \"gcs\", \"config\": {\"bucket\": \"$OPENDA_GCP_MAINNET_BUCKET\", \"credential\": \"$OPENDA_GCP_MAINNET_CREDENTIAL\"}}}]}}" + --btc-rpc-password "$BTC_MAIN_RPC_PWD"