Skip to content

Commit 57ee135

Browse files
ecPabloCopilot
andauthored
feat: add support for eip 1967 proxy decoding of implementation contract [DPT-108] (#559)
This pull request adds support for decoding proposals that use EIP-1967 proxies, enabling the analyzer to correctly handle transactions routed through proxy contracts. It introduces logic to detect EIP-1967 proxies, query their implementation addresses, and decode transactions using the implementation contract's ABI. Several interfaces and functions have been updated to support this feature, and related CLI commands and tests have been refactored to pass the necessary context and environment. **EIP-1967 Proxy Decoding Support** * Added logic in `experimental/analyzer/evm_analyzer.go` to detect EIP-1967 proxies, query the implementation address from the proxy's storage slot, and retry transaction decoding using the implementation's ABI. This includes helper functions for error detection, storage querying, and address book lookup. [[1]](diffhunk://#diff-d05cb08f5758df1d4fe8c917b80a15ba5a039afa96389c8a658cc9640bc69bd8R4-R26) [[2]](diffhunk://#diff-d05cb08f5758df1d4fe8c917b80a15ba5a039afa96389c8a658cc9640bc69bd8R67-R79) [[3]](diffhunk://#diff-d05cb08f5758df1d4fe8c917b80a15ba5a039afa96389c8a658cc9640bc69bd8R144-R274) **Interface and Function Refactoring** * Updated the `OnchainClient` interface in `chain/evm/evm_chain.go` to include a `StorageAt` method for reading contract storage slots, required for EIP-1967 detection. * Added a retrying implementation of `StorageAt` in `chain/evm/provider/rpcclient/multiclient.go`. * Refactored analyzer and report builder functions to accept `context.Context`, `ProposalContext`, and `deployment.Environment` parameters, enabling access to chain clients and address books for proxy decoding. [[1]](diffhunk://#diff-ff37930dedd57e6d416bf12ffbf08b8d4f98cea09a9b4583077aab2ce25210a9R4-R12) [[2]](diffhunk://#diff-ff37930dedd57e6d416bf12ffbf08b8d4f98cea09a9b4583077aab2ce25210a9L19-R29) [[3]](diffhunk://#diff-ff37930dedd57e6d416bf12ffbf08b8d4f98cea09a9b4583077aab2ce25210a9L36-R42) [[4]](diffhunk://#diff-7508803ab51e1e56d089e5224e2594cd0fb2ba5e66c768f3a05d9d1866ed9d28R4-R15) [[5]](diffhunk://#diff-7508803ab51e1e56d089e5224e2594cd0fb2ba5e66c768f3a05d9d1866ed9d28L25-R46) [[6]](diffhunk://#diff-7508803ab51e1e56d089e5224e2594cd0fb2ba5e66c768f3a05d9d1866ed9d28L64-R67) **CLI and Test Updates** * Updated CLI command implementations and tests to pass the new context and environment parameters to analyzer functions, ensuring compatibility with the new proxy decoding logic. [[1]](diffhunk://#diff-726dd799d05204c24b69b8bda1f4ede5393c5955b360b076db8d11bc01f56a1bL741-R743) [[2]](diffhunk://#diff-726dd799d05204c24b69b8bda1f4ede5393c5955b360b076db8d11bc01f56a1bL885-R887) [[3]](diffhunk://#diff-3818b4d496d99fec18364a7b0e6c7fcccbd4055c3d9b4f0adf35851350b2a89cL200-R200) [[4]](diffhunk://#diff-96db697e4922f8c507f56e4baaf253b0fa188dceeb762abe29657beb0e98c4d9L182-R182) [[5]](diffhunk://#diff-7b54608514607b52f696bac5ff122a5066d4315786095039743c5a1e4cb10924L17-R17) [[6]](diffhunk://#diff-7b54608514607b52f696bac5ff122a5066d4315786095039743c5a1e4cb10924L91-R91) [[7]](diffhunk://#diff-7b54608514607b52f696bac5ff122a5066d4315786095039743c5a1e4cb10924L115-R115) [[8]](diffhunk://#diff-7b54608514607b52f696bac5ff122a5066d4315786095039743c5a1e4cb10924L197-R197) **Documentation** * Added a changeset documenting the new EIP-1967 proxy decoding support for the `chainlink-deployments-framework` package. --------- Co-authored-by: Copilot <[email protected]>
1 parent dc2c113 commit 57ee135

File tree

17 files changed

+2516
-125
lines changed

17 files changed

+2516
-125
lines changed

.changeset/floppy-trams-kiss.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"chainlink-deployments-framework": minor
3+
---
4+
5+
Add support to decode proposals that use EIP-1967 proxies

.mockery.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,19 @@ packages:
9191
MutableRefStoreV2:
9292
MutableStoreV2:
9393
MutableUnaryStoreV2:
94+
github.com/smartcontractkit/chainlink-deployments-framework/chain/evm:
95+
config:
96+
all: false
97+
dir: "{{.InterfaceDir}}"
98+
filename: "mock_{{.InterfaceName | snakecase}}.go"
99+
structname: "{{.Mock}}{{.InterfaceName}}"
100+
interfaces:
101+
OnchainClient:
102+
github.com/smartcontractkit/chainlink-deployments-framework/experimental/analyzer:
103+
config:
104+
all: false
105+
dir: "{{.InterfaceDir}}"
106+
filename: "mock_{{.InterfaceName | snakecase}}.go"
107+
structname: "{{.Mock}}{{.InterfaceName}}"
108+
interfaces:
109+
ProposalContext:

chain/evm/evm_chain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ type OnchainClient interface {
2525

2626
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
2727
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
28+
// StorageAt reads a storage slot from the given account at the specified block number.
29+
// This is needed for operations like EIP-1967 proxy detection.
30+
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
2831
}
2932

3033
// Chain represents an EVM chain.

0 commit comments

Comments
 (0)