-
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
Add remaining CCIP views #15590
Merged
connorwstein
merged 10 commits into
develop
from
CCIP-3047-pre-testnet-define-ccipv-2-state-representation
Dec 11, 2024
Merged
Add remaining CCIP views #15590
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
321e3c3
Remove cap reg and add pr
connorwstein c3e6291
RMN
connorwstein cdc7879
CCIP home basics
connorwstein ac3c4c8
Fix test name
connorwstein 17d9b3e
Add to state
connorwstein e7ad238
Fix name
connorwstein 754dcc5
Basic sanity tests
connorwstein c5baa01
Fix state
connorwstein a04434f
Comments
connorwstein 2e0f211
Merge branch 'develop' into CCIP-3047-pre-testnet-define-ccipv-2-stat…
connorwstein 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
1,126 changes: 0 additions & 1,126 deletions
1,126
core/gethwrappers/ccip/generated/ccip_config/ccip_config.go
This file was deleted.
Oops, something went wrong.
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,45 @@ | ||
package v1_2 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment/common/view/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0" | ||
) | ||
|
||
type PriceRegistryView struct { | ||
types.ContractMetaData | ||
FeeTokens []common.Address `json:"feeTokens"` | ||
StalenessThreshold string `json:"stalenessThreshold"` | ||
Updaters []common.Address `json:"updaters"` | ||
} | ||
|
||
func GeneratePriceRegistryView(pr *price_registry_1_2_0.PriceRegistry) (PriceRegistryView, error) { | ||
if pr == nil { | ||
return PriceRegistryView{}, fmt.Errorf("cannot generate view for nil PriceRegistry") | ||
} | ||
meta, err := types.NewContractMetaData(pr, pr.Address()) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to generate contract metadata for PriceRegistry: %w", err) | ||
} | ||
ft, err := pr.GetFeeTokens(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get fee tokens: %w", err) | ||
} | ||
st, err := pr.GetStalenessThreshold(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get staleness threshold: %w", err) | ||
} | ||
updaters, err := pr.GetPriceUpdaters(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get price updaters: %w", err) | ||
} | ||
return PriceRegistryView{ | ||
ContractMetaData: meta, | ||
FeeTokens: ft, | ||
StalenessThreshold: st.String(), | ||
Updaters: updaters, | ||
}, nil | ||
} |
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,38 @@ | ||
package v1_2 | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
"github.com/smartcontractkit/chainlink/deployment/environment/memory" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/price_registry_1_2_0" | ||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
) | ||
|
||
func TestGeneratePriceRegistryView(t *testing.T) { | ||
e := memory.NewMemoryEnvironment(t, logger.TestLogger(t), zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ | ||
Chains: 1, | ||
}) | ||
chain := e.Chains[e.AllChainSelectors()[0]] | ||
f1, f2 := common.HexToAddress("0x1"), common.HexToAddress("0x2") | ||
_, tx, c, err := price_registry_1_2_0.DeployPriceRegistry( | ||
chain.DeployerKey, chain.Client, []common.Address{chain.DeployerKey.From}, []common.Address{f1, f2}, uint32(10)) | ||
_, err = deployment.ConfirmIfNoError(chain, tx, err) | ||
require.NoError(t, err) | ||
|
||
v, err := GeneratePriceRegistryView(c) | ||
require.NoError(t, err) | ||
assert.Equal(t, v.Owner, chain.DeployerKey.From) | ||
assert.Equal(t, v.TypeAndVersion, "PriceRegistry 1.2.0") | ||
assert.Equal(t, v.FeeTokens, []common.Address{f1, f2}) | ||
assert.Equal(t, v.StalenessThreshold, "10") | ||
assert.Equal(t, v.Updaters, []common.Address{chain.DeployerKey.From}) | ||
_, err = json.MarshalIndent(v, "", " ") | ||
require.NoError(t, err) | ||
} |
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,40 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment/common/view/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp" | ||
) | ||
|
||
type OffRampView struct { | ||
types.ContractMetaData | ||
StaticConfig evm_2_evm_offramp.EVM2EVMOffRampStaticConfig `json:"staticConfig"` | ||
DynamicConfig evm_2_evm_offramp.EVM2EVMOffRampDynamicConfig `json:"dynamicConfig"` | ||
} | ||
|
||
func GenerateOffRampView(r *evm_2_evm_offramp.EVM2EVMOffRamp) (OffRampView, error) { | ||
if r == nil { | ||
return OffRampView{}, fmt.Errorf("cannot generate view for nil OffRamp") | ||
} | ||
meta, err := types.NewContractMetaData(r, r.Address()) | ||
if err != nil { | ||
return OffRampView{}, fmt.Errorf("failed to generate contract metadata for OffRamp: %w", err) | ||
} | ||
staticConfig, err := r.GetStaticConfig(nil) | ||
if err != nil { | ||
return OffRampView{}, fmt.Errorf("failed to get static config for OffRamp: %w", err) | ||
} | ||
dynamicConfig, err := r.GetDynamicConfig(nil) | ||
if err != nil { | ||
return OffRampView{}, fmt.Errorf("failed to get dynamic config for OffRamp: %w", err) | ||
} | ||
|
||
// TODO: If needed, we can filter logs to get the OCR config. | ||
// May not be required for the legacy contracts. | ||
return OffRampView{ | ||
ContractMetaData: meta, | ||
StaticConfig: staticConfig, | ||
DynamicConfig: dynamicConfig, | ||
}, nil | ||
} |
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,60 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
chainsel "github.com/smartcontractkit/chain-selectors" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"math/big" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
"github.com/smartcontractkit/chainlink/deployment/environment/memory" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/commit_store" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_offramp" | ||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
) | ||
|
||
func TestOffRampView(t *testing.T) { | ||
e := memory.NewMemoryEnvironment(t, logger.TestLogger(t), zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ | ||
Chains: 1, | ||
}) | ||
chain := e.Chains[e.AllChainSelectors()[0]] | ||
_, tx, c, err := commit_store.DeployCommitStore( | ||
chain.DeployerKey, chain.Client, commit_store.CommitStoreStaticConfig{ | ||
ChainSelector: chainsel.TEST_90000002.Selector, | ||
SourceChainSelector: chainsel.TEST_90000001.Selector, | ||
OnRamp: common.HexToAddress("0x4"), | ||
RmnProxy: common.HexToAddress("0x1"), | ||
}) | ||
_, err = deployment.ConfirmIfNoError(chain, tx, err) | ||
require.NoError(t, err) | ||
sc := evm_2_evm_offramp.EVM2EVMOffRampStaticConfig{ | ||
ChainSelector: chainsel.TEST_90000002.Selector, | ||
SourceChainSelector: chainsel.TEST_90000001.Selector, | ||
RmnProxy: common.HexToAddress("0x1"), | ||
CommitStore: c.Address(), | ||
TokenAdminRegistry: common.HexToAddress("0x3"), | ||
OnRamp: common.HexToAddress("0x4"), | ||
} | ||
rl := evm_2_evm_offramp.RateLimiterConfig{ | ||
IsEnabled: true, | ||
Capacity: big.NewInt(100), | ||
Rate: big.NewInt(10), | ||
} | ||
_, tx, c2, err := evm_2_evm_offramp.DeployEVM2EVMOffRamp( | ||
chain.DeployerKey, chain.Client, sc, rl) | ||
_, err = deployment.ConfirmIfNoError(chain, tx, err) | ||
require.NoError(t, err) | ||
|
||
v, err := GenerateOffRampView(c2) | ||
require.NoError(t, err) | ||
assert.Equal(t, v.StaticConfig, sc) | ||
assert.Equal(t, v.TypeAndVersion, "EVM2EVMOffRamp 1.5.0") | ||
_, err = json.MarshalIndent(v, "", " ") | ||
require.NoError(t, err) | ||
} |
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,39 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment/common/view/types" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp" | ||
) | ||
|
||
type OnRampView struct { | ||
types.ContractMetaData | ||
StaticConfig evm_2_evm_onramp.EVM2EVMOnRampStaticConfig `json:"staticConfig"` | ||
DynamicConfig evm_2_evm_onramp.EVM2EVMOnRampDynamicConfig `json:"dynamicConfig"` | ||
} | ||
|
||
func GenerateOnRampView(r *evm_2_evm_onramp.EVM2EVMOnRamp) (OnRampView, error) { | ||
if r == nil { | ||
return OnRampView{}, fmt.Errorf("cannot generate view for nil OnRamp") | ||
} | ||
meta, err := types.NewContractMetaData(r, r.Address()) | ||
if err != nil { | ||
return OnRampView{}, fmt.Errorf("failed to generate contract metadata for OnRamp: %w", err) | ||
} | ||
staticConfig, err := r.GetStaticConfig(nil) | ||
if err != nil { | ||
return OnRampView{}, fmt.Errorf("failed to get static config for OnRamp: %w", err) | ||
} | ||
dynamicConfig, err := r.GetDynamicConfig(nil) | ||
if err != nil { | ||
return OnRampView{}, fmt.Errorf("failed to get dynamic config for OnRamp: %w", err) | ||
} | ||
|
||
// Add billing if needed, maybe not required for legacy contract? | ||
return OnRampView{ | ||
ContractMetaData: meta, | ||
StaticConfig: staticConfig, | ||
DynamicConfig: dynamicConfig, | ||
}, nil | ||
} |
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,71 @@ | ||
package v1_5 | ||
|
||
import ( | ||
"encoding/json" | ||
"math/big" | ||
"testing" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap/zapcore" | ||
|
||
"github.com/smartcontractkit/chainlink/deployment" | ||
"github.com/smartcontractkit/chainlink/deployment/environment/memory" | ||
"github.com/smartcontractkit/chainlink/v2/core/gethwrappers/ccip/generated/evm_2_evm_onramp" | ||
"github.com/smartcontractkit/chainlink/v2/core/logger" | ||
) | ||
|
||
func TestOnRampView(t *testing.T) { | ||
e := memory.NewMemoryEnvironment(t, logger.TestLogger(t), zapcore.InfoLevel, memory.MemoryEnvironmentConfig{ | ||
Chains: 1, | ||
}) | ||
chain := e.Chains[e.AllChainSelectors()[0]] | ||
_, tx, c, err := evm_2_evm_onramp.DeployEVM2EVMOnRamp( | ||
chain.DeployerKey, chain.Client, | ||
evm_2_evm_onramp.EVM2EVMOnRampStaticConfig{ | ||
LinkToken: common.HexToAddress("0x1"), | ||
ChainSelector: chain.Selector, | ||
DestChainSelector: 100, | ||
DefaultTxGasLimit: 10, | ||
MaxNopFeesJuels: big.NewInt(10), | ||
PrevOnRamp: common.Address{}, | ||
RmnProxy: common.HexToAddress("0x2"), | ||
TokenAdminRegistry: common.HexToAddress("0x3"), | ||
}, | ||
evm_2_evm_onramp.EVM2EVMOnRampDynamicConfig{ | ||
Router: common.HexToAddress("0x4"), | ||
MaxNumberOfTokensPerMsg: 0, | ||
DestGasOverhead: 0, | ||
DestGasPerPayloadByte: 0, | ||
DestDataAvailabilityOverheadGas: 0, | ||
DestGasPerDataAvailabilityByte: 0, | ||
DestDataAvailabilityMultiplierBps: 0, | ||
PriceRegistry: common.HexToAddress("0x5"), | ||
MaxDataBytes: 0, | ||
MaxPerMsgGasLimit: 0, | ||
DefaultTokenFeeUSDCents: 0, | ||
DefaultTokenDestGasOverhead: 0, | ||
EnforceOutOfOrder: false, | ||
}, | ||
evm_2_evm_onramp.RateLimiterConfig{ | ||
IsEnabled: true, | ||
Capacity: big.NewInt(100), | ||
Rate: big.NewInt(10), | ||
}, | ||
[]evm_2_evm_onramp.EVM2EVMOnRampFeeTokenConfigArgs{}, | ||
[]evm_2_evm_onramp.EVM2EVMOnRampTokenTransferFeeConfigArgs{}, | ||
[]evm_2_evm_onramp.EVM2EVMOnRampNopAndWeight{}, | ||
) | ||
_, err = deployment.ConfirmIfNoError(chain, tx, err) | ||
require.NoError(t, err) | ||
v, err := GenerateOnRampView(c) | ||
require.NoError(t, err) | ||
// Check a few fields. | ||
assert.Equal(t, v.StaticConfig.ChainSelector, chain.Selector) | ||
assert.Equal(t, v.DynamicConfig.Router, common.HexToAddress("0x4")) | ||
assert.Equal(t, v.TypeAndVersion, "EVM2EVMOnRamp 1.5.0") | ||
_, err = json.MarshalIndent(v, "", " ") | ||
require.NoError(t, err) | ||
|
||
} |
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.
Can you also remove CommitStore ? We need to anyway include it in LegacyState
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 think will be easy to just move to the new struct