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

fix: cache and fallback only work for OptimismGeneric and SimpleCommitment modes #156

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mcortesi
Copy link
Contributor

Put for OptimismKeccak was broken, since commit was nil.

Checking and how Get() works, neither cache or fallback are possible. So what makes sense is that on Put() we don't try to write to neither of those for this mode.

@samlaf
Copy link
Collaborator

samlaf commented Sep 27, 2024

@epociask I think this is true right? cache and fallback don't make sense in keccak commitment case, since s3 is the main storage engine for keccak commitments? Unless there's a way to put a redis cache in front of the s3 reason for whatever reason?

@epociask
Copy link
Collaborator

@mcortesi how would a commitment ever be nil for keccak if we're returning up the call-stack via putWithKey and never touching downstream secondary storage insertions? If not mistaken the proposed changes are isomorphic with the existing implementation

@mcortesi
Copy link
Contributor Author

@epociask the local variable commit which is then passed to HandleRedundanWrites() is only ever set as the result of putWithoutKey().

@epociask
Copy link
Collaborator

@mcortesi that is the intended behavior - we treat S3 or keccak256 commitment mode with less prestige since our initial reasons for supporting it was to enable a migration path from keccak to eigenda commitment modes for OP Stack

@mcortesi
Copy link
Contributor Author

mcortesi commented Oct 1, 2024

@epociask i understand that...

but if i call Put() with commitments.OptimismKeccak mode; and cache or fallback enabled you end up calling HandleRedudndateWrites() with nil, which will fail or have some weird behaviour.

Again, too much discussion for just some clean up really.

To me, the change means safer/more clear code. But if you don't agree, or feel it's unnecessary and are happy sending nil to function that don't expect that 🤷‍♂️. I think we are spending more time writing comments that coding it :)

}

if r.cacheEnabled() || r.fallbackEnabled() {
// FIXME commit here might be nil for OptimismKeccak mode
Copy link
Collaborator

Choose a reason for hiding this comment

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

OptimismKeccak mode never reaches this code. I'm confused by this comment.

@samlaf
Copy link
Collaborator

samlaf commented Oct 16, 2024

Hey @mcortesi just catching up here, sorry for the delay. I agree with the refactor because I think it makes the code clearer and less bug-prone to future changes, but I disagree with your reasoning. You must have missed the return statement in the OptimismKeccak case?

	case commitments.OptimismKeccak: // caching and fallbacks are unsupported for this commitment mode
		return r.putWithKey(ctx, key, value)

Hence

but if i call Put() with commitments.OptimismKeccak mode; and cache or fallback enabled you end up calling HandleRedudndateWrites() with nil, which will fail or have some weird behaviour.

is just not possible.

But please just fix the lint error, and remove the FIXME in the code which is confusing, and then we can merge this :)

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