Delete GasPrice from this world

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-08-06 23:08:42 +02:00
parent 4004c657b9
commit ab08858b45
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
37 changed files with 205 additions and 220 deletions

View File

@ -111,10 +111,10 @@ type FullNode interface {
// It fails if message fails to execute. // It fails if message fails to execute.
GasEstimateGasLimit(context.Context, *types.Message, types.TipSetKey) (int64, error) GasEstimateGasLimit(context.Context, *types.Message, types.TipSetKey) (int64, error)
// GasEstimateGasPrice estimates what gas price should be used for a // GasEsitmateGasPremium estimates what gas price should be used for a
// message to have high likelihood of inclusion in `nblocksincl` epochs. // message to have high likelihood of inclusion in `nblocksincl` epochs.
GasEstimateGasPrice(_ context.Context, nblocksincl uint64, GasEsitmateGasPremium(_ context.Context, nblocksincl uint64,
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
// MethodGroup: Sync // MethodGroup: Sync
@ -163,7 +163,7 @@ type FullNode interface {
MpoolSub(context.Context) (<-chan MpoolUpdate, error) MpoolSub(context.Context) (<-chan MpoolUpdate, error)
// MpoolEstimateGasPrice is depracated // MpoolEstimateGasPrice is depracated
// Deprecated: use GasEstimateGasPrice instead // Deprecated: use GasEsitmateGasPremium instead
MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
// MethodGroup: Miner // MethodGroup: Miner

View File

@ -85,7 +85,7 @@ type FullNodeStruct struct {
ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, error) `perm:"read"` ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, error) `perm:"read"`
ChainExport func(context.Context, types.TipSetKey) (<-chan []byte, error) `perm:"read"` ChainExport func(context.Context, types.TipSetKey) (<-chan []byte, error) `perm:"read"`
GasEstimateGasPrice func(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error) `perm:"read"` GasEsitmateGasPremium func(context.Context, uint64, address.Address, int64, types.TipSetKey) (types.BigInt, error) `perm:"read"`
GasEstimateGasLimit func(context.Context, *types.Message, types.TipSetKey) (int64, error) `perm:"read"` GasEstimateGasLimit func(context.Context, *types.Message, types.TipSetKey) (int64, error) `perm:"read"`
SyncState func(context.Context) (*api.SyncState, error) `perm:"read"` SyncState func(context.Context) (*api.SyncState, error) `perm:"read"`
@ -427,9 +427,9 @@ func (c *FullNodeStruct) ClientDealSize(ctx context.Context, root cid.Cid) (api.
return c.Internal.ClientDealSize(ctx, root) return c.Internal.ClientDealSize(ctx, root)
} }
func (c *FullNodeStruct) GasEstimateGasPrice(ctx context.Context, nblocksincl uint64, func (c *FullNodeStruct) GasEsitmateGasPremium(ctx context.Context, nblocksincl uint64,
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) { sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.GasEstimateGasPrice(ctx, nblocksincl, sender, gaslimit, tsk) return c.Internal.GasEsitmateGasPremium(ctx, nblocksincl, sender, gaslimit, tsk)
} }
func (c *FullNodeStruct) GasEstimateGasLimit(ctx context.Context, msg *types.Message, func (c *FullNodeStruct) GasEstimateGasLimit(ctx context.Context, msg *types.Message,
@ -458,7 +458,7 @@ func (c *FullNodeStruct) MpoolSub(ctx context.Context) (<-chan api.MpoolUpdate,
} }
func (c *FullNodeStruct) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) { func (c *FullNodeStruct) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) {
return c.Internal.GasEstimateGasPrice(ctx, nblocksincl, sender, limit, tsk) return c.Internal.GasEsitmateGasPremium(ctx, nblocksincl, sender, limit, tsk)
} }
func (c *FullNodeStruct) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) { func (c *FullNodeStruct) MinerGetBaseInfo(ctx context.Context, maddr address.Address, epoch abi.ChainEpoch, tsk types.TipSetKey) (*api.MiningBaseInfo, error) {

View File

@ -218,10 +218,9 @@ func waitForBlocks(ctx context.Context, t *testing.T, bm *blockMiner, paymentRec
// Add a real block // Add a real block
m, err := paymentReceiver.MpoolPushMessage(ctx, &types.Message{ m, err := paymentReceiver.MpoolPushMessage(ctx, &types.Message{
To: builtin.BurntFundsActorAddr, To: builtin.BurntFundsActorAddr,
From: receiverAddr, From: receiverAddr,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: big.Zero(),
}) })
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
@ -303,11 +302,9 @@ func sendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.
} }
msg := &types.Message{ msg := &types.Message{
From: senderAddr, From: senderAddr,
To: addr, To: addr,
Value: amount, Value: amount,
GasLimit: 0,
GasPrice: abi.NewTokenAmount(0),
} }
sm, err := sender.MpoolPushMessage(ctx, msg) sm, err := sender.MpoolPushMessage(ctx, msg)

View File

@ -489,8 +489,9 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) {
Method: 0, Method: 0,
GasLimit: 100_000_000, GasLimit: 100_000_000,
GasPrice: types.NewInt(0), GasFeeCap: types.NewInt(0),
GasPremium: types.NewInt(0),
} }
sig, err := cg.w.Sign(context.TODO(), cg.banker, msg.Cid().Bytes()) sig, err := cg.w.Sign(context.TODO(), cg.banker, msg.Cid().Bytes())

