We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
We current do the following sorting of evm event logs in octane:
topicI := slices.Concat(events[i].Topics...) topicJ := slices.Concat(events[j].Topics...) if cmp := bytes.Compare(topicI, topicJ); cmp != 0 { return cmp < 0 }
The spearbit audit raised that this could be replaced with:
if cmp := slices.CompareFunc(events[i].Topics, events[j].Topics, bytes.Compare); cmp != 0 { return cmp < 0 }
The suggestion is simpler and more performant, but introduces slightly different logic in some edge cases.
Replace this logic during the next network upgrade. Bumping evmengine consensus version by 1.
The text was updated successfully, but these errors were encountered:
Here's one example where the functions produce different results:
package main import ( "bytes" "fmt" "slices" ) func compareConcat(a, b [][]byte) bool { concatA := slices.Concat(a...) concatB := slices.Concat(b...) if cmp := bytes.Compare(concatA, concatB); cmp != 0 { return cmp < 0 } return false } func compareFunc(a, b [][]byte) bool { if cmp := slices.CompareFunc(a, b, bytes.Compare); cmp != 0 { return cmp < 0 } return false } func main() { slicesOfBytes := []struct { a, b [][]byte }{ // same result {[][]byte{[]byte("a")}, [][]byte{[]byte("b"), []byte("c")}}, // different results {[][]byte{[]byte("a")}, [][]byte{[]byte(""), []byte("bc")}}, } fmt.Println("Comparing slices with Concat method:") for _, pair := range slicesOfBytes { fmt.Printf("compareConcat(%v, %v) = %v\n", pair.a, pair.b, compareConcat(pair.a, pair.b)) } for _, pair := range slicesOfBytes { fmt.Printf("compareFunc(%v, %v) = %v\n", pair.a, pair.b, compareFunc(pair.a, pair.b)) } }
Sorry, something went wrong.
Actually, sorting events in a different order than original isn't valid, see piplabs/story#301. Closing in favour of #2106
No branches or pull requests
Problem to Solve
We current do the following sorting of evm event logs in octane:
The spearbit audit raised that this could be replaced with:
The suggestion is simpler and more performant, but introduces slightly different logic in some edge cases.
Proposed Solution
Replace this logic during the next network upgrade. Bumping evmengine consensus version by 1.
The text was updated successfully, but these errors were encountered: