-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Powergate CGO free & use testnet/3 #210
Conversation
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
… a problem, better this way Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for help reviewing.
@@ -1,4 +1,3 @@ | |||
**/docker-compose.yaml | |||
**/docker-compose-embedded.yaml | |||
**/Dockerfile | |||
extern |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bye extern
aka git-submodules.
- name: Set up Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
profile: minimal | ||
toolchain: nightly | ||
- name: Install OpenCL | ||
run: sudo apt-get update && sudo apt-get install -y mesa-opencl-icd ocl-icd-opencl-dev jq make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No Rust nor OpenCL for building the git-submodule.
Still self-hosted since running test is still heavy. Instead of running the devnet code, is running the devnet container.
@@ -1,32 +1,18 @@ | |||
SUBMODULES=.update-modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to see without diffs.
Now it's super simple. Also closes #212.
@@ -93,6 +92,7 @@ type Config struct { | |||
IpfsApiAddr ma.Multiaddr | |||
LotusAddress ma.Multiaddr | |||
LotusAuthToken string | |||
LotusMasterAddr string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
masterAddr, err = c.WalletDefaultAddress(context.Background()) | ||
if err != nil { | ||
return nil, fmt.Errorf("getting default address: %s", err) | ||
if masterAddr, err = c.WalletDefaultAddress(context.Background()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In embedded mode we get the master address as the default, like in the old days.
This because that whole devnet is ephemeral.
@@ -5,12 +5,10 @@ import ( | |||
"net/http" | |||
"time" | |||
|
|||
"github.com/filecoin-project/lotus/api/apistruct" | |||
"github.com/filecoin-project/lotus/build" | |||
"github.com/filecoin-project/lotus/lib/jsonrpc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice we use directly the jsonrpc
impl of Lotus and not having our own (based on them). So one less thing to mantain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That, plus not having to maintain all those API structs is much cleaner!
@@ -35,7 +33,8 @@ func New(maddr ma.Multiaddr, authToken string) (*apistruct.FullNodeStruct, func( | |||
closer, err := jsonrpc.NewMergeClient("ws://"+addr+"/rpc/v0", "Filecoin", | |||
[]interface{}{ | |||
&api.Internal, | |||
}, headers, jsonrpc.WithReconnect(true, time.Second*3, 0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reconnect thing is still enabled. I did a PR some months ago in Lotus with this feature.
filecoin-project/lotus#1155
So, it's baked in now.
@@ -54,16 +53,6 @@ func New(maddr ma.Multiaddr, authToken string) (*apistruct.FullNodeStruct, func( | |||
|
|||
} | |||
|
|||
func NewEmbedded() (*apistruct.FullNodeStruct, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥂
|
||
func CreateLocalDevnet(t *testing.T, numMiners int) (*ldevnet.LocalDevnet, address.Address, []address.Address, func()) { | ||
dnet, err := ldevnet.New(numMiners, ldevnet.DefaultDuration) | ||
func CreateLocalDevnet(t *testing.T, numMiners int) (*apistruct.FullNodeStruct, address.Address, []address.Address) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So now CreateLocalDevnet
spinup a docker container instead of running the devnet per-se.
The good part is that all code called this method, so changing this was indistinguishable for the clients.
ty := crypto.SigTypeUnknown | ||
if "bls" == typ { | ||
ty = crypto.SigTypeBLS | ||
} else if "secp256k1" == typ { | ||
ty = crypto.SigTypeSecp256k1 | ||
} else { | ||
return "", fmt.Errorf("unkown wallet type %s", typ) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick fix for the testnet/3
change since now it's typed, not a string.
I won't imagine the types of wallet to change much, so isn't that bad... but don't fully like this kind of ifs.
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge improvements! Lots of small changes, but looks good to me.
@@ -1,3 +0,0 @@ | |||
[submodule "extern/filecoin-ffi"] | |||
path = extern/filecoin-ffi | |||
url = https://github.com/filecoin-project/filecoin-ffi.git |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wohoo!
@@ -183,15 +190,15 @@ func pushNewChanges(ctx context.Context, api API, currState map[cid.Cid]*api.Dea | |||
Size: dinfo.Size, | |||
PricePerEpoch: dinfo.PricePerEpoch.Uint64(), | |||
Duration: dinfo.Duration, | |||
DealID: dinfo.DealID, | |||
DealID: uint64(dinfo.DealID), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha nice.
@@ -5,12 +5,10 @@ import ( | |||
"net/http" | |||
"time" | |||
|
|||
"github.com/filecoin-project/lotus/api/apistruct" | |||
"github.com/filecoin-project/lotus/build" | |||
"github.com/filecoin-project/lotus/lib/jsonrpc" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That, plus not having to maintain all those API structs is much cleaner!
@@ -54,16 +53,6 @@ func New(maddr ma.Multiaddr, authToken string) (*apistruct.FullNodeStruct, func( | |||
|
|||
} | |||
|
|||
func NewEmbedded() (*apistruct.FullNodeStruct, func(), error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👋 CGO
To have some context and motivation see #186.
Most of the deleted code wasn't really unnecessary but moved to:
https://github.com/textileio/lotus-client
https://github.com/textileio/lotus-devnet
Both repos have some work on that I pushed indiscriminately. From now on I'll stick to PRs to have a clearer history. Updates to those repos will be triggered by updating to a newer version of Lotus.
Also, while doing
lotus-client
I realized that with some PR and some OK from Lotus-team, might be reasonable to make direct-importing of the API part from Lotus. Now isn't possible since some dependency graph ends in the CGO world. (Which is what I fixed by building that almost-similar repo). Eventually, it would be nice to do that PR to have one less repo to maintain.The
lotus-devnet
seems more useful in the long-run, so I dropped some words in the readme on how to use it.The idea now is that Powergate uses
lotus-client
, which is a CGO free Lotus client. And use the docker-containers auto-generated bylotus-devnet
to:powd
anymore, but just a new container in the docker-compose.The above means Powergate isn't tied to any CGO thing anymore, so the
Makefile
, docker image building, and cross-platform compiling are much simplified.While doing the CGO stuff, we decided to switch to
testnet/3
to be a step ahead of what will happen. That took some extra work to get things working since the API was quite different compared tomaster
.The only thing that isn't good is that it seems that the devnet doesn't allow making more than one deal per run. I had to set an skip to the Renewal test that was working on
master
since, of course, that test implies making a second deal to renew the first one.I'll be tracking an issue I created here to see if that can be fixed.
Apart from that, the migration went fine with enough work.
Closes #186
Closes #211
Closes #212
Closes #213