From 4d3e6fa68f2ccb1cc181dcd2bb04d65911f700c9 Mon Sep 17 00:00:00 2001 From: Ferran Borreguero Date: Thu, 21 Sep 2023 17:39:02 +0200 Subject: [PATCH] Add value size counters for conf store precompiles (#42) --- core/vm/contracts_suave.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/core/vm/contracts_suave.go b/core/vm/contracts_suave.go index cad5c456b..f997d8bd6 100644 --- a/core/vm/contracts_suave.go +++ b/core/vm/contracts_suave.go @@ -11,9 +11,15 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/metrics" suave "github.com/ethereum/go-ethereum/suave/core" ) +var ( + confStorePrecompileStoreMeter = metrics.NewRegisteredMeter("suave/confstore/store", nil) + confStorePrecompileRetrieveMeter = metrics.NewRegisteredMeter("suave/confstore/retrieve", nil) +) + var ( isConfidentialAddress = common.HexToAddress("0x42010000") errIsConfidentialInvalidInputLength = errors.New("invalid input length") @@ -128,6 +134,10 @@ func (c *confStoreStore) runImpl(backend *SuaveExecutionBackend, bidId [16]byte, } } + if metrics.Enabled { + confStorePrecompileStoreMeter.Mark(int64(len(data))) + } + _, err := backend.ConfidentialStoreBackend.Store(bidId, caller, key, data) if err != nil { return err @@ -192,6 +202,10 @@ func (c *confStoreRetrieve) runImpl(backend *SuaveExecutionBackend, bidId [16]by return []byte(err.Error()), err } + if metrics.Enabled { + confStorePrecompileRetrieveMeter.Mark(int64(len(data))) + } + return data, nil }