-
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.
* Remove cap reg and add pr * RMN * CCIP home basics * Fix test name * Add to state * Fix name * Basic sanity tests * Fix state * Comments
- Loading branch information
1 parent
e48ca56
commit 266c147
Showing
14 changed files
with
533 additions
and
1,194 deletions.
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 %s: %w", pr.Address(), err) | ||
} | ||
ft, err := pr.GetFeeTokens(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get fee tokens %s: %w", pr.Address(), err) | ||
} | ||
st, err := pr.GetStalenessThreshold(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get staleness threshold %s: %w", pr.Address(), err) | ||
} | ||
updaters, err := pr.GetPriceUpdaters(nil) | ||
if err != nil { | ||
return PriceRegistryView{}, fmt.Errorf("failed to get price updaters %s: %w", pr.Address(), 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 %s: %w", r.Address(), err) | ||
} | ||
staticConfig, err := r.GetStaticConfig(nil) | ||
if err != nil { | ||
return OffRampView{}, fmt.Errorf("failed to get static config for OffRamp %s: %w", r.Address(), err) | ||
} | ||
dynamicConfig, err := r.GetDynamicConfig(nil) | ||
if err != nil { | ||
return OffRampView{}, fmt.Errorf("failed to get dynamic config for OffRamp %s: %w", r.Address(), 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 %s: %w", r.Address(), err) | ||
} | ||
staticConfig, err := r.GetStaticConfig(nil) | ||
if err != nil { | ||
return OnRampView{}, fmt.Errorf("failed to get static config for OnRamp %s: %w", r.Address(), err) | ||
} | ||
dynamicConfig, err := r.GetDynamicConfig(nil) | ||
if err != nil { | ||
return OnRampView{}, fmt.Errorf("failed to get dynamic config for OnRamp %s: %w", r.Address(), 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.