Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .github/workflows/node_docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ jobs:
${{ needs.build.outputs.digest-amd64 }} \
${{ needs.build.outputs.digest-arm64 }}

- name: Tag with commit SHA
run: |
SHORT_SHA="${{ github.sha }}"
SHORT_SHA=${SHORT_SHA:0:7}
SHA_TAG="sha-${SHORT_SHA}"
docker buildx imagetools create \
-t ${DOCKER_REGISTRY}/${DOCKER_REPOSITORY_STAGING}:${SHA_TAG} \
${{ needs.build.outputs.digest-amd64 }} \
${{ needs.build.outputs.digest-arm64 }}

- name: Setup ORAS
uses: oras-project/setup-oras@v1

Expand All @@ -128,12 +138,14 @@ jobs:
- name: Determine tags to promote
id: promote-tags
run: |
SHORT_SHA="${{ github.sha }}"
SHORT_SHA=${SHORT_SHA:0:7}
SHA_TAG="sha-${SHORT_SHA}"
if [[ "${{ github.ref }}" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/}
BASE_VERSION=${VERSION%}
echo "TAGS=latest $BASE_VERSION" >> $GITHUB_ENV
echo "TAGS=$VERSION $SHA_TAG" >> $GITHUB_ENV
else
echo "TAGS=latest" >> $GITHUB_ENV
echo "TAGS=latest $SHA_TAG" >> $GITHUB_ENV
fi

- name: Login to Dockerhub registry with ORAS
Expand All @@ -144,12 +156,16 @@ jobs:

- name: Promote to Dockerhub Production
run: |
set -e
for tag in $TAGS; do
echo "Current tag: $tag"
source_image="${DOCKER_REGISTRY}/${DOCKER_REPOSITORY_STAGING}:${tag}"
prod_image="${DOCKER_PUBLIC_REGISTRY}/${DOCKER_PUBLIC_REPOSITORY}:${tag}"
echo "Promoting ${source_image} to ${prod_image}"
oras cp -r "${source_image}" "${prod_image}"
if ! oras cp -r "${source_image}" "${prod_image}"; then
echo "Error: Failed to promote tag ${tag}" >&2
exit 1
fi
done

- name: Summary
Expand Down
2 changes: 2 additions & 0 deletions common/src/l2/taiko_driver/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct BuildPreconfBlockRequestBody {
pub struct BuildPreconfBlockResponse {
pub number: u64,
pub hash: B256,
pub state_root: B256,
pub parent_hash: B256,
}

Expand All @@ -28,6 +29,7 @@ impl BuildPreconfBlockResponse {
)
.ok()?,
hash: Self::to_b256(header.get("hash")?.as_str()?)?,
state_root: Self::to_b256(header.get("stateRoot")?.as_str()?)?,
parent_hash: Self::to_b256(header.get("parentHash")?.as_str()?)?,
})
}
Expand Down
24 changes: 19 additions & 5 deletions shasta/src/l1/execution_layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ use common::{
};
use pacaya::l1::traits::{OperatorError, PreconfOperator, WhitelistProvider};
use std::sync::Arc;
use taiko_bindings::inbox::{
IForcedInclusionStore::ForcedInclusion,
IInbox::CoreState,
Inbox::{self, InboxInstance},
use taiko_bindings::{
anchor::ICheckpointStore::Checkpoint,
inbox::{
IForcedInclusionStore::ForcedInclusion,
IInbox::CoreState,
Inbox::{self, InboxInstance},
},
};
use tokio::sync::mpsc::Sender;
use tracing::info;
Expand All @@ -37,6 +40,8 @@ pub struct ExecutionLayer {
pub transaction_monitor: TransactionMonitor,
contract_addresses: ContractAddresses,
inbox_instance: InboxInstance<DynProvider>,
// Surge: For signing the state checkpoints sent as proof with proposal
checkpoint_signer: alloy::signers::local::PrivateKeySigner,
}

impl ELTrait for ExecutionLayer {
Expand Down Expand Up @@ -91,6 +96,12 @@ impl ELTrait for ExecutionLayer {
transaction_monitor,
contract_addresses,
inbox_instance,
// Surge: Hard coding the private key for the POC
// (This is the first private key from foundry anvil)
checkpoint_signer: alloy::signers::local::PrivateKeySigner::from_bytes(
&"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
.parse::<alloy::primitives::FixedBytes<32>>()?,
)?,
})
}

