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

Commit

Permalink
fix(prover): update bindings && fix a delay calculation issue (#242)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored May 25, 2023
1 parent 31521ef commit 49c3d69
Show file tree
Hide file tree
Showing 10 changed files with 448 additions and 207 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ jobs:
with:
repository: taikoxyz/taiko-mono
path: ${{ env.TAIKO_MONO_DIR }}
ref: alpha-3

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand Down
2 changes: 1 addition & 1 deletion bindings/.githead
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8aa0940bc0ff576c30061c7c7e84416698dccbd7
a84ea79d8a660e67f1731784741c085b2cacc06f
310 changes: 236 additions & 74 deletions bindings/gen_taiko_l1.go

Large diffs are not rendered by default.

319 changes: 194 additions & 125 deletions bindings/gen_taiko_l2.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions integration_test/nodes/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ cd $TAIKO_MONO_DIR/packages/protocol &&
TAIKO_TOKEN_PREMINT_AMOUNT=18446744073709551614 \
L2_GENESIS_HASH=$L2_GENESIS_HASH \
L2_CHAIN_ID=167001 \
ADJUSTMENT_QUOTIENT=32000 \
forge script script/DeployOnL1.s.sol:DeployOnL1 \
--fork-url http://localhost:18545 \
--broadcast \
Expand Down
2 changes: 1 addition & 1 deletion prover/proof_producer/dummy_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type DummyProofProducer struct {
RandomDummyProofDelayUpperBound *time.Duration
}

func (d *DummyProofProducer) CalcDelay(
func (d *DummyProofProducer) CalcProofTimeTargetDelay(
header *types.Header,
) time.Duration {
return time.Duration(0)
Expand Down
2 changes: 1 addition & 1 deletion prover/proof_producer/proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type ProofProducer interface {
resultCh chan *ProofWithHeader,
) error
Cancel(ctx context.Context, blockID *big.Int) error
CalcDelay(header *types.Header) time.Duration
CalcProofTimeTargetDelay(header *types.Header) time.Duration
}

func DegreeToCircuitsIdx(degree uint64) (uint16, error) {
Expand Down
2 changes: 1 addition & 1 deletion prover/proof_producer/special_proof_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func NewSpecialProofProducer(
}, nil
}

func (p *SpecialProofProducer) CalcDelay(
func (p *SpecialProofProducer) CalcProofTimeTargetDelay(
header *types.Header,
) time.Duration {
return time.Duration(0)
Expand Down
9 changes: 6 additions & 3 deletions prover/proof_producer/zkevm_rpcd_producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,17 @@ func NewZkevmRpcdProducer(
}, nil
}

func (p *ZkevmRpcdProducer) CalcDelay(
func (p *ZkevmRpcdProducer) CalcProofTimeTargetDelay(
header *types.Header,
) time.Duration {
// if > 0, delay has not yet elapsed; proof should be delayed.
// if <= 0, delay has already elapsed; proof does not need delay.
delay := ((p.ProofTimeTarget + header.Time) - uint64(time.Now().Unix()))

log.Debug("Proof submission delay", "delay", delay)

if delay > 0 {
return time.Duration(delay)
return time.Duration(delay * uint64(time.Second))
} else {
return time.Duration(0)
}
Expand Down Expand Up @@ -153,7 +156,7 @@ func (p *ZkevmRpcdProducer) RequestProof(
return err
}

time.AfterFunc(p.CalcDelay(header), func() {
time.AfterFunc(p.CalcProofTimeTargetDelay(header), func() {
resultCh <- &ProofWithHeader{
BlockID: blockID,
Header: header,
Expand Down
7 changes: 6 additions & 1 deletion prover/proof_producer/zkevm_rpcd_producer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import (
)

func TestNewZkevmRpcdProducer(t *testing.T) {
var proofTimeTarget uint64 = 3

dummyZkevmRpcdProducer, err := NewZkevmRpcdProducer(
"http://localhost:18545",
"",
"",
"",
false,
0,
proofTimeTarget,
&bindings.TaikoDataConfig{},
)
require.Nil(t, err)
Expand Down Expand Up @@ -46,6 +48,8 @@ func TestNewZkevmRpcdProducer(t *testing.T) {
MixDigest: randHash(),
Nonce: types.BlockNonce{},
}

timeBefore := time.Now()
require.Nil(t, dummyZkevmRpcdProducer.RequestProof(
context.Background(),
&ProofRequestOptions{},
Expand All @@ -56,6 +60,7 @@ func TestNewZkevmRpcdProducer(t *testing.T) {
))

res := <-resCh
require.True(t, time.Now().After(timeBefore.Add(time.Duration(proofTimeTarget)*time.Second)))
require.Equal(t, res.BlockID, blockID)
require.Equal(t, res.Header, header)
require.NotEmpty(t, res.ZkProof)
Expand Down

0 comments on commit 49c3d69

Please sign in to comment.