-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ccip-3398 populate state initial PR (#14391)
* initial draft * individual snapshot * change interface name * changes * add all destchainselectors * rmn details * more changes * omitempty * add onRamp reader * changes * format errors * add Feequoter * change approach direct go-binding reference * fix import cycle * moduler * fix panic * add interface for snapshot * more changes * rename * fix lint * more review comments * fix rmnremote version * one more fix --------- Co-authored-by: Oliver Townsend <[email protected]>
- Loading branch information
1 parent
10f7aab
commit 674605e
Showing
12 changed files
with
579 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package view | ||
|
||
import ( | ||
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_2" | ||
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_5" | ||
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/v1_6" | ||
) | ||
|
||
type ChainView struct { | ||
TokenAdminRegistry map[string]v1_5.TokenAdminRegistryView `json:"tokenAdminRegistry,omitempty"` | ||
FeeQuoter map[string]v1_6.FeeQuoterView `json:"feeQuoter,omitempty"` | ||
NonceManager map[string]v1_6.NonceManagerView `json:"nonceManager,omitempty"` | ||
Router map[string]v1_2.RouterView `json:"router,omitempty"` | ||
RMN map[string]v1_6.RMNRemoteView `json:"rmn,omitempty"` | ||
OnRamp map[string]v1_6.OnRampView `json:"onRamp,omitempty"` | ||
} | ||
|
||
func NewChain() ChainView { | ||
return ChainView{ | ||
TokenAdminRegistry: make(map[string]v1_5.TokenAdminRegistryView), | ||
NonceManager: make(map[string]v1_6.NonceManagerView), | ||
Router: make(map[string]v1_2.RouterView), | ||
RMN: make(map[string]v1_6.RMNRemoteView), | ||
OnRamp: make(map[string]v1_6.OnRampView), | ||
FeeQuoter: make(map[string]v1_6.FeeQuoterView), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package view | ||
|
||
type CCIPView struct { | ||
Chains map[string]ChainView `json:"chains,omitempty"` | ||
} | ||
|
||
func NewCCIPView() CCIPView { | ||
return CCIPView{ | ||
Chains: make(map[string]ChainView), | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
integration-tests/deployment/ccip/view/types/contract_state.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/accounts/abi/bind" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
type ContractMetaData struct { | ||
TypeAndVersion string `json:"typeAndVersion,omitempty"` | ||
Address common.Address `json:"address,omitempty"` | ||
Owner common.Address `json:"owner,omitempty"` | ||
} | ||
|
||
func NewContractMetaData(tv Meta, addr common.Address) (ContractMetaData, error) { | ||
tvStr, err := tv.TypeAndVersion(nil) | ||
if err != nil { | ||
return ContractMetaData{}, err | ||
} | ||
owner, err := tv.Owner(nil) | ||
if err != nil { | ||
return ContractMetaData{}, err | ||
} | ||
return ContractMetaData{ | ||
TypeAndVersion: tvStr, | ||
Address: addr, | ||
Owner: owner, | ||
}, nil | ||
} | ||
|
||
type Meta interface { | ||
TypeAndVersion(opts *bind.CallOpts) (string, error) | ||
Owner(opts *bind.CallOpts) (common.Address, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package v1_2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/smartcontractkit/chainlink/integration-tests/deployment/ccip/view/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/router" | ||
) | ||
|
||
type RouterView struct { | ||
types.ContractMetaData | ||
WrappedNative common.Address `json:"wrappedNative,omitempty"` | ||
ARMProxy common.Address `json:"armProxy,omitempty"` | ||
OnRamps map[uint64]common.Address `json:"onRamps,omitempty"` // Map of DestinationChainSelectors to OnRamp Addresses | ||
OffRamps map[uint64]common.Address `json:"offRamps,omitempty"` // Map of SourceChainSelectors to a list of OffRamp Addresses | ||
} | ||
|
||
func GenerateRouterView(r *router.Router) (RouterView, error) { | ||
meta, err := types.NewContractMetaData(r, r.Address()) | ||
if err != nil { | ||
return RouterView{}, fmt.Errorf("view error to get router metadata: %w", err) | ||
} | ||
wrappedNative, err := r.GetWrappedNative(nil) | ||
if err != nil { | ||
return RouterView{}, fmt.Errorf("view error to get router wrapped native: %w", err) | ||
} | ||
armProxy, err := r.GetArmProxy(nil) | ||
if err != nil { | ||
return RouterView{}, fmt.Errorf("view error to get router arm proxy: %w", err) | ||
} | ||
onRamps := make(map[uint64]common.Address) | ||
offRamps := make(map[uint64]common.Address) | ||
offRampList, err := r.GetOffRamps(nil) | ||
if err != nil { | ||
return RouterView{}, fmt.Errorf("view error to get router offRamps: %w", err) | ||
} | ||
for _, offRamp := range offRampList { | ||
offRamps[offRamp.SourceChainSelector] = offRamp.OffRamp | ||
} | ||
for selector := range offRamps { | ||
onRamp, err := r.GetOnRamp(nil, selector) | ||
if err != nil { | ||
return RouterView{}, fmt.Errorf("view error to get router onRamp: %w", err) | ||
} | ||
onRamps[selector] = onRamp | ||
} | ||
return RouterView{ | ||
ContractMetaData: meta, | ||
WrappedNative: wrappedNative, | ||
ARMProxy: armProxy, | ||
OnRamps: onRamps, | ||
OffRamps: offRamps, | ||
}, nil | ||
} |
Oops, something went wrong.