Skip to content

Commit b5f56a2

Browse files
committed
rebase v1.18.0
feat: add GasOverPremium for gas estimate fix: current jsonrpc not support rpcerror fix: remove three deprecated api chore: udpate github.com/dgraph-io/ristretto to bb5d392ed82d fix: add gaspremium check when less than maxfee feat: add force network
1 parent dd2eb70 commit b5f56a2

File tree

21 files changed

+273
-125
lines changed

21 files changed

+273
-125
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ debug: build-devnets
7575
2k: GOFLAGS+=-tags=2k
7676
2k: build-devnets
7777

78+
force: GOFLAGS+=-tags=force
79+
force: build-devnets
80+
7881
calibnet: GOFLAGS+=-tags=calibnet
7982
calibnet: build-devnets
8083

api/api_errors.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package api
33
import (
44
"errors"
55
"reflect"
6-
7-
"github.com/filecoin-project/go-jsonrpc"
86
)
97

108
const (
11-
EOutOfGas = iota + jsonrpc.FirstUserCode
9+
// todo: add api.RPCErrors
10+
// EOutOfGas = iota + jsonrpc.FirstUserCode
11+
EOutOfGas = iota + 2
1212
EActorNotFound
1313
)
1414

@@ -24,7 +24,7 @@ func (e *ErrActorNotFound) Error() string {
2424
return "actor not found"
2525
}
2626

27-
var RPCErrors = jsonrpc.NewErrors()
27+
// var RPCErrors = jsonrpc.NewErrors()
2828

