Skip to content
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
6 changes: 5 additions & 1 deletion core/services/registrysyncer/local_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package registrysyncer

import (
"context"
"encoding/hex"
"errors"
"fmt"
"math"
Expand Down Expand Up @@ -116,7 +117,10 @@ func (c CapabilityConfiguration) Unmarshal() (capabilities.CapabilityConfigurati
}
transmitters := make([]ocrtypes.Account, len(pbCfg.Transmitters))
for i, t := range pbCfg.Transmitters {
transmitters[i] = ocrtypes.Account(t)
// OCR3 transmitter accounts cross the loop boundary as hex-encoded text.
// Keep LocalRegistry aligned with the external OCR config service so the
// imported registry path and the direct registry path serialize the same way.
transmitters[i] = ocrtypes.Account(hex.EncodeToString(t))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your proposed way makes sense if we say these are always EVM transmitters. If they could be non-evm in the future, than I think transmitters[i] = ocrtypes.Account(hex.EncodeToString(t)) makes sense.

}
if pbCfg.F > math.MaxUint8 {
return capabilities.CapabilityConfiguration{}, fmt.Errorf("OCR3Config %q: F value %d exceeds uint8 max", name, pbCfg.F)
Expand Down
31 changes: 29 additions & 2 deletions core/services/registrysyncer/local_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func TestCapabilityConfiguration_Unmarshal(t *testing.T) {

t.Run("Ocr3Configs", func(t *testing.T) {
signer := []byte{0x01, 0x02, 0x03}
transmitter := []byte("0xabc")
transmitter := []byte{0xde, 0xad, 0xbe, 0xef}

raw := mustMarshalProto(t, &capabilitiespb.CapabilityConfig{
Ocr3Configs: map[string]*capabilitiespb.OCR3Config{
Expand All @@ -209,14 +209,41 @@ func TestCapabilityConfiguration_Unmarshal(t *testing.T) {
require.Contains(t, got.Ocr3Configs, "__default__")
cfg := got.Ocr3Configs["__default__"]
assert.Equal(t, []ocrtypes.OnchainPublicKey{signer}, cfg.Signers)
assert.Equal(t, []ocrtypes.Account{ocrtypes.Account(transmitter)}, cfg.Transmitters)
assert.Equal(t, []ocrtypes.Account{ocrtypes.Account("deadbeef")}, cfg.Transmitters)
assert.Equal(t, uint8(2), cfg.F)
assert.Equal(t, []byte("onchain"), cfg.OnchainConfig)
assert.Equal(t, uint64(5), cfg.OffchainConfigVersion)
assert.Equal(t, []byte("offchain"), cfg.OffchainConfig)
assert.Equal(t, uint64(3), cfg.ConfigCount)
})

t.Run("Ocr3Configs normalizes transmitters to hex text", func(t *testing.T) {
raw := mustMarshalProto(t, &capabilitiespb.CapabilityConfig{
Ocr3Configs: map[string]*capabilitiespb.OCR3Config{
"aptos": {
Transmitters: [][]byte{
{0x00, 0xff},
[]byte("ascii-bytes"),
},
},
},
})
cc := CapabilityConfiguration{Config: raw}

got, err := cc.Unmarshal()
require.NoError(t, err)

Comment thread
cawthorne marked this conversation as resolved.
require.Contains(t, got.Ocr3Configs, "aptos")
cfg := got.Ocr3Configs["aptos"]
assert.Equal(t,
[]ocrtypes.Account{
ocrtypes.Account("00ff"),
ocrtypes.Account("61736369692d6279746573"),
},
cfg.Transmitters,
)
})

t.Run("OracleFactoryConfigs", func(t *testing.T) {
raw := mustMarshalProto(t, &capabilitiespb.CapabilityConfig{
OracleFactoryConfigs: map[string]*valuespb.Map{
Expand Down
Loading