Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/zondax/rosetta-filecoin-proxy
go 1.16

require (
github.com/Masterminds/semver v1.5.0
github.com/coinbase/rosetta-sdk-go v0.6.10
github.com/filecoin-project/go-address v0.0.5
github.com/filecoin-project/go-bitfield v0.2.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go
github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y=
github.com/Masterminds/glide v0.13.2/go.mod h1:STyF5vcenH/rUqTEv+/hBXlSTo7KYwg2oc2f4tzPWic=
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/vcs v1.13.0/go.mod h1:N09YCmOQr6RLxC6UNHzuVwAdodYbbnycGHSmwVJjcKA=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
Expand Down
16 changes: 16 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ package main

import (
"context"
"errors"
"fmt"
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"

"github.com/Masterminds/semver"
rosettaAsserter "github.com/coinbase/rosetta-sdk-go/asserter"
"github.com/coinbase/rosetta-sdk-go/server"
"github.com/coinbase/rosetta-sdk-go/types"
Expand Down Expand Up @@ -151,6 +154,19 @@ func connectAPI(addr string, token string) (api.FullNode, jsonrpc.ClientCloser,

srv.Logger.Info("Connected to Lotus version: ", version.String())

c, _ := semver.NewConstraint(">= 1.5")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue was very old...
I think what we eventually want is to avoid incorrect matches..
we should later make this a bit more flexible and make the 1.5 configurable
but we can leave like this for now

Copy link
Contributor Author

@rllola rllola Jul 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NewConstraint should let us pass version constraints at build. For now it is hardcoded so I don't check the error but we could easily have that.


semverString := strings.Split(version.String(), "+")[0]
v, err := semver.NewVersion(semverString)
if err != nil {
srv.Logger.Warn("Not a standard semver version. Unable to verify if this Lotus version is compatible with proxy.")
return nil, nil, errors.New("Not standard semver version sent by Lotus.")
}

if !c.Check(v) {
srv.Logger.Fatal("Lotus version should be 1.5 or higher.")
}

return lotusAPI, clientCloser, nil
}

Expand Down