Skip to content

Commit

Permalink
mark as v1
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv committed Jun 28, 2024
1 parent e72d323 commit b0ced3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions core/services/ocr3/plugins/ccipevm/commitcodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/ocr2/plugins/ccip/abihelpers"
)

// CommitPluginCodec is a codec for encoding and decoding commit plugin reports.
// CommitPluginCodecV1 is a codec for encoding and decoding commit plugin reports.
// Compatible with:
// - "EVM2EVMMultiOffRamp 1.6.0-dev"
type CommitPluginCodec struct {
type CommitPluginCodecV1 struct {
commitReportAcceptedEventInputs abi.Arguments
}

func NewCommitPluginCodec() *CommitPluginCodec {
func NewCommitPluginCodecV1() *CommitPluginCodecV1 {
abiParsed, err := abi.JSON(strings.NewReader(evm_2_evm_multi_offramp.EVM2EVMMultiOffRampABI))
if err != nil {
panic(fmt.Errorf("parse multi offramp abi: %s", err))
}
eventInputs := abihelpers.MustGetEventInputs("CommitReportAccepted", abiParsed)
return &CommitPluginCodec{commitReportAcceptedEventInputs: eventInputs}
return &CommitPluginCodecV1{commitReportAcceptedEventInputs: eventInputs}
}

func (c *CommitPluginCodec) Encode(ctx context.Context, report cciptypes.CommitPluginReport) ([]byte, error) {
func (c *CommitPluginCodecV1) Encode(ctx context.Context, report cciptypes.CommitPluginReport) ([]byte, error) {
merkleRoots := make([]evm_2_evm_multi_offramp.EVM2EVMMultiOffRampMerkleRoot, 0, len(report.MerkleRoots))
for _, root := range report.MerkleRoots {
merkleRoots = append(merkleRoots, evm_2_evm_multi_offramp.EVM2EVMMultiOffRampMerkleRoot{
Expand Down Expand Up @@ -81,7 +81,7 @@ func (c *CommitPluginCodec) Encode(ctx context.Context, report cciptypes.CommitP
return c.commitReportAcceptedEventInputs.PackValues([]interface{}{evmReport})
}

func (c *CommitPluginCodec) Decode(ctx context.Context, bytes []byte) (cciptypes.CommitPluginReport, error) {
func (c *CommitPluginCodecV1) Decode(ctx context.Context, bytes []byte) (cciptypes.CommitPluginReport, error) {
unpacked, err := c.commitReportAcceptedEventInputs.Unpack(bytes)
if err != nil {
return cciptypes.CommitPluginReport{}, err
Expand Down Expand Up @@ -154,4 +154,4 @@ func (c *CommitPluginCodec) Decode(ctx context.Context, bytes []byte) (cciptypes
}

// Ensure CommitPluginCodec implements the CommitPluginCodec interface
var _ cciptypes.CommitPluginCodec = (*CommitPluginCodec)(nil)
var _ cciptypes.CommitPluginCodec = (*CommitPluginCodecV1)(nil)
6 changes: 3 additions & 3 deletions core/services/ocr3/plugins/ccipevm/commitcodec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var randomReport = cciptypes.CommitPluginReport{
}

func TestCommitPluginCodec(t *testing.T) {
commitCodec := NewCommitPluginCodec()
commitCodec := NewCommitPluginCodecV1()
ctx := testutils.Context(t)
encodedReport, err := commitCodec.Encode(ctx, randomReport)
require.NoError(t, err)
Expand All @@ -57,7 +57,7 @@ func TestCommitPluginCodec(t *testing.T) {
}

func BenchmarkCommitPluginCodec_Encode(b *testing.B) {
commitCodec := NewCommitPluginCodec()
commitCodec := NewCommitPluginCodecV1()
ctx := testutils.Context(b)

for i := 0; i < b.N; i++ {
Expand All @@ -67,7 +67,7 @@ func BenchmarkCommitPluginCodec_Encode(b *testing.B) {
}

func BenchmarkCommitPluginCodec_Decode(b *testing.B) {
commitCodec := NewCommitPluginCodec()
commitCodec := NewCommitPluginCodecV1()
ctx := testutils.Context(b)
encodedReport, err := commitCodec.Encode(ctx, randomReport)
require.NoError(b, err)
Expand Down

0 comments on commit b0ced3f

Please sign in to comment.