-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Ccip-3398 populate state initial PR #14391
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
df3df9d
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 9106334
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 65efde9
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 99ab4c1
Merge branch 'develop' of github.com:smartcontractkit/chainlink into …
AnieeG 2d7dc6a
initial draft
AnieeG e575c22
individual snapshot
AnieeG 8fcec56
change interface name
AnieeG 17460da
changes
AnieeG 5a8812c
add all destchainselectors
AnieeG 85e01a8
rmn details
AnieeG f133c38
more changes
AnieeG 54dbed8
omitempty
AnieeG 2ea45cc
add onRamp reader
ogtownsend 6c5abd9
changes
AnieeG a7846c4
Merge branch 'ccip-3398-populate-state' of github.com:smartcontractki…
AnieeG 0fa1505
format errors
ogtownsend 9e932ec
add Feequoter
AnieeG 460bccb
Merge branch 'ccip-3398-populate-state' of github.com:smartcontractki…
AnieeG 5267bc6
change approach direct go-binding reference
AnieeG c2dddc4
fix import cycle
AnieeG 55424e8
moduler
AnieeG 25c21ac
fix panic
AnieeG 1684ad4
add interface for snapshot
AnieeG 939b246
update state generate
AnieeG c7d6023
more changes
AnieeG 53b4c40
rename
AnieeG fe85444
fix lint
AnieeG fa3760d
review comments
AnieeG dc695c9
more review comments
AnieeG 9fda18b
fix rmnremote version
AnieeG 145bf8f
one more fix
AnieeG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these might not always exist (e.g. WETH) but we can come back to that later, can just be empty in that case |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if the types directory is helping much - think we could just have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type directory is to avoid import cycle, We have the Contract struct getting imported into v1_2 ,v1_5 etc from parent view and then Chain struct has elements from v1_2, v1_5 in the parent view package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - I think it could be on the same hierarchical level though just to avoid the nesting