Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 85 additions & 17 deletions deployment/adapters/chain_family_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,37 @@ type CantonChainFamilyAdapter struct{}

var CantonFamilySelector = [4]byte{0xdf, 0xaf, 0xaf, 0x4b}

func isEVMRemote(remoteChainSelector uint64) bool {
family, err := chainsel.GetSelectorFamily(remoteChainSelector)
if err != nil {
return false
}

return family == chainsel.FamilyEVM
}

func DefaultCantonFeeQuoterDestChainConfig() lanes.FeeQuoterDestChainConfig {
return lanes.FeeQuoterDestChainConfig{
OverrideExistingConfig: false,
IsEnabled: true,
MaxDataBytes: 30_000,
MaxPerMsgGasLimit: 3_000_000,
DestGasOverhead: 300_000,
DestGasPerPayloadByteBase: 16,
ChainFamilySelector: binary.BigEndian.Uint32(CantonFamilySelector[:]),
DefaultTokenFeeUSDCents: 0,
DefaultTokenDestGasOverhead: 90_000,
DefaultTxGasLimit: 200_000,
NetworkFeeUSDCents: 50,
V1Params: nil,
V2Params: &lanes.FeeQuoterV2Params{
LinkFeeMultiplierPercent: 90,
USDPerUnitGas: big.NewInt(38),
},
}
}

