Skip to content

Commit dedf05b

Browse files
committed
update a few more functions
1 parent 541440d commit dedf05b

6 files changed

Lines changed: 55 additions & 47 deletions

File tree

pkg/loop/internal/pb/ccipocr3/chainaccessor.pb.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/loop/internal/pb/ccipocr3/chainaccessor.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ message GetChainFeePriceUpdateRequest {
108108
}
109109

110110
message GetChainFeePriceUpdateResponse {
111-
map<uint64, TimestampedBig> fee_price_updates = 1; // key is chain selector
111+
map<uint64, TimestampedUnixBig> fee_price_updates = 1; // key is chain selector
112112
}
113113

114114
message GetLatestPriceSeqNrResponse {

pkg/loop/internal/relayer/pluginprovider/ext/ccipocr3/chainaccessor.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (c *chainAccessorClient) Nonces(ctx context.Context, addresses map[ccipocr3
194194
return result, nil
195195
}
196196

197-
func (c *chainAccessorClient) GetChainFeePriceUpdate(ctx context.Context, selectors []ccipocr3.ChainSelector) map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig {
197+
func (c *chainAccessorClient) GetChainFeePriceUpdate(ctx context.Context, selectors []ccipocr3.ChainSelector) (map[ccipocr3.ChainSelector]ccipocr3.TimestampedUnixBig, error) {
198198
var chainSelectors []uint64
199199
for _, sel := range selectors {
200200
chainSelectors = append(chainSelectors, uint64(sel))
@@ -204,27 +204,25 @@ func (c *chainAccessorClient) GetChainFeePriceUpdate(ctx context.Context, select
204204
ChainSelectors: chainSelectors,
205205
})
206206
if err != nil {
207-
// This method returns a map, not error, so we need to handle errors differently
208-
// Return empty map for now - this matches the interface signature
209-
return make(map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig)
207+
return nil, err
210208
}
211209

212-
result := make(map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig)
213-
for chainSel, timestampedBig := range resp.FeePriceUpdates {
214-
result[ccipocr3.ChainSelector(chainSel)] = ccipocr3.TimestampedBig{
215-
Timestamp: timestampedBig.Timestamp.AsTime(),
216-
Value: pbToBigInt(timestampedBig.Value),
210+
result := make(map[ccipocr3.ChainSelector]ccipocr3.TimestampedUnixBig)
211+
for chainSel, timestampedUnixBig := range resp.FeePriceUpdates {
212+
result[ccipocr3.ChainSelector(chainSel)] = ccipocr3.TimestampedUnixBig{
213+
Value: pbToBigInt(timestampedUnixBig.Value).Int,
214+
Timestamp: timestampedUnixBig.Timestamp,
217215
}
218216
}
219-
return result
217+
return result, nil
220218
}
221219

222-
func (c *chainAccessorClient) GetLatestPriceSeqNr(ctx context.Context) (uint64, error) {
220+
func (c *chainAccessorClient) GetLatestPriceSeqNr(ctx context.Context) (ccipocr3.SeqNum, error) {
223221
resp, err := c.grpc.GetLatestPriceSeqNr(ctx, &emptypb.Empty{})
224222
if err != nil {
225223
return 0, err
226224
}
227-
return resp.SeqNr, nil
225+
return ccipocr3.SeqNum(resp.SeqNr), nil
228226
}
229227

230228
// SourceAccessor methods
@@ -515,13 +513,16 @@ func (s *chainAccessorServer) GetChainFeePriceUpdate(ctx context.Context, req *c
515513
chainSelectors = append(chainSelectors, ccipocr3.ChainSelector(sel))
516514
}
517515

518-
priceUpdates := s.impl.GetChainFeePriceUpdate(ctx, chainSelectors)
516+
priceUpdates, err := s.impl.GetChainFeePriceUpdate(ctx, chainSelectors)
517+
if err != nil {
518+
return nil, err
519+
}
519520

520-
pbUpdates := make(map[uint64]*ccipocr3pb.TimestampedBig)
521+
pbUpdates := make(map[uint64]*ccipocr3pb.TimestampedUnixBig)
521522
for chainSel, update := range priceUpdates {
522-
pbUpdates[uint64(chainSel)] = &ccipocr3pb.TimestampedBig{
523-
Value: intToPbBigInt(update.Value.Int),
524-
Timestamp: timestamppb.New(update.Timestamp),
523+
pbUpdates[uint64(chainSel)] = &ccipocr3pb.TimestampedUnixBig{
524+
Value: intToPbBigInt(update.Value),
525+
Timestamp: update.Timestamp,
525526
}
526527
}
527528

@@ -535,7 +536,7 @@ func (s *chainAccessorServer) GetLatestPriceSeqNr(ctx context.Context, req *empt
535536
if err != nil {
536537
return nil, err
537538
}
538-
return &ccipocr3pb.GetLatestPriceSeqNrResponse{SeqNr: seqNr}, nil
539+
return &ccipocr3pb.GetLatestPriceSeqNrResponse{SeqNr: uint64(seqNr)}, nil
539540
}
540541

541542
// SourceAccessor server methods

pkg/loop/internal/relayer/pluginprovider/ext/ccipocr3/test/chain_accessor.go

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,14 @@ func ChainAccessor(lggr logger.Logger) staticChainAccessor {
205205
"sender3": 5,
206206
},
207207
},
208-
chainFeePriceUpdates: map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig{
208+
chainFeePriceUpdates: map[ccipocr3.ChainSelector]ccipocr3.TimestampedUnixBig{
209209
ccipocr3.ChainSelector(1): {
210-
Timestamp: testTime,
211-
Value: ccipocr3.NewBigInt(big.NewInt(2000000000)),
210+
Timestamp: uint32(testTime.Unix()),
211+
Value: big.NewInt(2000000000),
212212
},
213213
ccipocr3.ChainSelector(2): {
214-
Timestamp: testTime.Add(time.Hour),
215-
Value: ccipocr3.NewBigInt(big.NewInt(1800000000)),
214+
Timestamp: uint32(testTime.Add(time.Hour).Unix()),
215+
Value: big.NewInt(1800000000),
216216
},
217217
},
218218
latestPriceSeqNr: 42,
@@ -294,7 +294,7 @@ type staticChainAccessorConfig struct {
294294
executedMessages map[ccipocr3.ChainSelector][]ccipocr3.SeqNum
295295
nextSeqNums map[ccipocr3.ChainSelector]ccipocr3.SeqNum
296296
nonces map[ccipocr3.ChainSelector]map[string]uint64
297-
chainFeePriceUpdates map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig
297+
chainFeePriceUpdates map[ccipocr3.ChainSelector]ccipocr3.TimestampedUnixBig
298298
latestPriceSeqNr uint64
299299
messages []ccipocr3.Message
300300
latestMessageSeqNr ccipocr3.SeqNum
@@ -351,12 +351,12 @@ func (s staticChainAccessor) Nonces(ctx context.Context, addresses map[ccipocr3.
351351
return s.nonces, nil
352352
}
353353

354-
func (s staticChainAccessor) GetChainFeePriceUpdate(ctx context.Context, chains []ccipocr3.ChainSelector) map[ccipocr3.ChainSelector]ccipocr3.TimestampedBig {
355-
return s.chainFeePriceUpdates
354+
func (s staticChainAccessor) GetChainFeePriceUpdate(ctx context.Context, chains []ccipocr3.ChainSelector) (map[ccipocr3.ChainSelector]ccipocr3.TimestampedUnixBig, error) {
355+
return s.chainFeePriceUpdates, nil
356356
}
357357

358-
func (s staticChainAccessor) GetLatestPriceSeqNr(ctx context.Context) (uint64, error) {
359-
return s.latestPriceSeqNr, nil
358+
func (s staticChainAccessor) GetLatestPriceSeqNr(ctx context.Context) (ccipocr3.SeqNum, error) {
359+
return ccipocr3.SeqNum(s.latestPriceSeqNr), nil
360360
}
361361

362362
// SourceAccessor implementation
@@ -774,8 +774,14 @@ func (s staticChainAccessor) evaluateNonces(ctx context.Context, other ccipocr3.
774774

775775
func (s staticChainAccessor) evaluateGetChainFeePriceUpdate(ctx context.Context, other ccipocr3.ChainAccessor) error {
776776
chains := []ccipocr3.ChainSelector{1, 2}
777-
otherUpdates := other.GetChainFeePriceUpdate(ctx, chains)
778-
myUpdates := s.GetChainFeePriceUpdate(ctx, chains)
777+
otherUpdates, err := other.GetChainFeePriceUpdate(ctx, chains)
778+
if err != nil {
779+
return fmt.Errorf("GetChainFeePriceUpdate failed: %w", err)
780+
}
781+
myUpdates, err := s.GetChainFeePriceUpdate(ctx, chains)
782+
if err != nil {
783+
return fmt.Errorf("GetChainFeePriceUpdate failed: %w", err)
784+
}
779785
if len(otherUpdates) != len(myUpdates) {
780786
return fmt.Errorf("GetChainFeePriceUpdate length mismatch: got %d, expected %d", len(otherUpdates), len(myUpdates))
781787
}
@@ -784,13 +790,13 @@ func (s staticChainAccessor) evaluateGetChainFeePriceUpdate(ctx context.Context,
784790
if !exists {
785791
return fmt.Errorf("GetChainFeePriceUpdate missing chain %d in other updates", chainSel)
786792
}
787-
if otherUpdate.Value.Cmp(myUpdate.Value.Int) != 0 {
793+
if otherUpdate.Value.Cmp(myUpdate.Value) != 0 {
788794
return fmt.Errorf("GetChainFeePriceUpdate chain %d Value mismatch: got %s, expected %s",
789795
chainSel, otherUpdate.Value.String(), myUpdate.Value.String())
790796
}
791-
if !otherUpdate.Timestamp.Equal(myUpdate.Timestamp) {
792-
return fmt.Errorf("GetChainFeePriceUpdate chain %d Timestamp mismatch: got %s, expected %s",
793-
chainSel, otherUpdate.Timestamp.Format(time.RFC3339), myUpdate.Timestamp.Format(time.RFC3339))
797+
if otherUpdate.Timestamp != myUpdate.Timestamp {
798+
return fmt.Errorf("GetChainFeePriceUpdate chain %d Timestamp mismatch: got %d, expected %d",
799+
chainSel, otherUpdate.Timestamp, myUpdate.Timestamp)
794800
}
795801
}
796802
return nil

pkg/loop/internal/relayer/pluginprovider/ext/ccipocr3/test/chain_accessor_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ func TestChainAccessor(t *testing.T) {
7474
})
7575

7676
t.Run("GetChainFeePriceUpdate", func(t *testing.T) {
77-
updates := chainAccessor.GetChainFeePriceUpdate(ctx, []ccipocr3.ChainSelector{1, 2})
77+
updates, err := chainAccessor.GetChainFeePriceUpdate(ctx, []ccipocr3.ChainSelector{1, 2})
78+
assert.NoError(t, err)
7879
assert.NotNil(t, updates)
7980
})
8081

8182
t.Run("GetLatestPriceSeqNr", func(t *testing.T) {
8283
seqNr, err := chainAccessor.GetLatestPriceSeqNr(ctx)
8384
assert.NoError(t, err)
84-
assert.Equal(t, uint64(42), seqNr)
85+
assert.Equal(t, ccipocr3.SeqNum(42), seqNr)
8586
})
8687

8788
t.Run("MsgsBetweenSeqNums", func(t *testing.T) {

pkg/types/ccipocr3/chainaccessor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ type DestinationAccessor interface {
134134
// Access Type: Method(GetChainFeePriceUpdate)
135135
// Contract: FeeQuoter
136136
// Confidence: Unconfirmed
137-
GetChainFeePriceUpdate(ctx context.Context, selectors []ChainSelector) map[ChainSelector]TimestampedBig
137+
GetChainFeePriceUpdate(ctx context.Context, selectors []ChainSelector) (map[ChainSelector]TimestampedUnixBig, error)
138138

139139
// GetLatestPriceSeqNr returns the latest price sequence number for the destination chain.
140140
// Not to confuse with the sequence number of the messages. This is the OCR sequence number.
141141
//
142142
// Access Type: Method(GetLatestPriceSequenceNumber)
143143
// Contract: OffRamp
144144
// Confidence: Unconfirmed
145-
GetLatestPriceSeqNr(ctx context.Context) (uint64, error)
145+
GetLatestPriceSeqNr(ctx context.Context) (SeqNum, error)
146146
}
147147

148148
type SourceAccessor interface {

0 commit comments

Comments
 (0)