diff --git a/cmd/thalos/server.go b/cmd/thalos/server.go index 712cc45..d4a764c 100644 --- a/cmd/thalos/server.go +++ b/cmd/thalos/server.go @@ -13,7 +13,6 @@ import ( "time" "github.com/cenkalti/backoff/v4" - eos "github.com/eoscanada/eos-go" shipclient "github.com/eosswedenorg-go/antelope-ship-client" shipws "github.com/eosswedenorg-go/antelope-ship-client/websocket" "github.com/eosswedenorg-go/pid" @@ -30,6 +29,7 @@ import ( redis_cache "github.com/go-redis/cache/v9" "github.com/nikoksr/notify" "github.com/nikoksr/notify/service/telegram" + antelopeapi "github.com/pnx/antelope-go/api" "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" @@ -155,12 +155,12 @@ func LogLevels() []string { return list } -func initAbiManager(api *eos.API, store cache.Store, chain_id string) *abi.AbiManager { +func initAbiManager(api *antelopeapi.Client, store cache.Store, chain_id string) *abi.AbiManager { cache := cache.NewCache("thalos::cache::abi::"+chain_id, store) return abi.NewAbiManager(cache, api) } -func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo func() *eos.InfoResp, cache *cache.Cache, current_block_no_cache bool) StateLoader { +func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo func() *antelopeapi.Info, cache *cache.Cache, current_block_no_cache bool) StateLoader { return func(state *State) { var source string @@ -186,7 +186,7 @@ func stateLoader(conf *config.Config, start_block_flag *pflag.Flag, chainInfo fu // Otherwise, set from api. if conf.Ship.IrreversibleOnly { source = "api (LIB)" - state.CurrentBlock = uint32(chainInfo().LastIrreversibleBlockNum) + state.CurrentBlock = uint32(chainInfo().LastIrreversableBlockNum) } else { source = "api (HEAD)" state.CurrentBlock = uint32(chainInfo().HeadBlockNum) @@ -246,12 +246,12 @@ func GetConfig(flags *pflag.FlagSet) (*config.Config, error) { // that pointer will live as long as the closure lives. // and inside the closure we will reference the pointer and only // call the api if it is nil. -func chainInfoOnce(api *eos.API) func() *eos.InfoResp { - var info *eos.InfoResp - return func() *eos.InfoResp { +func chainInfoOnce(api *antelopeapi.Client) func() *antelopeapi.Info { + var info *antelopeapi.Info + return func() *antelopeapi.Info { if info == nil { - log.WithField("api", api.BaseURL).Info("Get chain info from api") + log.WithField("api", api.Url).Info("Get chain info from api") ctx, cancel := context.WithTimeout(context.Background(), time.Second*10) defer cancel() @@ -262,7 +262,7 @@ func chainInfoOnce(api *eos.API) func() *eos.InfoResp { return nil } - info = result + info = &result } return info } @@ -381,7 +381,7 @@ func serverCmd(cmd *cobra.Command, args []string) { // Setup general cache cache := cache.NewCache("thalos::cache::instance::"+conf.Name, cacheStore) - eosClient := eos.New(conf.Api) + antelopeClient := antelopeapi.New(conf.Api) shClient := shipclient.NewStream(func(s *shipclient.Stream) { s.StartBlock = conf.Ship.StartBlockNum @@ -396,11 +396,11 @@ func serverCmd(cmd *cobra.Command, args []string) { return } - chainInfo := chainInfoOnce(eosClient) + chainInfo := chainInfoOnce(antelopeClient) chain_id := conf.Ship.Chain if len(chain_id) < 1 { - chain_id = chainInfo().ChainID.String() + chain_id = chainInfo().ChainID } processor := SpawnProccessor( @@ -411,7 +411,7 @@ func serverCmd(cmd *cobra.Command, args []string) { Prefix: conf.Redis.Prefix, ChainID: chain_id, }), - initAbiManager(eosClient, cacheStore, chain_id), + initAbiManager(antelopeClient, cacheStore, chain_id), codec, ) diff --git a/go.mod b/go.mod index 3645aa9..a3baa8e 100644 --- a/go.mod +++ b/go.mod @@ -5,39 +5,41 @@ go 1.20 require ( github.com/cenkalti/backoff/v4 v4.2.1 github.com/docker/go-units v0.5.0 - github.com/eoscanada/eos-go v0.10.3-0.20231109144819-59afdfa3a37d - github.com/eosswedenorg-go/antelope-ship-client v0.2.8 + github.com/eosswedenorg-go/antelope-ship-client v0.2.9 github.com/eosswedenorg-go/pid v1.0.1 github.com/eosswedenorg/thalos/api v1.0.0 github.com/go-redis/cache/v9 v9.0.0 github.com/go-redis/redismock/v9 v9.2.0 github.com/mitchellh/mapstructure v1.5.0 github.com/nikoksr/notify v0.41.0 + github.com/pnx/antelope-go v0.0.2-0.20240425200605-62ec2abfe722 github.com/redis/go-redis/v9 v9.5.1 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.18.2 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/blendle/zapdriver v1.3.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/eosswedenorg-go/jsontime v0.0.0-20230509125027-08422d6236c7 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/gorilla/websocket v1.5.1 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/imroc/req/v3 v3.7.6 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.7 // indirect - github.com/logrusorgru/aurora v2.0.3+incompatible // indirect + github.com/liamylian/jsontime/v2 v2.0.0 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/onsi/gomega v1.31.1 // indirect @@ -49,27 +51,22 @@ require ( github.com/sourcegraph/conc v0.3.0 // indirect github.com/spf13/afero v1.11.0 // indirect github.com/spf13/cast v1.6.0 // indirect - github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/technoweenie/multipartstreamer v1.0.1 // indirect - github.com/tidwall/gjson v1.17.1 // indirect - github.com/tidwall/match v1.1.1 // indirect - github.com/tidwall/pretty v1.2.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/vmihailenco/go-tinylfu v0.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.20.0 // indirect golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect - golang.org/x/net v0.21.0 // indirect + golang.org/x/net v0.22.0 // indirect golang.org/x/sync v0.6.0 // indirect - golang.org/x/sys v0.17.0 // indirect - golang.org/x/term v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) replace github.com/eosswedenorg/thalos/api => ./api + +replace github.com/pnx/antelope-go => ../../go/antelope-go diff --git a/go.sum b/go.sum index 8809c73..f040f95 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,5 @@ github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a h1:HbKu58rmZpUGpz5+4FfNmIU+FmZg2P3Xaj2v2bfNWmk= github.com/alicebob/miniredis/v2 v2.30.2 h1:lc1UAUT9ZA7h4srlfBmBt2aorm5Yftk9nBjxz7EyY9I= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/blendle/zapdriver v1.3.1 h1:C3dydBOWYRiOk+B8X9IVZ5IOe+7cl+tGOexN4QqHfpE= -github.com/blendle/zapdriver v1.3.1/go.mod h1:mdXfREi6u5MArG4j9fewC+FGnXaBR+T4Ox4J2u4eHCc= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= @@ -23,10 +20,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/eoscanada/eos-go v0.10.3-0.20231109144819-59afdfa3a37d h1:vK5PijzcJaUPOhgWvY9lL99H9t3lrRNHx2IDHqS0ILc= -github.com/eoscanada/eos-go v0.10.3-0.20231109144819-59afdfa3a37d/go.mod h1:L3avCf8OkDrjlUeNy9DdoV67TCmDNj2dSlc5Xp3DNNk= -github.com/eosswedenorg-go/antelope-ship-client v0.2.8 h1:xqtRrijqVcOgLeh5foXjNoqOXkU/w1l6T4unwLgCrP0= -github.com/eosswedenorg-go/antelope-ship-client v0.2.8/go.mod h1:YcOEgcsZs9a7MjFjRZiX6Qpgc+c0a09PPE4mg8I6IU4= +github.com/eosswedenorg-go/antelope-ship-client v0.2.9 h1:Isa90Tktdumj/P9XgQ8kBRqS+2MAdcPl7ev/n0KFvUQ= +github.com/eosswedenorg-go/antelope-ship-client v0.2.9/go.mod h1:a0Kp4BJID8DMD0pmHnK5/gojtpRhh2pqqgt4Hcy5Wrw= github.com/eosswedenorg-go/jsontime v0.0.0-20230509125027-08422d6236c7 h1:rLPu++RHaxg4WmUOXeWYioZuafWs0PVcYuvzOWbOJjk= github.com/eosswedenorg-go/jsontime v0.0.0-20230509125027-08422d6236c7/go.mod h1:eNUkVOymzgl0lViUhmm08PkutzqLnOQ6Dr+RUnf+Mq0= github.com/eosswedenorg-go/pid v1.0.1 h1:W4AEnnNwb041SpNR1uTZ/KbJ0OTA5eqiqIR1Q5Ah6A0= @@ -60,18 +55,26 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imroc/req/v3 v3.7.6 h1:SUVWgFt/dJsSzpzpnc8pHdL79zoE6O8FSCfNvbTZXVU= +github.com/imroc/req/v3 v3.7.6/go.mod h1:3JIicOKEDHfCSYYNLb/ObZNpx64EV5y40VlHMwhUCzU= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jarcoal/httpmock v1.2.0 h1:gSvTxxFR/MEMfsGrvRbdfpRUMBStovlSRLw0Ep1bwwc= github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= @@ -85,17 +88,17 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/logrusorgru/aurora v2.0.3+incompatible h1:tOpm7WcpBTn4fjmVfgpQq0EfczGlG91VSDkswnjF5A8= -github.com/logrusorgru/aurora v2.0.3+incompatible/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/liamylian/jsontime/v2 v2.0.0 h1:3if2kDW/boymUdO+4Qj/m4uaXMBSF6np9KEgg90cwH0= +github.com/liamylian/jsontime/v2 v2.0.0/go.mod h1:UHp1oAPqCBfspokvGmaGe0IAl2IgOpgOgDaKPcvcGGY= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= -github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/nikoksr/notify v0.41.0 h1:4LGE41GpWdHX5M3Xo6DlWRwS2WLDbOq1Rk7IzY4vjmQ= @@ -129,7 +132,6 @@ github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= github.com/onsi/gomega v1.31.1/go.mod h1:y40C95dwAD1Nz36SsEnxvfFe8FFfNxzI5eJ0EYGyAy0= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -159,8 +161,6 @@ github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= -github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 h1:RN5mrigyirb8anBEtdjtHFIufXdacyTi6i4KBfeNXeo= -github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091/go.mod h1:VlduQ80JcGJSargkRU4Sg9Xo63wZD/l8A5NC/Uo1/uU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -171,21 +171,13 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/technoweenie/multipartstreamer v1.0.1 h1:XRztA5MXiR1TIRHxH2uNxXxaIkKQDeX7m2XsSOlQEnM= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= -github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE= -github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU= -github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U= -github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= -github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4= -github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI= @@ -196,50 +188,32 @@ github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21 github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/gopher-lua v1.1.0 h1:BojcDhfyDWgU2f2TOzYK/g5p2gxMrku8oupLDqlnSqE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= -go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.20.0 h1:jmAMJJZXr5KiCw05dfYK9QnqaqKLYXijU23lsEdcQqg= -golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= @@ -247,8 +221,8 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -268,9 +242,7 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -283,16 +255,14 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -303,10 +273,8 @@ golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= @@ -337,11 +305,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU= diff --git a/internal/abi/manager.go b/internal/abi/manager.go index 2441e01..c8bbe83 100644 --- a/internal/abi/manager.go +++ b/internal/abi/manager.go @@ -5,19 +5,20 @@ import ( "fmt" "time" - eos "github.com/eoscanada/eos-go" "github.com/eosswedenorg/thalos/internal/cache" + "github.com/pnx/antelope-go/api" + "github.com/pnx/antelope-go/chain" ) // AbiManager handles an ABI cache that fetches the ABI from an API on cache miss. type AbiManager struct { cache *cache.Cache - api *eos.API + api *api.Client ctx context.Context } // Create a new ABI Manager -func NewAbiManager(cache *cache.Cache, api *eos.API) *AbiManager { +func NewAbiManager(cache *cache.Cache, api *api.Client) *AbiManager { return &AbiManager{ cache: cache, api: api, @@ -26,24 +27,24 @@ func NewAbiManager(cache *cache.Cache, api *eos.API) *AbiManager { } // Set or update an ABI in the cache. -func (mgr *AbiManager) SetAbi(account eos.AccountName, abi *eos.ABI) error { +func (mgr *AbiManager) SetAbi(account chain.Name, abi *chain.Abi) error { ctx, cancel := context.WithTimeout(mgr.ctx, time.Millisecond*500) defer cancel() - return mgr.cache.Set(ctx, string(account), *abi, time.Hour) + return mgr.cache.Set(ctx, account.String(), *abi, time.Hour) } // Get an ABI from the cache, on cache miss it is fetched from the // API, gets cached and then returned to the user -func (mgr *AbiManager) GetAbi(account eos.AccountName) (*eos.ABI, error) { - var abi eos.ABI +func (mgr *AbiManager) GetAbi(account chain.Name) (*chain.Abi, error) { + var abi chain.Abi if err := mgr.cacheGet(account, &abi); err != nil { ctx, cancel := context.WithTimeout(mgr.ctx, time.Second) defer cancel() - resp, err := mgr.api.GetABI(ctx, account) + resp, err := mgr.api.GetAbi(ctx, account.String()) if err != nil { return nil, fmt.Errorf("api: %s", err) } - abi = resp.ABI + abi = resp.Abi err = mgr.SetAbi(account, &abi) if err != nil { @@ -53,8 +54,8 @@ func (mgr *AbiManager) GetAbi(account eos.AccountName) (*eos.ABI, error) { return &abi, nil } -func (mgr *AbiManager) cacheGet(account eos.AccountName, value any) error { +func (mgr *AbiManager) cacheGet(account chain.Name, value any) error { ctx, cancel := context.WithTimeout(mgr.ctx, time.Millisecond*500) defer cancel() - return mgr.cache.Get(ctx, string(account), value) + return mgr.cache.Get(ctx, account.String(), value) } diff --git a/internal/abi/manager_test.go b/internal/abi/manager_test.go index 7ecfc75..edd32f1 100644 --- a/internal/abi/manager_test.go +++ b/internal/abi/manager_test.go @@ -1,13 +1,14 @@ package abi import ( + "encoding/json" "fmt" "net/http" "net/http/httptest" - "strings" "testing" - eos "github.com/eoscanada/eos-go" + "github.com/pnx/antelope-go/api" + "github.com/pnx/antelope-go/chain" "github.com/eosswedenorg/thalos/internal/cache" "github.com/stretchr/testify/assert" @@ -73,7 +74,7 @@ var abiString = ` } ` -func assert_abi(t *testing.T, abi *eos.ABI) { +func assert_abi(t *testing.T, abi *chain.Abi) { assert.Equal(t, abi.Version, "eosio::abi/1.0") // Types @@ -110,12 +111,12 @@ func assert_abi(t *testing.T, abi *eos.ABI) { assert.Equal(t, abi.Structs[3].Fields[0].Type, "string") // Actions - assert.Equal(t, abi.Actions[0].Name, eos.ActN("action_name_1")) + assert.Equal(t, abi.Actions[0].Name, chain.N("action_name_1")) assert.Equal(t, abi.Actions[0].Type, "struct_name_1") assert.Equal(t, abi.Actions[0].RicardianContract, "") // Tables - assert.Equal(t, abi.Tables[0].Name, eos.TableName("table_name_1")) + assert.Equal(t, abi.Tables[0].Name, chain.N("table_name_1")) assert.Equal(t, abi.Tables[0].Type, "struct_name_1") assert.Equal(t, abi.Tables[0].IndexType, "i64") assert.Equal(t, abi.Tables[0].KeyNames[0], "key_name_1") @@ -124,15 +125,10 @@ func assert_abi(t *testing.T, abi *eos.ABI) { assert.Equal(t, abi.Tables[0].KeyTypes[1], "int") } -func mockAPI(handler http.HandlerFunc) (*eos.API, *httptest.Server) { +func mockAPI(handler http.HandlerFunc) (*api.Client, *httptest.Server) { server := httptest.NewServer(handler) - return &eos.API{ - HttpClient: server.Client(), - BaseURL: strings.TrimRight(server.URL, "/"), - Compress: eos.CompressionZlib, - Header: make(http.Header), - }, server + return api.New(server.URL), server } func TestManager_GetAbiFromCache(t *testing.T) { @@ -143,13 +139,14 @@ func TestManager_GetAbiFromCache(t *testing.T) { mgr := NewAbiManager(cache, api) - abi, err := eos.NewABI(strings.NewReader(abiString)) + abi := chain.Abi{} + err := json.Unmarshal([]byte(abiString), &abi) assert.NoError(t, err) - err = mgr.SetAbi("testaccount", abi) + err = mgr.SetAbi(chain.N("testaccount"), &abi) assert.NoError(t, err) - c_abi, err := mgr.GetAbi("testaccount") + c_abi, err := mgr.GetAbi(chain.N("testaccount")) assert.NoError(t, err) assert_abi(t, c_abi) } @@ -166,8 +163,10 @@ func TestManager_GetAbiFromAPI(t *testing.T) { mgr := NewAbiManager(cache, api) - c_abi, err := mgr.GetAbi("testaccount") + c_abi, err := mgr.GetAbi(chain.N("testaccount")) assert.NoError(t, err) + fmt.Println(c_abi) + assert_abi(t, c_abi) } diff --git a/internal/server/helpers.go b/internal/server/helpers.go index f7ce531..5b3a006 100644 --- a/internal/server/helpers.go +++ b/internal/server/helpers.go @@ -1,25 +1,27 @@ package server -import "github.com/eoscanada/eos-go/ship" +import ( + "github.com/pnx/antelope-go/ship" +) // convert a ActionTrace to ActionTraceV1 func toActionTraceV1(trace *ship.ActionTrace) *ship.ActionTraceV1 { - if trace_v0, ok := trace.Impl.(*ship.ActionTraceV0); ok { + if trace.V0 != nil { // convert to v1 return &ship.ActionTraceV1{ - ActionOrdinal: trace_v0.ActionOrdinal, - CreatorActionOrdinal: trace_v0.CreatorActionOrdinal, - Receipt: trace_v0.Receipt, - Receiver: trace_v0.Receiver, - Act: trace_v0.Act, - ContextFree: trace_v0.ContextFree, - Elapsed: trace_v0.Elapsed, - Console: trace_v0.Console, - AccountRamDeltas: trace_v0.AccountRamDeltas, - Except: trace_v0.Except, - ErrorCode: trace_v0.ErrorCode, + ActionOrdinal: trace.V0.ActionOrdinal, + CreatorActionOrdinal: trace.V0.CreatorActionOrdinal, + Receipt: trace.V0.Receipt, + Receiver: trace.V0.Receiver, + Act: trace.V0.Act, + ContextFree: trace.V0.ContextFree, + Elapsed: trace.V0.Elapsed, + Console: trace.V0.Console, + AccountRamDeltas: trace.V0.AccountRamDeltas, + Except: trace.V0.Except, + ErrorCode: trace.V0.ErrorCode, ReturnValue: []byte{}, } } - return trace.Impl.(*ship.ActionTraceV1) + return trace.V1 } diff --git a/internal/server/ship_processor.go b/internal/server/ship_processor.go index aa4017a..7377763 100644 --- a/internal/server/ship_processor.go +++ b/internal/server/ship_processor.go @@ -1,8 +1,8 @@ package server import ( + "bytes" "encoding/hex" - "encoding/json" "github.com/eosswedenorg/thalos/api" "github.com/eosswedenorg/thalos/api/message" @@ -11,9 +11,9 @@ import ( log "github.com/sirupsen/logrus" - "github.com/eoscanada/eos-go" - "github.com/eoscanada/eos-go/ship" shipclient "github.com/eosswedenorg-go/antelope-ship-client" + "github.com/pnx/antelope-go/chain" + "github.com/pnx/antelope-go/ship" ) // logDecoratedEncoder decorates a message.Encoder and logs any error. @@ -51,10 +51,10 @@ type ShipProcessor struct { state State // System contract ("eosio" per default) - syscontract eos.AccountName + syscontract chain.Name // ABI Returned from SHIP - shipABI *eos.ABI + shipABI *chain.Abi } // SpawnProcessor creates a new ShipProccessor that consumes the shipclient.Stream passed to it. @@ -65,7 +65,7 @@ func SpawnProccessor(shipStream *shipclient.Stream, loader StateLoader, saver St writer: writer, shipStream: shipStream, encode: logDecoratedEncoder(codec.Encoder), - syscontract: eos.AccountName("eosio"), + syscontract: chain.N("eosio"), } loader(&processor.state) @@ -75,13 +75,13 @@ func SpawnProccessor(shipStream *shipclient.Stream, loader StateLoader, saver St shipStream.InitHandler = processor.initHandler // Needed because if nil, traces/table deltas will not be included in the response from ship. - shipStream.TraceHandler = func([]*ship.TransactionTraceV0) {} - shipStream.TableDeltaHandler = func([]*ship.TableDeltaV0) {} + shipStream.TraceHandler = func(*ship.TransactionTraceArray) {} + shipStream.TableDeltaHandler = func(*ship.TableDeltaArray) {} return processor } -func (processor *ShipProcessor) initHandler(abi *eos.ABI) { +func (processor *ShipProcessor) initHandler(abi *chain.Abi) { processor.shipABI = abi } @@ -101,26 +101,14 @@ func (processor *ShipProcessor) encodeQueue(channel api.Channel, v interface{}) return false } -func decode(abi *eos.ABI, act *ship.Action, v any) error { - jsondata, err := abi.DecodeAction(act.Data, act.Name) - if err != nil { - return err - } - return json.Unmarshal(jsondata, v) -} - // updateAbiFromAction updates the contract abi based on the ship.Action passed. -func (processor *ShipProcessor) updateAbiFromAction(act *ship.Action) error { - ABI, err := processor.abi.GetAbi(processor.syscontract) - if err != nil { - return err - } - +func (processor *ShipProcessor) updateAbiFromAction(act *chain.Action) error { set_abi := struct { Abi string - Account eos.AccountName + Account chain.Name }{} - if err = decode(ABI, act, &set_abi); err != nil { + + if err := act.DecodeInto(&set_abi); err != nil { return err } @@ -129,11 +117,11 @@ func (processor *ShipProcessor) updateAbiFromAction(act *ship.Action) error { return err } - contract_abi := eos.ABI{} - if err = eos.UnmarshalBinary(binary_abi, &contract_abi); err != nil { + contract_abi := chain.Abi{} + err = chain.NewDecoder(bytes.NewReader(binary_abi)).Decode(&contract_abi) + if err != nil { return err } - return processor.abi.SetAbi(set_abi.Account, &contract_abi) } @@ -161,14 +149,16 @@ func (processor *ShipProcessor) broadcastAction(act *message.ActionTrace) { } } -func (processor *ShipProcessor) processTransactionTrace(log *log.Entry, block *ship.SignedBlockBytes, trace *ship.TransactionTraceV0) { +func (processor *ShipProcessor) processTransactionTrace(log *log.Entry, blockNumber uint32, block *ship.SignedBlock, trace *ship.TransactionTraceV0) { logger := log.WithField("type", "trace").WithField("tx_id", trace.ID.String()).Dup() + timestamp := block.BlockHeader.Timestamp.Time().UTC() + transaction := message.TransactionTrace{ - ID: trace.ID.String(), - BlockNum: block.BlockNumber(), - Timestamp: block.Timestamp.UTC(), - Status: trace.Status.String(), + ID: trace.ID.String(), + BlockNum: blockNumber, + Timestamp: timestamp, + // Status: trace.Status, CPUUsageUS: trace.CPUUsageUS, NetUsage: trace.NetUsage, NetUsageWords: uint32(trace.NetUsageWords), @@ -185,8 +175,8 @@ func (processor *ShipProcessor) processTransactionTrace(log *log.Entry, block *s actMsg := processor.proccessActionTrace(logger, actionTrace) if actMsg != nil { actMsg.TxID = trace.ID.String() - actMsg.BlockNum = block.BlockNumber() - actMsg.Timestamp = block.Timestamp.UTC() + actMsg.BlockNum = blockNumber + actMsg.Timestamp = timestamp processor.broadcastAction(actMsg) @@ -199,8 +189,8 @@ func (processor *ShipProcessor) processTransactionTrace(log *log.Entry, block *s func (processor *ShipProcessor) proccessActionTrace(logger *log.Entry, trace *ship.ActionTraceV1) *message.ActionTrace { // Check if actions updates an abi. - if trace.Act.Account == processor.syscontract && trace.Act.Name == eos.ActionName("setabi") { - err := processor.updateAbiFromAction(trace.Act) + if trace.Act.Account == processor.syscontract && trace.Act.Name == chain.N("setabi") { + err := processor.updateAbiFromAction(&trace.Act) if err != nil { logger.WithError(err).Warn("Failed to update abi") } @@ -214,7 +204,7 @@ func (processor *ShipProcessor) proccessActionTrace(logger *log.Entry, trace *sh } if trace.Receipt != nil { - receipt := trace.Receipt.Impl.(*ship.ActionReceiptV0) + receipt := trace.Receipt.V0 act.Receipt = &message.ActionReceipt{ Receiver: receipt.Receiver.String(), ActDigest: receipt.ActDigest.String(), @@ -241,7 +231,7 @@ func (processor *ShipProcessor) proccessActionTrace(logger *log.Entry, trace *sh ABI, err := processor.abi.GetAbi(trace.Act.Account) if err == nil { - if err = decode(ABI, trace.Act, &act.Data); err != nil { + if act.Data, err = trace.Act.Decode(ABI); err != nil { logger.WithFields(log.Fields{ "contract": trace.Act.Account, "action": trace.Act.Name, @@ -256,89 +246,104 @@ func (processor *ShipProcessor) proccessActionTrace(logger *log.Entry, trace *sh } // Callback function called by shipclient.Stream when a new block arrives. -func (processor *ShipProcessor) processBlock(block *ship.GetBlocksResultV0) { +func (processor *ShipProcessor) processBlock(blockResult *ship.GetBlocksResultV0) { + block := ship.SignedBlock{} + blockResult.Block.Unpack(&block) + timestamp := block.BlockHeader.Timestamp.Time().UTC() + blockNumber := blockResult.ThisBlock.BlockNum + // Check to see if we have a microfork and post a message to // the rollback channel in that case. - if processor.state.CurrentBlock > 0 && block.ThisBlock.BlockNum < processor.state.CurrentBlock { + if processor.state.CurrentBlock > 0 && blockNumber < processor.state.CurrentBlock { log.WithField("old_block", processor.state.CurrentBlock). - WithField("new_block", block.ThisBlock.BlockNum). + WithField("new_block", blockResult.ThisBlock.BlockNum). Warn("Fork detected, old_block is greater than new_block") processor.encodeQueue(api.RollbackChannel, message.RollbackMessage{ OldBlockNum: processor.state.CurrentBlock, - NewBlockNum: block.ThisBlock.BlockNum, + NewBlockNum: blockResult.ThisBlock.BlockNum, }) } - processor.state.CurrentBlock = block.ThisBlock.BlockNum + processor.state.CurrentBlock = blockNumber - if block.ThisBlock.BlockNum%100 == 0 { - log.Infof("Current: %d, Head: %d", processor.state.CurrentBlock, block.Head.BlockNum) + if blockResult.ThisBlock.BlockNum%100 == 0 { + log.Infof("Current: %d, Head: %d", processor.state.CurrentBlock, blockResult.Head.BlockNum) } - if block.ThisBlock.BlockNum%10 == 0 { + if blockResult.ThisBlock.BlockNum%10 == 0 { hb := message.HeartBeat{ - BlockNum: block.ThisBlock.BlockNum, - LastIrreversibleBlockNum: block.LastIrreversible.BlockNum, - HeadBlockNum: block.Head.BlockNum, + BlockNum: blockNumber, + LastIrreversibleBlockNum: blockResult.LastIrreversible.BlockNum, + HeadBlockNum: blockResult.Head.BlockNum, } processor.encodeQueue(api.HeartbeatChannel, hb) } - mainLogger := log.WithField("block", block.ThisBlock.BlockNum).Dup() + mainLogger := log.WithField("block", blockNumber).Dup() // Process traces - if block.Traces != nil && len(block.Traces.Elem) > 0 { - for _, trace := range block.Traces.AsTransactionTracesV0() { - processor.processTransactionTrace(mainLogger, block.Block, trace) + if blockResult.Traces != nil { + unpacked := []ship.TransactionTrace{} + if err := blockResult.Traces.Unpack(&unpacked); err != nil { + mainLogger.WithError(err).Error("Failed to unpack transaction traces") + } else { + for _, trace := range unpacked { + processor.processTransactionTrace(mainLogger, blockNumber, &block, trace.V0) + } } } // Process deltas - for _, delta := range block.Deltas.AsTableDeltasV0() { + deltas := []ship.TableDelta{} + if err := blockResult.Deltas.Unpack(&deltas); err != nil { + mainLogger.WithError(err).Error("Failed to unpack table deltas") + } else { + for _, delta := range deltas { - logger := mainLogger.WithField("type", "table_delta").WithField("table", delta.Name).Dup() + logger := mainLogger.WithField("type", "table_delta").Dup() - rows := []message.TableDeltaRow{} - for _, row := range delta.Rows { + rows := []message.TableDeltaRow{} + for _, row := range delta.V0.Rows { - msg := message.TableDeltaRow{ - Present: row.Present, - RawData: row.Data, - } + msg := message.TableDeltaRow{ + Present: row.Present, + RawData: row.Data, + } + + if processor.shipABI != nil { - if processor.shipABI != nil { - v, err := processor.shipABI.DecodeTableRowTyped(delta.Name, row.Data) - if err == nil { - err = json.Unmarshal(v, &msg.Data) - if err != nil { - logger.WithError(err).Error("Failed to decode json") + v, err := processor.shipABI.Decode(bytes.NewReader(row.Data), delta.V0.Name) + if err == nil { + var ok bool + if msg.Data, ok = v.(map[string]any); !ok { + // logger.Error("Failed to cast table data") + } + } else { + logger.Error("Failed to decode table delta") } } else { - logger.Error("Failed to decode table delta") + logger.Warn("No SHIP ABI present") } - } else { - logger.Warn("No SHIP ABI present") + rows = append(rows, msg) } - rows = append(rows, msg) - } - - message := message.TableDelta{ - BlockNum: block.Block.BlockNumber(), - Timestamp: block.Block.Timestamp.UTC(), - Name: delta.Name, - Rows: rows, - } + message := message.TableDelta{ + BlockNum: blockNumber, + Timestamp: timestamp, + Name: delta.V0.Name, + Rows: rows, + } - channels := []api.Channel{ - api.TableDeltaChannel{}.Channel(), - api.TableDeltaChannel{Name: delta.Name}.Channel(), - } + channels := []api.Channel{ + api.TableDeltaChannel{}.Channel(), + api.TableDeltaChannel{Name: delta.V0.Name}.Channel(), + } - for _, channel := range channels { - processor.encodeQueue(channel, message) + for _, channel := range channels { + processor.encodeQueue(channel, message) + } } }