Closes: #760
Solution:
- emit tx index to cosmos events
- rpc side try to use the events, but fallback to heavier approach when fails.
Update rpc/ethereum/namespaces/eth/api.go
changelog
fix lint
fix TxIndexFromEvents
fix
Update rpc/ethereum/backend/backend.go
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Uses the fastest slice making idiom of creating the well known
size of a slice using
make([]sdk.Attribute, len(response.Logs))
for i, log := range response.Logs {
txLogAttrs[i] = ...
}
instead of
make([]sdk.Attribute, 0)
for _, log := range response.Logs {
txLogAttrs = append(txLogAttrs, ...)
}
which had a few problems:
1. Using 0 for size then appending is quite slow yet we know the exact size
2. Using append instead of indexing is slower
If we examine the advisory at https://bencher.orijtech.com/perfclinic/sliceupdate/
and the verdict at https://bencher.orijtech.com/perfclinic/sliceupdate/#verdict
this new scheme shows a massive improvement in that call site.
Fixes#825
* x/evm/keeper: save 24B with Go in-condition variable idiom
The prior code doubly invoked (*ethereum/go-ethereum/core/types.Transaction).To()
which is quite expensive, and firstly copies 20 bytes each time, then
that gets rounded up to the proper size class/pointer alignment so on
64-bit machines 20B -> 24B.
Isolating a benchmark for this code per issue #826 shows this saves
quite a bit of bytes and some nano seconds which all count up towards
the transactions per seconds being processed:
```shell
$ benchstat before.txt after.txt
name old time/op new time/op delta
CopyAddr-8 38.4ns ± 3% 19.3ns ± 3% -49.66% (p=0.000 n=10+10)
name old alloc/op new alloc/op delta
CopyAddr-8 48.0B ± 0% 24.0B ± 0% -50.00% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
CopyAddr-8 2.00 ± 0% 1.00 ± 0% -50.00% (p=0.000 n=10+10)
```
Fixes#826
* changelog
* lint
* Revert stray changes that were used in testing
* rm log
Co-authored-by: Federico Kunze Küllmer <federico.kunze94@gmail.com>
* Problem: tx log attribute value not parsable by some client
Closes: #614
Solution:
- encode the value to json string rather than bytes
Apply suggestions from code review
* rm cdc and changelog
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Co-authored-by: Federico Kunze <federico.kunze94@gmail.com>