From 483eb1da9cfd5a69c62758b58a968af6106615ed Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Mon, 12 Aug 2024 18:03:06 +0300 Subject: [PATCH 1/7] Add evm and flow fees metric --- bootstrap/bootstrap.go | 2 +- config/config.go | 2 +- go.mod | 12 +++-- go.sum | 23 ++++++---- metrics/collector.go | 74 +++++++++++++++++++++++++++++- metrics/nop.go | 18 +++++--- services/ingestion/engine.go | 7 ++- services/requester/pool.go | 11 ++++- services/requester/remote_state.go | 2 +- 9 files changed, 126 insertions(+), 25 deletions(-) diff --git a/bootstrap/bootstrap.go b/bootstrap/bootstrap.go index 064ad149..2a901315 100644 --- a/bootstrap/bootstrap.go +++ b/bootstrap/bootstrap.go @@ -295,7 +295,7 @@ func startServer( } // create transaction pool - txPool := requester.NewTxPool(client, transactionsPublisher, logger) + txPool := requester.NewTxPool(client, transactionsPublisher, logger, collector) evm, err := requester.NewEVM( client, diff --git a/config/config.go b/config/config.go index 7c073d91..0a7276c8 100644 --- a/config/config.go +++ b/config/config.go @@ -159,7 +159,7 @@ func FromFlags() (*Config, error) { // TEMP: Only set this after the HCU containing the direct call // hash calculation change has been successfully deployed. flag.Uint64Var(&cfg.HashCalculationHeightChange, "hash-calc-height-change", 0, "Cadence height at which the direct call hash calculation changed") - flag.IntVar(&cfg.MetricsPort, "metrics-port", 8080, "Port for the metrics server") + flag.IntVar(&cfg.MetricsPort, "metrics-port", 8081, "Port for the metrics server") flag.BoolVar(&cfg.IndexOnly, "index-only", false, "Run the gateway in index-only mode which only allows querying the state and indexing, but disallows sending transactions.") flag.Parse() diff --git a/go.mod b/go.mod index e94cdd43..acb5f847 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,14 @@ go 1.22 require ( cloud.google.com/go/storage v1.36.0 + github.com/aws/aws-sdk-go-v2 v1.27.0 github.com/cockroachdb/pebble v1.1.1 github.com/goccy/go-json v0.10.2 github.com/google/uuid v1.6.0 - github.com/onflow/atree v0.7.0-rc.2 - github.com/onflow/cadence v1.0.0-preview.39 + github.com/onflow/atree v0.8.0-rc.5 + github.com/onflow/cadence v1.0.0-preview.44 github.com/onflow/flow-go v0.36.4 - github.com/onflow/flow-go-sdk v1.0.0-preview.42 + github.com/onflow/flow-go-sdk v1.0.0-preview.47 github.com/onflow/flow/protobuf/go/flow v0.4.5 github.com/onflow/go-ethereum v1.14.7 github.com/prometheus/client_golang v1.18.0 @@ -37,6 +38,7 @@ require ( github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.2 // indirect + github.com/aws/smithy-go v1.20.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect @@ -208,6 +210,8 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect + lukechampine.com/blake3 v1.3.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +replace github.com/onflow/flow-go v0.36.4 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 diff --git a/go.sum b/go.sum index b5464197..ae50ebfb 100644 --- a/go.sum +++ b/go.sum @@ -978,6 +978,8 @@ github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqR github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 h1:bZ3VaQ5IzmXDGGtjD57P7niXX9BwTmhKDEf/cJJbLkk= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6/go.mod h1:kOwwE+pynAdIeKYh1txJbdUgM/zcmXJgoIBt4rv8Uwk= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= @@ -1009,6 +1011,8 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2 v1.23.1/go.mod h1:i1XDttT4rnf6vxc9AuskLc6s7XBee8rlLilKlc03uAA= +github.com/aws/aws-sdk-go-v2 v1.27.0 h1:7bZWKoXhzI+mMR/HjdMx8ZCC5+6fY0lS5tr0bbgiLlo= +github.com/aws/aws-sdk-go-v2 v1.27.0/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= github.com/aws/aws-sdk-go-v2/config v1.18.45/go.mod h1:ZwDUgFnQgsazQTnWfeLWk5GjeqTQTL8lMkoE1UXzxdE= github.com/aws/aws-sdk-go-v2/config v1.25.5/go.mod h1:Bf4gDvy4ZcFIK0rqDu1wp9wrubNba2DojiPB2rt6nvI= @@ -1042,6 +1046,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.25.4/go.mod h1:feTnm2Tk/pJxdX+eooEsx github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.17.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= +github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= +github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -1845,11 +1851,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= -github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U= -github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= +github.com/onflow/atree v0.8.0-rc.5 h1:1sU+c6UfDzq/EjM8nTw4EI8GvEMarcxkWkJKy6piFSY= +github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.39 h1:BDx+hO4THUW6cDN11tqVtBx8hFSUErjQkw/WDAGs0C4= -github.com/onflow/cadence v1.0.0-preview.39/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence v1.0.0-preview.44 h1:APQ8DzIS6kX4FMZsaYoucbvF/PPwjHEerr+aGRDcPz4= +github.com/onflow/cadence v1.0.0-preview.44/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= @@ -1861,11 +1867,9 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/ github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go v0.36.4 h1:T4678J5Ib6z2spIolhKCgDIUznxW7dNiJq1bzDntS9k= -github.com/onflow/flow-go v0.36.4/go.mod h1:OGWZcM13nXoqBF3nyv5en/NVtBN9e5zJe4eLV1dzXSE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.42 h1:XcHWRQfkJ5A24sNqnmo3DocHdf5ulDJLie9/yh5c1Y4= -github.com/onflow/flow-go-sdk v1.0.0-preview.42/go.mod h1:4/ELH5ooEdZ+9tZfoiTIkkB4B6wVgy4HbMjS/9w/67Q= +github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= +github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= @@ -3141,8 +3145,9 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= diff --git a/metrics/collector.go b/metrics/collector.go index c585a534..d7e974d4 100644 --- a/metrics/collector.go +++ b/metrics/collector.go @@ -2,8 +2,14 @@ package metrics import ( "fmt" + "math/big" + "strings" "time" + sdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/fvm/evm/events" + "github.com/onflow/flow-go/model/flow" + "github.com/onflow/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" "github.com/rs/zerolog" ) @@ -15,18 +21,22 @@ type Collector interface { EVMHeightIndexed(height uint64) EVMAccountInteraction(address string) MeasureRequestDuration(start time.Time, method string) + EVMFeesCollected(from common.Address, gasUsed uint64, gasPrice *big.Int) + FlowFeesCollected(from sdk.Address, txEvents []sdk.Event) } var _ Collector = &DefaultCollector{} type DefaultCollector struct { - // TODO: for now we cannot differentiate which api request failed number of times + logger zerolog.Logger apiErrorsCounter prometheus.Counter traceDownloadErrorCounter prometheus.Counter serverPanicsCounters *prometheus.CounterVec evmBlockHeight prometheus.Gauge evmAccountCallCounters *prometheus.CounterVec requestDurations *prometheus.HistogramVec + evmFees *prometheus.GaugeVec + flowFees *prometheus.GaugeVec } func NewCollector(logger zerolog.Logger) Collector { @@ -62,6 +72,20 @@ func NewCollector(logger zerolog.Logger) Collector { Buckets: prometheus.DefBuckets, }, []string{"method"}) + evmFees := prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: prefixedName("evm_fees_total"), + Help: "The total amount of fees collected on EVM side in gas", + }, []string{"account"}, + ) + + flowFees := prometheus.NewGaugeVec( + prometheus.GaugeOpts{ + Name: prefixedName("flow_fees_total"), + Help: "The total amount of fees collected on Flow side in FLOW", + }, []string{"account"}, + ) + metrics := []prometheus.Collector{ apiErrors, traceDownloadErrorCounter, @@ -69,19 +93,25 @@ func NewCollector(logger zerolog.Logger) Collector { evmBlockHeight, evmAccountCallCounters, requestDurations, + evmFees, + flowFees, } + if err := registerMetrics(logger, metrics...); err != nil { logger.Info().Msg("using noop collector as metric register failed") return NopCollector } return &DefaultCollector{ + logger: logger, apiErrorsCounter: apiErrors, traceDownloadErrorCounter: traceDownloadErrorCounter, serverPanicsCounters: serverPanicsCounters, evmBlockHeight: evmBlockHeight, evmAccountCallCounters: evmAccountCallCounters, requestDurations: requestDurations, + evmFees: evmFees, + flowFees: flowFees, } } @@ -123,6 +153,48 @@ func (c *DefaultCollector) MeasureRequestDuration(start time.Time, method string Observe(float64(time.Since(start))) } +func (c *DefaultCollector) EVMFeesCollected(from common.Address, gasUsed uint64, gasPrice *big.Int) { + gasUsedBigInt := new(big.Int).SetUint64(gasUsed) + gasBigInt := new(big.Int).Mul(gasUsedBigInt, gasPrice) + + gasFloat64, accuracy := gasBigInt.Float64() + if accuracy != big.Exact { + c.logger.Warn().Msg("precision lost when converting gas price to float64 in metrics collector") + return + } + + gas := float64(gasUsed) * gasFloat64 + c.evmFees.With(prometheus.Labels{"account": from.String()}).Add(gas) +} + +func (c *DefaultCollector) FlowFeesCollected(from sdk.Address, txEvents []sdk.Event) { + feesDeducted, err := findEvent(events.EventTypeFlowFeesDeducted, txEvents) + if err != nil { + c.logger.Debug().Err(err).Msg("fees metric will not be collected as appropriate event was not found") + return + } + + feesDeductedPayload, err := events.DecodeFlowFeesDeductedEventPayload(feesDeducted.Value) + if err != nil { + c.logger.Debug().Err(err).Msg("failed to decode fees deducted payload") + return + } + + c.flowFees. + With(prometheus.Labels{"account": from.String()}). + Add(float64(feesDeductedPayload.Amount)) +} + func prefixedName(name string) string { return fmt.Sprintf("evm_gateway_%s", name) } + +func findEvent(eventType flow.EventType, events []sdk.Event) (sdk.Event, error) { + for _, event := range events { + if strings.Contains(event.Type, string(eventType)) { + return event, nil + } + } + + return sdk.Event{}, fmt.Errorf("no event with type %s found", eventType) +} diff --git a/metrics/nop.go b/metrics/nop.go index f113bfb6..9d9839ad 100644 --- a/metrics/nop.go +++ b/metrics/nop.go @@ -1,7 +1,11 @@ package metrics import ( + "math/big" "time" + + sdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/go-ethereum/common" ) type nopCollector struct{} @@ -10,9 +14,11 @@ var _ Collector = &nopCollector{} var NopCollector = &nopCollector{} -func (c *nopCollector) ApiErrorOccurred() {} -func (c *nopCollector) TraceDownloadFailed() {} -func (c *nopCollector) ServerPanicked(string) {} -func (c *nopCollector) EVMHeightIndexed(uint64) {} -func (c *nopCollector) EVMAccountInteraction(string) {} -func (c *nopCollector) MeasureRequestDuration(time.Time, string) {} +func (c *nopCollector) ApiErrorOccurred() {} +func (c *nopCollector) TraceDownloadFailed() {} +func (c *nopCollector) ServerPanicked(string) {} +func (c *nopCollector) EVMHeightIndexed(uint64) {} +func (c *nopCollector) EVMAccountInteraction(string) {} +func (c *nopCollector) MeasureRequestDuration(time.Time, string) {} +func (c *nopCollector) EVMFeesCollected(common.Address, uint64, *big.Int) {} +func (c *nopCollector) FlowFeesCollected(sdk.Address, []sdk.Event) {} diff --git a/services/ingestion/engine.go b/services/ingestion/engine.go index b71d7882..804221fb 100644 --- a/services/ingestion/engine.go +++ b/services/ingestion/engine.go @@ -159,7 +159,12 @@ func (e *Engine) processEvents(events *models.CadenceEvents) error { for i, tx := range events.Transactions() { receipt := events.Receipts()[i] - err := e.indexTransaction(tx, receipt, batch) + from, err := tx.From() + if err == nil { + e.collector.EVMFeesCollected(from, receipt.GasUsed, receipt.EffectiveGasPrice) + } + + err = e.indexTransaction(tx, receipt, batch) if err != nil { return fmt.Errorf("failed to index transaction %s event: %w", tx.Hash().String(), err) } diff --git a/services/requester/pool.go b/services/requester/pool.go index 61405a29..8be7cc1a 100644 --- a/services/requester/pool.go +++ b/services/requester/pool.go @@ -12,6 +12,7 @@ import ( "github.com/rs/zerolog" "github.com/sethvargo/go-retry" + "github.com/onflow/flow-evm-gateway/metrics" "github.com/onflow/flow-evm-gateway/models" errs "github.com/onflow/flow-evm-gateway/models/errors" ) @@ -30,6 +31,7 @@ type TxPool struct { client *CrossSporkClient pool *sync.Map txPublisher *models.Publisher + collector metrics.Collector // todo add methods to inspect transaction pool state } @@ -37,12 +39,14 @@ func NewTxPool( client *CrossSporkClient, transactionsPublisher *models.Publisher, logger zerolog.Logger, + collector metrics.Collector, ) *TxPool { return &TxPool{ logger: logger.With().Str("component", "tx-pool").Logger(), client: client, txPublisher: transactionsPublisher, pool: &sync.Map{}, + collector: collector, } } @@ -67,7 +71,8 @@ func (t *TxPool) Send( backoff := retry.WithMaxDuration(time.Minute*3, retry.NewFibonacci(time.Millisecond*100)) - return retry.Do(ctx, backoff, func(ctx context.Context) error { + var txRes flow.TransactionResult + err := retry.Do(ctx, backoff, func(ctx context.Context) error { res, err := t.client.GetTransactionResult(ctx, flowTx.ID()) if err != nil { return fmt.Errorf("failed to retrieve flow transaction result %s: %w", flowTx.ID(), err) @@ -91,8 +96,12 @@ func (t *TxPool) Send( return fmt.Errorf("failed to submit flow evm transaction %s", evmTx.Hash()) } + txRes = *res return nil }) + + t.collector.FlowFeesCollected(flowTx.Payer, txRes.Events) + return err } // this will extract the evm specific error from the Flow transaction error message diff --git a/services/requester/remote_state.go b/services/requester/remote_state.go index 0878ecc3..6c6f5468 100644 --- a/services/requester/remote_state.go +++ b/services/requester/remote_state.go @@ -80,6 +80,6 @@ func (l *remoteLedger) SetValue(owner, key, value []byte) (err error) { panic("read only") } -func (l *remoteLedger) AllocateStorageIndex(owner []byte) (atree.StorageIndex, error) { +func (l *remoteLedger) AllocateSlabIndex(owner []byte) (atree.SlabIndex, error) { panic("read only") } From 53b7a9ad1def12e6b83cd5ab7c5b296811322039 Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Tue, 13 Aug 2024 12:39:06 +0300 Subject: [PATCH 2/7] run go mod tidy --- go.mod | 2 -- go.sum | 4 ---- 2 files changed, 6 deletions(-) diff --git a/go.mod b/go.mod index acb5f847..50269df2 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,6 @@ go 1.22 require ( cloud.google.com/go/storage v1.36.0 - github.com/aws/aws-sdk-go-v2 v1.27.0 github.com/cockroachdb/pebble v1.1.1 github.com/goccy/go-json v0.10.2 github.com/google/uuid v1.6.0 @@ -38,7 +37,6 @@ require ( github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/VictoriaMetrics/fastcache v1.12.2 // indirect - github.com/aws/smithy-go v1.20.2 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect diff --git a/go.sum b/go.sum index ae50ebfb..429e4e5d 100644 --- a/go.sum +++ b/go.sum @@ -1011,8 +1011,6 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM= github.com/aws/aws-sdk-go-v2 v1.23.1/go.mod h1:i1XDttT4rnf6vxc9AuskLc6s7XBee8rlLilKlc03uAA= -github.com/aws/aws-sdk-go-v2 v1.27.0 h1:7bZWKoXhzI+mMR/HjdMx8ZCC5+6fY0lS5tr0bbgiLlo= -github.com/aws/aws-sdk-go-v2 v1.27.0/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM= github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= github.com/aws/aws-sdk-go-v2/config v1.18.45/go.mod h1:ZwDUgFnQgsazQTnWfeLWk5GjeqTQTL8lMkoE1UXzxdE= github.com/aws/aws-sdk-go-v2/config v1.25.5/go.mod h1:Bf4gDvy4ZcFIK0rqDu1wp9wrubNba2DojiPB2rt6nvI= @@ -1046,8 +1044,6 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.25.4/go.mod h1:feTnm2Tk/pJxdX+eooEsx github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aws/smithy-go v1.17.0/go.mod h1:NukqUGpCZIILqqiV0NIjeFh24kd/FAa4beRb6nbIUPE= -github.com/aws/smithy-go v1.20.2 h1:tbp628ireGtzcHDDmLT/6ADHidqnwgF57XOXZe6tp4Q= -github.com/aws/smithy-go v1.20.2/go.mod h1:krry+ya/rV9RDcV/Q16kpu6ypI4K2czasz0NC3qS14E= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= From 7b26445fb9914bf7213db9da7e5d9812b2ed8d1f Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Tue, 13 Aug 2024 12:44:08 +0300 Subject: [PATCH 3/7] run go mod tidy in tests --- tests/go.mod | 8 ++++---- tests/go.sum | 15 ++++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 81154373..8b5869e6 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -4,12 +4,12 @@ go 1.22 require ( github.com/goccy/go-json v0.10.2 - github.com/onflow/cadence v1.0.0-preview.39 + github.com/onflow/cadence v1.0.0-preview.44 github.com/onflow/crypto v0.25.1 github.com/onflow/flow-emulator v1.0.0-preview.35.0.20240725141711-547155b39eb9 github.com/onflow/flow-evm-gateway v0.0.0-20240201154855-4d4d3d3f19c7 github.com/onflow/flow-go v0.36.4 - github.com/onflow/flow-go-sdk v1.0.0-preview.42 + github.com/onflow/flow-go-sdk v1.0.0-preview.47 github.com/onflow/go-ethereum v1.14.7 github.com/rs/zerolog v1.31.0 github.com/stretchr/testify v1.9.0 @@ -145,7 +145,7 @@ require ( github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/onflow/atree v0.7.0-rc.2 // indirect + github.com/onflow/atree v0.8.0-rc.5 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect @@ -232,7 +232,7 @@ require ( google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - lukechampine.com/blake3 v1.2.1 // indirect + lukechampine.com/blake3 v1.3.0 // indirect modernc.org/libc v1.37.6 // indirect modernc.org/mathutil v1.6.0 // indirect modernc.org/memory v1.7.2 // indirect diff --git a/tests/go.sum b/tests/go.sum index 9ee2ea1b..51dc61ed 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -2072,11 +2072,11 @@ github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:v github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onflow/atree v0.6.1-0.20230711151834-86040b30171f/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= -github.com/onflow/atree v0.7.0-rc.2 h1:mZmVrl/zPlfI44EjV3FdR2QwIqT8nz1sCONUBFcML/U= -github.com/onflow/atree v0.7.0-rc.2/go.mod h1:xvP61FoOs95K7IYdIYRnNcYQGf4nbF/uuJ0tHf4DRuM= +github.com/onflow/atree v0.8.0-rc.5 h1:1sU+c6UfDzq/EjM8nTw4EI8GvEMarcxkWkJKy6piFSY= +github.com/onflow/atree v0.8.0-rc.5/go.mod h1:yccR+LR7xc1Jdic0mrjocbHvUD7lnVvg8/Ct1AA5zBo= github.com/onflow/cadence v1.0.0-M3/go.mod h1:odXGZZ/wGNA5mwT8bC9v8u8EXACHllB2ABSZK65TGL8= -github.com/onflow/cadence v1.0.0-preview.39 h1:BDx+hO4THUW6cDN11tqVtBx8hFSUErjQkw/WDAGs0C4= -github.com/onflow/cadence v1.0.0-preview.39/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmpdpNNAFxBsjMlrqVD0= +github.com/onflow/cadence v1.0.0-preview.44 h1:APQ8DzIS6kX4FMZsaYoucbvF/PPwjHEerr+aGRDcPz4= +github.com/onflow/cadence v1.0.0-preview.44/go.mod h1:BCoenp1TYp+SmG7FGWStjehvvzcvNQ3xvpK5rkthq3Y= github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A= github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= @@ -2093,8 +2093,8 @@ github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyu github.com/onflow/flow-go v0.36.4 h1:T4678J5Ib6z2spIolhKCgDIUznxW7dNiJq1bzDntS9k= github.com/onflow/flow-go v0.36.4/go.mod h1:OGWZcM13nXoqBF3nyv5en/NVtBN9e5zJe4eLV1dzXSE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= -github.com/onflow/flow-go-sdk v1.0.0-preview.42 h1:XcHWRQfkJ5A24sNqnmo3DocHdf5ulDJLie9/yh5c1Y4= -github.com/onflow/flow-go-sdk v1.0.0-preview.42/go.mod h1:4/ELH5ooEdZ+9tZfoiTIkkB4B6wVgy4HbMjS/9w/67Q= +github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= +github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1 h1:woAAS5z651sDpi7ihAHll8NvRS9uFXIXkL6xR+bKFZY= github.com/onflow/flow-nft/lib/go/contracts v1.2.1/go.mod h1:2gpbza+uzs1k7x31hkpBPlggIRkI53Suo0n2AyA2HcE= github.com/onflow/flow-nft/lib/go/templates v1.2.0 h1:JSQyh9rg0RC+D1930BiRXN8lrtMs+ubVMK6aQPon6Yc= @@ -3482,8 +3482,9 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= -lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI= lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= +lukechampine.com/blake3 v1.3.0 h1:sJ3XhFINmHSrYCgl958hscfIa3bw8x4DqMP3u1YvoYE= +lukechampine.com/blake3 v1.3.0/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k= lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk= modernc.org/cc/v3 v3.36.0/go.mod h1:NFUHyPn4ekoC/JHeZFfZurN6ixxawE1BnVonP/oahEI= From 2f3c386c7358a7c12efe93238aa6c1d6437ce4cd Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Tue, 13 Aug 2024 12:49:02 +0300 Subject: [PATCH 4/7] add a replace in go.mod --- tests/go.mod | 2 ++ tests/go.sum | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/go.mod b/tests/go.mod index 8b5869e6..4fb6e09f 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -242,3 +242,5 @@ require ( ) replace github.com/onflow/flow-evm-gateway => ../ + +replace github.com/onflow/flow-go v0.36.4 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 diff --git a/tests/go.sum b/tests/go.sum index 51dc61ed..4053b059 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -981,6 +981,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 h1:bZ3VaQ5IzmXDGGtjD57P7niXX9BwTmhKDEf/cJJbLkk= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6/go.mod h1:kOwwE+pynAdIeKYh1txJbdUgM/zcmXJgoIBt4rv8Uwk= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= @@ -2090,8 +2092,6 @@ github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/ github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go v0.36.4 h1:T4678J5Ib6z2spIolhKCgDIUznxW7dNiJq1bzDntS9k= -github.com/onflow/flow-go v0.36.4/go.mod h1:OGWZcM13nXoqBF3nyv5en/NVtBN9e5zJe4eLV1dzXSE= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= github.com/onflow/flow-go-sdk v1.0.0-preview.47 h1:vdolgj6nFCR/xPoEOHyYzAg9o9hdXQpPnL7HJPPTXGU= github.com/onflow/flow-go-sdk v1.0.0-preview.47/go.mod h1:YAYzmUUytKqri3aMgeKGjvDjvawignNobUI9s2mKdXY= From afea3c7fd6003c493cee436258d7d20ea137e60a Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Wed, 14 Aug 2024 12:44:24 +0300 Subject: [PATCH 5/7] update flow-go replace --- go.mod | 2 +- go.sum | 4 ++-- tests/go.mod | 2 +- tests/go.sum | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 93c90b5e..d0ad4a6d 100644 --- a/go.mod +++ b/go.mod @@ -212,4 +212,4 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) -replace github.com/onflow/flow-go v0.37.1 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 +replace github.com/onflow/flow-go v0.37.1 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc diff --git a/go.sum b/go.sum index 01deb567..c21a6814 100644 --- a/go.sum +++ b/go.sum @@ -978,8 +978,8 @@ github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqR github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 h1:bZ3VaQ5IzmXDGGtjD57P7niXX9BwTmhKDEf/cJJbLkk= -github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6/go.mod h1:kOwwE+pynAdIeKYh1txJbdUgM/zcmXJgoIBt4rv8Uwk= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc h1:Cs/omBT4gRwW/L/GF4A8KQw0VPvCPQ6F8T9DVG6mGLI= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc/go.mod h1:hLFem+cwkq6650p4+0DUp36GH2QEuuFDCDUzDg0QZNE= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= diff --git a/tests/go.mod b/tests/go.mod index 8f78a128..acfbe8c4 100644 --- a/tests/go.mod +++ b/tests/go.mod @@ -243,4 +243,4 @@ require ( replace github.com/onflow/flow-evm-gateway => ../ -replace github.com/onflow/flow-go v0.37.1 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 +replace github.com/onflow/flow-go v0.37.1 => github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc diff --git a/tests/go.sum b/tests/go.sum index f79d1360..22296d62 100644 --- a/tests/go.sum +++ b/tests/go.sum @@ -981,8 +981,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6 h1:bZ3VaQ5IzmXDGGtjD57P7niXX9BwTmhKDEf/cJJbLkk= -github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240812142541-3dcd3ce6d5b6/go.mod h1:kOwwE+pynAdIeKYh1txJbdUgM/zcmXJgoIBt4rv8Uwk= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc h1:Cs/omBT4gRwW/L/GF4A8KQw0VPvCPQ6F8T9DVG6mGLI= +github.com/The-K-R-O-K/flow-go v0.35.15-crescendo-preview.28-atree-inlining.0.20240814093750-db66de6115bc/go.mod h1:hLFem+cwkq6650p4+0DUp36GH2QEuuFDCDUzDg0QZNE= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= From d54de8d979f7ab1ec299b2cf07f68eb2f2ff463c Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Thu, 15 Aug 2024 17:17:52 +0300 Subject: [PATCH 6/7] refactor evm fees interface --- metrics/collector.go | 19 ++++++++++++++++--- metrics/nop.go | 20 ++++++++++---------- services/ingestion/engine.go | 7 ++----- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/metrics/collector.go b/metrics/collector.go index d7e974d4..f5a64196 100644 --- a/metrics/collector.go +++ b/metrics/collector.go @@ -9,9 +9,10 @@ import ( sdk "github.com/onflow/flow-go-sdk" "github.com/onflow/flow-go/fvm/evm/events" "github.com/onflow/flow-go/model/flow" - "github.com/onflow/go-ethereum/common" "github.com/prometheus/client_golang/prometheus" "github.com/rs/zerolog" + + "github.com/onflow/flow-evm-gateway/models" ) type Collector interface { @@ -21,7 +22,7 @@ type Collector interface { EVMHeightIndexed(height uint64) EVMAccountInteraction(address string) MeasureRequestDuration(start time.Time, method string) - EVMFeesCollected(from common.Address, gasUsed uint64, gasPrice *big.Int) + EVMFeesCollected(tx models.Transaction, receipt *models.StorageReceipt) FlowFeesCollected(from sdk.Address, txEvents []sdk.Event) } @@ -153,7 +154,19 @@ func (c *DefaultCollector) MeasureRequestDuration(start time.Time, method string Observe(float64(time.Since(start))) } -func (c *DefaultCollector) EVMFeesCollected(from common.Address, gasUsed uint64, gasPrice *big.Int) { +func (c *DefaultCollector) EVMFeesCollected(tx models.Transaction, receipt *models.StorageReceipt) { + if receipt == nil { + return + } + + from, err := tx.From() + if err != nil { + return + } + + gasUsed := receipt.GasUsed + gasPrice := receipt.EffectiveGasPrice + gasUsedBigInt := new(big.Int).SetUint64(gasUsed) gasBigInt := new(big.Int).Mul(gasUsedBigInt, gasPrice) diff --git a/metrics/nop.go b/metrics/nop.go index 9d9839ad..731b5bae 100644 --- a/metrics/nop.go +++ b/metrics/nop.go @@ -1,11 +1,11 @@ package metrics import ( - "math/big" "time" sdk "github.com/onflow/flow-go-sdk" - "github.com/onflow/go-ethereum/common" + + "github.com/onflow/flow-evm-gateway/models" ) type nopCollector struct{} @@ -14,11 +14,11 @@ var _ Collector = &nopCollector{} var NopCollector = &nopCollector{} -func (c *nopCollector) ApiErrorOccurred() {} -func (c *nopCollector) TraceDownloadFailed() {} -func (c *nopCollector) ServerPanicked(string) {} -func (c *nopCollector) EVMHeightIndexed(uint64) {} -func (c *nopCollector) EVMAccountInteraction(string) {} -func (c *nopCollector) MeasureRequestDuration(time.Time, string) {} -func (c *nopCollector) EVMFeesCollected(common.Address, uint64, *big.Int) {} -func (c *nopCollector) FlowFeesCollected(sdk.Address, []sdk.Event) {} +func (c *nopCollector) ApiErrorOccurred() {} +func (c *nopCollector) TraceDownloadFailed() {} +func (c *nopCollector) ServerPanicked(string) {} +func (c *nopCollector) EVMHeightIndexed(uint64) {} +func (c *nopCollector) EVMAccountInteraction(string) {} +func (c *nopCollector) MeasureRequestDuration(time.Time, string) {} +func (c *nopCollector) EVMFeesCollected(models.Transaction, *models.StorageReceipt) {} +func (c *nopCollector) FlowFeesCollected(sdk.Address, []sdk.Event) {} diff --git a/services/ingestion/engine.go b/services/ingestion/engine.go index 816f45fd..522a1638 100644 --- a/services/ingestion/engine.go +++ b/services/ingestion/engine.go @@ -159,15 +159,12 @@ func (e *Engine) processEvents(events *models.CadenceEvents) error { for i, tx := range events.Transactions() { receipt := events.Receipts()[i] - from, err := tx.From() - if err == nil { - e.collector.EVMFeesCollected(from, receipt.GasUsed, receipt.EffectiveGasPrice) - } - err = e.indexTransaction(tx, receipt, batch) if err != nil { return fmt.Errorf("failed to index transaction %s event: %w", tx.Hash().String(), err) } + + e.collector.EVMFeesCollected(tx, receipt) } err = e.indexReceipts(events.Receipts(), events.Block(), batch) From cf92c7b976d50084a10649a76211cccc0cee9ab5 Mon Sep 17 00:00:00 2001 From: Illia Malachyn Date: Thu, 15 Aug 2024 17:21:04 +0300 Subject: [PATCH 7/7] add logs --- metrics/collector.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/metrics/collector.go b/metrics/collector.go index f5a64196..248a3b6b 100644 --- a/metrics/collector.go +++ b/metrics/collector.go @@ -156,11 +156,13 @@ func (c *DefaultCollector) MeasureRequestDuration(start time.Time, method string func (c *DefaultCollector) EVMFeesCollected(tx models.Transaction, receipt *models.StorageReceipt) { if receipt == nil { + c.logger.Debug().Msg("storage receipt is nil") return } from, err := tx.From() if err != nil { + c.logger.Debug().Msg("could not retrieve transaction sender") return } @@ -172,7 +174,7 @@ func (c *DefaultCollector) EVMFeesCollected(tx models.Transaction, receipt *mode gasFloat64, accuracy := gasBigInt.Float64() if accuracy != big.Exact { - c.logger.Warn().Msg("precision lost when converting gas price to float64 in metrics collector") + c.logger.Debug().Msg("precision lost when converting gas price to float64 in metrics collector") return }