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

Add metrics for counter and time spent on a suave precompile #41

Merged
merged 2 commits into from
Sep 25, 2023

Conversation

ferranbt
Copy link
Collaborator

@ferranbt ferranbt commented Sep 21, 2023

📝 Summary

This PR enables metrics to track how many times a SUAVE precompile gets called and how much time does it take to execute it.

📚 References


  • I have seen and agree to CONTRIBUTING.md

@@ -51,6 +54,16 @@ func (p *SuavePrecompiledContractWrapper) Run(input []byte) ([]byte, error) {
},
}

if metrics.EnabledExpensive {
precompileName := artifacts.ResolvePrecompileAddr(p.addr)
metrics.GetOrRegisterMeter("suave/runtime/"+precompileName, nil).Mark(1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feel free to propose another naming for the metric.

@@ -303,9 +303,22 @@ import (
"github.com/ethereum/go-ethereum/common"
)

// List of suave precompile addresses
var ( {{range .Functions}}{{.Name}}Addr = common.HexToAddress("{{.Address}}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The same thing is done in #40. Once both things are merged I will consolidate this in a single place.

"submitEthBlockBidToRelay": submitEthBlockBidToRelayAddr,
}

func ResolvePrecompileAddr(addr common.Address) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

perhaps more explicit could be PrecompileAddressToName?

@ferranbt ferranbt merged commit f1f54b8 into main Sep 25, 2023
4 checks passed
@ferranbt ferranbt deleted the suave-metrics/precompile-counter-timer branch September 25, 2023 08:15
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.

3 participants