Skip to content
This repository was archived by the owner on May 11, 2024. It is now read-only.

Commit 1689560

Browse files
Merge branch 'main' into eip4844
2 parents 7ccc57d + 9fa5ab6 commit 1689560

File tree

5 files changed

+79
-4
lines changed

5 files changed

+79
-4
lines changed

cmd/flags/prover.go

+7
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ var (
183183
Usage: "HTTP endpoint for main guardian prover health check server",
184184
Category: proverCategory,
185185
}
186+
// Guardian prover specific flag
187+
EnableLivenessBondProof = &cli.BoolFlag{
188+
Name: "prover.enableLivenessBondProof",
189+
Usage: "Toggles whether the proof is a dummy proof or returns keccak256(RETURN_LIVENESS_BOND) as proof",
190+
Value: false,
191+
Category: proverCategory,
192+
}
186193
)
187194

188195
// ProverFlags All prover flags.

prover/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type Config struct {
3737
BackOffRetryInterval time.Duration
3838
ProveUnassignedBlocks bool
3939
ContesterMode bool
40+
EnableLivenessBondProof bool
4041
RPCTimeout time.Duration
4142
WaitReceiptTimeout time.Duration
4243
ProveBlockGasLimit *uint64
@@ -146,6 +147,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
146147
BackOffRetryInterval: c.Duration(flags.BackOffRetryInterval.Name),
147148
ProveUnassignedBlocks: c.Bool(flags.ProveUnassignedBlocks.Name),
148149
ContesterMode: c.Bool(flags.ContesterMode.Name),
150+
EnableLivenessBondProof: c.Bool(flags.EnableLivenessBondProof.Name),
149151
RPCTimeout: c.Duration(flags.RPCTimeout.Name),
150152
WaitReceiptTimeout: c.Duration(flags.WaitReceiptTimeout.Name),
151153
ProveBlockGasLimit: proveBlockTxGasLimit,

prover/proof_producer/guardian_producer.go

+29-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,32 @@ import (
55
"math/big"
66

77
"github.com/ethereum/go-ethereum/core/types"
8+
"github.com/ethereum/go-ethereum/crypto"
89
"github.com/ethereum/go-ethereum/log"
910

1011
"github.com/taikoxyz/taiko-client/bindings"
1112
"github.com/taikoxyz/taiko-client/bindings/encoding"
1213
)
1314

1415
// GuardianProofProducer always returns an optimistic (dummy) proof.
15-
type GuardianProofProducer struct{ *DummyProofProducer }
16+
type GuardianProofProducer struct {
17+
returnLivenessBond bool
18+
*DummyProofProducer
19+
}
20+
21+
func NewGuardianProofProducer(returnLivenessBond bool) *GuardianProofProducer {
22+
gp := &GuardianProofProducer{
23+
returnLivenessBond: returnLivenessBond,
24+
}
25+
26+
if !returnLivenessBond {
27+
gp.DummyProofProducer = new(DummyProofProducer)
28+
}
29+
30+
return gp
31+
}
1632

1733
// RequestProof implements the ProofProducer interface.
18-
// TODO: support returning `keccak256("RETURN_LIVENESS_BOND")` as proof.
1934
func (g *GuardianProofProducer) RequestProof(
2035
ctx context.Context,
2136
opts *ProofRequestOptions,
@@ -31,6 +46,18 @@ func (g *GuardianProofProducer) RequestProof(
3146
"hash", header.Hash(),
3247
)
3348

49+
if g.returnLivenessBond {
50+
return &ProofWithHeader{
51+
BlockID: blockID,
52+
Meta: meta,
53+
Header: header,
54+
Proof: crypto.Keccak256([]byte("RETURN_LIVENESS_BOND")),
55+
Degree: CircuitsIdx,
56+
Opts: opts,
57+
Tier: g.Tier(),
58+
}, nil
59+
}
60+
3461
return g.DummyProofProducer.RequestProof(ctx, opts, blockID, meta, header, g.Tier())
3562
}
3663

prover/proof_producer/guardian_producer_test.go

+40-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
"github.com/ethereum/go-ethereum/common"
99
"github.com/ethereum/go-ethereum/core/types"
10+
"github.com/ethereum/go-ethereum/crypto"
1011
"github.com/stretchr/testify/require"
1112

1213
"github.com/taikoxyz/taiko-client/bindings"
@@ -32,7 +33,7 @@ func TestGuardianProducerRequestProof(t *testing.T) {
3233
}
3334

3435
var (
35-
producer = &GuardianProofProducer{}
36+
producer = NewGuardianProofProducer(false)
3637
blockID = common.Big32
3738
)
3839
res, err := producer.RequestProof(
@@ -49,3 +50,41 @@ func TestGuardianProducerRequestProof(t *testing.T) {
4950
require.Equal(t, res.Tier, encoding.TierGuardianID)
5051
require.NotEmpty(t, res.Proof)
5152
}
53+
54+
func TestGuardianProducerRequestProofReturnLivenessBond(t *testing.T) {
55+
header := &types.Header{
56+
ParentHash: randHash(),
57+
UncleHash: randHash(),
58+
Coinbase: common.BytesToAddress(randHash().Bytes()),
59+
Root: randHash(),
60+
TxHash: randHash(),
61+
ReceiptHash: randHash(),
62+
Difficulty: common.Big0,
63+
Number: common.Big256,
64+
GasLimit: 1024,
65+
GasUsed: 1024,
66+
Time: uint64(time.Now().Unix()),
67+
Extra: randHash().Bytes(),
68+
MixDigest: randHash(),
69+
Nonce: types.BlockNonce{},
70+
}
71+
72+
var (
73+
producer = NewGuardianProofProducer(true)
74+
blockID = common.Big32
75+
)
76+
res, err := producer.RequestProof(
77+
context.Background(),
78+
&ProofRequestOptions{},
79+
blockID,
80+
&bindings.TaikoDataBlockMetadata{},
81+
header,
82+
)
83+
require.Nil(t, err)
84+
85+
require.Equal(t, res.BlockID, blockID)
86+
require.Equal(t, res.Header, header)
87+
require.Equal(t, res.Tier, encoding.TierGuardianID)
88+
require.NotEmpty(t, res.Proof)
89+
require.Equal(t, res.Proof, crypto.Keccak256([]byte("RETURN_LIVENESS_BOND")))
90+
}

prover/prover.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
218218
}
219219
producer = zkEvmRpcdProducer
220220
case encoding.TierGuardianID:
221-
producer = &proofProducer.GuardianProofProducer{DummyProofProducer: new(proofProducer.DummyProofProducer)}
221+
producer = proofProducer.NewGuardianProofProducer(p.cfg.EnableLivenessBondProof)
222222
}
223223

224224
if submitter, err = proofSubmitter.New(

0 commit comments

Comments
 (0)