2929
func ErrorIsIn(err error, errorTypes []error) bool {
3030
for _, etype := range errorTypes {
@@ -36,7 +36,7 @@ func ErrorIsIn(err error, errorTypes []error) bool {
3636
return false
3737
}
3838

39-
func init() {
40-
RPCErrors.Register(EOutOfGas, new(*ErrOutOfGas))
41-
RPCErrors.Register(EActorNotFound, new(*ErrActorNotFound))
42-
}
39+
// func init() {
40+
// RPCErrors.Register(EOutOfGas, new(*ErrOutOfGas))
41+
// RPCErrors.Register(EActorNotFound, new(*ErrActorNotFound))
42+
// }

api/api_test.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ import (
1212
"testing"
1313

1414
"github.com/stretchr/testify/require"
15-
"golang.org/x/xerrors"
16-
17-
"github.com/filecoin-project/go-jsonrpc"
1815
)
1916

2017
func goCmd() string {
@@ -128,17 +125,18 @@ func TestPermTags(t *testing.T) {
128125
_ = PermissionedWorkerAPI(&WorkerStruct{})
129126
}
130127

131-
func TestRetryErrorIsInTrue(t *testing.T) {
132-
errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
133-
require.True(t, ErrorIsIn(&jsonrpc.RPCConnectionError{}, errorsToRetry))
134-
}
135-
136-
func TestRetryErrorIsInFalse(t *testing.T) {
137-
errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
138-
require.False(t, ErrorIsIn(xerrors.Errorf("random error"), errorsToRetry))
139-
}
140-
141-
func TestRetryWrappedErrorIsInTrue(t *testing.T) {
142-
errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
143-
require.True(t, ErrorIsIn(xerrors.Errorf("wrapped: %w", &jsonrpc.RPCConnectionError{}), errorsToRetry))
144-
}
128+
// todo: add api.RPCErrors
129+
// func TestRetryErrorIsInTrue(t *testing.T) {
130+
// errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
131+
// require.True(t, ErrorIsIn(&jsonrpc.RPCConnectionError{}, errorsToRetry))
132+
// }
133+
134+
// func TestRetryErrorIsInFalse(t *testing.T) {
135+
// errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
136+
// require.False(t, ErrorIsIn(xerrors.Errorf("random error"), errorsToRetry))
137+
// }
138+
139+
// func TestRetryWrappedErrorIsInTrue(t *testing.T) {
140+
// errorsToRetry := []error{&jsonrpc.RPCConnectionError{}}
141+
// require.True(t, ErrorIsIn(xerrors.Errorf("wrapped: %w", &jsonrpc.RPCConnectionError{}), errorsToRetry))
142+
// }

api/api_venus.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import (
44
"context"
55

66
"github.com/filecoin-project/go-address"
7-
"github.com/filecoin-project/go-state-types/abi"
8-
"github.com/filecoin-project/go-state-types/crypto"
7+
98
"github.com/filecoin-project/lotus/chain/types"
109
)
1110

@@ -19,15 +18,4 @@ type VenusAPI interface {
1918
MpoolPublishByAddr(context.Context, address.Address) error //perm:write
2019

2120
GasBatchEstimateMessageGas(ctx context.Context, estimateMessages []*EstimateMessage, fromNonce uint64, tsk types.TipSetKey) ([]*EstimateResult, error) //perm:read
22-
23-
// ChainGetRandomnessFromTickets is used to sample the chain for randomness.
24-
ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read
25-
26-
// ChainGetRandomnessFromBeacon is used to sample the beacon for randomness.
27-
ChainGetRandomnessFromBeacon(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read
28-
29-
// BeaconGetEntry returns the beacon entry for the given filecoin epoch. If
30-
// the entry has not yet been produced, the call will block until the entry
31-
// becomes available
32-
BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read
3321
}

api/client/client.go

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ import (
1818
// NewCommonRPCV0 creates a new http jsonrpc client.
1919
func NewCommonRPCV0(ctx context.Context, addr string, requestHeader http.Header) (api.CommonNet, jsonrpc.ClientCloser, error) {
2020
var res v0api.CommonNetStruct
21-
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
22-
api.GetInternalStructs(&res), requestHeader, jsonrpc.WithErrors(api.RPCErrors))
21+
// todo: add api.RPCErrors
22+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
23+
// api.GetInternalStructs(&res), requestHeader, jsonrpc.WithErrors(api.RPCErrors))
24+
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin", api.GetInternalStructs(&res), requestHeader)
2325

2426
return &res, closer, err
2527
}
@@ -28,17 +30,23 @@ func NewCommonRPCV0(ctx context.Context, addr string, requestHeader http.Header)
2830
func NewFullNodeRPCV0(ctx context.Context, addr string, requestHeader http.Header) (v0api.FullNode, jsonrpc.ClientCloser, error) {
2931
var res v0api.FullNodeStruct
3032

33+
// todo: add api.RPCErrors
34+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
35+
// api.GetInternalStructs(&res), requestHeader, jsonrpc.WithErrors(api.RPCErrors))
3136
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
32-
api.GetInternalStructs(&res), requestHeader, jsonrpc.WithErrors(api.RPCErrors))
37+
api.GetInternalStructs(&res), requestHeader)
3338

3439
return &res, closer, err
3540
}
3641

3742
// NewFullNodeRPCV1 creates a new http jsonrpc client.
3843
func NewFullNodeRPCV1(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.FullNode, jsonrpc.ClientCloser, error) {
3944
var res v1api.FullNodeStruct
45+
// todo: add api.RPCErrors
46+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
47+
// api.GetInternalStructs(&res), requestHeader, append([]jsonrpc.Option{jsonrpc.WithErrors(api.RPCErrors)}, opts...)...)
4048
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
41-
api.GetInternalStructs(&res), requestHeader, append([]jsonrpc.Option{jsonrpc.WithErrors(api.RPCErrors)}, opts...)...)
49+
api.GetInternalStructs(&res), requestHeader)
4250

4351
return &res, closer, err
4452
}
@@ -68,11 +76,17 @@ func NewStorageMinerRPCV0(ctx context.Context, addr string, requestHeader http.H
6876
}
6977

7078
var res v0api.StorageMinerStruct
79+
// todo: add api.RPCErrors
80+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
81+
// api.GetInternalStructs(&res), requestHeader,
82+
// append([]jsonrpc.Option{
83+
// rpcenc.ReaderParamEncoder(pushUrl),
84+
// jsonrpc.WithErrors(api.RPCErrors),
85+
// }, opts...)...)
7186
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
7287
api.GetInternalStructs(&res), requestHeader,
7388
append([]jsonrpc.Option{
7489
rpcenc.ReaderParamEncoder(pushUrl),
75-
jsonrpc.WithErrors(api.RPCErrors),
7690
}, opts...)...)
7791

