Compare commits

..

2 Commits

Author SHA1 Message Date
HAOYUatHZ
32ff705845 Merge branch 'develop' into pull-model-prover-client 2023-08-05 10:21:22 +08:00
HAOYUatHZ
b0b6a3db5e test(prover): add tests for TracesToChunkInfo (#719)
Co-authored-by: Steven Gu <asongala@163.com>
2023-08-05 10:21:14 +08:00
3 changed files with 44 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import (
"runtime/debug"
)
var tag = "v4.1.1"
var tag = "v4.1.0"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -8,19 +8,24 @@ import (
"scroll-tech/common/database"
)
const (
defaultNumberOfVerifierWorkers = 10
defaultNumberOfSessionRetryAttempts = 2
)
// ProverManager loads sequencer configuration items.
type ProverManager struct {
// The amount of provers to pick per proof generation session.
ProversPerSession uint8 `json:"provers_per_session"`
// Number of attempts that a session can be retried if previous attempts failed.
// Currently we only consider proving timeout as failure here.
SessionAttempts uint8 `json:"session_attempts"`
SessionAttempts uint8 `json:"session_attempts,omitempty"`
// Zk verifier config.
Verifier *VerifierConfig `json:"verifier,omitempty"`
// Proof collection time (in seconds).
CollectionTimeSec int `json:"collection_time_sec"`
// Max number of workers in verifier worker pool
MaxVerifierWorkers int `json:"max_verifier_workers"`
MaxVerifierWorkers int `json:"max_verifier_workers,omitempty"`
}
// L2 loads l2geth configuration items.
@@ -33,7 +38,7 @@ type L2 struct {
type Auth struct {
Secret string `json:"secret"`
ChallengeExpireDurationSec int `json:"challenge_expire_duration_sec"`
LoginExpireDurationSec int `json:"token_expire_duration_sec"`
LoginExpireDurationSec int `json:"token_expire_duration_sec"` // unit: seconds
}
// Config load configuration items.
@@ -64,5 +69,12 @@ func NewConfig(file string) (*Config, error) {
return nil, err
}
if cfg.ProverManager.MaxVerifierWorkers == 0 {
cfg.ProverManager.MaxVerifierWorkers = defaultNumberOfVerifierWorkers
}
if cfg.ProverManager.SessionAttempts == 0 {
cfg.ProverManager.SessionAttempts = defaultNumberOfSessionRetryAttempts
}
return cfg, nil
}

View File

@@ -1,5 +1,6 @@
//go:build ffi
// go test -v -race -gcflags="-l" -ldflags="-s=false" -tags ffi ./...
package core_test
import (
@@ -12,6 +13,7 @@ import (
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/stretchr/testify/assert"
scrollTypes "scroll-tech/common/types"
"scroll-tech/common/types/message"
"scroll-tech/prover/config"
@@ -47,6 +49,32 @@ func TestFFI(t *testing.T) {
as.NoError(err)
t.Log("Converted to chunk infos")
wrappedBlock1 := &scrollTypes.WrappedBlock{
Header: chunkTrace1[0].Header,
Transactions: chunkTrace1[0].Transactions,
WithdrawRoot: chunkTrace1[0].WithdrawTrieRoot,
}
chunk1 := &scrollTypes.Chunk{Blocks: []*scrollTypes.WrappedBlock{wrappedBlock1}}
chunkHash1, err := chunk1.Hash(0)
as.NoError(err)
as.Equal(chunkInfo1.PostStateRoot, wrappedBlock1.Header.Root)
as.Equal(chunkInfo1.WithdrawRoot, wrappedBlock1.WithdrawRoot)
as.Equal(chunkInfo1.DataHash, chunkHash1)
t.Log("Successful to check chunk info 1")
wrappedBlock2 := &scrollTypes.WrappedBlock{
Header: chunkTrace2[0].Header,
Transactions: chunkTrace2[0].Transactions,
WithdrawRoot: chunkTrace2[0].WithdrawTrieRoot,
}
chunk2 := &scrollTypes.Chunk{Blocks: []*scrollTypes.WrappedBlock{wrappedBlock2}}
chunkHash2, err := chunk2.Hash(chunk1.NumL1Messages(0))
as.NoError(err)
as.Equal(chunkInfo2.PostStateRoot, wrappedBlock2.Header.Root)
as.Equal(chunkInfo2.WithdrawRoot, wrappedBlock2.WithdrawRoot)
as.Equal(chunkInfo2.DataHash, chunkHash2)
t.Log("Successful to check chunk info 2")
chunkProof1, err := chunkProverCore.ProveChunk("chunk_proof1", chunkTrace1)
as.NoError(err)
t.Log("Generated and dumped chunk proof 1")