Skip to content

Commit 4932024

Browse files
committed
Merge remote-tracking branch 'origin/develop' into feat/cloak
2 parents 19380b3 + 1985e54 commit 4932024

File tree

20 files changed

+274
-12
lines changed

20 files changed

+274
-12
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coordinator/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ coordinator_tool:
3535
go build -ldflags "-X scroll-tech/common/version.ZkVersion=${ZK_VERSION}" -o $(PWD)/build/bin/coordinator_tool ./cmd/tool
3636

3737
localsetup: coordinator_api ## Local setup: build coordinator_api, copy config, and setup releases
38+
mkdir -p build/bin/conf
3839
@echo "Copying configuration files..."
3940
cp -r $(PWD)/conf/config.json $(PWD)/build/bin/conf/config.template.json
4041
@echo "Setting up releases..."

coordinator/build/setup_releases.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [ -z "${SCROLL_ZKVM_VERSION}" ]; then
77
fi
88

99
# set ASSET_DIR by reading from config.json
10-
CONFIG_FILE="bin/conf/config.json"
10+
CONFIG_FILE="bin/conf/config.template.json"
1111
if [ ! -f "$CONFIG_FILE" ]; then
1212
echo "Config file $CONFIG_FILE not found"
1313
exit 1

coordinator/internal/logic/libzkp/lib.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,20 @@ func SetDynamicFeature(feats string) {
147147
defer freeCString(cFeats)
148148
C.set_dynamic_feature(cFeats)
149149
}
150+
151+
// UnivTaskCompatibilityFix calls the universal task compatibility fix function
152+
func UniversalTaskCompatibilityFix(taskJSON string) (string, error) {
153+
cTaskJSON := goToCString(taskJSON)
154+
defer freeCString(cTaskJSON)
155+
156+
resultPtr := C.univ_task_compatibility_fix(cTaskJSON)
157+
if resultPtr == nil {
158+
return "", fmt.Errorf("univ_task_compatibility_fix failed")
159+
}
160+
161+
// Convert result to Go string and free C memory
162+
result := C.GoString(resultPtr)
163+
C.release_string(resultPtr)
164+
165+
return result, nil
166+
}

coordinator/internal/logic/libzkp/libzkp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,7 @@ void release_string(char* string_ptr);
5858

5959
void set_dynamic_feature(const char* feats);
6060

61+
// Universal task compatibility fix function
62+
char* univ_task_compatibility_fix(char* task_json);
6163

6264
#endif /* LIBZKP_H */

coordinator/internal/logic/provertask/batch_prover_task.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,14 @@ func (bp *BatchProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinato
213213
return nil, ErrCoordinatorInternalFailure
214214
}
215215
proverTask.Metadata = metadata
216+
217+
if isCompatibilityFixingVersion(taskCtx.ProverVersion) {
218+
log.Info("Apply compatibility fixing for prover", "version", taskCtx.ProverVersion)
219+
if err := fixCompatibility(taskMsg); err != nil {
220+
log.Error("apply compatibility failure", "err", err)
221+
return nil, ErrCoordinatorInternalFailure
222+
}
223+
}
216224
}
217225

218226
// Store session info.

coordinator/internal/logic/provertask/bundle_prover_task.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ func (bp *BundleProverTask) Assign(ctx *gin.Context, getTaskParameter *coordinat
211211
// bundle proof require snark
212212
taskMsg.UseSnark = true
213213
proverTask.Metadata = metadata
214+
215+
if isCompatibilityFixingVersion(taskCtx.ProverVersion) {
216+
log.Info("Apply compatibility fixing for prover", "version", taskCtx.ProverVersion)
217+
if err := fixCompatibility(taskMsg); err != nil {
218+
log.Error("apply compatibility failure", "err", err)
219+
return nil, ErrCoordinatorInternalFailure
220+
}
221+
}
214222
}
215223

216224
// Store session info.

coordinator/internal/logic/provertask/prover_task.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"gorm.io/gorm"
1616

1717
"scroll-tech/common/types/message"
18+
"scroll-tech/common/version"
1819

1920
"scroll-tech/coordinator/internal/config"
2021
"scroll-tech/coordinator/internal/logic/libzkp"
@@ -219,6 +220,23 @@ func (b *BaseProverTask) applyUniversal(schema *coordinatorType.GetTaskSchema) (
219220
return schema, []byte(metadata), nil
220221
}
221222

223+
const CompatibilityVersion = "4.5.43"
224+
225+
func isCompatibilityFixingVersion(ver string) bool {
226+
return !version.CheckScrollRepoVersion(ver, CompatibilityVersion)
227+
}
228+
229+
func fixCompatibility(schema *coordinatorType.GetTaskSchema) error {
230+
231+
fixedTask, err := libzkp.UniversalTaskCompatibilityFix(schema.TaskData)
232+
if err != nil {
233+
return err
234+
}
235+
schema.TaskData = fixedTask
236+
237+
return nil
238+
}
239+
222240
func newGetTaskCounterVec(factory promauto.Factory, taskType string) *prometheus.CounterVec {
223241
getTaskCounterInitOnce.Do(func() {
224242
getTaskCounterVec = factory.NewCounterVec(prometheus.CounterOpts{

coordinator/test/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func setupCoordinator(t *testing.T, proversPerSession uint8, coordinatorURL stri
132132
func setEnv(t *testing.T) {
133133
var err error
134134

135-
version.Version = "v4.4.89"
135+
version.Version = "v4.5.45"
136136

137137
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.LogfmtFormat()))
138138
glogger.Verbosity(log.LvlInfo)

crates/libzkp/src/lib.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,47 @@ pub fn checkout_chunk_task(
4848
)?)
4949
}
5050

51+
/// Convert the universal task json into compatible form for old prover
52+
pub fn univ_task_compatibility_fix(task_json: &str) -> eyre::Result<String> {
53+
use scroll_zkvm_types::proof::VmInternalStarkProof;
54+
55+
let task: tasks::ProvingTask = serde_json::from_str(task_json)?;
56+
let aggregated_proofs: Vec<VmInternalStarkProof> = task
57+
.aggregated_proofs
58+
.into_iter()
59+
.map(|proof| VmInternalStarkProof {
60+
proofs: proof.proofs,
61+
public_values: proof.public_values,
62+
})
63+
.collect();
64+
65+
#[derive(Serialize)]
66+
struct CompatibleProvingTask {
67+
/// seralized witness which should be written into stdin first
68+
pub serialized_witness: Vec<Vec<u8>>,
69+
/// aggregated proof carried by babybear fields, should be written into stdin
70+
/// followed `serialized_witness`
71+
pub aggregated_proofs: Vec<VmInternalStarkProof>,
72+
/// Fork name specify
73+
pub fork_name: String,
74+
/// The vk of app which is expcted to prove this task
75+
pub vk: Vec<u8>,
76+
/// An identifier assigned by coordinator, it should be kept identify for the
77+
/// same task (for example, using chunk, batch and bundle hashes)
78+
pub identifier: String,
79+
}
80+
81+
let compatible_u_task = CompatibleProvingTask {
82+
serialized_witness: task.serialized_witness,
83+
aggregated_proofs,
84+
fork_name: task.fork_name,
85+
vk: task.vk,
86+
identifier: task.identifier,
87+
};
88+
89+
Ok(serde_json::to_string(&compatible_u_task)?)
90+
}
91+
5192
/// Generate required staff for proving tasks
5293
/// return (pi_hash, metadata, task)
5394
pub fn gen_universal_task(

0 commit comments

Comments
 (0)