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

Improve documentation of error codes #418

Closed
wants to merge 6 commits into from
Closed
Changes from 1 commit
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
115 changes: 89 additions & 26 deletions docs/error_codes.md
Original file line number Diff line number Diff line change
@@ -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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

### 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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
Review this values and increase or reduce it according the current gas price and your requirements.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **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`.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
Provide as many as signatures as the owners threshold.
Copy link
Member

Choose a reason for hiding this comment

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

This is less about the signatures provide, more about the length of the bytes data. For this it probably makes sense to further explain how the signature data is created.

Copy link
Member Author

@moisses89 moisses89 Jul 18, 2022

Choose a reason for hiding this comment

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

Maybe instead add an example, add a doc link that contains examples:

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

What do you think?


- **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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
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).
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
Review the `s` value to point to correct data signature or add missing data signature.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS023: Invalid contract signature location:** data not complete
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS024: Invalid contract signature provided**
The EIP1271 signature provided is wrong.
Copy link
Member

Choose a reason for hiding this comment

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

WE should link the EIP here. Also please use EIP-1271 (which the -) ;)

If you don't want to use this type of signature review the `v` value (0 is equals to contract signature).
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
The `hash` to generate the `signature` must be calculated by the account address provided in `r` value.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS025: Hash has not been approved**
The address provided on 'r' has not the hash in the list of approved.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS026: Invalid owner provided**
Copy link
Member

Choose a reason for hiding this comment

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

We more info here. This error can happen also if the nonce has changed and therefore the Safe transaction hash is different than expected.

The owner provided doesn't exist for the `Safe`
Review that the owners provided on `r` exist and the owners are correctly sorted.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

### 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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
- **GS031: Method can only be called from this contract**
Wrong contract is trying to execute a non authorized method.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

### 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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS101: Invalid module address provided**
The module address provided cannot be `Zero` or `SENTINEL`.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS102: Module has already been added**
The module that are trying to add was added before.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS103: Invalid prevModule, module pair provided**
`prevModule` is not linked with `module` in the dynamic list.
Copy link
Member

Choose a reason for hiding this comment

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

prevModule is not the previous element to module in the module 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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **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.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

- **GS205: Invalid prevOwner, owner pair provided**
`prevOwner` is not linked with `owner` in the dynamic list.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved
Review that you are providing the correct values.
moisses89 marked this conversation as resolved.
Show resolved Hide resolved

### Guard management related
- `GS300`: `Guard does not implement IERC165`