From 5eb3dcc19f97db087c9bcfe90c090e1dff43693a Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:34:35 +0200 Subject: [PATCH 1/2] copy data instead of reference return --- storage/pebble/storage.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/pebble/storage.go b/storage/pebble/storage.go index b7d9a445..a0938e84 100644 --- a/storage/pebble/storage.go +++ b/storage/pebble/storage.go @@ -88,6 +88,10 @@ func (s *Storage) get(keyCode byte, key ...[]byte) ([]byte, error) { prefixedKey := makePrefix(keyCode, key...) data, closer, err := s.db.Get(prefixedKey) + // temp workaround to a weird bug where the data changes after returned + cp := make([]byte, len(data)) + copy(cp, data) + if err != nil { if errors.Is(err, pebble.ErrNotFound) { return nil, errs.ErrNotFound @@ -102,7 +106,7 @@ func (s *Storage) get(keyCode byte, key ...[]byte) ([]byte, error) { } }(closer) - return data, nil + return cp, nil } // batchGet loads the value from an indexed batch if data is found, else it loads the value from the storage. From 46ba091253a9e002c9ad93af7734a75f5693a18b Mon Sep 17 00:00:00 2001 From: sideninja <75445744+sideninja@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:34:50 +0200 Subject: [PATCH 2/2] remove log --- api/api.go | 1 - 1 file changed, 1 deletion(-) diff --git a/api/api.go b/api/api.go index 507f6da1..a8dde16f 100644 --- a/api/api.go +++ b/api/api.go @@ -883,7 +883,6 @@ func (b *BlockChainAPI) prepareBlockResponse( fullTx bool, ) (*Block, error) { h, err := block.Hash() - fmt.Println("### HASH", h) if err != nil { b.logger.Error().Err(err).Msg("failed to calculate hash for block by number") return nil, errs.ErrInternal