From 548e1f44dccd2829eadbca8a2f40b68a238ac1ed Mon Sep 17 00:00:00 2001 From: jmank88 Date: Tue, 18 Apr 2023 12:05:04 -0500 Subject: [PATCH] core/services/relay/evm: restore checksummed transmitter addresses --- core/services/relay/evm/config_poller.go | 3 +-- core/services/relay/evm/config_poller_test.go | 9 +-------- core/services/relay/evm/contract_transmitter.go | 3 +-- core/services/relay/evm/contract_transmitter_test.go | 3 +-- 4 files changed, 4 insertions(+), 14 deletions(-) diff --git a/core/services/relay/evm/config_poller.go b/core/services/relay/evm/config_poller.go index 93a5e6fe78c..217545de2b4 100644 --- a/core/services/relay/evm/config_poller.go +++ b/core/services/relay/evm/config_poller.go @@ -3,7 +3,6 @@ package evm import ( "context" "database/sql" - "fmt" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" @@ -50,7 +49,7 @@ func configFromLog(logData []byte) (ocrtypes.ContractConfig, error) { var transmitAccounts []ocrtypes.Account for _, addr := range unpacked.Transmitters { - transmitAccounts = append(transmitAccounts, ocrtypes.Account(fmt.Sprintf("0x%x", addr))) + transmitAccounts = append(transmitAccounts, ocrtypes.Account(addr.String())) } var signers []ocrtypes.OnchainPublicKey for _, addr := range unpacked.Signers { diff --git a/core/services/relay/evm/config_poller_test.go b/core/services/relay/evm/config_poller_test.go index 58b29b1cbcb..ca652b3508b 100644 --- a/core/services/relay/evm/config_poller_test.go +++ b/core/services/relay/evm/config_poller_test.go @@ -2,7 +2,6 @@ package evm import ( "math/big" - "strings" "testing" "time" @@ -94,19 +93,13 @@ func TestConfigPoller(t *testing.T) { return ocrtypes2.ConfigDigest{} != digest }, testutils.WaitTimeout(t), 100*time.Millisecond).Should(gomega.BeTrue()) - transmitters := make([]ocrtypes2.Account, len(contractConfig.Transmitters)) - for i, t := range contractConfig.Transmitters { - tt := strings.ToLower(string(t)) - transmitters[i] = ocrtypes2.Account(tt) - } - // Assert the config returned is the one we configured. newConfig, err := logPoller.LatestConfig(testutils.Context(t), configBlock) require.NoError(t, err) // Note we don't check onchainConfig, as that is populated in the contract itself. assert.Equal(t, digest, [32]byte(newConfig.ConfigDigest)) assert.Equal(t, contractConfig.Signers, newConfig.Signers) - assert.Equal(t, transmitters, newConfig.Transmitters) + assert.Equal(t, contractConfig.Transmitters, newConfig.Transmitters) assert.Equal(t, contractConfig.F, newConfig.F) assert.Equal(t, contractConfig.OffchainConfigVersion, newConfig.OffchainConfigVersion) assert.Equal(t, contractConfig.OffchainConfig, newConfig.OffchainConfig) diff --git a/core/services/relay/evm/contract_transmitter.go b/core/services/relay/evm/contract_transmitter.go index 8be6a674cc8..8969bb47705 100644 --- a/core/services/relay/evm/contract_transmitter.go +++ b/core/services/relay/evm/contract_transmitter.go @@ -4,7 +4,6 @@ import ( "context" "database/sql" "encoding/hex" - "fmt" "math/big" "github.com/ethereum/go-ethereum" @@ -170,7 +169,7 @@ func (oc *contractTransmitter) LatestConfigDigestAndEpoch(ctx context.Context) ( // FromAccount returns the account from which the transmitter invokes the contract func (oc *contractTransmitter) FromAccount() ocrtypes.Account { - return ocrtypes.Account(fmt.Sprintf("0x%x", oc.transmitter.FromAddress())) + return ocrtypes.Account(oc.transmitter.FromAddress().String()) } func (oc *contractTransmitter) Start(ctx context.Context) error { return nil } diff --git a/core/services/relay/evm/contract_transmitter_test.go b/core/services/relay/evm/contract_transmitter_test.go index 9de5c93c7a0..224c8f4e253 100644 --- a/core/services/relay/evm/contract_transmitter_test.go +++ b/core/services/relay/evm/contract_transmitter_test.go @@ -3,7 +3,6 @@ package evm import ( "context" "encoding/hex" - "fmt" "strings" "testing" @@ -67,5 +66,5 @@ func TestContractTransmitter(t *testing.T) { require.NoError(t, err) assert.Equal(t, "000130da6b9315bd59af6b0a3f5463c0d0a39e92eaa34cbcbdbace7b3bfcc777", hex.EncodeToString(digest[:])) assert.Equal(t, uint32(2), epoch) - assert.Equal(t, fmt.Sprintf("0x%x", sampleAddress), string(ot.FromAccount())) + assert.Equal(t, sampleAddress.String(), string(ot.FromAccount())) }