Skip to content

Commit f27d1c6

Browse files
committed
Add more Seth docs to mdbook
1 parent 8242bcb commit f27d1c6

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

book/src/libs/seth.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ Reliable and debug-friendly Ethereum client
3636
15. [Bulk transaction tracing](#bulk-transaction-tracing)
3737
16. [RPC traffic logging](#rpc-traffic-logging)
3838
17. [Read-only mode](#read-only-mode)
39+
18. [ABI Finder](#abi-finder)
40+
19. [Contract Map](#contract-map)
41+
20. [Contract Store](#contract-store)
3942

4043
## Goals
4144

@@ -839,3 +842,47 @@ Additionally, when the client is build anc `cfg.ReadOnly = true` is set, we will
839842
* RPC health check is disabled
840843
* pending nonce protection is disabled
841844
* gas bumping is disabled
845+
846+
## ABI Finder
847+
848+
In order to be able to decode and trace transactions and calls between smart contracts we need their ABIs. Unfortunately it might happen that two or more contracts have methods with the same signatures, which might result in incorrect tracing. To make that problem less severe we have decided to add a single point of entry for contract deployment in Seth as that way we always know what contract is deployed at which address and thus avoid incorrect tracing due to potentially ambiguous method signatures.
849+
850+
1. We don’t know what contract (ABI) is located at a given address. Should be the case, when the contract either wasn’t uploaded via Seth or we haven’t supplied Seth with a contract map as part of its configuration (more on that later).
851+
852+
a. We sequentially iterate over all known ABIs (map: `name -> ABI_name`) checking whether it has a method with a given signature. Once we get a first match we will upsert that (`address -> ABI_name`) data into the contract map and return the ABI.
853+
854+
The caveat here is that if the method we are searching for belongs is present in more than one ABI we might associate the address with an incorrect address (we will use the first match).
855+
856+
b. If no match is found we will return an error.
857+
858+
2. We know what ABI is located at a given address. It should be the case, when we have either uploaded the contract via Seth, provided Seth with a contract map or already traced a transaction to that address and found an ABI with matching method signature.
859+
860+
a. We fetch the corresponding ABIand check if it indeed contains the method we are looking for (as mentioned earlier in some cases it might not be the case).
861+
862+
b. If it does, we return the ABI.
863+
864+
c. If it doesn’t we iterate over all known ABIs, in the same way as in 1a. If we find a match we update the (`address -> ABI_name`) association in the contract map and return the ABI.
865+
866+
It is possible that this will happen multiple times in case we have multiple contracts with multiple identical methods, but given a sufficiently diverse set of methods that were called we should eventually arrive at a fully correct contract map.
867+
868+
d. If no match is found we will return an error.
869+
870+
### Example
871+
872+
![tracing_example](./images/tracing_example.png)
873+
874+
## Contract Map
875+
876+
We support in-memory contract map and a TOML file contract map that keeps the association of (`address -> ABI_name`). The latter map is only used for non-simulated networks. Every time we deploy a contract we save (`address -> ABI_name`) entry in the in-memory map.If the network is not a simulated one we also save it in a file. That file can later be pointed to in Seth configuration and we will load the contract map from it (**currently without validating whether we have all the ABIs mentioned in the file**).
877+
878+
When saving contract deployment information we will either generate filename for you (if you didn’t configure Seth to use a particular file) using the pattern of `deployed_contracts_${network_name}_${timestamp}.toml` or use the filename provided in Seth TOML configuration file.
879+
880+
It has to be noted that the file contract map is currently updated only, when new contracts are deployed. There’s no mechanism for updating it if we found the mapping invalid (which might be the case if you manually created the entry in the file).
881+
882+
## Contract Store
883+
884+
Seth can be used with the contract store, but it would have very limited usage as transaction decoding and tracing cannot work with ABIs. Thus, when you initialise Seth with contract store it is necessary that it can load at least one ABI.
885+
886+
Another use of Contract Store is simplified contract deployment. For that we also need the contract's bytecode. The contract store can be used to store the bytecode of the contract and then deploy it using the `DeployContractFromContractStore(auth *bind.TransactOpts, name string, backend bind.ContractBackend, params ...interface{})` method. When Seth is intialisied with the contract store and no bytecode files (`*.bin`) are provided, it will log a warning, but initialise successfully nonetheless.
887+
888+
If bytecode file wasn't provided you need to use `DeployContract(auth *bind.TransactOpts, name string, abi abi.ABI, bytecode []byte, backend bind.ContractBackend, params ...interface{})` method, which expects you to provide contract name (best if equal to the name of the ABI file), bytecode and the ABI.

seth/docs/abi_finder_contract_map.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

seth/docs/contract_store.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)