diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index f75278c8b1..f94160fdd4 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -219,7 +219,7 @@ func (abi *ABI) MethodById(sigdata []byte) (*Method, error) { // ABI and returns nil if none found. func (abi *ABI) EventByID(topic common.Hash) (*Event, error) { for _, event := range abi.Events { - if bytes.Equal(event.ID.Bytes(), topic.Bytes()) { + if event.ID == topic { return &event, nil } } diff --git a/core/blockchain_snapshot_test.go b/core/blockchain_snapshot_test.go index ae9398b97d..de985635db 100644 --- a/core/blockchain_snapshot_test.go +++ b/core/blockchain_snapshot_test.go @@ -20,7 +20,6 @@ package core import ( - "bytes" "fmt" "math/big" "os" @@ -110,7 +109,7 @@ func (basic *snapshotTestBasic) prepare(t *testing.T) (*BlockChain, []*types.Blo // will be persisted atomically. chain.snaps.Cap(blocks[point-1].Root(), 0) diskRoot, blockRoot := chain.snaps.DiskRoot(), blocks[point-1].Root() - if !bytes.Equal(diskRoot.Bytes(), blockRoot.Bytes()) { + if diskRoot != blockRoot { t.Fatalf("Failed to flush disk layer change, want %x, got %x", blockRoot, diskRoot) } } @@ -149,7 +148,7 @@ func (basic *snapshotTestBasic) verify(t *testing.T, chain *BlockChain, blocks [ if block == nil { t.Errorf("The corresponding block[%d] of snapshot disk layer is missing", basic.expSnapshotBottom) } else if basic.scheme == rawdb.HashScheme { - if !bytes.Equal(chain.snaps.DiskRoot().Bytes(), block.Root().Bytes()) { + if chain.snaps.DiskRoot() != block.Root() { t.Errorf("The snapshot disk layer root is incorrect, want %x, get %x", block.Root(), chain.snaps.DiskRoot()) } } diff --git a/core/vm/instructions_test.go b/core/vm/instructions_test.go index 72f561f4bf..09a4ff27ff 100644 --- a/core/vm/instructions_test.go +++ b/core/vm/instructions_test.go @@ -680,7 +680,7 @@ func TestCreate2Addresses(t *testing.T) { fmt.Printf("Example %d\n* address `0x%x`\n* salt `0x%x`\n* init_code `0x%x`\n* gas (assuming no mem expansion): `%v`\n* result: `%s`\n\n", i,origin, salt, code, gas, address.String()) */ expected := common.BytesToAddress(common.FromHex(tt.expected)) - if !bytes.Equal(expected.Bytes(), address.Bytes()) { + if expected != address { t.Errorf("test %d: expected %s, got %s", i, expected.String(), address.String()) } } diff --git a/signer/fourbyte/validation.go b/signer/fourbyte/validation.go index 8bff011925..25e8aa14fd 100644 --- a/signer/fourbyte/validation.go +++ b/signer/fourbyte/validation.go @@ -74,7 +74,7 @@ func (db *Database) ValidateTransaction(selector *string, tx *apitypes.SendTxArg if !tx.To.ValidChecksum() { messages.Warn("Invalid checksum on recipient address") } - if bytes.Equal(tx.To.Address().Bytes(), common.Address{}.Bytes()) { + if tx.To.Address() == (common.Address{}) { messages.Crit("Transaction recipient is the zero address") } switch { diff --git a/triedb/pathdb/journal.go b/triedb/pathdb/journal.go index 02bdef5d34..ddf93abfb6 100644 --- a/triedb/pathdb/journal.go +++ b/triedb/pathdb/journal.go @@ -91,7 +91,7 @@ func (db *Database) loadJournal(diskRoot common.Hash) (layer, error) { } // The journal is not matched with persistent state, discard them. // It can happen that geth crashes without persisting the journal. - if !bytes.Equal(root.Bytes(), diskRoot.Bytes()) { + if root != diskRoot { return nil, fmt.Errorf("%w want %x got %x", errUnmatchedJournal, root, diskRoot) } // Load the disk layer from the journal