Skip to content

Commit

Permalink
Use witness from execution layer rather than consensus layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mdehoog committed Oct 3, 2024
1 parent f4e28c3 commit c767378
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 37 deletions.
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
19 changes: 9 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
26 changes: 7 additions & 19 deletions op-proposer/proposer/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand All @@ -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 {
Expand All @@ -52,9 +52,6 @@ type ethClient struct {
proofsCache *caching.LRUCache[[common.AddressLength + common.HashLength]byte, *eth.AccountResult]
}

var _ L1Client = &ethClient{}
var _ L2Client = &ethClient{}

func NewClient(client *ethclient.Client, metrics caching.Metrics) Client {
cacheSize := 1000
return &ethClient{
Expand Down Expand Up @@ -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()
}
Expand All @@ -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{
Expand All @@ -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
}
4 changes: 1 addition & 3 deletions op-proposer/proposer/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type Prover struct {
configHash common.Hash
l1 L1Client
l2 L2Client
rollup RollupClient
enclave enclave.RPC
}

Expand Down Expand Up @@ -50,7 +49,6 @@ func NewProver(
configHash: configHash,
l1: l1,
l2: l2,
rollup: rollup,
enclave: enclav,
}, nil
}
Expand All @@ -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)
})
Expand Down

0 comments on commit c767378

Please sign in to comment.