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

Validate for duplicated names/addrs in precompile spec #132

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Changes from all commits
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
16 changes: 16 additions & 0 deletions suave/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ func main() {
return ff.Functions[i].Name < ff.Functions[j].Name
})

funcsByName := make(map[string]struct{})
funcsByAddr := make(map[string]struct{})
for _, f := range ff.Functions {
// validate that there are no two functions with the same name
if _, ok := funcsByName[f.Name]; ok {
panic(fmt.Sprintf("duplicate function name: %s", f.Name))
}
funcsByName[f.Name] = struct{}{}

// validate that there are no two functions with the same address
if _, ok := funcsByAddr[f.Address]; ok {
panic(fmt.Sprintf("duplicate function address: %s", f.Address))
}
funcsByAddr[f.Address] = struct{}{}
}

if err := applyTemplate(structsTemplate, ff, "./core/types/suave_structs.go"); err != nil {
panic(err)
}
Expand Down
Loading