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

hardcoded in a few of the keccakd constants #459

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"search.exclude": { "lib": true },
"files.associations": {
".gas-snapshot": "julia"
}
},
"makefile.configureOnOpen": false
}
3 changes: 1 addition & 2 deletions src/contracts/examples/v4-example/V4DAppControl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ contract V4DAppControl is DAppControl {
} else {
if (params.amountSpecified > 0) {
// Buying Pool's token0 with amountSpecified of User's token1
}
else {
} else {
// Buying amountSpecified of Pool's token0 with User's token1
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/contracts/types/AtlasConstants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ contract AtlasConstants {
// ------------------------------------------------------- //

// Atlas constants
uint256 internal constant _GAS_VALUE_DECIMALS_TO_DROP = 1e9; // measured in gwei
uint256 internal constant _GAS_VALUE_DECIMALS_TO_DROP = 0x3b9aca00; // 1e9; // measured in gwei
uint256 internal constant _UNLOCKED = 0;

// Atlas constants used in `_bidFindingIteration()`
uint256 internal constant _BITS_FOR_INDEX = 16;
uint256 internal constant _FIRST_16_BITS_TRUE_MASK = uint256(0xFFFF);
uint256 internal constant _FIRST_16_BITS_TRUE_MASK = 0xFFFF;

// Escrow constants
uint256 internal constant _VALIDATION_GAS_LIMIT = 500_000;
Expand All @@ -35,12 +35,13 @@ contract AtlasConstants {
// First 160 bits of _solverLock are the address of the current solver.
// The 161st bit represents whether the solver has called back via `reconcile`.
// The 162nd bit represents whether the solver's outstanding debt has been repaid via `reconcile`.
uint256 internal constant _SOLVER_CALLED_BACK_MASK = 1 << 161;
uint256 internal constant _SOLVER_FULFILLED_MASK = 1 << 162;
uint256 internal constant _SOLVER_CALLED_BACK_MASK =
2_923_003_274_661_805_836_407_369_665_432_566_039_311_865_085_952; // 1 << 161;
uint256 internal constant _SOLVER_FULFILLED_MASK = 5_846_006_549_323_611_672_814_739_330_865_132_078_623_730_171_904; // 1
// << 162;

// Used to set Lock phase without changing the activeEnvironment or callConfig.
uint256 internal constant _LOCK_PHASE_MASK =
uint256(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00);
uint256 internal constant _LOCK_PHASE_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00;

// ValidCalls error threshold before which the metacall reverts, and after which it returns gracefully to store
// nonces as used.
Expand All @@ -50,5 +51,5 @@ contract AtlasConstants {
// ATLAS VERIFICATION CONSTANTS //
// ------------------------------------------------------- //

uint8 internal constant _MAX_SOLVERS = type(uint8).max - 1;
uint8 internal constant _MAX_SOLVERS = 254; // type(uint8).max - 1;
}
6 changes: 3 additions & 3 deletions src/contracts/types/DAppOperation.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

bytes32 constant DAPP_TYPEHASH = keccak256(
"DAppOperation(address from,address to,uint256 nonce,uint256 deadline,address control,address bundler,bytes32 userOpHash,bytes32 callChainHash)"
);
//keccak256("DAppOperation(address from,address to,uint256 nonce,uint256 deadline,address control,address
// bundler,bytes32 userOpHash,bytes32 callChainHash)");
bytes32 constant DAPP_TYPEHASH = 0x88ef8fc82c1c9cd8c70c0ba2062b71d8e01324e34aea7264c6a6f2220a2e21a5;

struct DAppOperation {
address from; // signer of the DAppOperation
Expand Down
6 changes: 3 additions & 3 deletions src/contracts/types/SolverOperation.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.28;

bytes32 constant SOLVER_TYPEHASH = keccak256(
"SolverOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 deadline,address solver,address control,bytes32 userOpHash,address bidToken,uint256 bidAmount,bytes data)"
);
// keccak256("SolverOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256
// deadline,address solver,address control,bytes32 userOpHash,address bidToken,uint256 bidAmount,bytes data)");
bytes32 constant SOLVER_TYPEHASH = 0x57d8655e41f8b345d65e4e5aad590481b56d0ebc5b7a589653f3f46f30ba3076;

// NOTE: The calldata length of this SolverOperation struct is 608 bytes when the `data` field is excluded. This value
// is stored in the `_SOLVER_OP_BASE_CALLDATA` constant in AtlasConstants.sol and must be kept up-to-date with any
Expand Down
12 changes: 6 additions & 6 deletions src/contracts/types/UserOperation.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
pragma solidity 0.8.28;

// Default UserOperation typehash
bytes32 constant USER_TYPEHASH_DEFAULT = keccak256(
"UserOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 nonce,uint256 deadline,address dapp,address control,uint32 callConfig,address sessionKey,bytes data)"
);
// keccak256("UserOperation(address from,address to,uint256 value,uint256 gas,uint256 maxFeePerGas,uint256 nonce,uint256
// deadline,address dapp,address control,uint32 callConfig,address sessionKey,bytes data)");
bytes32 constant USER_TYPEHASH_DEFAULT = 0xf31c75b3100e5767eb039f15afcdf4cefd3b35ea6ae27ffc4135a27b83d0610e;

// Trusted UserOperation typehash
// NOTE: This is explicitly for the 'trustedOpHash' configuration option meant so that solvers can submit
// SolverOperations
// prior to seeing the UserOperation or its hash. In this scenario, the Solvers should trust the signer of the
// UserOperation.
bytes32 constant USER_TYPEHASH_TRUSTED = keccak256(
"UserOperation(address from,address to,address dapp,address control,uint32 callConfig,address sessionKey)"
);
// keccak256("UserOperation(address from,address to,address dapp,address control,uint32 callConfig,address
// sessionKey)");
bytes32 constant USER_TYPEHASH_TRUSTED = 0xca1d2fd72c857f54b9c8b2576463534d8f4df0fcd25f408c17991285b16ca41a;

struct UserOperation {
address from; // User address
Expand Down
Loading