View File

@ -37,7 +37,6 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value
Method: method, Method: method,
Params: params, Params: params,
GasLimit: 1_000_000_000_000_000, GasLimit: 1_000_000_000_000_000,
GasPrice: types.NewInt(0),
Value: value, Value: value,
Nonce: act.Nonce, Nonce: act.Nonce,
}) })

View File

@ -126,17 +126,17 @@ func (ms *msgSet) add(m *types.SignedMessage) (bool, error) {
if has { if has {
if m.Cid() != exms.Cid() { if m.Cid() != exms.Cid() {
// check if RBF passes // check if RBF passes
minPrice := exms.Message.GasPrice minPrice := exms.Message.GasPremium
minPrice = types.BigAdd(minPrice, types.BigDiv(types.BigMul(minPrice, rbfNum), rbfDenom)) minPrice = types.BigAdd(minPrice, types.BigDiv(types.BigMul(minPrice, rbfNum), rbfDenom))
minPrice = types.BigAdd(minPrice, types.NewInt(1)) minPrice = types.BigAdd(minPrice, types.NewInt(1))
if types.BigCmp(m.Message.GasPrice, minPrice) >= 0 { if types.BigCmp(m.Message.GasPremium, minPrice) >= 0 {
log.Infow("add with RBF", "oldprice", exms.Message.GasPrice, log.Infow("add with RBF", "oldpremium", exms.Message.GasPremium,
"newprice", m.Message.GasPrice, "addr", m.Message.From, "nonce", m.Message.Nonce) "newpremium", m.Message.GasPremium, "addr", m.Message.From, "nonce", m.Message.Nonce)
} else { } else {
log.Info("add with duplicate nonce") log.Info("add with duplicate nonce")
return false, xerrors.Errorf("message from %s with nonce %d already in mpool,"+ return false, xerrors.Errorf("message from %s with nonce %d already in mpool,"+
" increase GasPrice to %s from %s to trigger replace by fee", " increase GasPremium to %s from %s to trigger replace by fee",
m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPrice) m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPremium)
} }
} }
} }

View File

@ -207,7 +207,7 @@ func (mp *MessagePool) getPendingMessages(curTs, ts *types.TipSet) (map[address.
if dupNonce { if dupNonce {
// duplicate nonce, selfishly keep the message with the highest GasPrice // duplicate nonce, selfishly keep the message with the highest GasPrice
// if the gas prices are the same, keep the one with the highest GasLimit // if the gas prices are the same, keep the one with the highest GasLimit
switch m.Message.GasPrice.Int.Cmp(other.Message.GasPrice.Int) { switch m.Message.GasPremium.Int.Cmp(other.Message.GasPremium.Int) {
case 0: case 0:
if m.Message.GasLimit > other.Message.GasLimit { if m.Message.GasLimit > other.Message.GasLimit {
mset[m.Message.Nonce] = m mset[m.Message.Nonce] = m

View File

@ -40,9 +40,13 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
if msg.GasLimit == 0 { if msg.GasLimit == 0 {
msg.GasLimit = build.BlockGasLimit msg.GasLimit = build.BlockGasLimit
} }
if msg.GasPrice == types.EmptyInt { if msg.GasFeeCap == types.EmptyInt {
msg.GasPrice = types.NewInt(0) msg.GasFeeCap = types.NewInt(0)
} }
if msg.GasPremium == types.EmptyInt {
msg.GasPremium = types.NewInt(0)
}
if msg.Value == types.EmptyInt { if msg.Value == types.EmptyInt {
msg.Value = types.NewInt(0) msg.Value = types.NewInt(0)
} }
@ -50,7 +54,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
if span.IsRecordingEvents() { if span.IsRecordingEvents() {
span.AddAttributes( span.AddAttributes(
trace.Int64Attribute("gas_limit", msg.GasLimit), trace.Int64Attribute("gas_limit", msg.GasLimit),
trace.Int64Attribute("gas_price", int64(msg.GasPrice.Uint64())), trace.StringAttribute("gas_feecap", msg.GasFeeCap.String()),
trace.StringAttribute("value", msg.Value.String()), trace.StringAttribute("value", msg.Value.String()),
) )
} }
@ -111,7 +115,7 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
if span.IsRecordingEvents() { if span.IsRecordingEvents() {
span.AddAttributes( span.AddAttributes(
trace.Int64Attribute("gas_limit", msg.GasLimit), trace.Int64Attribute("gas_limit", msg.GasLimit),
trace.Int64Attribute("gas_price", int64(msg.GasPrice.Uint64())), trace.StringAttribute("gas_feecap", msg.GasFeeCap.String()),
trace.StringAttribute("value", msg.Value.String()), trace.StringAttribute("value", msg.Value.String()),
) )
} }

View File

@ -173,7 +173,6 @@ func TestForkHeightTriggers(t *testing.T) {
Method: builtin.MethodsInit.Exec, Method: builtin.MethodsInit.Exec,
Params: enc, Params: enc,
GasLimit: types.TestGasLimit, GasLimit: types.TestGasLimit,
GasPrice: types.NewInt(0),
} }
sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes()) sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes())
if err != nil { if err != nil {
@ -200,7 +199,6 @@ func TestForkHeightTriggers(t *testing.T) {
Params: nil, Params: nil,
Nonce: nonce, Nonce: nonce,
GasLimit: types.TestGasLimit, GasLimit: types.TestGasLimit,
GasPrice: types.NewInt(0),
} }
nonce++ nonce++

View File

@ -175,14 +175,15 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
} }
cronMsg := &types.Message{ cronMsg := &types.Message{
To: builtin.CronActorAddr, To: builtin.CronActorAddr,
From: builtin.SystemActorAddr, From: builtin.SystemActorAddr,
Nonce: ca.Nonce, Nonce: ca.Nonce,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: types.NewInt(0), GasFeeCap: types.NewInt(0),
GasLimit: build.BlockGasLimit * 10000, // Make super sure this is never too little GasPremium: types.NewInt(0),
Method: builtin.MethodsCron.EpochTick, GasLimit: build.BlockGasLimit * 10000, // Make super sure this is never too little
Params: nil, Method: builtin.MethodsCron.EpochTick,
Params: nil,
} }
ret, err := vmi.ApplyImplicitMessage(ctx, cronMsg) ret, err := vmi.ApplyImplicitMessage(ctx, cronMsg)
if err != nil { if err != nil {
@ -262,14 +263,15 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
} }
rwMsg := &types.Message{ rwMsg := &types.Message{
From: builtin.SystemActorAddr, From: builtin.SystemActorAddr,
To: builtin.RewardActorAddr, To: builtin.RewardActorAddr,
Nonce: sysAct.Nonce, Nonce: sysAct.Nonce,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: types.NewInt(0), GasFeeCap: types.NewInt(0),
GasLimit: 1 << 30, GasPremium: types.NewInt(0),
Method: builtin.MethodsReward.AwardBlockReward, GasLimit: 1 << 30,
Params: params, Method: builtin.MethodsReward.AwardBlockReward,
Params: params,
} }
ret, err := vmi.ApplyImplicitMessage(ctx, rwMsg) ret, err := vmi.ApplyImplicitMessage(ctx, rwMsg)
if err != nil { if err != nil {

View File

@ -677,11 +677,6 @@ func (t *Message) MarshalCBOR(w io.Writer) error {
return err return err
} }
// t.GasPrice (big.Int) (struct)
if err := t.GasPrice.MarshalCBOR(w); err != nil {
return err
}
// t.GasLimit (int64) (int64) // t.GasLimit (int64) (int64)
if t.GasLimit >= 0 { if t.GasLimit >= 0 {
if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.GasLimit)); err != nil { if err := cbg.WriteMajorTypeHeaderBuf(scratch, w, cbg.MajUnsignedInt, uint64(t.GasLimit)); err != nil {
@ -812,10 +807,6 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error {
{ {
if err := t.GasPrice.UnmarshalCBOR(br); err != nil {
return xerrors.Errorf("unmarshaling t.GasPrice: %w", err)
}
} }
// t.GasLimit (int64) (int64) // t.GasLimit (int64) (int64)
{ {

View File

@ -35,7 +35,6 @@ type Message struct {
Value abi.TokenAmount Value abi.TokenAmount
// TODO: remove // TODO: remove
GasPrice BigInt
GasLimit int64 GasLimit int64
GasFeeCap abi.TokenAmount GasFeeCap abi.TokenAmount
GasPremium abi.TokenAmount GasPremium abi.TokenAmount

View File

@ -22,13 +22,14 @@ func blsaddr(n int64) address.Address {
func BenchmarkSerializeMessage(b *testing.B) { func BenchmarkSerializeMessage(b *testing.B) {
m := &Message{ m := &Message{
To: blsaddr(1), To: blsaddr(1),
From: blsaddr(2), From: blsaddr(2),
Nonce: 197, Nonce: 197,
Method: 1231254, Method: 1231254,
Params: []byte("some bytes, idk. probably at least ten of them"), Params: []byte("some bytes, idk. probably at least ten of them"),
GasLimit: 126723, GasLimit: 126723,
GasPrice: NewInt(1776234), GasPremium: NewInt(1245667),
GasFeeCap: NewInt(1245667),
} }
b.ReportAllocs() b.ReportAllocs()

View File

@ -13,14 +13,15 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) {
from, _ := address.NewIDAddress(603911192) from, _ := address.NewIDAddress(603911192)
smsg := &types.SignedMessage{ smsg := &types.SignedMessage{
Message: types.Message{ Message: types.Message{
To: to, To: to,
From: from, From: from,
Params: []byte("some bytes, idk"), Params: []byte("some bytes, idk"),
Method: 1235126, Method: 1235126,
Value: types.NewInt(123123), Value: types.NewInt(123123),
GasPrice: types.NewInt(1234), GasFeeCap: types.NewInt(1234),
GasLimit: 100_000_000, GasPremium: types.NewInt(132414234),
Nonce: 123123, GasLimit: 100_000_000,
Nonce: 123123,
}, },
} }

View File

@ -190,7 +190,6 @@ func toLotusMsg(msg *vtypes.Message) *types.Message {
Method: msg.Method, Method: msg.Method,
Value: msg.Value, Value: msg.Value,
GasPrice: msg.GasPrice,
GasLimit: msg.GasLimit, GasLimit: msg.GasLimit,
GasFeeCap: msg.GasPrice, // TODO: update chian val to use GasFeeCap GasFeeCap: msg.GasPrice, // TODO: update chian val to use GasFeeCap
GasPremium: big.Zero(), GasPremium: big.Zero(),

View File

@ -146,14 +146,15 @@ func MakeUnsignedMessageVectors() []vectors.UnsignedMessageVector {
rand.Read(params) rand.Read(params)
msg := &types.Message{ msg := &types.Message{
To: to, To: to,
From: from, From: from,
Value: types.NewInt(rand.Uint64()), Value: types.NewInt(rand.Uint64()),
Method: abi.MethodNum(rand.Uint64()), Method: abi.MethodNum(rand.Uint64()),
GasPrice: types.NewInt(rand.Uint64()), GasFeeCap: types.NewInt(rand.Uint64()),
GasLimit: rand.Int63(), GasPremium: types.NewInt(rand.Uint64()),
Nonce: rand.Uint64(), GasLimit: rand.Int63(),
Params: params, Nonce: rand.Uint64(),
Params: params,
} }
ser, err := msg.Serialize() ser, err := msg.Serialize()

View File

@ -430,22 +430,22 @@ var chainListCmd = &cli.Command{
psum := big.NewInt(0) psum := big.NewInt(0)
for _, m := range msgs.BlsMessages { for _, m := range msgs.BlsMessages {
limitSum += m.GasLimit limitSum += m.GasLimit
psum = big.Add(psum, m.GasPrice) psum = big.Add(psum, m.GasPremium)
} }
for _, m := range msgs.SecpkMessages { for _, m := range msgs.SecpkMessages {
limitSum += m.Message.GasLimit limitSum += m.Message.GasLimit
psum = big.Add(psum, m.Message.GasPrice) psum = big.Add(psum, m.Message.GasPremium)
} }
lenmsgs := len(msgs.BlsMessages) + len(msgs.SecpkMessages) lenmsgs := len(msgs.BlsMessages) + len(msgs.SecpkMessages)
avgprice := big.Zero() avgpremium := big.Zero()
if lenmsgs > 0 { if lenmsgs > 0 {
avgprice = big.Div(psum, big.NewInt(int64(lenmsgs))) avgpremium = big.Div(psum, big.NewInt(int64(lenmsgs)))
} }
fmt.Printf("\t%s: \t%d msgs, gasLimit: %d / %d (%0.2f%%), avgPrice: %s\n", b.Miner, len(msgs.BlsMessages)+len(msgs.SecpkMessages), limitSum, build.BlockGasLimit, 100*float64(limitSum)/float64(build.BlockGasLimit), avgprice) fmt.Printf("\t%s: \t%d msgs, gasLimit: %d / %d (%0.2f%%), avgPrice: %s\n", b.Miner, len(msgs.BlsMessages)+len(msgs.SecpkMessages), limitSum, build.BlockGasLimit, 100*float64(limitSum)/float64(build.BlockGasLimit), avgpremium)
} }
if i < len(tss)-1 { if i < len(tss)-1 {
msgs, err := api.ChainGetParentMessages(ctx, tss[i+1].Blocks()[0].Cid()) msgs, err := api.ChainGetParentMessages(ctx, tss[i+1].Blocks()[0].Cid())
@ -1030,9 +1030,9 @@ var chainGasPriceCmd = &cli.Command{
nb := []int{1, 2, 3, 5, 10, 20, 50, 100, 300} nb := []int{1, 2, 3, 5, 10, 20, 50, 100, 300}
for _, nblocks := range nb { for _, nblocks := range nb {
addr := builtin.SystemActorAddr // TODO: make real when used in GasEstimateGasPrice addr := builtin.SystemActorAddr // TODO: make real when used in GasEsitmateGasPremium
est, err := api.GasEstimateGasPrice(ctx, uint64(nblocks), addr, 10000, types.EmptyTSK) est, err := api.GasEsitmateGasPremium(ctx, uint64(nblocks), addr, 10000, types.EmptyTSK)
if err != nil { if err != nil {
return err return err
} }

View File

@ -246,8 +246,12 @@ var mpoolReplaceCmd = &cli.Command{
Name: "replace", Name: "replace",
Usage: "replace a message in the mempool", Usage: "replace a message in the mempool",
Flags: []cli.Flag{ Flags: []cli.Flag{
&cli.Int64Flag{ &cli.StringFlag{
Name: "gas-price", Name: "gas-feecap",
Usage: "gas feecap for new message",
},
&cli.StringFlag{
Name: "gas-premium",
Usage: "gas price for new message", Usage: "gas price for new message",
}, },
&cli.Int64Flag{ &cli.Int64Flag{
@ -304,7 +308,15 @@ var mpoolReplaceCmd = &cli.Command{
msg := found.Message msg := found.Message
msg.GasLimit = cctx.Int64("gas-limit") msg.GasLimit = cctx.Int64("gas-limit")
msg.GasPrice = types.NewInt(uint64(cctx.Int64("gas-price"))) msg.GasPremium, err = types.BigFromString(cctx.String("gas-premium"))
if err != nil {
return fmt.Errorf("parsing gas-premium: %w", err)
}
// TODO: estiamte fee cap here
msg.GasFeeCap, err = types.BigFromString(cctx.String("gas-feecap"))
if err != nil {
return fmt.Errorf("parsing gas-feecap: %w", err)
}
smsg, err := api.WalletSignMessage(ctx, msg.From, &msg) smsg, err := api.WalletSignMessage(ctx, msg.From, &msg)
if err != nil { if err != nil {

View File

@ -27,10 +27,15 @@ var sendCmd = &cli.Command{
Usage: "optionally specify the account to send funds from", Usage: "optionally specify the account to send funds from",
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "gas-price", Name: "gas-premium",
Usage: "specify gas price to use in AttoFIL", Usage: "specify gas price to use in AttoFIL",
Value: "0", Value: "0",
}, },
&cli.StringFlag{
Name: "gas-feecap",
Usage: "specify gas fee cap to use in AttoFIL",
Value: "0",
},
&cli.Int64Flag{ &cli.Int64Flag{
Name: "gas-limit", Name: "gas-limit",
Usage: "specify gas limit", Usage: "specify gas limit",
@ -99,6 +104,10 @@ var sendCmd = &cli.Command{
if err != nil { if err != nil {
return err return err
} }
gfc, err := types.BigFromString(cctx.String("gas-feecap"))
if err != nil {
return err
}
method := abi.MethodNum(cctx.Uint64("method")) method := abi.MethodNum(cctx.Uint64("method"))
@ -122,13 +131,14 @@ var sendCmd = &cli.Command{
} }
msg := &types.Message{ msg := &types.Message{
From: fromAddr, From: fromAddr,
To: toAddr, To: toAddr,
Value: types.BigInt(val), Value: types.BigInt(val),
GasPrice: gp, GasPremium: gp,
GasLimit: cctx.Int64("gas-limit"), GasFeeCap: gfc,
Method: method, GasLimit: cctx.Int64("gas-limit"),
Params: params, Method: method,
Params: params,
} }
if cctx.Int64("nonce") > 0 { if cctx.Int64("nonce") > 0 {

View File

@ -5,7 +5,6 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/multiformats/go-multiaddr"
"html/template" "html/template"
"io" "io"
"os" "os"
@ -15,6 +14,8 @@ import (
"strings" "strings"
"time" "time"
"github.com/multiformats/go-multiaddr"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/multiformats/go-multihash" "github.com/multiformats/go-multihash"
@ -1383,13 +1384,11 @@ var stateCallCmd = &cli.Command{
} }
ret, err := api.StateCall(ctx, &types.Message{ ret, err := api.StateCall(ctx, &types.Message{
From: froma, From: froma,
To: toa, To: toa,
Value: types.BigInt(value), Value: types.BigInt(value),
GasLimit: 10000000000, Method: abi.MethodNum(method),
GasPrice: types.NewInt(0), Params: params,
Method: abi.MethodNum(method),
Params: params,
}, ts.Key()) }, ts.Key())
if err != nil { if err != nil {
return fmt.Errorf("state call failed: %s", err) return fmt.Errorf("state call failed: %s", err)

View File

@ -74,11 +74,9 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre
select { select {
case <-tick.C: case <-tick.C:
msg := &types.Message{ msg := &types.Message{
From: from, From: from,
To: sendSet[rand.Intn(20)], To: sendSet[rand.Intn(20)],
Value: types.NewInt(1), Value: types.NewInt(1),
GasLimit: 0,
GasPrice: types.NewInt(0),
} }
smsg, err := api.MpoolPushMessage(ctx, msg) smsg, err := api.MpoolPushMessage(ctx, msg)

View File

@ -30,7 +30,8 @@ create table if not exists messages
"to" text not null, "to" text not null,
nonce bigint not null, nonce bigint not null,
value text not null, value text not null,
gasprice bigint not null, gasfeecap bigint not null,
gaspremium bigint not null,
gaslimit bigint not null, gaslimit bigint not null,
method bigint, method bigint,
params bytea params bytea
@ -219,7 +220,7 @@ create temp table msgs (like messages excluding constraints) on commit drop;
return xerrors.Errorf("prep temp: %w", err) return xerrors.Errorf("prep temp: %w", err)
} }
stmt, err := tx.Prepare(`copy msgs (cid, "from", "to", nonce, "value", gasprice, gaslimit, method, params) from stdin `) stmt, err := tx.Prepare(`copy msgs (cid, "from", "to", nonce, "value", gaspremium, gasfeecap gaslimit, method, params) from stdin `)
if err != nil { if err != nil {
return err return err
} }
@ -231,7 +232,8 @@ create temp table msgs (like messages excluding constraints) on commit drop;
m.To.String(), m.To.String(),
m.Nonce, m.Nonce,
m.Value.String(), m.Value.String(),
m.GasPrice.String(), m.GasFeeCap.String(),
m.GasPremium.String(),
m.GasLimit, m.GasLimit,
m.Method, m.Method,
m.Params, m.Params,

View File

@ -279,9 +279,6 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
Value: types.BigInt(h.sendPerRequest), Value: types.BigInt(h.sendPerRequest),
From: h.from, From: h.from,
To: to, To: to,
GasPrice: types.NewInt(0),
GasLimit: 0,
}) })
if err != nil { if err != nil {
w.WriteHeader(400) w.WriteHeader(400)
@ -353,9 +350,6 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
Value: types.BigInt(h.sendPerRequest), Value: types.BigInt(h.sendPerRequest),
From: h.from, From: h.from,
To: owner, To: owner,
GasPrice: types.NewInt(0),
GasLimit: 0,
}) })
if err != nil { if err != nil {
w.WriteHeader(400) w.WriteHeader(400)
@ -390,9 +384,6 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
Method: builtin.MethodsPower.CreateMiner, Method: builtin.MethodsPower.CreateMiner,
Params: params, Params: params,
GasLimit: 0,
GasPrice: types.NewInt(0),
} }
signed, err := h.api.MpoolPushMessage(r.Context(), createStorageMinerMsg) signed, err := h.api.MpoolPushMessage(r.Context(), createStorageMinerMsg)

View File

@ -51,7 +51,7 @@ var minerSelectMsgsCmd = &cli.Command{
to = "..." + to[len(to)-8:] to = "..." + to[len(to)-8:]
} }
fmt.Printf("%d: %s -> %s, method %d, gasPrice %s, gasLimit %d, val %s\n", i, from, to, f.Message.Method, f.Message.GasPrice, f.Message.GasLimit, types.FIL(f.Message.Value)) fmt.Printf("%d: %s -> %s, method %d, gasFeecap %s, gasPremium %s, gasLimit %d, val %s\n", i, from, to, f.Message.Method, f.Message.GasFeeCap, f.Message.GasPremium, f.Message.GasLimit, types.FIL(f.Message.Value))
totalGas += f.Message.GasLimit totalGas += f.Message.GasLimit
} }

View File

@ -143,12 +143,10 @@ var verifRegVerifyClientCmd = &cli.Command{
ctx := lcli.ReqContext(cctx) ctx := lcli.ReqContext(cctx)
msg := &types.Message{ msg := &types.Message{
To: builtin.VerifiedRegistryActorAddr, To: builtin.VerifiedRegistryActorAddr,
From: fromk, From: fromk,
Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient, Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient,
GasPrice: types.NewInt(1), Params: params,
GasLimit: 0,
Params: params,
} }
smsg, err := api.MpoolPushMessage(ctx, msg) smsg, err := api.MpoolPushMessage(ctx, msg)

View File

@ -102,8 +102,8 @@ var initCmd = &cli.Command{
Usage: "don't use storageminer repo for sector storage", Usage: "don't use storageminer repo for sector storage",
}, },
&cli.StringFlag{ &cli.StringFlag{
Name: "gas-price", Name: "gas-premium",
Usage: "set gas price for initialization messages in AttoFIL", Usage: "set gas premium for initialization messages in AttoFIL",
Value: "0", Value: "0",
}, },
}, },
@ -116,7 +116,7 @@ var initCmd = &cli.Command{
} }
ssize := abi.SectorSize(sectorSizeInt) ssize := abi.SectorSize(sectorSizeInt)
gasPrice, err := types.BigFromString(cctx.String("gas-price")) gasPrice, err := types.BigFromString(cctx.String("gas-premium"))
if err != nil { if err != nil {
return xerrors.Errorf("failed to parse gas-price flag: %s", err) return xerrors.Errorf("failed to parse gas-price flag: %s", err)
} }
@ -552,13 +552,12 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address.
} }
msg := &types.Message{ msg := &types.Message{
To: addr, To: addr,
From: mi.Worker, From: mi.Worker,
Method: builtin.MethodsMiner.ChangePeerID, Method: builtin.MethodsMiner.ChangePeerID,
Params: enc, Params: enc,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: gasPrice, GasPremium: gasPrice,
GasLimit: 0,
} }
smsg, err := api.MpoolPushMessage(ctx, msg) smsg, err := api.MpoolPushMessage(ctx, msg)
@ -637,8 +636,8 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID,
Method: builtin.MethodsPower.CreateMiner, Method: builtin.MethodsPower.CreateMiner,
Params: params, Params: params,
GasLimit: 0, GasLimit: 0,
GasPrice: gasPrice, GasPremium: gasPrice,
} }
signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg) signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg)

View File

@ -123,12 +123,10 @@ func (c *ClientNodeAdapter) ListClientDeals(ctx context.Context, addr address.Ad
func (c *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error) { func (c *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error) {
// (Provider Node API) // (Provider Node API)
smsg, err := c.MpoolPushMessage(ctx, &types.Message{ smsg, err := c.MpoolPushMessage(ctx, &types.Message{
To: builtin.StorageMarketActorAddr, To: builtin.StorageMarketActorAddr,
From: addr, From: addr,
Value: amount, Value: amount,
GasPrice: types.NewInt(0), Method: builtin.MethodsMarket.AddBalance,
GasLimit: 0,
Method: builtin.MethodsMarket.AddBalance,
}) })
if err != nil { if err != nil {
return cid.Undef, err return cid.Undef, err

View File

@ -74,13 +74,11 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
// TODO: We may want this to happen after fetching data // TODO: We may want this to happen after fetching data
smsg, err := n.MpoolPushMessage(ctx, &types.Message{ smsg, err := n.MpoolPushMessage(ctx, &types.Message{
To: builtin.StorageMarketActorAddr, To: builtin.StorageMarketActorAddr,
From: mi.Worker, From: mi.Worker,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: types.NewInt(0), Method: builtin.MethodsMarket.PublishStorageDeals,
GasLimit: 0, Params: params,
Method: builtin.MethodsMarket.PublishStorageDeals,
Params: params,
}) })
if err != nil { if err != nil {
return cid.Undef, err return cid.Undef, err
@ -175,12 +173,10 @@ func (n *ProviderNodeAdapter) EnsureFunds(ctx context.Context, addr, wallet addr
func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error) { func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address, amount abi.TokenAmount) (cid.Cid, error) {
// (Provider Node API) // (Provider Node API)
smsg, err := n.MpoolPushMessage(ctx, &types.Message{ smsg, err := n.MpoolPushMessage(ctx, &types.Message{
To: builtin.StorageMarketActorAddr, To: builtin.StorageMarketActorAddr,
From: addr, From: addr,
Value: amount, Value: amount,
GasPrice: types.NewInt(0), Method: builtin.MethodsMarket.AddBalance,
GasLimit: 0,
Method: builtin.MethodsMarket.AddBalance,
}) })
if err != nil { if err != nil {
return cid.Undef, err return cid.Undef, err

View File

@ -32,9 +32,9 @@ type FullNodeAPI struct {
} }
// MpoolEstimateGasPrice estimates gas price // MpoolEstimateGasPrice estimates gas price
// Deprecated: used GasEstimateGasPrice instead // Deprecated: used GasEsitmateGasPremium instead
func (fa *FullNodeAPI) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) { func (fa *FullNodeAPI) MpoolEstimateGasPrice(ctx context.Context, nblocksincl uint64, sender address.Address, limit int64, tsk types.TipSetKey) (types.BigInt, error) {
return fa.GasEstimateGasPrice(ctx, nblocksincl, sender, limit, tsk) return fa.GasEsitmateGasPremium(ctx, nblocksincl, sender, limit, tsk)
} }
var _ api.FullNode = &FullNodeAPI{} var _ api.FullNode = &FullNodeAPI{}

View File

@ -27,7 +27,7 @@ type GasAPI struct {
const MinGasPrice = 1 const MinGasPrice = 1
func (a *GasAPI) GasEstimateGasPrice(ctx context.Context, nblocksincl uint64, func (a *GasAPI) GasEsitmateGasPremium(ctx context.Context, nblocksincl uint64,
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) { sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error) {
if nblocksincl == 0 { if nblocksincl == 0 {
@ -68,7 +68,7 @@ func (a *GasAPI) GasEstimateGasPrice(ctx context.Context, nblocksincl uint64,
} }
prices = append(prices, gasMeta{ prices = append(prices, gasMeta{
price: msg.VMMessage().GasPrice, price: msg.VMMessage().GasPremium,
used: r.GasUsed, used: r.GasUsed,
}) })
gasUsed += r.GasUsed gasUsed += r.GasUsed

View File

@ -112,12 +112,12 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t
msg.GasLimit = int64(float64(gasLimit) * GasMargin) msg.GasLimit = int64(float64(gasLimit) * GasMargin)
} }
if msg.GasPrice == types.EmptyInt || types.BigCmp(msg.GasPrice, types.NewInt(0)) == 0 { if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
gasPrice, err := a.GasEstimateGasPrice(ctx, 2, msg.From, msg.GasLimit, types.TipSetKey{}) gasPrice, err := a.GasEsitmateGasPremium(ctx, 2, msg.From, msg.GasLimit, types.TipSetKey{})
if err != nil { if err != nil {
return nil, xerrors.Errorf("estimating gas price: %w", err) return nil, xerrors.Errorf("estimating gas price: %w", err)
} }
msg.GasPrice = gasPrice msg.GasPremium = gasPrice
} }
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 { if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
msg.GasPremium = types.NewInt(100) msg.GasPremium = types.NewInt(100)

View File

@ -45,10 +45,6 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Ad
return cid.Undef, xerrors.Errorf("must provide source address") return cid.Undef, xerrors.Errorf("must provide source address")
} }
if gp == types.EmptyInt {
gp = types.NewInt(0)
}
// Set up constructor parameters for multisig // Set up constructor parameters for multisig
msigParams := &samsig.ConstructorParams{ msigParams := &samsig.ConstructorParams{
Signers: addrs, Signers: addrs,
@ -74,12 +70,11 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Ad
// now we create the message to send this with // now we create the message to send this with
msg := types.Message{ msg := types.Message{
To: builtin.InitActorAddr, To: builtin.InitActorAddr,
From: src, From: src,
Method: builtin.MethodsInit.Exec, Method: builtin.MethodsInit.Exec,
Params: enc, Params: enc,
Value: val, Value: val,
GasPrice: gp,
} }
// send the message out to the network // send the message out to the network

View File

@ -968,12 +968,10 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr
} }
ret, err := a.StateManager.Call(ctx, &types.Message{ ret, err := a.StateManager.Call(ctx, &types.Message{
From: maddr, From: maddr,
To: builtin.StorageMarketActorAddr, To: builtin.StorageMarketActorAddr,
Method: builtin.MethodsMarket.VerifyDealsForActivation, Method: builtin.MethodsMarket.VerifyDealsForActivation,
GasLimit: 0, Params: params,
GasPrice: types.NewInt(0),
Params: params,
}, ts) }, ts)
if err != nil { if err != nil {
return types.EmptyInt, err return types.EmptyInt, err
@ -1048,12 +1046,10 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
} }
ret, err := a.StateManager.Call(ctx, &types.Message{ ret, err := a.StateManager.Call(ctx, &types.Message{
From: maddr, From: maddr,
To: builtin.StorageMarketActorAddr, To: builtin.StorageMarketActorAddr,
Method: builtin.MethodsMarket.VerifyDealsForActivation, Method: builtin.MethodsMarket.VerifyDealsForActivation,
GasLimit: 0, Params: params,
GasPrice: types.NewInt(0),
Params: params,
}, ts) }, ts)
if err != nil { if err != nil {
return types.EmptyInt, err return types.EmptyInt, err

View File

@ -103,13 +103,11 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a
require.NoError(t, err) require.NoError(t, err)
msg := &types.Message{ msg := &types.Message{
To: act, To: act,
From: waddr, From: waddr,
Method: builtin.MethodsMiner.ChangePeerID, Method: builtin.MethodsMiner.ChangePeerID,
Params: enc, Params: enc,
Value: types.NewInt(0), Value: types.NewInt(0),
GasPrice: types.NewInt(0),
GasLimit: 0,
} }
_, err = tnd.MpoolPushMessage(ctx, msg) _, err = tnd.MpoolPushMessage(ctx, msg)

View File

@ -241,13 +241,11 @@ func (ca *channelAccessor) createPaych(ctx context.Context, from, to address.Add
} }
msg := &types.Message{ msg := &types.Message{
To: builtin.InitActorAddr, To: builtin.InitActorAddr,
From: from, From: from,
Value: amt, Value: amt,
Method: builtin.MethodsInit.Exec, Method: builtin.MethodsInit.Exec,
Params: enc, Params: enc,
GasLimit: 0,
GasPrice: types.NewInt(0),
} }
smsg, err := ca.api.MpoolPushMessage(ctx, msg) smsg, err := ca.api.MpoolPushMessage(ctx, msg)
@ -323,12 +321,10 @@ func (ca *channelAccessor) waitPaychCreateMsg(channelID string, mcid cid.Cid) er
// addFunds sends a message to add funds to the channel and returns the message cid // addFunds sends a message to add funds to the channel and returns the message cid
func (ca *channelAccessor) addFunds(ctx context.Context, channelInfo *ChannelInfo, amt types.BigInt, cb onCompleteFn) (*cid.Cid, error) { func (ca *channelAccessor) addFunds(ctx context.Context, channelInfo *ChannelInfo, amt types.BigInt, cb onCompleteFn) (*cid.Cid, error) {
msg := &types.Message{ msg := &types.Message{
To: *channelInfo.Channel, To: *channelInfo.Channel,
From: channelInfo.Control, From: channelInfo.Control,
Value: amt, Value: amt,
Method: 0, Method: 0,
GasLimit: 0,
GasPrice: types.NewInt(0),
} }
smsg, err := ca.api.MpoolPushMessage(ctx, msg) smsg, err := ca.api.MpoolPushMessage(ctx, msg)

View File

@ -237,15 +237,16 @@ func (s SealingAPIAdapter) StateMarketStorageDeal(ctx context.Context, dealID ab
return deal.Proposal, nil return deal.Proposal, nil
} }
//TODO: rename/remove gasPrice and gasLimit
func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error) { func (s SealingAPIAdapter) SendMsg(ctx context.Context, from, to address.Address, method abi.MethodNum, value, gasPrice big.Int, gasLimit int64, params []byte) (cid.Cid, error) {
msg := types.Message{ msg := types.Message{
To: to, To: to,
From: from, From: from,
Value: value, Value: value,
GasPrice: gasPrice, GasPremium: gasPrice,
GasLimit: gasLimit, GasLimit: gasLimit,
Method: method, Method: method,
Params: params, Params: params,
} }
smsg, err := s.delegate.MpoolPushMessage(ctx, &msg) smsg, err := s.delegate.MpoolPushMessage(ctx, &msg)

View File

@ -281,7 +281,10 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
msgn := make(map[msgTag][]cid.Cid) msgn := make(map[msgTag][]cid.Cid)
for i, msg := range msgs { for i, msg := range msgs {
p := NewPoint("chain.message_gasprice", msg.Message.GasPrice.Int64()) // FIXME: use float so this doesn't overflow
p := NewPoint("chain.message_gaspremium", msg.Message.GasPremium.Int64())
pl.AddPoint(p)
p = NewPoint("chain.message_gasfeecap", msg.Message.GasFeeCap.Int64())
pl.AddPoint(p) pl.AddPoint(p)
bs, err := msg.Message.Serialize() bs, err := msg.Message.Serialize()