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

Commit

Permalink
feat(prover): implementing --graffiti flag for prover as input to b…
Browse files Browse the repository at this point in the history
…lock evidence (#209)

Co-authored-by: jeff <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: David <[email protected]>
  • Loading branch information
4 people authored May 3, 2023
1 parent cc0da63 commit 2340210
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/flags/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ var (
Category: proverCategory,
Value: false,
}
Graffiti = &cli.StringFlag{
Name: "graffiti",
Usage: "When string is passed, adds additional graffiti info to proof evidence",
Category: proverCategory,
Value: "",
}
)

// All prover flags.
Expand All @@ -74,4 +80,5 @@ var ProverFlags = MergeFlags(CommonFlags, []cli.Flag{
Dummy,
RandomDummyProofDelay,
OracleProver,
Graffiti,
})
2 changes: 2 additions & 0 deletions prover/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Config struct {
MaxConcurrentProvingJobs uint
Dummy bool
OracleProver bool
Graffiti string
RandomDummyProofDelayLowerBound *time.Duration
RandomDummyProofDelayUpperBound *time.Duration
}
Expand Down Expand Up @@ -89,6 +90,7 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
MaxConcurrentProvingJobs: c.Uint(flags.MaxConcurrentProvingJobs.Name),
Dummy: c.Bool(flags.Dummy.Name),
OracleProver: c.Bool(flags.OracleProver.Name),
Graffiti: c.String(flags.Graffiti.Name),
RandomDummyProofDelayLowerBound: randomDummyProofDelayLowerBound,
RandomDummyProofDelayUpperBound: randomDummyProofDelayUpperBound,
}, nil
Expand Down
3 changes: 3 additions & 0 deletions prover/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext() {
&cli.BoolFlag{Name: flags.Dummy.Name},
&cli.StringFlag{Name: flags.RandomDummyProofDelay.Name},
&cli.BoolFlag{Name: flags.OracleProver.Name},
&cli.StringFlag{Name: flags.Graffiti.Name},
}
app.Action = func(ctx *cli.Context) error {
c, err := NewConfigFromCliContext(ctx)
Expand All @@ -48,6 +49,7 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext() {
s.Equal(time.Hour, *c.RandomDummyProofDelayUpperBound)
s.True(c.Dummy)
s.True(c.OracleProver)
s.Equal("", c.Graffiti)
s.Nil(new(Prover).InitFromCli(context.Background(), ctx))

return err
Expand All @@ -65,5 +67,6 @@ func (s *ProverTestSuite) TestNewConfigFromCliContext() {
"-" + flags.Dummy.Name,
"-" + flags.RandomDummyProofDelay.Name, "30m-1h",
"-" + flags.OracleProver.Name,
"-" + flags.Graffiti.Name, "",
}))
}
9 changes: 8 additions & 1 deletion prover/proof_submitter/valid_proof_submitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type ValidProofSubmitter struct {
proverAddress common.Address
mutex *sync.Mutex
isOracle bool
graffiti [32]byte
}

// NewValidProofSubmitter creates a new ValidProofSubmitter instance.
Expand All @@ -43,12 +44,16 @@ func NewValidProofSubmitter(
proverPrivKey *ecdsa.PrivateKey,
mutex *sync.Mutex,
isOracle bool,
graffiti string,
) (*ValidProofSubmitter, error) {
anchorValidator, err := anchorTxValidator.New(taikoL2Address, rpc.L2ChainID, rpc)
if err != nil {
return nil, err
}

var bytes [32]byte
copy(bytes[:], []byte(graffiti))

return &ValidProofSubmitter{
rpc: rpc,
proofProducer: proofProducer,
Expand All @@ -58,6 +63,7 @@ func NewValidProofSubmitter(
proverAddress: crypto.PubkeyToAddress(proverPrivKey.PublicKey),
mutex: mutex,
isOracle: isOracle,
graffiti: bytes,
}, nil
}

Expand Down Expand Up @@ -102,6 +108,7 @@ func (s *ValidProofSubmitter) SubmitProof(
"beneficiary", proofWithHeader.Meta.Beneficiary,
"hash", proofWithHeader.Header.Hash(),
"proof", common.Bytes2Hex(proofWithHeader.ZkProof),
"graffiti", string(s.graffiti[:]),
)
var (
blockID = proofWithHeader.BlockID
Expand Down Expand Up @@ -162,7 +169,7 @@ func (s *ValidProofSubmitter) SubmitProof(
ParentHash: block.ParentHash(),
BlockHash: block.Hash(),
SignalRoot: signalRoot,
Graffiti: [32]byte{},
Graffiti: s.graffiti,
ParentGasUsed: uint32(parent.GasUsed()),
GasUsed: uint32(block.GasUsed()),
Proof: zkProof,
Expand Down
1 change: 1 addition & 0 deletions prover/proof_submitter/valid_proof_submitter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (s *ProofSubmitterTestSuite) SetupTest() {
l1ProverPrivKey,
&sync.Mutex{},
false,
"test",
)
s.Nil(err)

Expand Down
1 change: 1 addition & 0 deletions prover/prover.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func InitFromConfig(ctx context.Context, p *Prover, cfg *Config) (err error) {
p.cfg.L1ProverPrivKey,
p.submitProofTxMutex,
p.cfg.OracleProver,
p.cfg.Graffiti,
); err != nil {
return err
}
Expand Down

0 comments on commit 2340210

Please sign in to comment.