Skip to content
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

Merged
merged 18 commits into from
Mar 27, 2020
Merged

Make Powergate CGO free & use testnet/3 #210

merged 18 commits into from
Mar 27, 2020

Conversation

jsign
Copy link
Contributor

@jsign jsign commented Mar 24, 2020

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-devnetseems 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 by lotus-devnet to:

  • Use in the docker-file of the embedded mode. The network isn't run by powd anymore, but just a new container in the docker-compose.
  • In integration tests.

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 to master.

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

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>
@jsign jsign changed the title Make Powergate CGO free Make Powergate CGO free &move to testnet/3 Mar 25, 2020
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>
@jsign jsign changed the title Make Powergate CGO free &move to testnet/3 Make Powergate CGO free & use testnet/3 Mar 25, 2020
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
… a problem, better this way

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
@jsign jsign self-assigned this Mar 26, 2020
@jsign jsign added this to the Sprint 33 milestone Mar 26, 2020
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>
Copy link
Contributor Author

@jsign jsign left a 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
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bye externaka git-submodules.

Comment on lines -14 to -20
- 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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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"
Copy link
Contributor Author

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.

Copy link
Member

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))
Copy link
Contributor Author

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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👋

Copy link
Member

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) {
Copy link
Contributor Author

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.

Comment on lines +33 to +40
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)
}
Copy link
Contributor Author

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.

@jsign jsign marked this pull request as ready for review March 26, 2020 19:59
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Copy link
Member

@asutula asutula left a 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
Copy link
Member

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),
Copy link
Member

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"
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

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

🥂

Copy link
Member

@sanderpick sanderpick left a comment

Choose a reason for hiding this comment

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

LGTM! 👋 CGO

@jsign jsign merged commit 9500445 into master Mar 27, 2020
@jsign jsign deleted the jsign/pg5 branch March 27, 2020 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants