From c8e14388e478471411abb10f3a99ab3bd9206a95 Mon Sep 17 00:00:00 2001 From: katzman Date: Tue, 9 Apr 2024 12:08:32 -0700 Subject: [PATCH] Add clearer messaging around the risks of overwriting _getNonce (#70) * Add clearer messaging around the risks of overwriting _getNonce * Update MultisigBase.sol Improve clarity of comment --- script/universal/MultisigBase.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/script/universal/MultisigBase.sol b/script/universal/MultisigBase.sol index 193c100..853fb74 100644 --- a/script/universal/MultisigBase.sol +++ b/script/universal/MultisigBase.sol @@ -21,6 +21,12 @@ abstract contract MultisigBase is Simulator { // Virtual method which can be overwritten // Default logic here is vestigial for backwards compatibility + // IMPORTANT: this method is used in the sign, simulate, AND execution contexts + // If you override it, ensure that the behavior is correct for all contexts + // As an example, if you are pre-signing a message that needs safe.nonce+1 (before safe.nonce is executed), + // you should explicitly set the nonce value with an env var. + // Overwriting this method with safe.nonce + 1 will cause issues upon execution because the transaction + // hash will differ from the one signed. function _getNonce(IGnosisSafe safe) internal view virtual returns (uint256 nonce) { nonce = safe.nonce(); console.log("Safe current nonce:", nonce);