diff --git a/accounts/abi/bind/precompilebind/precompile_event_template.go b/accounts/abi/bind/precompilebind/precompile_event_template.go index 469a44d601..3a5582b35e 100644 --- a/accounts/abi/bind/precompilebind/precompile_event_template.go +++ b/accounts/abi/bind/precompilebind/precompile_event_template.go @@ -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}} @@ -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}}