-
Notifications
You must be signed in to change notification settings - Fork 405
fix: count gas for TypedValue.Sprint and println #3921
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
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
also related: #3819. |
|
||
func (av *ArrayValue) ProtectedString(m *Machine, seen *seenValues) string { | ||
defer func() { | ||
// 7 characters for the array itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't follow where the value 7 comes from. What's the rationale? It seems like a magic number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return line array[]
ss := make([]string, len(av.List)) | ||
if av.Data == nil { | ||
for i, e := range av.List { | ||
ss[i] = e.ProtectedString(seen) | ||
m.GasMeter.ConsumeGas(OpCPUAssign, CPUCYCLES) | ||
ss[i] = e.ProtectedString(m, seen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this consumption? The elements should be consumed during their own visit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an assignement at the line below. Shouldn't we charge for it?
} | ||
// NOTE: we may want to unify the representation, | ||
// but for now tests expect this to be different. | ||
// This may be helpful for testing implementation behavior. | ||
m.GasMeter.ConsumeGas(OpCPUAssign, CPUCYCLES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not sure we should call .ConsumeGas in so many places.
Can we add a test to verify that gas is counted properly? |
Closes 3816