Skip to content
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

Offchain usdc #112

Merged
merged 26 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f478a01
basic attestation service
RensR Sep 5, 2023
7a883b7
add hard coded LP subscription logic
RensR Sep 5, 2023
5468713
check usdc messges attestation in batch building (mock)
RensR Sep 5, 2023
1a7b5a9
add logpoller IndexedLogsByTxHash
RensR Sep 6, 2023
1577e56
refactor USDC service to be self contained
RensR Sep 6, 2023
2ac5879
make offchain token data providers generic
RensR Sep 7, 2023
8c2250f
add all usdc token and messageTransmitter addresses
RensR Sep 7, 2023
0f2e9eb
minor code improvements
RensR Sep 13, 2023
bb5b50e
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 13, 2023
f738579
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 13, 2023
a523911
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 14, 2023
256c29f
fix evm logs reference
RensR Sep 14, 2023
68a70d5
review comments
RensR Sep 14, 2023
addbdbb
renames and passing in uri
RensR Sep 19, 2023
b7f2f81
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 19, 2023
0ef66b3
re-use logindex and tx hash from exec plugin
RensR Sep 19, 2023
239b7ca
cached reader + ReadTokenData rename
RensR Sep 19, 2023
8029d4c
fix test, rm unused code
RensR Sep 20, 2023
6e31124
pass in internal.EVM2EVMOnRampCCIPSendRequestedWithMeta
RensR Sep 20, 2023
0e80c67
extract chains logic and fix linting
RensR Sep 20, 2023
7be78f6
add cached reader test & reader mock
RensR Sep 20, 2023
142a6d1
more tests, real context and extract into method
RensR Sep 20, 2023
50a59b2
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 20, 2023
acfeef5
read usdc config from jobspec
RensR Sep 20, 2023
d00da8c
improve logging, reduce exported usdc types
RensR Sep 20, 2023
e4f6b07
Merge branch 'ccip-develop' into offchain-usdc
RensR Sep 21, 2023
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
Prev Previous commit
Next Next commit
check usdc messges attestation in batch building (mock)
  • Loading branch information
RensR committed Sep 5, 2023
commit 546871371c5ef267a0c90a63a206f8b02f6270f6
32 changes: 25 additions & 7 deletions core/services/ocr2/plugins/ccip/execution_reporting_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/hasher"
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/observability"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/utils"
)

const (
Expand Down Expand Up @@ -525,11 +526,35 @@ func (r *ExecutionReportingPlugin) buildBatch(
msgLggr.Errorw("Skipping message unable to compute aggregate value", "err", err)
continue
}

// if token limit is smaller than message value skip message
if tokensLeft, hasCapacity := hasEnoughTokens(aggregateTokenLimit, msgValue, inflightAggregateValue); !hasCapacity {
msgLggr.Warnw("token limit is smaller than message value", "aggregateTokenLimit", tokensLeft.String(), "msgValue", msgValue.String())
continue
}

// Any tokens that require offchain token data should be added here.
var tokenData [][]byte
RensR marked this conversation as resolved.
Show resolved Hide resolved
for _, token := range msg.TokenAmounts {
switch token.Token {
case r.config.usdcService.SourceUSDCToken:
usdcMessageBody := ""
msgHash := utils.Keccak256Fixed([]byte(usdcMessageBody))
success, attestation, err := r.config.usdcService.IsAttestationComplete(string(msgHash[:]))
if err != nil {
msgLggr.Errorw("Skipping message unable to check USDC attestation", "err", err)
continue
}
if !success {
msgLggr.Warnw("Skipping message USDC attestation not ready")
continue
}
tokenData = append(tokenData, []byte(attestation))
default:
tokenData = append(tokenData, []byte{})
RensR marked this conversation as resolved.
Show resolved Hide resolved
}
}

// Fee boosting
execGasPriceEstimateValue, err := execGasPriceEstimate()
if err != nil {
Expand Down Expand Up @@ -599,13 +624,6 @@ func (r *ExecutionReportingPlugin) buildBatch(
}
}

var tokenData [][]byte

// TODO add attestation data for USDC here
for range msg.TokenAmounts {
tokenData = append(tokenData, []byte{})
}

msgLggr.Infow("Adding msg to batch", "seqNum", msg.SequenceNumber, "nonce", msg.Nonce,
"value", msgValue, "aggregateTokenLimit", aggregateTokenLimit)
executableMessages = append(executableMessages, NewObservedMessage(msg.SequenceNumber, tokenData))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func setupExecTestHarness(t *testing.T) execTestHarness {
sourceWrappedNativeToken: th.Source.WrappedNative.Address(),
leafHasher: hasher.NewLeafHasher(th.Source.ChainSelector, th.Dest.ChainSelector, th.Source.OnRamp.Address(), hasher.NewKeccakCtx()),
destGasEstimator: destFeeEstimator,
usdcService: customtokens.NewUSDCService("", th.Source.ChainSelector),
},
onchainConfig: th.ExecOnchainConfig,
offchainConfig: offchainConfig,
Expand Down