func defaultCantonFeeQuoterDestChainConfig() lanes.FeeQuoterDestChainConfig {
return lanes.FeeQuoterDestChainConfig{
OverrideExistingConfig: false,
IsEnabled: true,
Expand All @@ -57,7 +87,7 @@ func DefaultCantonFeeQuoterDestChainConfig() lanes.FeeQuoterDestChainConfig {
V1Params: nil,
V2Params: &lanes.FeeQuoterV2Params{
LinkFeeMultiplierPercent: 90,
USDPerUnitGas: big.NewInt(38),
USDPerUnitGas: big.NewInt(1e6),
},
}
}
Expand Down Expand Up @@ -188,13 +218,7 @@ func (a *CantonChainFamilyAdapter) configureChainForLanes(
if err != nil {
return out, fmt.Errorf("resolve executor for remote chain %d: %w", remoteSelector, err)
}
defaultInboundCCVs, err := resolveContractRefsByAddresses(
ds,
input.ChainSelector,
datastore.ContractType(committeeverifierop.ContractType),
committeeverifierop.Version,
remoteCfg.DefaultInboundCCVs,
)
defaultInboundCCVs, err := resolveDefaultInboundCCVs(ds, input.ChainSelector, remoteCfg)
if err != nil {
return out, fmt.Errorf("resolve default inbound ccvs for remote chain %d: %w", remoteSelector, err)
}
Expand Down Expand Up @@ -413,8 +437,11 @@ func (a *CantonChainFamilyAdapter) GetDefaultCommitteeVerifierRemoteChainConfig(
}

// GetDefaultFeeQuoterDestChainConfig implements [adapters.ChainFamily].
func (a *CantonChainFamilyAdapter) GetDefaultFeeQuoterDestChainConfig(_, _ uint64, chainFamilySelector [4]byte) ccipadapters.FeeQuoterDestChainConfigOverrides {
func (a *CantonChainFamilyAdapter) GetDefaultFeeQuoterDestChainConfig(_, remoteChainSelector uint64, chainFamilySelector [4]byte) ccipadapters.FeeQuoterDestChainConfigOverrides {
defaults := DefaultCantonFeeQuoterDestChainConfig()
if !isEVMRemote(remoteChainSelector) {
defaults = defaultCantonFeeQuoterDestChainConfig()
}
linkFeeMultiplier := uint8(0)
if defaults.V2Params != nil {
linkFeeMultiplier = defaults.V2Params.LinkFeeMultiplierPercent
Expand Down Expand Up @@ -448,20 +475,31 @@ func (a *CantonChainFamilyAdapter) GetDefaultFinalityConfig() finality.Config {
}

// GetDefaultRemoteChainConfig implements [adapters.ChainFamily].
func (a *CantonChainFamilyAdapter) GetDefaultRemoteChainConfig(_, _ uint64) ccipadapters.RemoteChainDefaults {
func (a *CantonChainFamilyAdapter) GetDefaultRemoteChainConfig(_, remoteChainSelector uint64) ccipadapters.RemoteChainDefaults {
if isEVMRemote(remoteChainSelector) {
return ccipadapters.RemoteChainDefaults{
AllowTrafficFrom: true,
BaseExecutionGasCost: 50_000,
TokenReceiverAllowed: true,
MessageNetworkFeeUSDCents: 50,
TokenNetworkFeeUSDCents: 50,
}
}

return ccipadapters.RemoteChainDefaults{
AllowTrafficFrom: true, // TODO: check what this does?
ExecutorDestChainConfig: ccipadapters.ExecutorDestChainConfig{
USDCentsFee: 0,
Enabled: true,
},
AllowTrafficFrom: true,
BaseExecutionGasCost: 50_000,
TokenReceiverAllowed: true,
MessageNetworkFeeUSDCents: 0,
TokenNetworkFeeUSDCents: 0,
MessageNetworkFeeUSDCents: 10,
TokenNetworkFeeUSDCents: 25,
}
}

// GetDefaultExecutorDestChainConfig implements [adapters.ChainFamily].
func (a *CantonChainFamilyAdapter) GetDefaultExecutorDestChainConfig(_, _ uint64) ccipadapters.ExecutorDestChainConfig {
return ccipadapters.ExecutorDestChainConfig{USDCentsFee: 0, Enabled: true}
}

func findContractRef(ds datastore.DataStore, chainSelector uint64, contractType datastore.ContractType, version *semver.Version, qualifier string) (datastore.AddressRef, error) {
return ds.Addresses().Get(datastore.NewAddressRefKey(chainSelector, contractType, version, qualifier))
}
Expand Down Expand Up @@ -502,6 +540,36 @@ func resolveContractRefsByAddresses(ds datastore.DataStore, chainSelector uint64
return refs, nil
}

func resolveDefaultInboundCCVs(
ds datastore.DataStore,
chainSelector uint64,
remoteCfg ccipadapters.RemoteChainConfig[[]byte, string],
) ([]datastore.AddressRef, error) {
if len(remoteCfg.DefaultInboundCCVs) > 0 {
return resolveContractRefsByAddresses(
ds,
chainSelector,
datastore.ContractType(committeeverifierop.ContractType),
committeeverifierop.Version,
remoteCfg.DefaultInboundCCVs,
)
}

// Hardening: default inbound CCV is invalid-ccv (fail-closed) when not explicitly configured.
ref, err := findContractRef(
ds,
chainSelector,
datastore.ContractType(committeeverifierop.ContractType),
committeeverifierop.Version,
"invalid-ccv",
)
if err != nil {
return nil, fmt.Errorf("resolve default invalid-ccv inbound qualifier: %w", err)
}

return []datastore.AddressRef{ref}, nil
Comment on lines +587 to +595
Comment on lines +587 to +595
}

func convertCommitteeVerifierConfigs(configs []ccipadapters.CommitteeVerifierConfig[datastore.AddressRef]) []lanes.CommitteeVerifierConfig[datastore.AddressRef] {
out := make([]lanes.CommitteeVerifierConfig[datastore.AddressRef], 0, len(configs))
for _, cfg := range configs {
Expand Down
2 changes: 1 addition & 1 deletion deployment/adapters/configure_lanes_token_prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const defaultLinkTokenInstrumentID = "link-token"
const defaultLinkUsdPerTokenDollars int64 = 10

// defaultNativeUsdPerToken is the nominal Amulet/USD spot used when FamilyExtras omit a price.
const defaultNativeUsdPerToken = "0.1"
const defaultNativeUsdPerToken = "0.15"

// cantonUsdPerTokenScale is the internal fixed-point scale (USD * 1e8) before formatting to Decimal.
const cantonUsdPerTokenScale int64 = 100_000_000
Expand Down
Loading