From c767378dbbfa63764eb85f5f37074d89e0d19e94 Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Wed, 2 Oct 2024 22:16:03 -1000 Subject: [PATCH] Use witness from execution layer rather than consensus layer --- go.mod | 10 +++++----- go.sum | 19 +++++++++---------- op-proposer/proposer/clients.go | 26 +++++++------------------- op-proposer/proposer/prover.go | 4 +--- 4 files changed, 22 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 5835f7f..45e1af3 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.1 require ( github.com/aws/aws-sdk-go v1.55.5 github.com/ethereum-optimism/optimism v1.9.1 - github.com/ethereum/go-ethereum v1.14.8 + github.com/ethereum/go-ethereum v1.14.11 github.com/hashicorp/go-multierror v1.1.1 github.com/hf/nitrite v0.0.0-20211104000856-f9e0dcc73703 github.com/hf/nsm v0.0.0-20220930140112-cd181bd646b9 @@ -44,7 +44,7 @@ require ( github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 // indirect github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240910145426-b3905c89e8ac // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/ethereum/go-verkle v0.1.1-0.20240730162217-217a0b67275d // indirect + github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fxamacker/cbor/v2 v2.2.0 // indirect github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect @@ -90,7 +90,7 @@ require ( github.com/status-im/keycard-go v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/stretchr/testify v1.9.0 // indirect - github.com/supranational/blst v0.3.11 // indirect + github.com/supranational/blst v0.3.13 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect github.com/tklauser/go-sysconf v0.3.12 // indirect github.com/tklauser/numcpus v0.6.1 // indirect @@ -113,6 +113,6 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/ethereum/go-ethereum => github.com/mdehoog/op-geth v0.0.0-20241002023607-43dc294cc4c3 +replace github.com/ethereum/go-ethereum => github.com/mdehoog/op-geth v0.0.0-20241003075401-d8f4cde5a852 -replace github.com/ethereum-optimism/optimism => github.com/mdehoog/optimism v0.0.0-20241001203046-805d67718cf1 +replace github.com/ethereum-optimism/optimism => github.com/mdehoog/optimism v0.0.0-20241002221953-1c750e49427c diff --git a/go.sum b/go.sum index 51bc723..9ae8975 100644 --- a/go.sum +++ b/go.sum @@ -99,8 +99,8 @@ github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-2024091014542 github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240910145426-b3905c89e8ac/go.mod h1:XaVXL9jg8BcyOeugECgIUGa9Y3DjYJj71RHmb5qon6M= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/ethereum/go-verkle v0.1.1-0.20240730162217-217a0b67275d h1:t4fSYjUeLzkCQLDIXllbRPOXugApjLsgqpwApMnEdus= -github.com/ethereum/go-verkle v0.1.1-0.20240730162217-217a0b67275d/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 h1:8NfxH2iXvJ60YRB8ChToFTUzl8awsc3cJ8CbLjGIl/A= +github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= @@ -220,10 +220,10 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mdehoog/op-geth v0.0.0-20241002023607-43dc294cc4c3 h1:HAqzJUaXo3ik9rd9zkRg9N4Gz8xyhZRFW2A1fYz5tv0= -github.com/mdehoog/op-geth v0.0.0-20241002023607-43dc294cc4c3/go.mod h1:1464Ksh6V0aIBkmZcXwRPIB/zi/yVtCgC5pSDxgEWQM= -github.com/mdehoog/optimism v0.0.0-20241001203046-805d67718cf1 h1:zwmY7ubZHuAzqVKLMGolN/jxbUTqKlb3hw3cqV0fytg= -github.com/mdehoog/optimism v0.0.0-20241001203046-805d67718cf1/go.mod h1:igQrSEnYkwYi8uLnabhvKOYHhE4ceQIZlMjNwG8vIbw= +github.com/mdehoog/op-geth v0.0.0-20241003075401-d8f4cde5a852 h1:sxczPjBB5xXnQWhdSrLdQLLIi/ZVv22pVOmd6xrHq8A= +github.com/mdehoog/op-geth v0.0.0-20241003075401-d8f4cde5a852/go.mod h1:7S4pp8KHBmEmKkRjL1BPOc6jY9hW+64YeMUjR3RVLw4= +github.com/mdehoog/optimism v0.0.0-20241002221953-1c750e49427c h1:Bb8sqokCf3tfNG8Uw95VtvDlTeDXA8jandtHkkA5dTQ= +github.com/mdehoog/optimism v0.0.0-20241002221953-1c750e49427c/go.mod h1:ym7scR7ZHvEmwx1DLGVDzFlAdR+uhP1+Z4XCiFuSD5s= github.com/mdlayher/socket v0.4.1 h1:eM9y2/jlbs1M615oshPQOHZzj6R6wMT7bX5NPiQvn2U= github.com/mdlayher/socket v0.4.1/go.mod h1:cAqeGjoufqdxWkD7DkpyS+wcefOtmu5OQ8KuoJGIReA= github.com/mdlayher/vsock v1.2.1 h1:pC1mTJTvjo1r9n9fbm7S1j04rCgCzhCOS5DY0zqHlnQ= @@ -276,9 +276,8 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= -github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= -github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -320,8 +319,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= -github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= +github.com/supranational/blst v0.3.13 h1:AYeSxdOMacwu7FBmpfloBz5pbFXDmJL33RuwnKtmTjk= +github.com/supranational/blst v0.3.13/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI= github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= diff --git a/op-proposer/proposer/clients.go b/op-proposer/proposer/clients.go index 0ab921d..893decb 100644 --- a/op-proposer/proposer/clients.go +++ b/op-proposer/proposer/clients.go @@ -30,6 +30,7 @@ type L2Client interface { HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error) + ExecutionWitness(ctx context.Context, hash common.Hash) ([]byte, error) Close() } @@ -41,7 +42,6 @@ type Client interface { type RollupClient interface { RollupConfig(ctx context.Context) (*rollup.Config, error) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) - WitnessAtBlock(ctx context.Context, hash common.Hash) ([]byte, error) } type ethClient struct { @@ -52,9 +52,6 @@ type ethClient struct { proofsCache *caching.LRUCache[[common.AddressLength + common.HashLength]byte, *eth.AccountResult] } -var _ L1Client = ðClient{} -var _ L2Client = ðClient{} - func NewClient(client *ethclient.Client, metrics caching.Metrics) Client { cacheSize := 1000 return ðClient{ @@ -158,6 +155,12 @@ func (e *ethClient) GetProof(ctx context.Context, address common.Address, hash c return proof, nil } +func (e *ethClient) ExecutionWitness(ctx context.Context, hash common.Hash) ([]byte, error) { + var buf hexutil.Bytes + err := e.client.Client().CallContext(ctx, &buf, "debug_executionWitness", hash) + return buf, err +} + func (e *ethClient) Close() { e.client.Close() } @@ -167,8 +170,6 @@ type rollupClient struct { witnessCache *caching.LRUCache[common.Hash, []byte] } -var _ RollupClient = &rollupClient{} - func NewRollupClient(client *rpc.Client, metrics caching.Metrics) RollupClient { cacheSize := 1000 return &rollupClient{ @@ -194,16 +195,3 @@ func (w *rollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) } return &status, nil } - -func (w *rollupClient) WitnessAtBlock(ctx context.Context, hash common.Hash) ([]byte, error) { - if witness, ok := w.witnessCache.Get(hash); ok { - return witness, nil - } - var witness hexutil.Bytes - err := w.client.CallContext(ctx, &witness, "optimism_witnessAtBlock", hash) - if err != nil { - return nil, err - } - w.witnessCache.Add(hash, witness) - return witness, nil -} diff --git a/op-proposer/proposer/prover.go b/op-proposer/proposer/prover.go index 3686c0a..a0be4f4 100644 --- a/op-proposer/proposer/prover.go +++ b/op-proposer/proposer/prover.go @@ -19,7 +19,6 @@ type Prover struct { configHash common.Hash l1 L1Client l2 L2Client - rollup RollupClient enclave enclave.RPC } @@ -50,7 +49,6 @@ func NewProver( configHash: configHash, l1: l1, l2: l2, - rollup: rollup, enclave: enclav, }, nil } @@ -69,7 +67,7 @@ func (o *Prover) Generate(ctx context.Context, blockNumber uint64) (*Proposal, b block := blockResult.value witnessCh := await(func() ([]byte, error) { - return o.rollup.WitnessAtBlock(ctx, block.Hash()) + return o.l2.ExecutionWitness(ctx, block.Hash()) }, func(err error) error { return fmt.Errorf("failed to fetch witness: %w", err) })