Last active
March 10, 2022 14:42
-
-
Save gballet/743b5be921f09b762c5d343c251eb528 to your computer and use it in GitHub Desktop.
A tx blob verification benchmark for eip 4844
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'trustless' setup in progress, please wait | |
done | |
goos: freebsd | |
goarch: amd64 | |
pkg: gballet.eu/testkzg | |
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz | |
BenchmarkPolyEval-8 24 42047844 ns/op 1008948 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 22 49744581 ns/op 1008948 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 25 44590933 ns/op 1008944 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 24 51210360 ns/op 1008948 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 25 42969705 ns/op 1008944 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 27 43452784 ns/op 1008947 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 26 45130464 ns/op 1008944 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 25 54170210 ns/op 1008944 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 19 60885720 ns/op 1008944 B/op 8300 allocs/op | |
BenchmarkPolyEval-8 18 62286777 ns/op 1008944 B/op 8300 allocs/op | |
PASS | |
ok gballet.eu/testkzg 14.526s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module gballet.eu/testkzg | |
go 1.17 | |
require ( | |
github.com/herumi/bls-eth-go-binary v0.0.0-20210302070600-dfaa902c7773 // indirect | |
github.com/holiman/uint256 v1.1.1 // indirect | |
github.com/kilic/bls12-381 v0.1.1-0.20210208205449-6045b0235e36 // indirect | |
github.com/protolambda/go-kzg v0.0.0-20220220065500-36404333406f // indirect | |
golang.org/x/sys v0.0.0-20210305034016-7844c3c200c3 // indirect | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"github.com/protolambda/go-kzg" | |
"github.com/protolambda/go-kzg/bls" | |
) | |
const FieldElementsPerBlob = 4096 | |
// testPoly creates a polynomial with random coefficients | |
func testPoly(n int) []bls.Fr { | |
var tmp [32]byte | |
polynomial := make([]bls.Fr, n, n) | |
for i := 0; i < n; i++ { | |
rand.Read(tmp[:]) | |
bls.FrFrom32(&polynomial[i], tmp) | |
} | |
return polynomial | |
} | |
func main() { | |
polynomial := testPoly(FieldElementsPerBlob) | |
fmt.Println("created polynomial") | |
fmt.Println(ks.CommitToPoly(polynomial)) | |
} | |
var ks *kzg.KZGSettings | |
func init() { | |
fmt.Println("'trustless' setup in progress, please wait") | |
fs := kzg.NewFFTSettings(12) | |
s1, s2 := kzg.GenerateTestingSetup("1927409816240961209460912649124", FieldElementsPerBlob+1) | |
ks = kzg.NewKZGSettings(fs, s1, s2) | |
fmt.Println("done") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "testing" | |
func BenchmarkPolyEval(b *testing.B) { | |
polynomial := testPoly(FieldElementsPerBlob) | |
b.ReportAllocs() | |
b.ResetTimer() | |
for i := 0; i < b.N; i++ { | |
ks.CommitToPoly(polynomial) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment