Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: downgrade kona #179

Merged
merged 6 commits into from
Oct 21, 2024
Merged
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
142 changes: 70 additions & 72 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ kzg-rs = { version = "0.2.2" }

# kona
# Note: Switch to latest version of kona once the std::process::Command issue is resolved.
kona-common = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-common-proc = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-preimage = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged", features = [
kona-common = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-common-proc = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-preimage = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona", features = [
"rkyv",
] }
kona-primitives = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-mpt = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-derive = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged", default-features = false }
kona-executor = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-client = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-host = { git = "https://github.com/moongate-forks/kona", branch = "ratan/native-client-command-bugged" }
kona-primitives = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-mpt = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-derive = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona", default-features = false }
kona-executor = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-client = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }
kona-host = { git = "https://github.com/moongate-forks/kona", branch = "patch-10-17-kona" }

# op-succinct
op-succinct-prove = { path = "scripts/prove" }
Expand Down Expand Up @@ -93,7 +93,7 @@ lto = "fat"
[patch.crates-io]
tiny-keccak = { git = "https://github.com/sp1-patches/tiny-keccak", branch = "patch-v2.0.2" }
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", branch = "patch-sha2-v0.10.8" }
# TODO: Change this back to the original patch branch once the changes to sp1-lib to fix secp256k1 addition have been merged and a stable version tag is released.
# TODO: Update this to patch-ecdsa-v0.16.8 when updating SP1 to v3.0.0.
ecdsa = { git = "https://github.com/sp1-patches/signatures", branch = "ratan/secp256k1-add-fixes-v0.16.8" }
bn = { git = "https://github.com/0xWOLAND/bn.git", package = "substrate-bn" }
sha3 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha3", branch = "patch-sha3-v0.10.8" }
2 changes: 1 addition & 1 deletion book/getting-started/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The last step is to update your OP Stack configuration to use the new `OPSuccinctL2OutputOracle` contract managed by the `op-succinct-proposer` service.

> ⚠️ **Warning**: All proposed, non-finalized output roots on the `L2OutputOracleProxy` will be automatically finalized after the upgrade to `op-succinct`, as the `finalizationPeriod` is set to 0 by default. For security, we recommend ensuring that all old proposer output roots are correct before upgrading.
> ⚠️ **Caution**: When upgrading to the `OPSuccinctL2OutputOracle` contract, maintain the existing `finalizationPeriod` for a duration equal to at least one `finalizationPeriod`. Failure to do so will result in immediate finalization of all pending output roots upon upgrade, which is unsafe. Only after this waiting period has elapsed should you set the `finalizationPeriod` to 0.

## Self-Managed OP Stack Chains

Expand Down
8 changes: 4 additions & 4 deletions configs/13269/rollup.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"l2_time": 1723487352,
"system_config": {
"batcherAddr": "0x6322c47FEE60e15FC1B7ba65f1cfd66201E4c61d",
"batcherAddr": "0x6322c47fee60e15fc1b7ba65f1cfd66201e4c61d",
"overhead": "0xbc",
"scalar": "0xa6fe0",
"gasLimit": 30000000,
Expand Down Expand Up @@ -41,8 +41,8 @@
"ecotone_time": 0,
"fjord_time": 0,
"granite_time": 1725984001,
"batch_inbox_address": "0x136B12DB1FbaC1d6Aa6D0a1D2b724892c6FbA921",
"deposit_contract_address": "0x16839f9F6a11195A72B88744336EDFf036e7B3d5",
"l1_system_config_address": "0x19145e3aEe49C40D9f499F705F25ac1eA7409834",
"batch_inbox_address": "0x136b12db1fbac1d6aa6d0a1d2b724892c6fba921",
"deposit_contract_address": "0x16839f9f6a11195a72b88744336edff036e7b3d5",
"l1_system_config_address": "0x19145e3aee49c40d9f499f705f25ac1ea7409834",
"protocol_versions_address": "0x0000000000000000000000000000000000000000"
}
47 changes: 47 additions & 0 deletions configs/15107/rollup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"genesis": {
"l1": {
"number": 6810323,
"hash": "0xe3d1b1463dc367692b66172f41b5afacfa83b3d74daad8d44d4f3b98026d9b08"
},
"l2": {
"number": 0,
"hash": "0x4103a20d40c65c102dbab5cc86b8f313d1467d4bc44a67730a68e88a001ed528"
},
"l2_time": 1728005724,
"system_config": {
"batcherAddr": "0x619989c355ae587f202c3d9a280526ab6dd8895a",
"overhead": "0xbc",
"scalar": "0x10b30",
"gasLimit": 30000000,
"baseFeeScalar": null,
"blobBaseFeeScalar": null,
"eip1559Denominator": null,
"eip1559Elasticity": null
}
},
"block_time": 10,
"max_sequencer_drift": 600,
"seq_window_size": 3600,
"channel_timeout": 300,
"granite_channel_timeout": 50,
"l1_chain_id": 11155111,
"l2_chain_id": 15107,
"base_fee_params": {
"max_change_denominator": "0x32",
"elasticity_multiplier": "0x6"
},
"canyon_base_fee_params": {
"max_change_denominator": "0xfa",
"elasticity_multiplier": "0x6"
},
"regolith_time": 0,
"canyon_time": 0,
"delta_time": 0,
"ecotone_time": 0,
"fjord_time": 0,
"batch_inbox_address": "0x49290eb79886449325c3647b9d29f59d0f03ab54",
"deposit_contract_address": "0xe57867e254bc69beb7614f0375be7dbd9a098974",
"l1_system_config_address": "0xd3207b99c3aa2d4fb455d4d81b37132008262672",
"protocol_versions_address": "0x0000000000000000000000000000000000000000"
}
Binary file modified elf/fault-proof-elf
Binary file not shown.
Binary file modified elf/range-elf
Binary file not shown.
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ run-multi start end use-cache="false" prove="false":
# Runs the cost estimator for a given block range.
cost-estimator start end:
#!/usr/bin/env bash
cargo run --bin cost_estimator --release -- --start {{start}} --end {{end}}
cargo run --bin cost-estimator --release -- --start {{start}} --end {{end}}

