-
Notifications
You must be signed in to change notification settings - Fork 53
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
Version abstraction #151
Version abstraction #151
Conversation
@@ -29,9 +28,8 @@ const ( | |||
ExecutionStateFailure | |||
) | |||
|
|||
// TODO: Deprecate in favour of version specific types |
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.
Intention is all geth/log poller code will live in ccipdata under a reader so specific versions can be supported (not just latest version)
|
||
func jobSpecToCommitPluginConfig(lggr logger.Logger, jb job.Job, pr pipeline.Runner, chainSet evm.LegacyChainContainer) (*CommitPluginConfig, *BackfillArgs, error) { |
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.
just to share code with the UnregisterFilter call in DeleteJob. Intention is to rename as Close(...) and just close each reader instead (which internally will unregister filters)
@@ -172,16 +177,6 @@ func CommitReportToEthTxMeta(report []byte) (*txmgr.TxMeta, error) { | |||
}, nil | |||
} | |||
|
|||
func getCommitPluginSourceLpFilters(onRamp common.Address) []logpoller.Filter { |
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 commit plugin's CCIPSend events are tied to a specific onramp address version - so this is now handled in the OnRampReader
return err | ||
} | ||
return unregisterCommitPluginFilters(ctx, sourceChain.LogPoller(), destChain.LogPoller(), commitStore, common.HexToAddress(pluginConfig.OffRamp), qopts...) | ||
// TODO: once offramp/commit are abstracted, we can call Close on the offramp/commit readers to unregister filters. |
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.
Will follow up with abstracting the rest of these
checkFinalityTags bool | ||
lggr logger.Logger | ||
// Source | ||
onRampReader ccipdata.OnRampReader |
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.
notice how the source log poller is now completely abstracted in the commit plugin (can't quite abstract it yet in exec since source price reg is not yet abstracted)
@@ -1475,13 +1476,3 @@ func GetBalance(t *testing.T, chain bind.ContractBackend, tokenAddr common.Addre | |||
require.NoError(t, err) | |||
return bal | |||
} | |||
|
|||
func GenerateCCIPSendLog(t *testing.T, message evm_2_evm_onramp.InternalEVM2EVMMessage) types.Log { |
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.
unused
@@ -18,7 +17,5 @@ var ( | |||
type Reader interface { | |||
// ReadTokenData returns the attestation bytes if ready, and throws an error if not ready. | |||
ReadTokenData(ctx context.Context, msg internal.EVM2EVMOnRampCCIPSendRequestedWithMeta) (tokenData []byte, err error) | |||
|
|||
// GetSourceLogPollerFilters returns the filters that should be used for the source chain log poller | |||
GetSourceLogPollerFilters() []logpoller.Filter |
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.
ccipdata.USDCReader is now logpoller owner
@@ -37,20 +34,6 @@ const ( | |||
attestationStatusPending attestationStatus = "pending_confirmations" | |||
) | |||
|
|||
// usdcPayload has to match the onchain event emitted by the USDC message transmitter |
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.
log details pushed down to USDCReader
if err != nil { | ||
return []byte{}, err | ||
} | ||
|
||
parsedMsgBody, err := decodeUSDCMessageSent(usdcMessageBody) |
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.
GetLastUSDCMessage handles parsing now
require.NoError(t, err) | ||
// Message is the bytes itself from MessageSend(bytes message) | ||
// i.e. ABI parsed. | ||
message := "0x0000000000000001000000020000000000048d71000000000000000000000000eb08f243e5d3fcff26a9e38ae5520a669f4019d000000000000000000000000023a04d5935ed8bc8e3eb78db3541f0abfb001c6e0000000000000000000000006cb3ed9b441eb674b58495c8b3324b59faff5243000000000000000000000000000000005425890298aed601595a70ab815c96711a31bc65000000000000000000000000ab4f961939bfe6a93567cc57c59eed7084ce2131000000000000000000000000000000000000000000000000000000000000271000000000000000000000000035e08285cfed1ef159236728f843286c55fc0861" |
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.
making this a true black box test just canned input/output
…ctkit/ccip into feature/backwards-compat-1.2
leafHasher hashlib.LeafHasherInterface[[32]byte] | ||
checkFinalityTags bool | ||
lggr logger.Logger | ||
// Source |
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.
Having the source/dest dependencies grouped by a comment like this could be improved.
Sometimes it's a bit confusing to just see plugin.onRamp
plugin.offRamp
, you won't know where this contract exists unless you are familiar with the whole ccip architecture or read the comment (which might also end up being incorrect) in the commitPluginConfig.
I would suggest something like this.
type CommitPluginConfig {
source SourceChainDeps
dest DestChainDeps
}
type SourceChainDeps struct {
onRampReader ccipdata.OnRampReader
}
type DestChainDeps struct {
offRampReader ccipdata.OffRampReader
}
func (plugin) Whatever() {
plugin.sourceChain.onRampReader.GetWhatever()
plugin.destChain.offRampReader.GetWhatever()
}
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.
seem like a marginal improvement but would prefer to come back to it after all the versioning abstraction is done
core/services/ocr2/plugins/ccip/commit_reporting_plugin_test.go
Outdated
Show resolved
Hide resolved
core/services/ocr2/plugins/ccip/commit_reporting_plugin_test.go
Outdated
Show resolved
Hide resolved
@@ -302,9 +184,11 @@ func parseLogs[T any](logs []logpoller.Log, lggr logger.Logger, parseFunc func(l | |||
if err == nil { | |||
reqs = append(reqs, Event[T]{ | |||
Data: *data, | |||
BlockMeta: BlockMeta{ | |||
Meta: Meta{ |
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.
Since we are also moving towards supporting non-evm:
// now
type Meta struct {
BlockTimestamp time.Time
BlockNumber int64
TxHash common.Hash
LogIndex uint
}
// should be something like this since logIndex is evm-specific
type Meta struct {
BlockTimestamp time.Time
BlockNumber int64
TxHash common.Hash
EvmMeta *EvmMeta
}
type EvmMeta struct {
LogIndex uint
}
// or like this...
type Meta struct {
ChainType string
BlockTimestamp time.Time
BlockNumber int64
TxHash common.Hash
Meta json.RawMessage
}
// and unmarshal Meta according to the ChainType
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.
yeah still way far out though. Can address that when we get there I'd say out of scope atm
Hash [32]byte | ||
// TODO: add more fields as we abstract exec plugin | ||
// also this Log can eventually go away with destchain abstractions | ||
Log types.Log // Raw event data |
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.
just a note: Log (types.Log)
is also evm specific
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'm aware 😄
GetSendRequestsBetweenSeqNums(ctx context.Context, seqNumMin, seqNumMax uint64, confs int) ([]Event[EVM2EVMMessage], error) | ||
|
||
// Get router configured in the onRamp | ||
Router() common.Address |
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 would suggest renaming this method to RouterAddress()
because without reading the method signature I would expect that onramp.Router()
returns a router instance that I can use to call Router
specific methods.
} | ||
} | ||
|
||
func latestFinalizedBlockHash(ctx context.Context, client client.Client) (common.Hash, error) { |
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.
This function could be moved under some library package (would be nice to have some unit tests also).
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.
not worth it as we intend to remove it entirely shortly smartcontractkit/chainlink#10762
} | ||
|
||
func (o *OnRampV1_0_0) GetSendRequestsGteSeqNum(ctx context.Context, seqNum uint64, confs int) ([]Event[EVM2EVMMessage], error) { | ||
if !o.finalityTags { |
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's the duplicate code I mentioned in the slack thread.
This code is identical for OnRampV1_0_0 and OnRampV1_2_0.
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.
We need to think of some way to reduce this
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.
seems ok to me
- 1_0_0 code will be removed after the upgrade is complete. Generally true that older versions will be phased out
- finalityTags handling will be pushed to lp CCIP-1078 Support for finality tags in LogPoller chainlink#10762 which reduces this to a single lp call
core/services/ocr2/plugins/ccip/internal/ccipdata/onramp_v1_2_0.go
Outdated
Show resolved
Hide resolved
case "1.2.0": | ||
return NewOnRampV1_2_0(lggr, sourceSelector, destSelector, onRampAddress, sourceLP, source, finalityTags) | ||
default: | ||
return nil, errors.Errorf("expected version 1.0.0 got %v", version.String()) |
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.
nit: maybe just invalid version %v
, we aren't strictly expecting a specific version.
Motivation
Solution