-
Notifications
You must be signed in to change notification settings - Fork 56
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
Using a provider proxied commit store implementation in commit #1080
Changes from all commits
f03236d
4f9e441
a064f30
d2d35c4
1de5fa5
e9d82db
7ab347c
960e345
3c2c95c
86e9d67
556029a
8b73917
94b889b
803c56e
2acea48
47718e8
9b45f76
b621b9a
e5dc7bf
4cace59
6a0377a
9378b94
361728f
2f0e45c
7e1d03d
d3c516d
bd95c1b
90dc562
920374f
8540ea9
e98bdbc
07ccda7
70a15aa
b70d3d4
0be8855
8d0837e
4519b80
2834b5f
1613c32
d9b08b0
e444f19
d52dd00
bcdd10b
888f4a7
ee2d33f
1a17c6c
179579e
96a35a7
5f8d16d
fbc97ee
557caaa
a0726b6
3813786
d249482
bb2211d
4b82947
5c7746e
3fec276
f4d2f0a
3adff7a
178df14
32ab382
2210061
c6807e4
defd47b
e40f782
b02afb2
b5ecbbb
0664631
39a7de7
a4474ab
0b2c451
f8e3c5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,7 @@ import ( | |
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline" | ||
) | ||
|
||
func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, srcChain legacyevm.Chain, dstChain legacyevm.Chain, chainSet legacyevm.LegacyChainContainer, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) { | ||
func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider commontypes.CCIPCommitProvider, dstProvider commontypes.CCIPCommitProvider, chainSet legacyevm.LegacyChainContainer, jb job.Job, lggr logger.Logger, pr pipeline.Runner, argsNoPlugin libocr2.OCR2OracleArgs, new bool, sourceChainID int64, destChainID int64, logError func(string)) ([]job.ServiceCtx, error) { | ||
spec := jb.OCR2OracleSpec | ||
|
||
var pluginConfig ccipconfig.CommitPluginJobSpecConfig | ||
|
@@ -52,25 +52,19 @@ func NewCommitServices(ctx context.Context, ds sqlutil.DataSource, srcProvider c | |
return nil, err | ||
} | ||
|
||
// TODO CCIP-2493 EVM family specific behavior leaked for CommitStore, which requires access to two relayers | ||
versionFinder := factory.NewEvmVersionFinder() | ||
commitStoreAddress := common.HexToAddress(spec.ContractID) | ||
sourceMaxGasPrice := srcChain.Config().EVM().GasEstimator().PriceMax().ToInt() | ||
commitStoreReader, err := ccip.NewCommitStoreReader(lggr, versionFinder, ccipcalc.EvmAddrToGeneric(commitStoreAddress), dstChain.Client(), dstChain.LogPoller()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = commitStoreReader.SetGasEstimator(ctx, srcChain.GasEstimator()) | ||
srcCommitStore, err := srcProvider.NewCommitStoreReader(ctx, ccipcalc.EvmAddrToGeneric(commitStoreAddress)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
err = commitStoreReader.SetSourceMaxGasPrice(ctx, sourceMaxGasPrice) | ||
dstCommitStore, err := dstProvider.NewCommitStoreReader(ctx, ccipcalc.EvmAddrToGeneric(commitStoreAddress)) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
var commitStoreReader ccipdata.CommitStoreReader | ||
commitStoreReader = ccip.NewProviderProxyCommitStoreReader(srcCommitStore, dstCommitStore) | ||
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. why not initialize directly? (remove line 66) 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. NewProviderProxyCommitStoreReader returns a
|
||
commitLggr := lggr.Named("CCIPCommit").With("sourceChain", sourceChainID, "destChain", destChainID) | ||
|
||
var priceGetter pricegetter.PriceGetter | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
package ccip | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io" | ||
"math/big" | ||
"time" | ||
|
||
"go.uber.org/multierr" | ||
|
||
"github.com/smartcontractkit/chainlink/v2/core/chains/evm/gas" | ||
|
||
cciptypes "github.com/smartcontractkit/chainlink-common/pkg/types/ccip" | ||
) | ||
|
||
// The disjunct methods in IncompleteSourceCommitStoreReader and IncompleteDestCommitStoreReader satisfy the full | ||
// CommitStoreReader iface in Union | ||
var _ cciptypes.CommitStoreReader = (*ProviderProxyCommitStoreReader)(nil) | ||
|
||
// ProviderProxyCommitStoreReader is a CommitStoreReader that proxies to two custom provider grpc backed implementations | ||
// of a CommitStoreReader. | ||
// [ProviderProxyCommitStoreReader] lives in the memory space of the reporting plugin factory and reporting plugin, and should have no chain-specific details. | ||
// Why? Historical implementations of a commit store consumed in reporting plugins mixed usage of a gas estimator from | ||
// the source relayer and contract read and write abilities to a dest relayer. This is not valid in LOOP world. | ||
type ProviderProxyCommitStoreReader struct { | ||
srcCommitStoreReader IncompleteSourceCommitStoreReader | ||
dstCommitStoreReader IncompleteDestCommitStoreReader | ||
} | ||
|
||
// IncompleteSourceCommitStoreReader contains only the methods of CommitStoreReader that are serviced by the source chain/relayer. | ||
type IncompleteSourceCommitStoreReader interface { | ||
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. I feel |
||
ChangeConfig(ctx context.Context, onchainConfig []byte, offchainConfig []byte) (cciptypes.Address, error) | ||
GasPriceEstimator(ctx context.Context) (cciptypes.GasPriceEstimatorCommit, error) | ||
OffchainConfig(ctx context.Context) (cciptypes.CommitOffchainConfig, error) | ||
io.Closer | ||
} | ||
|
||
// IncompleteDestCommitStoreReader contains only the methods of CommitStoreReader that are serviced by the dest chain/relayer. | ||
type IncompleteDestCommitStoreReader interface { | ||
DecodeCommitReport(ctx context.Context, report []byte) (cciptypes.CommitStoreReport, error) | ||
EncodeCommitReport(ctx context.Context, report cciptypes.CommitStoreReport) ([]byte, error) | ||
GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) | ||
GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) | ||
GetCommitStoreStaticConfig(ctx context.Context) (cciptypes.CommitStoreStaticConfig, error) | ||
GetExpectedNextSequenceNumber(ctx context.Context) (uint64, error) | ||
GetLatestPriceEpochAndRound(ctx context.Context) (uint64, error) | ||
IsBlessed(ctx context.Context, root [32]byte) (bool, error) | ||
IsDestChainHealthy(ctx context.Context) (bool, error) | ||
IsDown(ctx context.Context) (bool, error) | ||
VerifyExecutionReport(ctx context.Context, report cciptypes.ExecReport) (bool, error) | ||
io.Closer | ||
} | ||
|
||
func NewProviderProxyCommitStoreReader(srcReader cciptypes.CommitStoreReader, dstReader cciptypes.CommitStoreReader) *ProviderProxyCommitStoreReader { | ||
return &ProviderProxyCommitStoreReader{ | ||
srcCommitStoreReader: srcReader, | ||
dstCommitStoreReader: dstReader, | ||
} | ||
} | ||
|
||
// ChangeConfig updates the offchainConfig values for the source relayer gas estimator by calling ChangeConfig | ||
// on the source relayer. Once this is called, GasPriceEstimator and OffchainConfig can be called. | ||
func (p *ProviderProxyCommitStoreReader) ChangeConfig(ctx context.Context, onchainConfig []byte, offchainConfig []byte) (cciptypes.Address, error) { | ||
return p.srcCommitStoreReader.ChangeConfig(ctx, onchainConfig, offchainConfig) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) DecodeCommitReport(ctx context.Context, report []byte) (cciptypes.CommitStoreReport, error) { | ||
return p.dstCommitStoreReader.DecodeCommitReport(ctx, report) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) EncodeCommitReport(ctx context.Context, report cciptypes.CommitStoreReport) ([]byte, error) { | ||
return p.dstCommitStoreReader.EncodeCommitReport(ctx, report) | ||
} | ||
|
||
// GasPriceEstimator constructs a gas price estimator on the source relayer | ||
func (p *ProviderProxyCommitStoreReader) GasPriceEstimator(ctx context.Context) (cciptypes.GasPriceEstimatorCommit, error) { | ||
return p.srcCommitStoreReader.GasPriceEstimator(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) GetAcceptedCommitReportsGteTimestamp(ctx context.Context, ts time.Time, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) { | ||
return p.dstCommitStoreReader.GetAcceptedCommitReportsGteTimestamp(ctx, ts, confirmations) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) GetCommitReportMatchingSeqNum(ctx context.Context, seqNum uint64, confirmations int) ([]cciptypes.CommitStoreReportWithTxMeta, error) { | ||
return p.dstCommitStoreReader.GetCommitReportMatchingSeqNum(ctx, seqNum, confirmations) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) GetCommitStoreStaticConfig(ctx context.Context) (cciptypes.CommitStoreStaticConfig, error) { | ||
return p.dstCommitStoreReader.GetCommitStoreStaticConfig(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) GetExpectedNextSequenceNumber(ctx context.Context) (uint64, error) { | ||
return p.dstCommitStoreReader.GetExpectedNextSequenceNumber(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) GetLatestPriceEpochAndRound(ctx context.Context) (uint64, error) { | ||
return p.dstCommitStoreReader.GetLatestPriceEpochAndRound(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) IsBlessed(ctx context.Context, root [32]byte) (bool, error) { | ||
return p.dstCommitStoreReader.IsBlessed(ctx, root) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) IsDestChainHealthy(ctx context.Context) (bool, error) { | ||
return p.dstCommitStoreReader.IsDestChainHealthy(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) IsDown(ctx context.Context) (bool, error) { | ||
return p.dstCommitStoreReader.IsDown(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) OffchainConfig(ctx context.Context) (cciptypes.CommitOffchainConfig, error) { | ||
return p.srcCommitStoreReader.OffchainConfig(ctx) | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) VerifyExecutionReport(ctx context.Context, report cciptypes.ExecReport) (bool, error) { | ||
return p.dstCommitStoreReader.VerifyExecutionReport(ctx, report) | ||
} | ||
|
||
// SetGasEstimator is invalid on ProviderProxyCommitStoreReader. The provider based impl's do not have SetGasEstimator | ||
// defined, so this serves no purpose other than satisfying an interface. | ||
func (p *ProviderProxyCommitStoreReader) SetGasEstimator(ctx context.Context, gpe gas.EvmFeeEstimator) error { | ||
return fmt.Errorf("invalid usage of ProviderProxyCommitStoreReader") | ||
} | ||
|
||
// SetSourceMaxGasPrice is invalid on ProviderProxyCommitStoreReader. The provider based impl's do not have SetSourceMaxGasPrice | ||
// defined, so this serves no purpose other than satisfying an interface. | ||
func (p *ProviderProxyCommitStoreReader) SetSourceMaxGasPrice(ctx context.Context, sourceMaxGasPrice *big.Int) error { | ||
return fmt.Errorf("invalid usage of ProviderProxyCommitStoreReader") | ||
} | ||
|
||
func (p *ProviderProxyCommitStoreReader) Close() error { | ||
return multierr.Append(p.srcCommitStoreReader.Close(), p.dstCommitStoreReader.Close()) | ||
} |
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.
that will cause confusion, worths at least adding a comment explaining
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'll add here: #1150