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

CCIP-3920 Enabling fee boosting #278

Merged
merged 6 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion execute/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (p PluginFactory) NewReportingPlugin(

costlyMessageObserver := exectypes.NewCostlyMessageObserverWithDefaults(
p.lggr,
false, // TODO: enable
true,
ccipReader,
offchainConfig.RelativeBoostPerWaitHour,
p.estimateProvider,
Expand Down
54 changes: 52 additions & 2 deletions pkg/reader/ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,56 @@ func (r *ccipChainReader) ExecutedMessageRanges(
return executed, nil
}

// Temporary struct to properly deserialize cciptypes.Message before we have support for cciptypes.BigInt
type ccipMessageTokenAmount struct {
SourcePoolAddress cciptypes.UnknownAddress
DestTokenAddress cciptypes.UnknownAddress
ExtraData cciptypes.Bytes
Amount *big.Int
DestExecData cciptypes.Bytes
}

func (t *ccipMessageTokenAmount) ToOnRampToken() cciptypes.RampTokenAmount {
return cciptypes.RampTokenAmount{
SourcePoolAddress: t.SourcePoolAddress,
DestTokenAddress: t.DestTokenAddress,
ExtraData: t.ExtraData,
Amount: cciptypes.NewBigInt(t.Amount),
DestExecData: t.DestExecData,
}
}

type ccipMessage struct {
Header cciptypes.RampMessageHeader
Sender cciptypes.UnknownAddress
Data cciptypes.Bytes
Receiver cciptypes.UnknownAddress
ExtraArgs cciptypes.Bytes
FeeToken cciptypes.UnknownAddress
FeeTokenAmount *big.Int
FeeValueJuels *big.Int
TokenAmounts []ccipMessageTokenAmount
}

func (m *ccipMessage) ToMessage() cciptypes.Message {
tk := make([]cciptypes.RampTokenAmount, len(m.TokenAmounts))
for i := range m.TokenAmounts {
tk[i] = m.TokenAmounts[i].ToOnRampToken()
}

return cciptypes.Message{
Header: m.Header,
Sender: m.Sender,
Data: m.Data,
Receiver: m.Receiver,
ExtraArgs: m.ExtraArgs,
FeeToken: m.FeeToken,
FeeTokenAmount: cciptypes.NewBigInt(m.FeeTokenAmount),
FeeValueJuels: cciptypes.NewBigInt(m.FeeValueJuels),
TokenAmounts: tk,
}
}

func (r *ccipChainReader) MsgsBetweenSeqNums(
ctx context.Context, sourceChainSelector cciptypes.ChainSelector, seqNumRange cciptypes.SeqNumRange,
) ([]cciptypes.Message, error) {
Expand All @@ -292,7 +342,7 @@ func (r *ccipChainReader) MsgsBetweenSeqNums(

type SendRequestedEvent struct {
DestChainSelector cciptypes.ChainSelector
Message cciptypes.Message
Message ccipMessage
}

seq, err := r.contractReaders[sourceChainSelector].ExtendedQueryKey(
Expand Down Expand Up @@ -337,7 +387,7 @@ func (r *ccipChainReader) MsgsBetweenSeqNums(
msg.Message.Header.OnRamp = onRampAddress

if valid {
msgs = append(msgs, msg.Message)
msgs = append(msgs, msg.Message.ToMessage())
}
}

Expand Down
Loading