Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support large zk code #785

Merged
merged 5 commits into from
Dec 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update
Liuhaai committed Dec 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit dca7dac5a54baa82de880b1b99468090a59f95f0
2 changes: 1 addition & 1 deletion project/project_test.go
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ func TestProjectMeta_FetchProjectFile_http(t *testing.T) {
p = p.ApplyFuncReturn(io.ReadAll, jc, nil)

nfd := *fd
nfd.Hash = [32]byte{1}
nfd.Hash = [32]byte{}
_, err := nfd.FetchFile()
r.ErrorContains(err, "failed to validate project file hash")
})
4 changes: 2 additions & 2 deletions util/filefetcher/file.go
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ type Filedescriptor struct {
Hash [32]byte
}

func (fd *Filedescriptor) FetchFile() ([]byte, error) {
func (fd *Filedescriptor) FetchFile(skipHash ...bool) ([]byte, error) {
u, err := url.Parse(fd.Uri)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse project file uri %s", fd.Uri)
@@ -44,7 +44,7 @@ func (fd *Filedescriptor) FetchFile() ([]byte, error) {
return nil, errors.Wrapf(err, "failed to read project file, uri %s", fd.Uri)
}

if !bytes.Equal(fd.Hash[:], make([]byte, 32)) {
if skipHash[0] {
h := sha256.New()
if _, err := h.Write(data); err != nil {
return nil, errors.Wrap(err, "failed to generate project file hash")
3 changes: 2 additions & 1 deletion vm/vm.go
Original file line number Diff line number Diff line change
@@ -62,7 +62,8 @@ func decodeBinary(b string) ([]byte, error) {
if strings.Contains(b, "http") ||
strings.Contains(b, "ipfs") {
fd := filefetcher.Filedescriptor{Uri: b}
return fd.FetchFile()
skipHash := true
return fd.FetchFile(skipHash)
}
return hex.DecodeString(b)
}