Skip to content

Commit

Permalink
update evmlistener 0.3.5 (#8)
Browse files Browse the repository at this point in the history
* update log

* restore build
  • Loading branch information
secmask committed Apr 13, 2023
1 parent 14d673c commit fc264ac
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
# echo "::set-output name=version::$IMAGE_WITH_VERSION_TAG"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v2
if: github.event_name != 'pull_request'
# ===== for docker.io =====
# - name: Docker login
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@master
uses: docker/setup-buildx-action@v2

- name: Gcloud Auth
uses: google-github-actions/auth@v0
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## BUILDER
FROM golang:1.17 as builder
FROM golang:1.20 as builder

WORKDIR /src

Expand Down
31 changes: 16 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.20
require (
github.com/KyberNetwork/cclog v1.0.1
github.com/TheZeroSlave/zapsentry v1.12.0
github.com/ethereum/go-ethereum v1.10.26
github.com/getsentry/sentry-go v0.15.0
github.com/ethereum/go-ethereum v1.11.5
github.com/getsentry/sentry-go v0.18.0
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.8.1
github.com/golang-migrate/migrate/v4 v4.15.1
Expand All @@ -21,32 +21,34 @@ require (
)

require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/holiman/uint256 v1.2.0 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
golang.org/x/net v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/text v0.7.0 // indirect
)

require (
github.com/KyberNetwork/evmlistener v0.0.0-20221215082215-726216112b55
github.com/KyberNetwork/evmlistener v0.3.5
github.com/Masterminds/squirrel v1.5.3
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-redis/redis/v8 v8.11.5
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
Expand All @@ -57,16 +59,15 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/ugorji/go/codec v1.2.7 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/crypto v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/sys v0.5.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
93 changes: 54 additions & 39 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/evmlistenerclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (c *Client) GConsume(ctx context.Context) ([]Message, error) {
if data, ok := msg.Values[messageKey]; ok {
err := json.Unmarshal([]byte(data.(string)), &newMessage)
if err != nil {
c.l.Errorf("error on unmarshal stream message:%v\n", msg.ID)
c.l.Errorf("error on unmarshal stream message:%v %+v [%+v]", msg.ID, err, data)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/onchain/simclient/simclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func NewSimClient(url string, client *http.Client, accounts OverrideAccounts) (*
}

cc := &http.Client{Transport: round}
r, err := rpc.DialHTTPWithClient(url, cc)
r, err := rpc.DialOptions(context.Background(), url, rpc.WithHTTPClient(cc))
if err != nil {
return nil, errors.WithMessage(err, "simclient: dial rpc")
}
Expand Down
2 changes: 1 addition & 1 deletion internal/parser/kyberswap/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package kyberswap

import (
"errors"
"github.com/ethereum/go-ethereum/core/types"

"github.com/KyberNetwork/tradelogs/internal/storage"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)

const (
Expand Down
5 changes: 3 additions & 2 deletions internal/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package worker

import (
"context"
"github.com/KyberNetwork/tradelogs/pkg/convert"

"github.com/KyberNetwork/tradelogs/internal/evmlistenerclient"
"github.com/KyberNetwork/tradelogs/internal/parser"
Expand Down Expand Up @@ -62,11 +63,11 @@ func (w *Worker) processMessages(m []evmlistenerclient.Message) error {
if len(log.Topics) == 0 {
continue
}
ps := w.p[log.Topics[0].Hex()]
ps := w.p[log.Topics[0]]
if ps == nil {
continue
}
order, err := ps.Parse(log, block.Timestamp)
order, err := ps.Parse(convert.ToETHLog(log), block.Timestamp)
if err != nil {
return err
}
Expand Down
25 changes: 25 additions & 0 deletions pkg/convert/convert.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package convert

import (
types2 "github.com/KyberNetwork/evmlistener/pkg/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"math"
"math/big"

Expand Down Expand Up @@ -71,3 +74,25 @@ func RoundDown(value float64, tickSize float64) float64 {
r, _ := rec.Float64()
return r
}

func ToArrHashs(ss []string) []common.Hash {
res := make([]common.Hash, 0, len(ss))
for _, v := range ss {
res = append(res, common.HexToHash(v))
}
return res
}

func ToETHLog(log types2.Log) types.Log {
return types.Log{
Address: common.HexToAddress(log.Address),
Topics: ToArrHashs(log.Topics),
Data: log.Data,
BlockNumber: log.BlockNumber,
TxHash: common.HexToHash(log.TxHash),
TxIndex: log.TxIndex,
BlockHash: common.HexToHash(log.BlockHash),
Index: log.Index,
Removed: log.Removed,
}
}

0 comments on commit fc264ac

Please sign in to comment.