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

idea: Interchangeable query mode #491

Open
wei3erHase opened this issue Apr 11, 2024 · 1 comment
Open

idea: Interchangeable query mode #491

wei3erHase opened this issue Apr 11, 2024 · 1 comment

Comments

@wei3erHase
Copy link
Collaborator

The current queryMode relies now in 2 conditions, vaultState.isQueryDisabled and EVMCallModeHelpers.isStaticCall() (which checks tx.origin == 0, as proof of static call). The reason for isQueryDisabled is that, on a shady EVM in which tx.origin could in fact be address(0), it can be disabled to avoid rugs.

Query mode is not even testable in foundry, since mocking the tx.origin is tricky, then it creates the must of having Hardhat tests (which imo, should not be there and save us hrs of compiling + running tests).

The idea I've got is: just one more proxy implementation bro, one more..
Vault -> Extension -> Admin -> ActivateQueryMode

Why? because we don't care about the gas consumption of activating vaultState.isQueryEnabled.

contract ActivateQueryMode {
   function queryMode() external onlyVault {
        require(tx.origin == 0);
        vaultState.isQueryEnabled = true;
    }
}

In this way, we can replace ActivateQueryMode contract with anything, for tests for example, we skip the require, for shady EVMs, we add requirement conditions, we allow this contract to be different from implementation to implementation, w/o having to change the core codebase (or even adding logic to it).

@jubeira
Copy link
Contributor

jubeira commented Apr 29, 2024

Interesting idea @wei3erHase.

Query mode is not even testable in foundry, since mocking the tx.origin is tricky, then it creates the must of having Hardhat tests (which imo, should not be there and save us hrs of compiling + running tests).

Is that really the case though? I understand you can also prank the origin: https://book.getfoundry.sh/cheatcodes/start-prank. Would that tilt the scales?

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

No branches or pull requests

2 participants