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

Chore/transport code #5779

Merged
merged 6 commits into from
Mar 1, 2023
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
7 changes: 6 additions & 1 deletion app/submodule/eth/eth_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,12 @@ func (a *ethAPI) EthGetBalance(ctx context.Context, address types.EthAddress, bl
return types.EthBigInt{}, fmt.Errorf("cannot parse block param: %s", blkParam)
}

actor, err := a.chain.StateGetActor(ctx, filAddr, ts.Key())
_, view, err := a.em.chainModule.Stmgr.StateView(ctx, ts)
if err != nil {
return types.EthBigInt{}, fmt.Errorf("failed to compute tipset state: %w", err)
}

actor, err := view.LoadActor(ctx, filAddr)
if err != nil {
if errors.Is(err, types.ErrActorNotFound) {
return types.EthBigIntZero, nil
Expand Down
64 changes: 44 additions & 20 deletions cmd/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
fbig "github.com/filecoin-project/go-state-types/big"
builtintypes "github.com/filecoin-project/go-state-types/builtin"
"github.com/ipfs/go-cid"
cmds "github.com/ipfs/go-ipfs-cmds"
"github.com/pkg/errors"
Expand Down Expand Up @@ -106,12 +107,6 @@ var msgSendCmd = &cmds.Command{
return fmt.Errorf("mal-formed value: %v", err)
}

methodID := builtin.MethodSend
method, ok := req.Options["method"]
if ok {
methodID = abi.MethodNum(method.(uint64))
}

var fromAddr address.Address
if addrStr, _ := req.Options["from-eth-addr"].(string); len(addrStr) != 0 {
fromAddr, err = address.NewFromString(addrStr)
Expand All @@ -125,14 +120,53 @@ var msgSendCmd = &cmds.Command{
}
}

if fromAddr.Protocol() == address.Delegated {
var params []byte
if rawPH := req.Options["params-hex"]; rawPH != nil {
decparams, err := hex.DecodeString(rawPH.(string))
if err != nil {
return fmt.Errorf("failed to decode hex params: %w", err)
}
params = decparams
}

methodID := builtin.MethodSend
method := req.Options["method"]
if types.IsEthAddress(fromAddr) {
// Method numbers don't make sense from eth accounts.
if method != nil {
return fmt.Errorf("messages from f410f addresses may not specify a method number")
}

// Now, figure out the correct method number from the recipient.
if toAddr == builtintypes.EthereumAddressManagerActorAddr {
methodID = builtintypes.MethodsEAM.CreateExternal
} else {
methodID = builtintypes.MethodsEVM.InvokeContract
}

if req.Options["params-json"] != nil {
return fmt.Errorf("may not call with json parameters from an eth account")
}

// And format the parameters, if present.
if len(params) > 0 {
var buf bytes.Buffer
if err := cbg.WriteByteArray(&buf, params); err != nil {
return fmt.Errorf("failed to marshal EVM parameters")
}
params = buf.Bytes()
}

// We can only send to an f410f or f0 address.
if !(toAddr.Protocol() == address.ID || toAddr.Protocol() == address.Delegated) {
// Resolve id addr if possible.
toAddr, err = env.(*node.Env).ChainAPI.StateLookupID(ctx, toAddr, types.EmptyTSK)
if err != nil {
return fmt.Errorf("f4 addresses can only send to other f4 or id addresses. could not find id address for %s", toAddr.String())
return fmt.Errorf("addresses starting with f410f can only send to other addresses starting with f410f, or id addresses. could not find id address for %s", toAddr.String())
}
}
} else if method != nil {
methodID = abi.MethodNum(method.(uint64))
}

if methodID == builtin.MethodSend && fromAddr.String() == toAddr.String() {
Expand All @@ -148,24 +182,14 @@ var msgSendCmd = &cmds.Command{
return err
}

var params []byte
rawPJ := req.Options["params-json"]
if rawPJ != nil {
decparams, err := decodeTypedParams(ctx, env.(*node.Env), toAddr, methodID, rawPJ.(string))
if err != nil {
return fmt.Errorf("failed to decode json params: %s", err)
}
params = decparams
}

rawPH := req.Options["params-hex"]
if rawPH != nil {
if params != nil {
return fmt.Errorf("can only specify one of 'params-json' and 'params-hex'")
}
decparams, err := hex.DecodeString(rawPH.(string))
decparams, err := decodeTypedParams(ctx, env.(*node.Env), toAddr, methodID, rawPJ.(string))
if err != nil {
return fmt.Errorf("failed to decode hex params: %s", err)
return fmt.Errorf("failed to decode json params: %s", err)
}
params = decparams
}
Expand Down
2 changes: 1 addition & 1 deletion extern/filecoin-ffi
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/filecoin-project/go-fil-markets v1.25.2
github.com/filecoin-project/go-jsonrpc v0.1.5
github.com/filecoin-project/go-paramfetch v0.0.4
github.com/filecoin-project/go-state-types v0.10.0-rc3
github.com/filecoin-project/go-state-types v0.10.0
github.com/filecoin-project/pubsub v1.0.0
github.com/filecoin-project/specs-actors v0.9.15
github.com/filecoin-project/specs-actors/v2 v2.3.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.10.0-rc3 h1:qExCc2swTe5ndsiu9dEoMqIwppjuTNRbsAFgpzHnHbc=
github.com/filecoin-project/go-state-types v0.10.0-rc3/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024=
github.com/filecoin-project/go-state-types v0.10.0 h1:vsSThZIaPmOxNGG59+8D/HnlWRtlbdOjduH6ye+v8f0=
github.com/filecoin-project/go-state-types v0.10.0/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024=
github.com/filecoin-project/go-statemachine v0.0.0-20200925024713-05bd7c71fbfe/go.mod h1:FGwQgZAt2Gh5mjlwJUlVB62JeYdo+if0xWxSEfBD9ig=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statemachine v1.0.2/go.mod h1:jZdXXiHa61n4NmgWFG4w8tnqgvZVHYbJ3yW7+y8bF54=
Expand Down
38 changes: 21 additions & 17 deletions pkg/messagepool/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,16 @@ func (mp *MessagePool) evalMessageGasLimit(ctx context.Context, msgIn *types.Mes

ret := res.MsgRct.GasUsed

// todo: remove after nv18
transitionalMulti := 1.0
// Overestimate gas around the upgrade
if ts.Height() <= mp.forkParams.UpgradeSkyrHeight && (mp.forkParams.UpgradeSkyrHeight-ts.Height() <= 20) {
transitionalMulti = 2.0

if ts.Height() <= mp.forkParams.UpgradeHyggeHeight && (mp.forkParams.UpgradeHyggeHeight-ts.Height() <= 20) {
func() {
// Bare transfers get about 3x more expensive: https://github.com/filecoin-project/FIPs/blob/master/FIPS/fip-0057.md#product-considerations
if msgIn.Method == builtin.MethodSend {
transitionalMulti = 3.0
return
}

_, st, err := mp.sm.ParentState(ctx, ts)
if err != nil {
return
Expand All @@ -312,26 +315,27 @@ func (mp *MessagePool) evalMessageGasLimit(ctx context.Context, msgIn *types.Mes

if builtin.IsStorageMinerActor(act.Code) {
switch msgIn.Method {
case 5:
transitionalMulti = 3.954
case 3:
transitionalMulti = 1.92
case 4:
transitionalMulti = 1.72
case 6:
transitionalMulti = 4.095
transitionalMulti = 1.06
case 7:
// skip, stay at 2.0
// transitionalMulti = 1.289
case 11:
transitionalMulti = 17.8758
transitionalMulti = 1.2
case 16:
transitionalMulti = 2.1704
case 25:
transitionalMulti = 3.1177
transitionalMulti = 1.19
case 18:
transitionalMulti = 1.73
case 23:
transitionalMulti = 1.73
case 26:
transitionalMulti = 2.3322
transitionalMulti = 1.15
case 27:
transitionalMulti = 1.18
default:
}
}

// skip storage market, 80th percentie for everything ~1.9, leave it at 2.0
}()
log.Infof("overestimate gas around the upgrade msg: %v, transitional multi: %v", msg, transitionalMulti)
}
Expand Down
2 changes: 1 addition & 1 deletion venus-devtool/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/filecoin-project/go-data-transfer v1.15.2
github.com/filecoin-project/go-fil-markets v1.25.2
github.com/filecoin-project/go-jsonrpc v0.2.1
github.com/filecoin-project/go-state-types v0.10.0-rc3
github.com/filecoin-project/go-state-types v0.10.0
github.com/filecoin-project/lotus v1.20.0-rc2
github.com/filecoin-project/venus v0.0.0-00010101000000-000000000000
github.com/google/uuid v1.3.0
Expand Down
4 changes: 2 additions & 2 deletions venus-devtool/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ github.com/filecoin-project/go-state-types v0.1.4/go.mod h1:xCA/WfKlC2zcn3fUmDv4
github.com/filecoin-project/go-state-types v0.1.6/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.8/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.1.10/go.mod h1:UwGVoMsULoCK+bWjEdd/xLCvLAQFBC7EDT477SKml+Q=
github.com/filecoin-project/go-state-types v0.10.0-rc3 h1:qExCc2swTe5ndsiu9dEoMqIwppjuTNRbsAFgpzHnHbc=
github.com/filecoin-project/go-state-types v0.10.0-rc3/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024=
github.com/filecoin-project/go-state-types v0.10.0 h1:vsSThZIaPmOxNGG59+8D/HnlWRtlbdOjduH6ye+v8f0=
github.com/filecoin-project/go-state-types v0.10.0/go.mod h1:aLIas+W8BWAfpLWEPUOGMPBdhcVwoCG4pIQSQk26024=
github.com/filecoin-project/go-statemachine v1.0.2 h1:421SSWBk8GIoCoWYYTE/d+qCWccgmRH0uXotXRDjUbc=
github.com/filecoin-project/go-statestore v0.2.0 h1:cRRO0aPLrxKQCZ2UOQbzFGn4WDNdofHZoGPjfNaAo5Q=
github.com/filecoin-project/go-statestore v0.2.0/go.mod h1:8sjBYbS35HwPzct7iT4lIXjLlYyPor80aU7t7a/Kspo=
Expand Down
Binary file modified venus-shared/actors/builtin-actors-code/v10.tar.zst
Binary file not shown.
Loading