# Runs the client program in native execution mode. Modified version of Kona Native Client execution:
# https://github.com/ethereum-optimism/kona/blob/ae71b9df103c941c06b0dc5400223c4f13fe5717/bin/client/justfile#L65-L108
Expand Down
7 changes: 7 additions & 0 deletions proposer/op/proposer/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ func (l *L2OutputSubmitter) StartL2OutputSubmitting() error {
}
}

// Validate the contract's configuration of the aggregation and range verification keys as well
// as the rollup config hash.
err = l.ValidateConfig(l.Cfg.L2OutputOracleAddr.Hex())
if err != nil {
return fmt.Errorf("failed to validate config: %w", err)
}

l.wg.Add(1)
go l.loop()

Expand Down
94 changes: 72 additions & 22 deletions proposer/op/proposer/prove.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"net"
"net/http"
"strings"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -149,7 +150,7 @@ func (l *L2OutputSubmitter) RequestQueuedProofs(ctx context.Context) error {
}

// The total number of concurrent proofs is capped at MAX_CONCURRENT_PROOF_REQUESTS.
if (witnessGenProofs+provingProofs) >= int(l.Cfg.MaxConcurrentProofRequests) {
if (witnessGenProofs + provingProofs) >= int(l.Cfg.MaxConcurrentProofRequests) {
l.Log.Info("max concurrent proof requests reached, waiting for next cycle")
return nil
}
Expand Down Expand Up @@ -244,19 +245,6 @@ func (l *L2OutputSubmitter) RequestOPSuccinctProof(p ent.ProofRequest) error {
return nil
}

type SpanProofRequest struct {
Start uint64 `json:"start"`
End uint64 `json:"end"`
}

type AggProofRequest struct {
Subproofs [][]byte `json:"subproofs"`
L1Head string `json:"head"`
}
type ProofResponse struct {
ProofID string `json:"proof_id"`
}

// Request a span proof for the range [l2Start, l2End].
func (l *L2OutputSubmitter) RequestSpanProof(l2Start, l2End uint64) (string, error) {
if l2Start >= l2End {
Expand All @@ -273,7 +261,7 @@ func (l *L2OutputSubmitter) RequestSpanProof(l2Start, l2End uint64) (string, err
return "", fmt.Errorf("failed to marshal request body: %w", err)
}

return l.RequestProofFromServer("request_span_proof", jsonBody)
return l.RequestProofFromServer(proofrequest.TypeSPAN, jsonBody)
}

// Request an aggregate proof for the range [start, end]. If there is not a consecutive set of span proofs,
Expand All @@ -296,12 +284,18 @@ func (l *L2OutputSubmitter) RequestAggProof(start, end uint64, l1BlockHash strin
}

// Request the agg proof from the server.
return l.RequestProofFromServer("request_agg_proof", jsonBody)
return l.RequestProofFromServer(proofrequest.TypeAGG, jsonBody)
}

// Request a proof from the OP Succinct server, given the path and the body of the request. Returns
// the proof ID on a successful request.
func (l *L2OutputSubmitter) RequestProofFromServer(urlPath string, jsonBody []byte) (string, error) {
func (l *L2OutputSubmitter) RequestProofFromServer(proofType proofrequest.Type, jsonBody []byte) (string, error) {
var urlPath string
if proofType == proofrequest.TypeAGG {
urlPath = "request_agg_proof"
} else if proofType == proofrequest.TypeSPAN {
urlPath = "request_span_proof"
}
req, err := http.NewRequest("POST", l.Cfg.OPSuccinctServerUrl+"/"+urlPath, bytes.NewBuffer(jsonBody))
if err != nil {
return "", fmt.Errorf("failed to create request: %w", err)
Expand Down Expand Up @@ -341,11 +335,6 @@ func (l *L2OutputSubmitter) RequestProofFromServer(urlPath string, jsonBody []by
return response.ProofID, nil
}

type ProofStatus struct {
Status string `json:"status"`
Proof []byte `json:"proof"`
}

// Get the status of a proof given its ID.
func (l *L2OutputSubmitter) GetProofStatus(proofId string) (string, []byte, error) {
req, err := http.NewRequest("GET", l.Cfg.OPSuccinctServerUrl+"/status/"+proofId, nil)
Expand Down Expand Up @@ -382,3 +371,64 @@ func (l *L2OutputSubmitter) GetProofStatus(proofId string) (string, []byte, erro

return response.Status, response.Proof, nil
}

// Validate the contract's configuration of the aggregation and range verification keys as well
// as the rollup config hash.
func (l *L2OutputSubmitter) ValidateConfig(address string) error {
l.Log.Info("requesting config validation", "address", address)
requestBody := ValidateConfigRequest{
Address: address,
}
jsonBody, err := json.Marshal(requestBody)
if err != nil {
return fmt.Errorf("failed to marshal request body: %w", err)
}

req, err := http.NewRequest("POST", l.Cfg.OPSuccinctServerUrl+"/validate_config", bytes.NewBuffer(jsonBody))
if err != nil {
return fmt.Errorf("failed to create request: %w", err)
}

client := &http.Client{
Timeout: PROOF_STATUS_TIMEOUT,
}
resp, err := client.Do(req)
if err != nil {
if err, ok := err.(net.Error); ok && err.Timeout() {
return fmt.Errorf("request timed out after %s: %w", PROOF_STATUS_TIMEOUT, err)
}
return fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()

// Read the response body
body, err := io.ReadAll(resp.Body)
if err != nil {
return fmt.Errorf("error reading the response body: %v", err)
}

// Create a variable of the ValidateConfigResponse type
var response ValidateConfigResponse

// Unmarshal the JSON into the response variable
err = json.Unmarshal(body, &response)
if err != nil {
return fmt.Errorf("error decoding JSON response: %v", err)
}

var invalidConfigs []string
if !response.RollupConfigHashValid {
invalidConfigs = append(invalidConfigs, "rollup config hash")
}
if !response.AggVkeyValid {
invalidConfigs = append(invalidConfigs, "aggregation verification key")
}
if !response.RangeVkeyValid {
invalidConfigs = append(invalidConfigs, "range verification key")
}
if len(invalidConfigs) > 0 {
return fmt.Errorf("config is invalid: %s", strings.Join(invalidConfigs, ", "))
}

return nil
}
30 changes: 30 additions & 0 deletions proposer/op/proposer/rpc_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package proposer

type SpanProofRequest struct {
Start uint64 `json:"start"`
End uint64 `json:"end"`
}

type AggProofRequest struct {
Subproofs [][]byte `json:"subproofs"`
L1Head string `json:"head"`
}

type ValidateConfigRequest struct {
Address string `json:"address"`
}

type ValidateConfigResponse struct {
RollupConfigHashValid bool `json:"rollup_config_hash_valid"`
AggVkeyValid bool `json:"agg_vkey_valid"`
RangeVkeyValid bool `json:"range_vkey_valid"`
}

type ProofResponse struct {
ProofID string `json:"proof_id"`
}

type ProofStatus struct {
Status string `json:"status"`
Proof []byte `json:"proof"`
}
1 change: 1 addition & 0 deletions proposer/succinct/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = "bin/server.rs"
# workspace
tokio = { workspace = true }
alloy-primitives = { workspace = true }
alloy = { workspace = true }

# local
op-succinct-host-utils.workspace = true
Expand Down
Loading
Loading