Skip to content

Commit

Permalink
Add value size counters for conf store precompiles (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt authored Sep 21, 2023
1 parent 8f443af commit 4d3e6fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/vm/contracts_suave.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 4d3e6fa

Please sign in to comment.