7892
return &res, closer, err
@@ -85,13 +99,22 @@ func NewWorkerRPCV0(ctx context.Context, addr string, requestHeader http.Header)
8599
}
86100

87101
var res api.WorkerStruct
102+
// todo: add api.RPCErrors
103+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
104+
// api.GetInternalStructs(&res),
105+
// requestHeader,
106+
// rpcenc.ReaderParamEncoder(pushUrl),
107+
// jsonrpc.WithNoReconnect(),
108+
// jsonrpc.WithTimeout(30*time.Second),
109+
// jsonrpc.WithErrors(api.RPCErrors),
110+
// )
88111
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
89112
api.GetInternalStructs(&res),
90113
requestHeader,
91114
rpcenc.ReaderParamEncoder(pushUrl),
92115
jsonrpc.WithNoReconnect(),
93116
jsonrpc.WithTimeout(30*time.Second),
94-
jsonrpc.WithErrors(api.RPCErrors),
117+
// jsonrpc.WithErrors(api.RPCErrors),
95118
)
96119

97120
return &res, closer, err
@@ -100,10 +123,16 @@ func NewWorkerRPCV0(ctx context.Context, addr string, requestHeader http.Header)
100123
// NewGatewayRPCV1 creates a new http jsonrpc client for a gateway node.
101124
func NewGatewayRPCV1(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (api.Gateway, jsonrpc.ClientCloser, error) {
102125
var res api.GatewayStruct
126+
// todo: add api.RPCErrors
127+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
128+
// api.GetInternalStructs(&res),
129+
// requestHeader,
130+
// append(opts, jsonrpc.WithErrors(api.RPCErrors))...,
131+
// )
103132
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
104133
api.GetInternalStructs(&res),
105134
requestHeader,
106-
append(opts, jsonrpc.WithErrors(api.RPCErrors))...,
135+
opts...,
107136
)
108137

109138
return &res, closer, err
@@ -112,21 +141,32 @@ func NewGatewayRPCV1(ctx context.Context, addr string, requestHeader http.Header
112141
// NewGatewayRPCV0 creates a new http jsonrpc client for a gateway node.
113142
func NewGatewayRPCV0(ctx context.Context, addr string, requestHeader http.Header, opts ...jsonrpc.Option) (v0api.Gateway, jsonrpc.ClientCloser, error) {
114143
var res v0api.GatewayStruct
144+
// todo: add api.RPCErrors
145+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
146+
// api.GetInternalStructs(&res),
147+
// requestHeader,
148+
// append(opts, jsonrpc.WithErrors(api.RPCErrors))...,
149+
// )
115150
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
116151
api.GetInternalStructs(&res),
117152
requestHeader,
118-
append(opts, jsonrpc.WithErrors(api.RPCErrors))...,
153+
opts...,
119154
)
120155

121156
return &res, closer, err
122157
}
123158

124159
func NewWalletRPCV0(ctx context.Context, addr string, requestHeader http.Header) (api.Wallet, jsonrpc.ClientCloser, error) {
125160
var res api.WalletStruct
161+
// todo: add api.RPCErrors
162+
// closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
163+
// api.GetInternalStructs(&res),
164+
// requestHeader,
165+
// jsonrpc.WithErrors(api.RPCErrors),
166+
// )
126167
closer, err := jsonrpc.NewMergeClient(ctx, addr, "Filecoin",
127168
api.GetInternalStructs(&res),
128169
requestHeader,
129-
jsonrpc.WithErrors(api.RPCErrors),
130170
)
131171

132172
return &res, closer, err

api/proxy_gen.go

Lines changed: 0 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ type MessageSendSpec struct {
5858
MaxFee abi.TokenAmount
5959
MsgUuid uuid.UUID
6060
GasOverEstimation float64
61+
GasOverPremium float64
6162
}
6263

6364
type MpoolMessageWhole struct {

0 commit comments

Comments
 (0)