Compare commits

..

3 Commits

Author SHA1 Message Date
Steven
e6fe25f10f fix: Update libzkp to use scroll-prover v0.5.14 (#782)
Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com>
2023-08-14 14:23:43 +08:00
HAOYUatHZ
251c706c04 feat(coordinator): use dotenv for whitelist (#784)
Co-authored-by: Your Name <you@example.com>
2023-08-14 13:34:40 +08:00
HAOYUatHZ
55658c6f52 feat(coordinator): add chunk prover whitelist (#783) 2023-08-14 10:59:43 +08:00
6 changed files with 63 additions and 17 deletions

View File

@@ -32,7 +32,7 @@ dependencies = [
[[package]]
name = "aggregator"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"ark-std",
"env_logger 0.10.0",
@@ -433,7 +433,7 @@ checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1"
[[package]]
name = "bus-mapping"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"eth-types",
"ethers-core",
@@ -1049,7 +1049,7 @@ dependencies = [
[[package]]
name = "eth-types"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"ethers-core",
"ethers-signers",
@@ -1226,7 +1226,7 @@ dependencies = [
[[package]]
name = "external-tracer"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"eth-types",
"geth-utils",
@@ -1439,7 +1439,7 @@ dependencies = [
[[package]]
name = "gadgets"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"digest 0.7.6",
"eth-types",
@@ -1479,7 +1479,7 @@ dependencies = [
[[package]]
name = "geth-utils"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"env_logger 0.9.3",
"gobuild 0.1.0-alpha.2 (git+https://github.com/scroll-tech/gobuild.git)",
@@ -2077,7 +2077,7 @@ dependencies = [
[[package]]
name = "keccak256"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"env_logger 0.9.3",
"eth-types",
@@ -2264,7 +2264,7 @@ dependencies = [
[[package]]
name = "mock"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"eth-types",
"ethers-core",
@@ -2279,7 +2279,7 @@ dependencies = [
[[package]]
name = "mpt-zktrie"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"bus-mapping",
"eth-types",
@@ -2755,7 +2755,7 @@ dependencies = [
[[package]]
name = "prover"
version = "0.4.0"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.13#0756ac68ee2f41c51f09a748cd28220290fe49ae"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.14#7653cd664105077ac1540ecfdb0602e3858f59a6"
dependencies = [
"aggregator",
"anyhow",
@@ -4040,7 +4040,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "types"
version = "0.4.0"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.13#0756ac68ee2f41c51f09a748cd28220290fe49ae"
source = "git+https://github.com/scroll-tech/scroll-prover?tag=v0.5.14#7653cd664105077ac1540ecfdb0602e3858f59a6"
dependencies = [
"base64 0.13.1",
"blake2",
@@ -4491,7 +4491,7 @@ checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9"
[[package]]
name = "zkevm-circuits"
version = "0.1.0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.13#a8c59b2e6e0a845c78d6b93a80c0a9c0601f59d0"
source = "git+https://github.com/scroll-tech/zkevm-circuits.git?tag=v0.5.14rc1#ae23cd7af80f1ba9d0f0bb1a4367ffe626ade86e"
dependencies = [
"array-init",
"bus-mapping",

View File

@@ -20,8 +20,8 @@ maingate = { git = "https://github.com/scroll-tech/halo2wrong", branch = "halo2-
halo2curves = { git = "https://github.com/scroll-tech/halo2curves.git", branch = "0.3.1-derive-serde" }
[dependencies]
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.13" }
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.13" }
prover = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.14" }
types = { git = "https://github.com/scroll-tech/scroll-prover", tag = "v0.5.14" }
halo2_proofs = { git = "https://github.com/scroll-tech/halo2.git", branch = "develop" }
log = "0.4"

View File

@@ -6,7 +6,7 @@ import (
"strings"
)
var tag = "v4.1.38"
var tag = "v4.1.41"
var commit = func() string {
if info, ok := debug.ReadBuildInfo(); ok {

View File

@@ -47,7 +47,10 @@ require (
google.golang.org/protobuf v1.31.0 // indirect
)
require github.com/prometheus/client_golang v1.14.0
require (
github.com/joho/godotenv v1.5.1
github.com/prometheus/client_golang v1.14.0
)
require (
github.com/beorn7/perks v1.0.1 // indirect

View File

@@ -82,6 +82,8 @@ github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=

View File

@@ -4,8 +4,12 @@ import (
"context"
"encoding/json"
"fmt"
"os"
"strconv"
"strings"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/scroll-tech/go-ethereum/common"
@@ -53,6 +57,38 @@ func NewChunkProverTask(cfg *config.Config, db *gorm.DB, reg prometheus.Register
return cp
}
// TODO: change to use publickey
func isChunkProverWhitelisted(proverName string) bool {
if err := godotenv.Load(); err != nil {
return false
}
whitelist := os.Getenv("WHITELISTED_CHUNK_PROVERS")
wProvers := strings.Split(whitelist, ";")
for _, wProver := range wProvers {
if proverName == wProver {
return true
}
}
return false
}
// TODO: change to use chunk hash
func isChunkWhitelisted(index uint64) bool {
if err := godotenv.Load(); err != nil {
return false
}
whitelist := os.Getenv("WHITELISTED_INDEXES")
wIndexes := strings.Split(whitelist, ";")
for _, wIndex := range wIndexes {
if strconv.FormatUint(index, 10) == wIndex {
return true
}
}
return false
}
// Assign the chunk proof which need to prove
func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinatorType.GetTaskParameter) (*coordinatorType.GetTaskSchema, error) {
publicKey, publicKeyExist := ctx.Get(coordinatorType.PublicKey)
@@ -69,7 +105,7 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
if !proverVersionExist {
return nil, fmt.Errorf("get prover version from context failed")
}
if !version.CheckScrollProverVersion(proverVersion.(string)) {
if !version.CheckScrollProverVersion(proverVersion.(string)) && !isChunkProverWhitelisted(proverName.(string)) {
return nil, fmt.Errorf("incompatible prover version. please upgrade your prover, expect version: %s, actual version: %s", version.Version, proverVersion.(string))
}
@@ -98,6 +134,11 @@ func (cp *ChunkProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
chunkTask := chunkTasks[0]
// only whitelisted provers can prove whitelisted chunk
if !isChunkProverWhitelisted(proverName.(string)) && isChunkWhitelisted(chunkTask.Index) {
return nil, fmt.Errorf("get empty chunk proving task list")
}
log.Info("start chunk generation session", "id", chunkTask.Hash, "public key", publicKey, "prover name", proverName)
if !cp.checkAttemptsExceeded(chunkTask.Hash, message.ProofTypeChunk) {