Expand Down Expand Up @@ -167,6 +178,7 @@ impl ExecutionLayer {
&self,
l2_blocks: Vec<L2BlockV2>,
num_forced_inclusion: u8,
checkpoint: Checkpoint,
) -> Result<(), Error> {
info!(
"📦 Proposing with {} blocks | num_forced_inclusion: {}",
Expand All @@ -176,13 +188,15 @@ impl ExecutionLayer {

// Build propose transaction
// TODO fill extra gas percentege from config
let builder = ProposalTxBuilder::new(self.provider.clone(), 10);
let builder =
ProposalTxBuilder::new(self.provider.clone(), 10, self.checkpoint_signer.clone());
let tx = builder
.build_propose_tx(
l2_blocks,
self.preconfer_address,
self.contract_addresses.shasta_inbox,
num_forced_inclusion,
checkpoint,
)
.await?;

Expand Down
43 changes: 40 additions & 3 deletions shasta/src/l1/proposal_tx_builder.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::l2::bindings::SurgeInbox;
use alloy::{
consensus::SidecarBuilder,
eips::eip4844::BlobTransactionSidecar,
Expand All @@ -8,11 +9,14 @@ use alloy::{
},
providers::{DynProvider, Provider},
rpc::types::TransactionRequest,
signers::Signer,
sol_types::SolValue,
};
use alloy_json_rpc::RpcError;
use anyhow::Error;
use common::l1::{fees_per_gas::FeesPerGas, tools, transaction_error::TransactionError};
use common::shared::l2_block_v2::L2BlockV2;
use taiko_bindings::anchor::ICheckpointStore::Checkpoint;
use taiko_bindings::inbox::{IInbox::ProposeInput, Inbox, LibBlobs::BlobReference};
use taiko_protocol::shasta::{
BlobCoder,
Expand All @@ -23,13 +27,19 @@ use tracing::warn;
pub struct ProposalTxBuilder {
provider: DynProvider,
extra_gas_percentage: u64,
checkpoint_signer: alloy::signers::local::PrivateKeySigner,
}

impl ProposalTxBuilder {
pub fn new(provider: DynProvider, extra_gas_percentage: u64) -> Self {
pub fn new(
provider: DynProvider,
extra_gas_percentage: u64,
checkpoint_signer: alloy::signers::local::PrivateKeySigner,
) -> Self {
Self {
provider,
extra_gas_percentage,
checkpoint_signer,
}
}

Expand All @@ -40,9 +50,10 @@ impl ProposalTxBuilder {
from: Address,
to: Address,
num_forced_inclusion: u8,
checkpoint: Checkpoint,
) -> Result<TransactionRequest, Error> {
let tx_blob = self
.build_propose_blob(l2_blocks, from, to, num_forced_inclusion)
.build_propose_blob(l2_blocks, from, to, num_forced_inclusion, checkpoint)
.await?;
let tx_blob_gas = match self.provider.estimate_gas(tx_blob.clone()).await {
Ok(gas) => gas,
Expand Down Expand Up @@ -87,6 +98,7 @@ impl ProposalTxBuilder {
from: Address,
to: Address,
num_forced_inclusion: u8,
checkpoint: Checkpoint,
) -> Result<TransactionRequest, Error> {
let mut block_manifests = <Vec<BlockManifest>>::with_capacity(l2_blocks.len());
for l2_block in &l2_blocks {
Expand Down Expand Up @@ -128,18 +140,43 @@ impl ProposalTxBuilder {
numForcedInclusions: u16::from(num_forced_inclusion), // TODO SHASTA: receive this as u16 parameter
};

tracing::debug!("Propose input: {:?}", input);

let inbox = Inbox::new(to, self.provider.clone());
let encoded_proposal_input = inbox.encodeProposeInput(input).call().await?;

// Surge: using `proposeWithProof(..)` in Surge Inbox
let proof_data = self.build_proof_data(&checkpoint).await?;
let tx = TransactionRequest::default()
.with_from(from)
.with_to(to)
.with_blob_sidecar(sidecar)
.with_call(&Inbox::proposeCall {
.with_call(&SurgeInbox::proposeWithProofCall {
_lookahead: Bytes::new(),
_data: encoded_proposal_input,
_proof: proof_data,
});

tracing::debug!("Transaction input: {:?}", tx.input);

Ok(tx)
}

// Surge: builds the 161-byte proof data
// [0..96: ABI-encoded checkpoint][96..161: signed checkpoint digest]
async fn build_proof_data(&self, checkpoint: &Checkpoint) -> Result<Bytes, Error> {
let checkpoint_encoded = checkpoint.abi_encode();
let checkpoint_digest = alloy::primitives::keccak256(&checkpoint_encoded);
let signature = self.checkpoint_signer.sign_hash(&checkpoint_digest).await?;

let mut signature_bytes = [0_u8; 65];
signature_bytes[..32].copy_from_slice(signature.r().to_be_bytes::<32>().as_slice());
signature_bytes[32..64].copy_from_slice(signature.s().to_be_bytes::<32>().as_slice());
signature_bytes[64] = (signature.v() as u8) + 27;

let mut proof_data = Vec::with_capacity(161);
proof_data.extend_from_slice(&checkpoint_encoded);
proof_data.extend_from_slice(&signature_bytes);
Ok(Bytes::from(proof_data))
}
}
8,745 changes: 8,744 additions & 1 deletion shasta/src/l2/abi/Bridge.json

Large diffs are not rendered by default.

Loading
Loading