From 66b8dd2c1bcfc349a706e322a61d2eadd176c543 Mon Sep 17 00:00:00 2001 From: moisses89 Date: Mon, 4 Jul 2022 11:49:45 +0200 Subject: [PATCH 1/6] Add more information to error documentation --- docs/error_codes.md | 115 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 89 insertions(+), 26 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index 8af4ed722..ebaac5c36 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -1,42 +1,105 @@ ## Error codes ### General init related -- `GS000`: `Could not finish initialization` -- `GS001`: `Threshold needs to be defined` +- **GS000: Could not finish initialization** + +- **GS001: Threshold needs to be defined** +Threshold is `equals to zero`, some error could happen during the Safe creation. ### General gas/ execution related -- `GS010`: `Not enough gas to execute Safe transaction` -- `GS011`: `Could not pay gas costs with ether` -- `GS012`: `Could not pay gas costs with token` -- `GS013`: `Safe transaction failed when gasPrice and safeTxGas were 0` +- **GS010: Not enough gas to execute Safe transaction** +SafeTxHash is too high or gas limit is too low to execute the transaction, remeber that `3000 gwei` are needed to events. +Review this values and increase or reduce it according the current gas price and your requirements. + +- **GS011: Could not pay gas costs with ether** +The transaction that you are trying to execute cannot be paid with `ether`. +Configure the correct token on gasToken parameter. + +- **GS012: Could not pay gas costs with token** +The transaction that you are trying to execute cannot be paid with the `token` configured on gasToken. +Configure the correct token on gasToken parameter or set it to 0 if you want use `ether`. + +- **GS013: Safe transaction failed when gasPrice and safeTxGas were 0** +This happen because the safe try to use all provided gas (gasLimit) but was insufficient. +Increase the gasLimit value and retry. ### General signature validation related -- `GS020`: `Signatures data too short` -- `GS021`: `Invalid contract signature location: inside static part` -- `GS022`: `Invalid contract signature location: length not present` -- `GS023`: `Invalid contract signature location: data not complete` -- `GS024`: `Invalid contract signature provided` -- `GS025`: `Hash has not been approved` -- `GS026`: `Invalid owner provided` +- **GS020: Signatures data too short** +There are less signatures that the owners threeshold. +Provide as many as signatures as the owners threshold. + +- **GS021: Invalid contract signature location:** inside static part +`s` value is pointing inside the static part, instead to dynamic part (should point to the corresponding data signature). +Review the value of `s` to point to the beggining of the correct signature. +More information about signatures: https://docs.gnosis-safe.io/contracts/signatures + +- **GS022: Invalid contract signature location:** length not present +`s` value is greater than the last position of signatures (is pointing to empty value). +Review the `s` value to point to correct data signature or add missing data signature. + +- **GS023: Invalid contract signature location:** data not complete + +- **GS024: Invalid contract signature provided** +The EIP1271 signature provided is wrong. +If you don't want to use this type of signature review the `v` value (0 is equals to contract signature). +The `hash` to generate the `signature` must be calculated by the account address provided in `r` value. + +- **GS025: Hash has not been approved** +The address provided on 'r' has not the hash in the list of approved. +If you want to pre-approve the `tx-hash` take a look that you are calculating correctly the `hash` with the correct owner and calling the method with the correct owner. + +- **GS026: Invalid owner provided** +The owner provided doesn't exist for the `Safe` +Review that the owners provided on `r` exist and the owners are correctly sorted. ### General auth related -- `GS030`: `Only owners can approve a hash` -- `GS031`: `Method can only be called from this contract` +- **GS030`: Only owners can approve a hash** +The sender is not an owner. +Review that are using the correct sender. +- **GS031: Method can only be called from this contract** +Wrong contract is trying to execute a non authorized method. ### Module management related -- `GS100`: `Modules have already been initialized` -- `GS101`: `Invalid module address provided` -- `GS102`: `Module has already been added` -- `GS103`: `Invalid prevModule, module pair provided` -- `GS104`: `Method can only be called from an enabled module` +- **GS100: Modules have already been initialized** +`setupModules` can be called once. + +- **GS101: Invalid module address provided** +The module address provided cannot be `Zero` or `SENTINEL`. + +- **GS102: Module has already been added** +The module that are trying to add was added before. + +- **GS103: Invalid prevModule, module pair provided** +`prevModule` is not linked with `module` in the dynamic list. +Review that you are providing the correct values. + +- **GS104: Method can only be called from an enabled module** + ### Owner management related -- `GS200`: `Owners have already been setup` -- `GS201`: `Threshold cannot exceed owner count` -- `GS202`: `Threshold needs to be greater than 0` -- `GS203`: `Invalid owner address provided` -- `GS204`: `Address is already an owner` -- `GS205`: `Invalid prevOwner, owner pair provided` +- **GS200: Owners have already been setup** +`setupOwners` can be called once. +If you want to add, swap or remove and owner use the correspond method: + - `adOwnerWithThreshold` + - `swapOwner` + - `removeOwner` + +- **GS201: Threshold cannot exceed owner count** +Sender is trying to configure a threshold greater than the total of owners or trying to remove an owner when the threshold is equals to the total of owners. + +- **GS202: Threshold needs to be greater than 0** +Sender is calling `changeThreshold` with 0. + +- **GS203: Invalid owner address provided** +The owner address provided cannot be `Zero`, `SENTINEL` or the current `safe` address. + +- **GS204: Address is already an owner** +Sender is trying to add an owner that was added before. +Review that are setting the correct owner address. + +- **GS205: Invalid prevOwner, owner pair provided** +`prevOwner` is not linked with `owner` in the dynamic list. +Review that you are providing the correct values. ### Guard management related - `GS300`: `Guard does not implement IERC165` From a848e5d0e6af90531af77f3af5fcf5cf9444e5c7 Mon Sep 17 00:00:00 2001 From: moisses89 Date: Wed, 6 Jul 2022 11:18:51 +0200 Subject: [PATCH 2/6] Improve information of error codes --- docs/error_codes.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index ebaac5c36..73405963c 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -4,20 +4,20 @@ - **GS000: Could not finish initialization** - **GS001: Threshold needs to be defined** -Threshold is `equals to zero`, some error could happen during the Safe creation. +Threshold is `equal to zero`, some error could happen during the Safe setup. ### General gas/ execution related - **GS010: Not enough gas to execute Safe transaction** -SafeTxHash is too high or gas limit is too low to execute the transaction, remeber that `3000 gwei` are needed to events. -Review this values and increase or reduce it according the current gas price and your requirements. +SafeTxHash is too high or gas limit is too low to execute the transaction, keep in mind that `2500 gwei` are needed to events and `500 gwei` to perform code until execution. +Review this values and increase the `gasLimit` or reduce the `safeTxHash` according the current gas price and your requirements. - **GS011: Could not pay gas costs with ether** -The transaction that you are trying to execute cannot be paid with `ether`. -Configure the correct token on gasToken parameter. +There are not enough funds of `ether` to execute the transaction. +Make sure that you have enough funds of `ether` or choose other token with enough funds setting it in `gasToken`. - **GS012: Could not pay gas costs with token** -The transaction that you are trying to execute cannot be paid with the `token` configured on gasToken. -Configure the correct token on gasToken parameter or set it to 0 if you want use `ether`. +There are not enough funds of the token choosen on `gasToken` to execute the transaction. +Make sure you have enough of the gasToken or set it to `address(0)` if you want use ether. - **GS013: Safe transaction failed when gasPrice and safeTxGas were 0** This happen because the safe try to use all provided gas (gasLimit) but was insufficient. @@ -70,16 +70,15 @@ The module address provided cannot be `Zero` or `SENTINEL`. The module that are trying to add was added before. - **GS103: Invalid prevModule, module pair provided** -`prevModule` is not linked with `module` in the dynamic list. -Review that you are providing the correct values. +`prevModule` is not the previous element to `module` in the module list. - **GS104: Method can only be called from an enabled module** ### Owner management related - **GS200: Owners have already been setup** -`setupOwners` can be called once. -If you want to add, swap or remove and owner use the correspond method: +`setupOwners` can only be called once. +If you want to add, swap or remove an owner use the corresponding method: - `adOwnerWithThreshold` - `swapOwner` - `removeOwner` @@ -91,15 +90,13 @@ Sender is trying to configure a threshold greater than the total of owners or tr Sender is calling `changeThreshold` with 0. - **GS203: Invalid owner address provided** -The owner address provided cannot be `Zero`, `SENTINEL` or the current `safe` address. +The owner address provided cannot be `address(0)`, sentinel address `address(1)` or the current `safe` address. - **GS204: Address is already an owner** Sender is trying to add an owner that was added before. -Review that are setting the correct owner address. - **GS205: Invalid prevOwner, owner pair provided** -`prevOwner` is not linked with `owner` in the dynamic list. -Review that you are providing the correct values. +`prevOwner` is not the previous element to `owner` in the owner list. ### Guard management related - `GS300`: `Guard does not implement IERC165` From d1850b50575fbb15d103d11cacd52bed8f2be677 Mon Sep 17 00:00:00 2001 From: moisses89 Date: Wed, 6 Jul 2022 16:54:13 +0200 Subject: [PATCH 3/6] Add more documentation and fix some errors --- docs/error_codes.md | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index 73405963c..a398143c3 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -8,8 +8,7 @@ Threshold is `equal to zero`, some error could happen during the Safe setup. ### General gas/ execution related - **GS010: Not enough gas to execute Safe transaction** -SafeTxHash is too high or gas limit is too low to execute the transaction, keep in mind that `2500 gwei` are needed to events and `500 gwei` to perform code until execution. -Review this values and increase the `gasLimit` or reduce the `safeTxHash` according the current gas price and your requirements. +SafeTxGas is too high or gas limit is too low to execute the transaction, keep in mind that `2500 gwei` are needed to events and `500 gwei` to perform code until execution. - **GS011: Could not pay gas costs with ether** There are not enough funds of `ether` to execute the transaction. @@ -20,54 +19,56 @@ There are not enough funds of the token choosen on `gasToken` to execute the tra Make sure you have enough of the gasToken or set it to `address(0)` if you want use ether. - **GS013: Safe transaction failed when gasPrice and safeTxGas were 0** -This happen because the safe try to use all provided gas (gasLimit) but was insufficient. -Increase the gasLimit value and retry. +Transaction is not succesful, this could be for due to multiple reasons. ### General signature validation related - **GS020: Signatures data too short** -There are less signatures that the owners threeshold. +There are less signatures than the owners threshold. Provide as many as signatures as the owners threshold. - **GS021: Invalid contract signature location:** inside static part -`s` value is pointing inside the static part, instead to dynamic part (should point to the corresponding data signature). -Review the value of `s` to point to the beggining of the correct signature. +Wrong contract `v=0` signature because `s` value is pointing inside the static part, instead to dynamic part (should point to the corresponding data signature). +Review the value of `s` to point to the begining of the correct signature. More information about signatures: https://docs.gnosis-safe.io/contracts/signatures - **GS022: Invalid contract signature location:** length not present -`s` value is greater than the last position of signatures (is pointing to empty value). -Review the `s` value to point to correct data signature or add missing data signature. +Wrong contract `v=0` signature because `s` value is greater than the last position of signatures (it's pointing to empty value). +Review s value to point to the correct data signature position or add the missing data signature. - **GS023: Invalid contract signature location:** data not complete +Wrong contract `v=0` signature because `startingPosition + contractSignatureLen` is out of bounds. - **GS024: Invalid contract signature provided** The EIP1271 signature provided is wrong. -If you don't want to use this type of signature review the `v` value (0 is equals to contract signature). -The `hash` to generate the `signature` must be calculated by the account address provided in `r` value. +If you don't want to use this type of signature review the `v` value (0 for a contract signature). +The `hash` to generate the `signature` must be calculated by the account address provided in `r` value. +More information about signatures: https://docs.gnosis-safe.io/contracts/signatures - **GS025: Hash has not been approved** -The address provided on 'r' has not the hash in the list of approved. -If you want to pre-approve the `tx-hash` take a look that you are calculating correctly the `hash` with the correct owner and calling the method with the correct owner. +The owner provided on 'r' has not pre-approved the safeTxHash. +To pre-approve the safeTxHash call `approveHash` with the safeTxHash calculated by the owner. - **GS026: Invalid owner provided** The owner provided doesn't exist for the `Safe` -Review that the owners provided on `r` exist and the owners are correctly sorted. +Review that the signing owners are owners of the Safe and signatures are correctly sorted ascending by the owner (without EIP55 encoding). ### General auth related - **GS030`: Only owners can approve a hash** The sender is not an owner. -Review that are using the correct sender. +Review that a correct owner is being used. + - **GS031: Method can only be called from this contract** -Wrong contract is trying to execute a non authorized method. +This method is only meant to be called from the contract itself. ### Module management related - **GS100: Modules have already been initialized** -`setupModules` can be called once. +`setupModules` can only be called once. - **GS101: Invalid module address provided** -The module address provided cannot be `Zero` or `SENTINEL`. +A module address cannot be zero address `address(0)` or sentinel address `address(1)`. - **GS102: Module has already been added** -The module that are trying to add was added before. +The module was added before. - **GS103: Invalid prevModule, module pair provided** `prevModule` is not the previous element to `module` in the module list. From 220d4785000a4114d48bd075adf0a6864b2c9727 Mon Sep 17 00:00:00 2001 From: moisses89 Date: Thu, 7 Jul 2022 13:32:35 +0200 Subject: [PATCH 4/6] Fix some mistakes --- docs/error_codes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index a398143c3..d8b1b3903 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -8,7 +8,7 @@ Threshold is `equal to zero`, some error could happen during the Safe setup. ### General gas/ execution related - **GS010: Not enough gas to execute Safe transaction** -SafeTxGas is too high or gas limit is too low to execute the transaction, keep in mind that `2500 gwei` are needed to events and `500 gwei` to perform code until execution. +SafeTxGas is too high or gas limit is too low to execute the transaction, keep in mind that we require some gas, at least `2500` is needed for events and at least `500` to perform code until execution. - **GS011: Could not pay gas costs with ether** There are not enough funds of `ether` to execute the transaction. @@ -28,12 +28,12 @@ Provide as many as signatures as the owners threshold. - **GS021: Invalid contract signature location:** inside static part Wrong contract `v=0` signature because `s` value is pointing inside the static part, instead to dynamic part (should point to the corresponding data signature). -Review the value of `s` to point to the begining of the correct signature. +Review the value of `s` to point to the beginning of the correct signature. More information about signatures: https://docs.gnosis-safe.io/contracts/signatures - **GS022: Invalid contract signature location:** length not present Wrong contract `v=0` signature because `s` value is greater than the last position of signatures (it's pointing to empty value). -Review s value to point to the correct data signature position or add the missing data signature. +Review `s` value points to the correct data signature position or add the missing data signature. - **GS023: Invalid contract signature location:** data not complete Wrong contract `v=0` signature because `startingPosition + contractSignatureLen` is out of bounds. From c704ae357063ef72f744ae6cbf5542d81b994c09 Mon Sep 17 00:00:00 2001 From: moisses89 Date: Mon, 18 Jul 2022 14:00:43 +0200 Subject: [PATCH 5/6] Add examples and link-docs --- docs/error_codes.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index d8b1b3903..ec797496c 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -23,13 +23,16 @@ Transaction is not succesful, this could be for due to multiple reasons. ### General signature validation related - **GS020: Signatures data too short** -There are less signatures than the owners threshold. -Provide as many as signatures as the owners threshold. +The length of required signatures is less than 65*threeshold. +Each signature has a constant length of 65 bytes `{32-bytes r}{32-bytes s}{1-byte v}`. If more data is necessary it can be appended to the end. +More information about signatures: +https://docs.gnosis-safe.io/contracts/signatures - **GS021: Invalid contract signature location:** inside static part Wrong contract `v=0` signature because `s` value is pointing inside the static part, instead to dynamic part (should point to the corresponding data signature). Review the value of `s` to point to the beginning of the correct signature. -More information about signatures: https://docs.gnosis-safe.io/contracts/signatures +More information about signatures: +https://docs.gnosis-safe.io/contracts/signatures - **GS022: Invalid contract signature location:** length not present Wrong contract `v=0` signature because `s` value is greater than the last position of signatures (it's pointing to empty value). @@ -39,14 +42,17 @@ Review `s` value points to the correct data signature position or add the missin Wrong contract `v=0` signature because `startingPosition + contractSignatureLen` is out of bounds. - **GS024: Invalid contract signature provided** -The EIP1271 signature provided is wrong. +The `EIP-1271` signature provided is wrong. If you don't want to use this type of signature review the `v` value (0 for a contract signature). The `hash` to generate the `signature` must be calculated by the account address provided in `r` value. -More information about signatures: https://docs.gnosis-safe.io/contracts/signatures +More information about signatures: +https://docs.gnosis-safe.io/contracts/signatures +https://eips.ethereum.org/EIPS/eip-1271 - **GS025: Hash has not been approved** The owner provided on 'r' has not pre-approved the safeTxHash. To pre-approve the safeTxHash call `approveHash` with the safeTxHash calculated by the owner. +This error could happen also if the nonce has changed and therefore the safeTxHash is different than expected. - **GS026: Invalid owner provided** The owner provided doesn't exist for the `Safe` @@ -58,7 +64,6 @@ The sender is not an owner. Review that a correct owner is being used. - **GS031: Method can only be called from this contract** -This method is only meant to be called from the contract itself. ### Module management related - **GS100: Modules have already been initialized** @@ -68,7 +73,6 @@ This method is only meant to be called from the contract itself. A module address cannot be zero address `address(0)` or sentinel address `address(1)`. - **GS102: Module has already been added** -The module was added before. - **GS103: Invalid prevModule, module pair provided** `prevModule` is not the previous element to `module` in the module list. @@ -94,7 +98,6 @@ Sender is calling `changeThreshold` with 0. The owner address provided cannot be `address(0)`, sentinel address `address(1)` or the current `safe` address. - **GS204: Address is already an owner** -Sender is trying to add an owner that was added before. - **GS205: Invalid prevOwner, owner pair provided** `prevOwner` is not the previous element to `owner` in the owner list. From 9606fbea61d6add85106e8c16830a8be0571afcd Mon Sep 17 00:00:00 2001 From: moisses89 Date: Wed, 20 Jul 2022 10:39:41 +0200 Subject: [PATCH 6/6] Fix minor issues in documentation --- docs/error_codes.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/error_codes.md b/docs/error_codes.md index ec797496c..e8edd79e1 100644 --- a/docs/error_codes.md +++ b/docs/error_codes.md @@ -37,7 +37,9 @@ https://docs.gnosis-safe.io/contracts/signatures - **GS022: Invalid contract signature location:** length not present Wrong contract `v=0` signature because `s` value is greater than the last position of signatures (it's pointing to empty value). Review `s` value points to the correct data signature position or add the missing data signature. - +More information about contract signature: +https://docs.gnosis-safe.io/contracts/signatures + - **GS023: Invalid contract signature location:** data not complete Wrong contract `v=0` signature because `startingPosition + contractSignatureLen` is out of bounds. @@ -50,13 +52,13 @@ https://docs.gnosis-safe.io/contracts/signatures https://eips.ethereum.org/EIPS/eip-1271 - **GS025: Hash has not been approved** -The owner provided on 'r' has not pre-approved the safeTxHash. +The owner provided on `r` has not pre-approved the safeTxHash. To pre-approve the safeTxHash call `approveHash` with the safeTxHash calculated by the owner. This error could happen also if the nonce has changed and therefore the safeTxHash is different than expected. - **GS026: Invalid owner provided** The owner provided doesn't exist for the `Safe` -Review that the signing owners are owners of the Safe and signatures are correctly sorted ascending by the owner (without EIP55 encoding). +Review that the signing owners are owners of the Safe and signatures are correctly sorted ascending by the owner (without `EIP-55` encoding). ### General auth related - **GS030`: Only owners can approve a hash** @@ -81,8 +83,8 @@ A module address cannot be zero address `address(0)` or sentinel address `addres ### Owner management related -- **GS200: Owners have already been setup** -`setupOwners` can only be called once. +- **GS200: Owners have already been setup** +`setupOwners` can only be called once. If you want to add, swap or remove an owner use the corresponding method: - `adOwnerWithThreshold` - `swapOwner`