Skip to content

Commit

Permalink
chore(f3): upgrade go-f3 to 0.3.0 (#4776)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanabi1224 authored Sep 19, 2024
1 parent c1623d2 commit 6a5013c
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 11 deletions.
2 changes: 1 addition & 1 deletion f3-sidecar/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# F3 sidecar binaries image
FROM golang:1.21-bullseye AS builder
FROM golang:1.22-bullseye AS builder

WORKDIR /f3

Expand Down
1 change: 1 addition & 0 deletions f3-sidecar/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type F3Api struct {
ProtectPeer func(context.Context, peer.ID) (bool, error)
GetParticipatingMinerIDs func(context.Context) ([]uint64, error)
SignMessage func(context.Context, []byte, []byte) (*crypto.Signature, error)
Finalize func(context.Context, gpbft.TipSetKey) error
}

type FilecoinApi struct {
Expand Down
4 changes: 4 additions & 0 deletions f3-sidecar/ec.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ func (ec *ForestEC) GetPowerTable(ctx context.Context, tsk gpbft.TipSetKey) (gpb
return ec.f3api.GetPowerTable(ctx, tsk)
}

func (ec *ForestEC) Finalize(ctx context.Context, tsk gpbft.TipSetKey) error {
return ec.f3api.Finalize(ctx, tsk)
}

func (ec *ForestEC) Sign(ctx context.Context, sender gpbft.PubKey, msg []byte) ([]byte, error) {
signature, err := ec.f3api.SignMessage(ctx, sender, msg)
if err != nil {
Expand Down
7 changes: 7 additions & 0 deletions f3-sidecar/ec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ func TestGetPowerTable(t *testing.T) {
require.NoError(t, err)
fmt.Printf("GetPowerTable: %s\n", string(ptJsonBytes))
}

func TestFinalize(t *testing.T) {
head, err := EC.GetHead(ctx)
require.NoError(t, err)
err = EC.Finalize(ctx, head.Key())
require.NoError(t, err)
}
5 changes: 2 additions & 3 deletions f3-sidecar/go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module f3-sidecar/v2

go 1.21
go 1.22

require (
github.com/filecoin-project/go-f3 v0.2.0
github.com/filecoin-project/go-f3 v0.3.0
github.com/filecoin-project/go-jsonrpc v0.6.0
github.com/filecoin-project/go-state-types v0.14.0
github.com/ipfs/go-datastore v0.6.0
Expand All @@ -16,7 +16,6 @@ require (
)

require (
github.com/Kubuxu/go-broadcast v0.0.0-20240621161059-1a8c90734cd6 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions f3-sidecar/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Kubuxu/go-broadcast v0.0.0-20240621161059-1a8c90734cd6 h1:yh2/1fz3ajTaeKskSWxtSBNScdRZfQ/A5nyd9+64T6M=
github.com/Kubuxu/go-broadcast v0.0.0-20240621161059-1a8c90734cd6/go.mod h1:5LOj/fF3Oc/cvJqzDiyfx4XwtBPRWUYEz+V+b13sH5U=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
Expand Down Expand Up @@ -63,8 +61,8 @@ github.com/filecoin-project/go-bitfield v0.2.4 h1:uZ7MeE+XfM5lqrHJZ93OnhQKc/rveW
github.com/filecoin-project/go-bitfield v0.2.4/go.mod h1:CNl9WG8hgR5mttCnUErjcQjGvuiZjRqK9rHVBsQF4oM=
github.com/filecoin-project/go-clock v0.1.0 h1:SFbYIM75M8NnFm1yMHhN9Ahy3W5bEZV9gd6MPfXbKVU=
github.com/filecoin-project/go-clock v0.1.0/go.mod h1:4uB/O4PvOjlx1VCMdZ9MyDZXRm//gkj1ELEbxfI1AZs=
github.com/filecoin-project/go-f3 v0.2.0 h1:Gis44+hOrDjSUEw3IDmU7CudNILi5e+bb1pgZgp680k=
github.com/filecoin-project/go-f3 v0.2.0/go.mod h1:43fBLX0iX0+Nnw4Z91wSrdfDYAd6YEDexy7GcLnIJtk=
github.com/filecoin-project/go-f3 v0.3.0 h1:GUY7+QSyWqX4MEuFtQAYkYLRM1t3GleZ0U2I87oOStM=
github.com/filecoin-project/go-f3 v0.3.0/go.mod h1:MVf4ynbRdLMnZZWK8GJCex0VH1lQvh9AwFTMEu7jX1Y=
github.com/filecoin-project/go-jsonrpc v0.6.0 h1:/fFJIAN/k6EgY90m7qbyfY28woMwyseZmh2gVs5sYjY=
github.com/filecoin-project/go-jsonrpc v0.6.0/go.mod h1:/n/niXcS4ZQua6i37LcVbY1TmlJR0UIK9mDFQq2ICek=
github.com/filecoin-project/go-state-types v0.14.0 h1:JFw8r/LA0/Hvu865Yn2Gz3R5e2woItKeHTgbT4VsXoU=
Expand Down
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.21
go 1.22

use (
./f3-sidecar
Expand Down
3 changes: 3 additions & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/filecoin-project/go-address v1.1.0/go.mod h1:5t3z6qPmIADZBtuE9EIzi0Ew
github.com/filecoin-project/go-amt-ipld/v4 v4.2.0/go.mod h1:0eDVF7pROvxrsxvLJx+SJZXqRaXXcEPUcgb/rG0zGU4=
github.com/filecoin-project/go-commp-utils v0.1.3/go.mod h1:3ENlD1pZySaUout0p9ANQrY3fDFoXdqyX04J+dWpK30=
github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837/go.mod h1:e2YBjSblNVoBckkbv3PPqsq71q98oFkFqL7s1etViGo=
github.com/filecoin-project/go-f3 v0.3.0 h1:GUY7+QSyWqX4MEuFtQAYkYLRM1t3GleZ0U2I87oOStM=
github.com/filecoin-project/go-f3 v0.3.0/go.mod h1:MVf4ynbRdLMnZZWK8GJCex0VH1lQvh9AwFTMEu7jX1Y=
github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ=
github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBwFmYdT8SOFUwB3ovSUfG1Ux0g=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
Expand All @@ -87,6 +89,7 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-pdf/fpdf v0.9.0/go.mod h1:oO8N111TkmKb9D7VvWGLvLJlaZUQVPM+6V42pp3iV4Y=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM=
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
Expand Down
2 changes: 1 addition & 1 deletion interop-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ This crate contains interops tests for Forest.
To compile and run the interop tests, below dependencies are required in
addition to the Rust toolchain.

- [Go 1.21.x](https://go.dev/dl/)
- [Go 1.22.x](https://go.dev/dl/)

To run the interop tests

Expand Down
2 changes: 1 addition & 1 deletion interop-tests/src/tests/go_app/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module test/v2

go 1.21
go 1.22

require (
github.com/ipfs/boxo v0.22.0
Expand Down
19 changes: 19 additions & 0 deletions src/rpc/methods/f3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,25 @@ impl RpcMethod<0> for GetParticipatingMinerIDs {
}
}

pub enum Finalize {}
impl RpcMethod<1> for Finalize {
const NAME: &'static str = "F3.Finalize";
const PARAM_NAMES: [&'static str; 1] = ["tipset_key"];
const API_PATHS: ApiPaths = ApiPaths::V1;
const PERMISSION: Permission = Permission::Read;

type Params = (F3TipSetKey,);
type Ok = ();

async fn handle(
_: Ctx<impl Blockstore>,
(_tsk,): Self::Params,
) -> Result<Self::Ok, ServerError> {
// TODO(hanabi1224): https://github.com/ChainSafe/forest/issues/4775
Ok(())
}
}

pub enum SignMessage {}
impl RpcMethod<2> for SignMessage {
const NAME: &'static str = "F3.SignMessage";
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ macro_rules! for_each_method {
$callback!(crate::rpc::f3::GetPowerTable);
$callback!(crate::rpc::f3::GetTipset);
$callback!(crate::rpc::f3::GetTipsetByEpoch);
$callback!(crate::rpc::f3::Finalize);
$callback!(crate::rpc::f3::ProtectPeer);
$callback!(crate::rpc::f3::SignMessage);

Expand Down

0 comments on commit 6a5013c

Please sign in to comment.