crypto/kzg4844: pull in the C and Go libs for KZG cryptography (#27155)

* cryto/kzg4844: pull in the C and Go libs for KZG cryptography

* go.mod: pull in the KZG libraries

* crypto/kzg4844: add basic becnhmarks for ballpark numbers

* cmd, crypto: integrate both CKZG and GoKZG all the time, add flag

* cmd/utils, crypto/kzg4844: run library init on startup

* crypto/kzg4844: make linter happy

* crypto/kzg4844: push missing file

* crypto/kzg4844: fully disable CKZG but leave in the sources

* build, crypto/kzg4844, internal: link CKZG by default and with portable mode

* crypto/kzg4844: drop verifying the trusted setup in gokzg

* internal/build: yolo until it works?

* cmd/utils: make flag description friendlier

Co-authored-by: Martin Holst Swende <martin@swende.se>

* crypto/ckzg: no need for double availability check

* build: tiny flag cleanup nitpick

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
This commit is contained in:
Péter Szilágyi
2023-05-10 14:54:14 +03:00
committed by GitHub
co-authored by Martin Holst Swende
parent ae7db289b8
commit 2169fa343a
12 changed files with 8890 additions and 39 deletions
+3 -24
View File
@@ -53,31 +53,10 @@ func (g *GoToolchain) Go(command string, args ...string) *exec.Cmd {
} else if os.Getenv("CC") != "" {
tool.Env = append(tool.Env, "CC="+os.Getenv("CC"))
}
return tool
}
// CKZG by default is not portable, append the necessary build flags to make
// it not rely on modern CPU instructions and enable linking against
tool.Env = append(tool.Env, "CGO_CFLAGS=-D__BLST_PORTABLE__")
// Install creates an invocation of 'go install'. The command is configured to output
// executables to the given 'gobin' directory.
//
// This can be used to install auxiliary build tools without modifying the local go.mod and
// go.sum files. To install tools which are not required by go.mod, ensure that all module
// paths in 'args' contain a module version suffix (e.g. "...@latest").
func (g *GoToolchain) Install(gobin string, args ...string) *exec.Cmd {
if !filepath.IsAbs(gobin) {
panic("GOBIN must be an absolute path")
}
tool := g.goTool("install")
tool.Env = append(tool.Env, "GOBIN="+gobin)
tool.Args = append(tool.Args, "-mod=readonly")
tool.Args = append(tool.Args, args...)
// Ensure GOPATH is set because go install seems to absolutely require it. This uses
// 'go env' because it resolves the default value when GOPATH is not set in the
// environment. Ignore errors running go env and leave any complaining about GOPATH to
// the install command.
pathTool := g.goTool("env", "GOPATH")
output, _ := pathTool.Output()
tool.Env = append(tool.Env, "GOPATH="+string(output))
return tool
}