-
Notifications
You must be signed in to change notification settings - Fork 450
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
Make config.MaxLogCalls dependant on some consensus param #2732
Conversation
00dd54f
to
e6b06fa
Compare
Codecov Report
@@ Coverage Diff @@
## master #2732 +/- ##
==========================================
- Coverage 47.09% 47.09% -0.01%
==========================================
Files 350 350
Lines 56309 56309
==========================================
- Hits 26520 26519 -1
Misses 26817 26817
- Partials 2972 2973 +1
Continue to review full report at Codecov.
|
config/consensus.go
Outdated
// MaxLogCalls is the highest allowable log messages that may appear in | ||
// any version, used for decoding purposes. Never decrease this value. | ||
const MaxLogCalls = 32 | ||
|
||
// MaxLogicSigMaxSize is the largest logical signature appear in any of the supported | ||
// protocols, used for decoding purposes. | ||
var MaxLogicSigMaxSize int |
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 want to move this one variable out when all the nearby values are of the same variety - they are not consensus parameters, rather they are conservative esitmates of the largest that some encoded message part can be. It's not just this variable that is like that.
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 problem with other values they are derived from consensus param, and this one is not because MaxLogCalls
not in consensus. In fact it should not be even called Max...
@@ -57,7 +57,7 @@ const MaxByteMathSize = 64 | |||
const MaxLogSize = 1024 | |||
|
|||
// MaxLogCalls is the limit of total log calls during a program execution | |||
const MaxLogCalls = config.MaxLogCalls | |||
const MaxLogCalls = 32 |
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.
By not using the same variable, the MaxEncodedTealLogCalls becomes completely "invisible". A reasonable person might make it so that teal v6 allows more logs calls, but preserves compatibility for v5 and below. They would not even know there is a place where we put alloc bounds on it.
Here's an entirely different proposal that I think is simple, correct, and the same as what we do elsewhere. Notice how we set the bounds on deltas:
// These bounds could be tighter, but since these values are just to
// prevent DoS, setting them to be the maximum number of allowed
// executed TEAL instructions should be fine (order of ~1000)
checkSetMax(p.MaxAppProgramLen, &MaxStateDeltaKeys)
checkSetMax(p.MaxAppProgramLen, &MaxEvalDeltaAccounts)
checkSetMax(p.MaxAppProgramLen, &MaxAppProgramLen)
This is wildly bigger than it needs to be, but we're only trying to avoid crazy huge DoS messages. So let's just set the bound on MaxLogCalls the same way. Add:
checkSetMax(p.MaxAppProgramLen, &MaxLogCalls)
Now it's derived from consensus and doesn't need to be revisited.
Although we have another problem - nowadays, I suppose these bounds are not as obviously correct as they used to be. You could loop, setting many keys, perhaps more that 1000. We could use the MaxAppCost, rather than MaxAppLen though, since that's what would stop us. (Though it would need to be MaxGroupSize*MaxAppCost. because of pooling)
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.
Looks reasonable, done
e6b06fa
to
25d4a28
Compare
* Commented some constants in teal evaluator and added a test enforcing their values and directing on how to change them if/when needed.
25d4a28
to
197cc22
Compare
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.
Seems good, glad we found middle ground.
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.
look good to me
Summary
enforcing their values and directing on how to change them if/when needed.
Test Plan
Existing tests