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

feat: Refactor filtering and adding std dev filter #300

Merged
merged 30 commits into from
Jul 24, 2024

Conversation

hacheigriega
Copy link
Member

@hacheigriega hacheigriega commented Jul 9, 2024

Explanation of Changes

Fixing issues identified during devnet testing

  • Consensus is always set to false if tally VM does not run even if filtering result gives consensus = true.
  • Handle the case when reveal value is not found at a given JSON path.
  • Invalid JSON path, invalid reveal encoding, and non-zero exit code should all be treated as "corrupt reveals."
  • Add events
  • Hex-encode tally VM inputs.

This PR also refactors filtering and adds a new filter standard deviation.

  • Make use of a new interface type Filter to clean up the code.
  • Add standard deviation filter

Closes: #284
Closes: #286

if maxFreq*3 < len(reveals)*2 {
return outliers, false, nil
}

for i, r := range revealVals {
if freq[r] != maxFreq || reveals[i].ExitCode != 0 {
continue
if freq[r] == maxFreq {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning was that since we know at this point that

  • Corrupt reveals are <= 1/3
  • Max frequency occurs >= 2/3

=> corrupt reveals can never have the frequency of maxFreq.

@hacheigriega hacheigriega changed the title fix: Mode filter fix and refactor feat: Refactor filtering and adding std dev filter Jul 9, 2024
@hacheigriega hacheigriega marked this pull request as draft July 9, 2024 21:55
@hacheigriega hacheigriega marked this pull request as ready for review July 12, 2024 21:01
Copy link
Member

@Thomasvdam Thomasvdam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a high level the code makes sense to me (as names of functions, location in files, etc). I need to take a real close look at the filters: how they determine consensus and if this aligns with what Franklin and Mario have in mind. I'm not sharp enough right now, so I'll have a look tomorrow together with Franklin.

@hacheigriega
Copy link
Member Author

@Thomasvdam Sounds good and thanks. I'll have this PR fully ready for review by then. I will also share a flow chart I drew.

@hacheigriega
Copy link
Member Author

x/wasm-storage/keeper/abci.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
@FranklinWaller
Copy link
Member

Review was together done with @Thomasvdam btw

@hacheigriega
Copy link
Member Author

Ready for final review. The simulation test fails due to its inherent instability. We will have to wait for Cosmos team's simulation test refactoring.

x/wasm-storage/keeper/abci_test.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter_test.go Outdated Show resolved Hide resolved
x/wasm-storage/keeper/filter_test.go Outdated Show resolved Hide resolved
x/wasm-storage/types/sigma.go Show resolved Hide resolved
x/wasm-storage/types/filters.go Outdated Show resolved Hide resolved
@hacheigriega
Copy link
Member Author

@Thomasvdam Oh yes you're right. I thought we were assuming that the results would be base64-encoded, but I realized that I came up with that assumption myself. We should probably use JSON number for this instead, huh?

@Thomasvdam
Copy link
Member

Yeah I think so :)

@hacheigriega
Copy link
Member Author

hacheigriega commented Jul 19, 2024

Yeah I think so :)

Fixed in 482764d. parseReveals() parses any values into strings, which then are parsed into integers using strconv functions in the standard deviation filter. So for example both 4 and "4" work. EDIT: Deleted outdated info

x/wasm-storage/keeper/filter.go Outdated Show resolved Hide resolved
x/wasm-storage/types/filters.go Show resolved Hide resolved
x/wasm-storage/types/filters_util.go Outdated Show resolved Hide resolved
x/wasm-storage/types/sigma.go Show resolved Hide resolved
x/wasm-storage/types/filters.go Show resolved Hide resolved
@hacheigriega hacheigriega requested a review from Thomasvdam July 23, 2024 13:41
@hacheigriega hacheigriega merged commit 4334f73 into main Jul 24, 2024
16 of 17 checks passed
@hacheigriega hacheigriega deleted the hy/filter-refactor branch July 24, 2024 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Decode filtering ✨ Add filter types Mode and StdDev
4 participants