Skip to content

Commit

Permalink
add signature to topic count
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyonur committed Feb 27, 2024
1 parent e8f5cbf commit e1d9e93
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions accounts/abi/bind/precompilebind/precompile_event_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ accessibleState.GetStateDB().AddLog(
{{range .Contract.Events}}
{{$event := .}}
{{$createdDataStruct := false}}
{{$topicCount := 0}}
{{$topicCount := 1}}
{{- range .Normalized.Inputs}}
{{- if .Indexed}}
{{$topicCount = add $topicCount 1}}
Expand All @@ -81,8 +81,9 @@ accessibleState.GetStateDB().AddLog(
// The gas cost of the non-indexed data depends on the data type and the data size.
func Get{{.Normalized.Name}}EventGasCost({{if $createdDataStruct}} data {{.Normalized.Name}}EventData{{end}}) uint64 {
gas := contract.LogGas // base gas cost
{{if $topicCount | lt 0}}
{{if $topicCount | lt 1}}
// Add topics gas cost ({{$topicCount}} topics)
// Topics always include the signature hash of the event. The rest are the indexed event arguments.
gas += contract.LogTopicGas * {{$topicCount}}
{{end}}
Expand Down

0 comments on commit e1d9e93

Please sign in to comment.