From 74a62561478bf48a6a32bb046c0417826cc939b9 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 3 Dec 2024 09:27:49 +0000 Subject: [PATCH] fix address compare (#2175) * fix address compare * fix the receipt log filtering --- go/enclave/rpc/GetTransactionReceipt.go | 6 +++--- go/host/enclave/service.go | 4 ++-- .../tests/nodescenario/sequencer_multi_enclave_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go/enclave/rpc/GetTransactionReceipt.go b/go/enclave/rpc/GetTransactionReceipt.go index b135f29d1d..107a2c90d2 100644 --- a/go/enclave/rpc/GetTransactionReceipt.go +++ b/go/enclave/rpc/GetTransactionReceipt.go @@ -86,7 +86,7 @@ func fetchFromCache(ctx context.Context, storage storage.Storage, cacheService * // receipt found in cache // for simplicity only the tx sender will access the cache // check whether the requester is the sender - if rec.From != requester { + if *rec.From != *requester { return nil, nil } @@ -145,8 +145,8 @@ func isAddress(topics []gethcommon.Hash, nr int, requester *gethcommon.Address) if len(topics) < nr+1 { return false } - topic := gethcommon.Address(topics[nr].Bytes()) - return topic == *requester + addressFromTopic := gethcommon.BytesToAddress(topics[nr].Bytes()) + return addressFromTopic == *requester } // marshalReceipt marshals a transaction receipt into a JSON object. diff --git a/go/host/enclave/service.go b/go/host/enclave/service.go index c0eab697ca..e027e26c48 100644 --- a/go/host/enclave/service.go +++ b/go/host/enclave/service.go @@ -127,7 +127,7 @@ func (e *Service) EvictEnclave(enclaveID *common.EnclaveID) { e.haLock.Lock() defer e.haLock.Unlock() for i, guardian := range e.enclaveGuardians { - if guardian.GetEnclaveID() == enclaveID { + if *(guardian.GetEnclaveID()) == *enclaveID { failedEnclaveIdx = i break } @@ -141,7 +141,7 @@ func (e *Service) EvictEnclave(enclaveID *common.EnclaveID) { e.enclaveGuardians = append(e.enclaveGuardians[:failedEnclaveIdx], e.enclaveGuardians[failedEnclaveIdx+1:]...) e.logger.Warn("Evicted enclave from HA pool.", log.EnclaveIDKey, enclaveID) - if e.activeSequencerID == enclaveID { + if *e.activeSequencerID == *enclaveID { // sequencer enclave has failed, so we need to select another one to promote as the active sequencer var i int for i = 0; i < len(e.enclaveGuardians); i++ { diff --git a/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go b/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go index 7226e71c5c..3e16b07c59 100644 --- a/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go +++ b/integration/networktest/tests/nodescenario/sequencer_multi_enclave_test.go @@ -38,7 +38,7 @@ func TestMultiEnclaveSequencer(t *testing.T) { // This test runs with an HA sequencer, does a transfer then kills the active sequencer enclave, // allows it time to failover then performs another transfer to check the failover was successful. // Note: this is a happy path failover, we need to test for edge cases etc and test the failover in a live testnet -func TestHASequencerFailover(t *testing.T) { +func TestHASequencerBackup(t *testing.T) { networktest.TestOnlyRunsInIDE(t) doubleTransferAmount := big.NewInt(2).Mul(big.NewInt(2), _transferAmount) networktest.Run(