Delete GasPrice from this world
Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
parent
4004c657b9
commit
ab08858b45
@ -111,10 +111,10 @@ type FullNode interface {
|
||||
// It fails if message fails to execute.
|
||||
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.
|
||||
|
||||
GasEstimateGasPrice(_ context.Context, nblocksincl uint64,
|
||||
GasEsitmateGasPremium(_ context.Context, nblocksincl uint64,
|
||||
sender address.Address, gaslimit int64, tsk types.TipSetKey) (types.BigInt, error)
|
||||
|
||||
// MethodGroup: Sync
|
||||
@ -163,7 +163,7 @@ type FullNode interface {
|
||||
MpoolSub(context.Context) (<-chan MpoolUpdate, error)
|
||||
|
||||
// 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)
|
||||
|
||||
// MethodGroup: Miner
|
||||
|
@ -85,7 +85,7 @@ type FullNodeStruct struct {
|
||||
ChainGetPath func(context.Context, types.TipSetKey, types.TipSetKey) ([]*api.HeadChange, 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"`
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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) {
|
||||
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,
|
||||
@ -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) {
|
||||
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) {
|
||||
|
@ -218,10 +218,9 @@ func waitForBlocks(ctx context.Context, t *testing.T, bm *blockMiner, paymentRec
|
||||
|
||||
// Add a real block
|
||||
m, err := paymentReceiver.MpoolPushMessage(ctx, &types.Message{
|
||||
To: builtin.BurntFundsActorAddr,
|
||||
From: receiverAddr,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: big.Zero(),
|
||||
To: builtin.BurntFundsActorAddr,
|
||||
From: receiverAddr,
|
||||
Value: types.NewInt(0),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@ -303,11 +302,9 @@ func sendFunds(ctx context.Context, t *testing.T, sender TestNode, addr address.
|
||||
}
|
||||
|
||||
msg := &types.Message{
|
||||
From: senderAddr,
|
||||
To: addr,
|
||||
Value: amount,
|
||||
GasLimit: 0,
|
||||
GasPrice: abi.NewTokenAmount(0),
|
||||
From: senderAddr,
|
||||
To: addr,
|
||||
Value: amount,
|
||||
}
|
||||
|
||||
sm, err := sender.MpoolPushMessage(ctx, msg)
|
||||
|
@ -489,8 +489,9 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) {
|
||||
|
||||
Method: 0,
|
||||
|
||||
GasLimit: 100_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 100_000_000,
|
||||
GasFeeCap: types.NewInt(0),
|
||||
GasPremium: types.NewInt(0),
|
||||
}
|
||||
|
||||
sig, err := cg.w.Sign(context.TODO(), cg.banker, msg.Cid().Bytes())
|
||||
|
@ -37,7 +37,6 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value
|
||||
Method: method,
|
||||
Params: params,
|
||||
GasLimit: 1_000_000_000_000_000,
|
||||
GasPrice: types.NewInt(0),
|
||||
Value: value,
|
||||
Nonce: act.Nonce,
|
||||
})
|
||||
|
@ -126,17 +126,17 @@ func (ms *msgSet) add(m *types.SignedMessage) (bool, error) {
|
||||
if has {
|
||||
if m.Cid() != exms.Cid() {
|
||||
// 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.NewInt(1))
|
||||
if types.BigCmp(m.Message.GasPrice, minPrice) >= 0 {
|
||||
log.Infow("add with RBF", "oldprice", exms.Message.GasPrice,
|
||||
"newprice", m.Message.GasPrice, "addr", m.Message.From, "nonce", m.Message.Nonce)
|
||||
if types.BigCmp(m.Message.GasPremium, minPrice) >= 0 {
|
||||
log.Infow("add with RBF", "oldpremium", exms.Message.GasPremium,
|
||||
"newpremium", m.Message.GasPremium, "addr", m.Message.From, "nonce", m.Message.Nonce)
|
||||
} else {
|
||||
log.Info("add with duplicate nonce")
|
||||
return false, xerrors.Errorf("message from %s with nonce %d already in mpool,"+
|
||||
" increase GasPrice to %s from %s to trigger replace by fee",
|
||||
m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPrice)
|
||||
" increase GasPremium to %s from %s to trigger replace by fee",
|
||||
m.Message.From, m.Message.Nonce, minPrice, m.Message.GasPremium)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ func (mp *MessagePool) getPendingMessages(curTs, ts *types.TipSet) (map[address.
|
||||
if dupNonce {
|
||||
// duplicate nonce, selfishly keep the message with the highest GasPrice
|
||||
// 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:
|
||||
if m.Message.GasLimit > other.Message.GasLimit {
|
||||
mset[m.Message.Nonce] = m
|
||||
|
@ -40,9 +40,13 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
|
||||
if msg.GasLimit == 0 {
|
||||
msg.GasLimit = build.BlockGasLimit
|
||||
}
|
||||
if msg.GasPrice == types.EmptyInt {
|
||||
msg.GasPrice = types.NewInt(0)
|
||||
if msg.GasFeeCap == types.EmptyInt {
|
||||
msg.GasFeeCap = types.NewInt(0)
|
||||
}
|
||||
if msg.GasPremium == types.EmptyInt {
|
||||
msg.GasPremium = types.NewInt(0)
|
||||
}
|
||||
|
||||
if msg.Value == types.EmptyInt {
|
||||
msg.Value = types.NewInt(0)
|
||||
}
|
||||
@ -50,7 +54,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate
|
||||
if span.IsRecordingEvents() {
|
||||
span.AddAttributes(
|
||||
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()),
|
||||
)
|
||||
}
|
||||
@ -111,7 +115,7 @@ func (sm *StateManager) CallWithGas(ctx context.Context, msg *types.Message, pri
|
||||
if span.IsRecordingEvents() {
|
||||
span.AddAttributes(
|
||||
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()),
|
||||
)
|
||||
}
|
||||
|
@ -173,7 +173,6 @@ func TestForkHeightTriggers(t *testing.T) {
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
GasLimit: types.TestGasLimit,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes())
|
||||
if err != nil {
|
||||
@ -200,7 +199,6 @@ func TestForkHeightTriggers(t *testing.T) {
|
||||
Params: nil,
|
||||
Nonce: nonce,
|
||||
GasLimit: types.TestGasLimit,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
nonce++
|
||||
|
||||
|
@ -175,14 +175,15 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
|
||||
}
|
||||
|
||||
cronMsg := &types.Message{
|
||||
To: builtin.CronActorAddr,
|
||||
From: builtin.SystemActorAddr,
|
||||
Nonce: ca.Nonce,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: build.BlockGasLimit * 10000, // Make super sure this is never too little
|
||||
Method: builtin.MethodsCron.EpochTick,
|
||||
Params: nil,
|
||||
To: builtin.CronActorAddr,
|
||||
From: builtin.SystemActorAddr,
|
||||
Nonce: ca.Nonce,
|
||||
Value: types.NewInt(0),
|
||||
GasFeeCap: types.NewInt(0),
|
||||
GasPremium: types.NewInt(0),
|
||||
GasLimit: build.BlockGasLimit * 10000, // Make super sure this is never too little
|
||||
Method: builtin.MethodsCron.EpochTick,
|
||||
Params: nil,
|
||||
}
|
||||
ret, err := vmi.ApplyImplicitMessage(ctx, cronMsg)
|
||||
if err != nil {
|
||||
@ -262,14 +263,15 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, parentEpoch abi.ChainEp
|
||||
}
|
||||
|
||||
rwMsg := &types.Message{
|
||||
From: builtin.SystemActorAddr,
|
||||
To: builtin.RewardActorAddr,
|
||||
Nonce: sysAct.Nonce,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 1 << 30,
|
||||
Method: builtin.MethodsReward.AwardBlockReward,
|
||||
Params: params,
|
||||
From: builtin.SystemActorAddr,
|
||||
To: builtin.RewardActorAddr,
|
||||
Nonce: sysAct.Nonce,
|
||||
Value: types.NewInt(0),
|
||||
GasFeeCap: types.NewInt(0),
|
||||
GasPremium: types.NewInt(0),
|
||||
GasLimit: 1 << 30,
|
||||
Method: builtin.MethodsReward.AwardBlockReward,
|
||||
Params: params,
|
||||
}
|
||||
ret, err := vmi.ApplyImplicitMessage(ctx, rwMsg)
|
||||
if err != nil {
|
||||
|
@ -677,11 +677,6 @@ func (t *Message) MarshalCBOR(w io.Writer) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.GasPrice (big.Int) (struct)
|
||||
if err := t.GasPrice.MarshalCBOR(w); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// t.GasLimit (int64) (int64)
|
||||
if t.GasLimit >= 0 {
|
||||
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)
|
||||
{
|
||||
|
@ -35,7 +35,6 @@ type Message struct {
|
||||
Value abi.TokenAmount
|
||||
|
||||
// TODO: remove
|
||||
GasPrice BigInt
|
||||
GasLimit int64
|
||||
GasFeeCap abi.TokenAmount
|
||||
GasPremium abi.TokenAmount
|
||||
|
@ -22,13 +22,14 @@ func blsaddr(n int64) address.Address {
|
||||
|
||||
func BenchmarkSerializeMessage(b *testing.B) {
|
||||
m := &Message{
|
||||
To: blsaddr(1),
|
||||
From: blsaddr(2),
|
||||
Nonce: 197,
|
||||
Method: 1231254,
|
||||
Params: []byte("some bytes, idk. probably at least ten of them"),
|
||||
GasLimit: 126723,
|
||||
GasPrice: NewInt(1776234),
|
||||
To: blsaddr(1),
|
||||
From: blsaddr(2),
|
||||
Nonce: 197,
|
||||
Method: 1231254,
|
||||
Params: []byte("some bytes, idk. probably at least ten of them"),
|
||||
GasLimit: 126723,
|
||||
GasPremium: NewInt(1245667),
|
||||
GasFeeCap: NewInt(1245667),
|
||||
}
|
||||
|
||||
b.ReportAllocs()
|
||||
|
@ -13,14 +13,15 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) {
|
||||
from, _ := address.NewIDAddress(603911192)
|
||||
smsg := &types.SignedMessage{
|
||||
Message: types.Message{
|
||||
To: to,
|
||||
From: from,
|
||||
Params: []byte("some bytes, idk"),
|
||||
Method: 1235126,
|
||||
Value: types.NewInt(123123),
|
||||
GasPrice: types.NewInt(1234),
|
||||
GasLimit: 100_000_000,
|
||||
Nonce: 123123,
|
||||
To: to,
|
||||
From: from,
|
||||
Params: []byte("some bytes, idk"),
|
||||
Method: 1235126,
|
||||
Value: types.NewInt(123123),
|
||||
GasFeeCap: types.NewInt(1234),
|
||||
GasPremium: types.NewInt(132414234),
|
||||
GasLimit: 100_000_000,
|
||||
Nonce: 123123,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,6 @@ func toLotusMsg(msg *vtypes.Message) *types.Message {
|
||||
Method: msg.Method,
|
||||
|
||||
Value: msg.Value,
|
||||
GasPrice: msg.GasPrice,
|
||||
GasLimit: msg.GasLimit,
|
||||
GasFeeCap: msg.GasPrice, // TODO: update chian val to use GasFeeCap
|
||||
GasPremium: big.Zero(),
|
||||
|
@ -146,14 +146,15 @@ func MakeUnsignedMessageVectors() []vectors.UnsignedMessageVector {
|
||||
rand.Read(params)
|
||||
|
||||
msg := &types.Message{
|
||||
To: to,
|
||||
From: from,
|
||||
Value: types.NewInt(rand.Uint64()),
|
||||
Method: abi.MethodNum(rand.Uint64()),
|
||||
GasPrice: types.NewInt(rand.Uint64()),
|
||||
GasLimit: rand.Int63(),
|
||||
Nonce: rand.Uint64(),
|
||||
Params: params,
|
||||
To: to,
|
||||
From: from,
|
||||
Value: types.NewInt(rand.Uint64()),
|
||||
Method: abi.MethodNum(rand.Uint64()),
|
||||
GasFeeCap: types.NewInt(rand.Uint64()),
|
||||
GasPremium: types.NewInt(rand.Uint64()),
|
||||
GasLimit: rand.Int63(),
|
||||
Nonce: rand.Uint64(),
|
||||
Params: params,
|
||||
}
|
||||
|
||||
ser, err := msg.Serialize()
|
||||
|
14
cli/chain.go
14
cli/chain.go
@ -430,22 +430,22 @@ var chainListCmd = &cli.Command{
|
||||
psum := big.NewInt(0)
|
||||
for _, m := range msgs.BlsMessages {
|
||||
limitSum += m.GasLimit
|
||||
psum = big.Add(psum, m.GasPrice)
|
||||
psum = big.Add(psum, m.GasPremium)
|
||||
}
|
||||
|
||||
for _, m := range msgs.SecpkMessages {
|
||||
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)
|
||||
|
||||
avgprice := big.Zero()
|
||||
avgpremium := big.Zero()
|
||||
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 {
|
||||
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}
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
18
cli/mpool.go
18
cli/mpool.go
@ -246,8 +246,12 @@ var mpoolReplaceCmd = &cli.Command{
|
||||
Name: "replace",
|
||||
Usage: "replace a message in the mempool",
|
||||
Flags: []cli.Flag{
|
||||
&cli.Int64Flag{
|
||||
Name: "gas-price",
|
||||
&cli.StringFlag{
|
||||
Name: "gas-feecap",
|
||||
Usage: "gas feecap for new message",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-premium",
|
||||
Usage: "gas price for new message",
|
||||
},
|
||||
&cli.Int64Flag{
|
||||
@ -304,7 +308,15 @@ var mpoolReplaceCmd = &cli.Command{
|
||||
msg := found.Message
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
|
26
cli/send.go
26
cli/send.go
@ -27,10 +27,15 @@ var sendCmd = &cli.Command{
|
||||
Usage: "optionally specify the account to send funds from",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-price",
|
||||
Name: "gas-premium",
|
||||
Usage: "specify gas price to use in AttoFIL",
|
||||
Value: "0",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-feecap",
|
||||
Usage: "specify gas fee cap to use in AttoFIL",
|
||||
Value: "0",
|
||||
},
|
||||
&cli.Int64Flag{
|
||||
Name: "gas-limit",
|
||||
Usage: "specify gas limit",
|
||||
@ -99,6 +104,10 @@ var sendCmd = &cli.Command{
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gfc, err := types.BigFromString(cctx.String("gas-feecap"))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
method := abi.MethodNum(cctx.Uint64("method"))
|
||||
|
||||
@ -122,13 +131,14 @@ var sendCmd = &cli.Command{
|
||||
}
|
||||
|
||||
msg := &types.Message{
|
||||
From: fromAddr,
|
||||
To: toAddr,
|
||||
Value: types.BigInt(val),
|
||||
GasPrice: gp,
|
||||
GasLimit: cctx.Int64("gas-limit"),
|
||||
Method: method,
|
||||
Params: params,
|
||||
From: fromAddr,
|
||||
To: toAddr,
|
||||
Value: types.BigInt(val),
|
||||
GasPremium: gp,
|
||||
GasFeeCap: gfc,
|
||||
GasLimit: cctx.Int64("gas-limit"),
|
||||
Method: method,
|
||||
Params: params,
|
||||
}
|
||||
|
||||
if cctx.Int64("nonce") > 0 {
|
||||
|
15
cli/state.go
15
cli/state.go
@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"html/template"
|
||||
"io"
|
||||
"os"
|
||||
@ -15,6 +14,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
"github.com/multiformats/go-multihash"
|
||||
@ -1383,13 +1384,11 @@ var stateCallCmd = &cli.Command{
|
||||
}
|
||||
|
||||
ret, err := api.StateCall(ctx, &types.Message{
|
||||
From: froma,
|
||||
To: toa,
|
||||
Value: types.BigInt(value),
|
||||
GasLimit: 10000000000,
|
||||
GasPrice: types.NewInt(0),
|
||||
Method: abi.MethodNum(method),
|
||||
Params: params,
|
||||
From: froma,
|
||||
To: toa,
|
||||
Value: types.BigInt(value),
|
||||
Method: abi.MethodNum(method),
|
||||
Params: params,
|
||||
}, ts.Key())
|
||||
if err != nil {
|
||||
return fmt.Errorf("state call failed: %s", err)
|
||||
|
@ -74,11 +74,9 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre
|
||||
select {
|
||||
case <-tick.C:
|
||||
msg := &types.Message{
|
||||
From: from,
|
||||
To: sendSet[rand.Intn(20)],
|
||||
Value: types.NewInt(1),
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
From: from,
|
||||
To: sendSet[rand.Intn(20)],
|
||||
Value: types.NewInt(1),
|
||||
}
|
||||
|
||||
smsg, err := api.MpoolPushMessage(ctx, msg)
|
||||
|
@ -30,7 +30,8 @@ create table if not exists messages
|
||||
"to" text not null,
|
||||
nonce bigint not null,
|
||||
value text not null,
|
||||
gasprice bigint not null,
|
||||
gasfeecap bigint not null,
|
||||
gaspremium bigint not null,
|
||||
gaslimit bigint not null,
|
||||
method bigint,
|
||||
params bytea
|
||||
@ -219,7 +220,7 @@ create temp table msgs (like messages excluding constraints) on commit drop;
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
@ -231,7 +232,8 @@ create temp table msgs (like messages excluding constraints) on commit drop;
|
||||
m.To.String(),
|
||||
m.Nonce,
|
||||
m.Value.String(),
|
||||
m.GasPrice.String(),
|
||||
m.GasFeeCap.String(),
|
||||
m.GasPremium.String(),
|
||||
m.GasLimit,
|
||||
m.Method,
|
||||
m.Params,
|
||||
|
@ -279,9 +279,6 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) {
|
||||
Value: types.BigInt(h.sendPerRequest),
|
||||
From: h.from,
|
||||
To: to,
|
||||
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
})
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
@ -353,9 +350,6 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
||||
Value: types.BigInt(h.sendPerRequest),
|
||||
From: h.from,
|
||||
To: owner,
|
||||
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
})
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
@ -390,9 +384,6 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Method: builtin.MethodsPower.CreateMiner,
|
||||
Params: params,
|
||||
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
}
|
||||
|
||||
signed, err := h.api.MpoolPushMessage(r.Context(), createStorageMinerMsg)
|
||||
|
@ -51,7 +51,7 @@ var minerSelectMsgsCmd = &cli.Command{
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -143,12 +143,10 @@ var verifRegVerifyClientCmd = &cli.Command{
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
msg := &types.Message{
|
||||
To: builtin.VerifiedRegistryActorAddr,
|
||||
From: fromk,
|
||||
Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient,
|
||||
GasPrice: types.NewInt(1),
|
||||
GasLimit: 0,
|
||||
Params: params,
|
||||
To: builtin.VerifiedRegistryActorAddr,
|
||||
From: fromk,
|
||||
Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient,
|
||||
Params: params,
|
||||
}
|
||||
|
||||
smsg, err := api.MpoolPushMessage(ctx, msg)
|
||||
|
@ -102,8 +102,8 @@ var initCmd = &cli.Command{
|
||||
Usage: "don't use storageminer repo for sector storage",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "gas-price",
|
||||
Usage: "set gas price for initialization messages in AttoFIL",
|
||||
Name: "gas-premium",
|
||||
Usage: "set gas premium for initialization messages in AttoFIL",
|
||||
Value: "0",
|
||||
},
|
||||
},
|
||||
@ -116,7 +116,7 @@ var initCmd = &cli.Command{
|
||||
}
|
||||
ssize := abi.SectorSize(sectorSizeInt)
|
||||
|
||||
gasPrice, err := types.BigFromString(cctx.String("gas-price"))
|
||||
gasPrice, err := types.BigFromString(cctx.String("gas-premium"))
|
||||
if err != nil {
|
||||
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{
|
||||
To: addr,
|
||||
From: mi.Worker,
|
||||
Method: builtin.MethodsMiner.ChangePeerID,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: 0,
|
||||
To: addr,
|
||||
From: mi.Worker,
|
||||
Method: builtin.MethodsMiner.ChangePeerID,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPremium: gasPrice,
|
||||
}
|
||||
|
||||
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,
|
||||
Params: params,
|
||||
|
||||
GasLimit: 0,
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: 0,
|
||||
GasPremium: gasPrice,
|
||||
}
|
||||
|
||||
signed, err := api.MpoolPushMessage(ctx, createStorageMinerMsg)
|
||||
|
@ -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) {
|
||||
// (Provider Node API)
|
||||
smsg, err := c.MpoolPushMessage(ctx, &types.Message{
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: addr,
|
||||
Value: amount,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: addr,
|
||||
Value: amount,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
})
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
|
@ -74,13 +74,11 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark
|
||||
|
||||
// TODO: We may want this to happen after fetching data
|
||||
smsg, err := n.MpoolPushMessage(ctx, &types.Message{
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: mi.Worker,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
Method: builtin.MethodsMarket.PublishStorageDeals,
|
||||
Params: params,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: mi.Worker,
|
||||
Value: types.NewInt(0),
|
||||
Method: builtin.MethodsMarket.PublishStorageDeals,
|
||||
Params: params,
|
||||
})
|
||||
if err != nil {
|
||||
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) {
|
||||
// (Provider Node API)
|
||||
smsg, err := n.MpoolPushMessage(ctx, &types.Message{
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: addr,
|
||||
Value: amount,
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
From: addr,
|
||||
Value: amount,
|
||||
Method: builtin.MethodsMarket.AddBalance,
|
||||
})
|
||||
if err != nil {
|
||||
return cid.Undef, err
|
||||
|
@ -32,9 +32,9 @@ type FullNodeAPI struct {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
return fa.GasEstimateGasPrice(ctx, nblocksincl, sender, limit, tsk)
|
||||
return fa.GasEsitmateGasPremium(ctx, nblocksincl, sender, limit, tsk)
|
||||
}
|
||||
|
||||
var _ api.FullNode = &FullNodeAPI{}
|
||||
|
@ -27,7 +27,7 @@ type GasAPI struct {
|
||||
|
||||
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) {
|
||||
|
||||
if nblocksincl == 0 {
|
||||
@ -68,7 +68,7 @@ func (a *GasAPI) GasEstimateGasPrice(ctx context.Context, nblocksincl uint64,
|
||||
}
|
||||
|
||||
prices = append(prices, gasMeta{
|
||||
price: msg.VMMessage().GasPrice,
|
||||
price: msg.VMMessage().GasPremium,
|
||||
used: r.GasUsed,
|
||||
})
|
||||
gasUsed += r.GasUsed
|
||||
|
@ -112,12 +112,12 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t
|
||||
msg.GasLimit = int64(float64(gasLimit) * GasMargin)
|
||||
}
|
||||
|
||||
if msg.GasPrice == types.EmptyInt || types.BigCmp(msg.GasPrice, types.NewInt(0)) == 0 {
|
||||
gasPrice, err := a.GasEstimateGasPrice(ctx, 2, msg.From, msg.GasLimit, types.TipSetKey{})
|
||||
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {
|
||||
gasPrice, err := a.GasEsitmateGasPremium(ctx, 2, msg.From, msg.GasLimit, types.TipSetKey{})
|
||||
if err != nil {
|
||||
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 {
|
||||
msg.GasPremium = types.NewInt(100)
|
||||
|
@ -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")
|
||||
}
|
||||
|
||||
if gp == types.EmptyInt {
|
||||
gp = types.NewInt(0)
|
||||
}
|
||||
|
||||
// Set up constructor parameters for multisig
|
||||
msigParams := &samsig.ConstructorParams{
|
||||
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
|
||||
msg := types.Message{
|
||||
To: builtin.InitActorAddr,
|
||||
From: src,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
Value: val,
|
||||
GasPrice: gp,
|
||||
To: builtin.InitActorAddr,
|
||||
From: src,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
Value: val,
|
||||
}
|
||||
|
||||
// send the message out to the network
|
||||
|
@ -968,12 +968,10 @@ func (a *StateAPI) StateMinerPreCommitDepositForPower(ctx context.Context, maddr
|
||||
}
|
||||
|
||||
ret, err := a.StateManager.Call(ctx, &types.Message{
|
||||
From: maddr,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
Params: params,
|
||||
From: maddr,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||
Params: params,
|
||||
}, ts)
|
||||
if err != nil {
|
||||
return types.EmptyInt, err
|
||||
@ -1048,12 +1046,10 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
|
||||
}
|
||||
|
||||
ret, err := a.StateManager.Call(ctx, &types.Message{
|
||||
From: maddr,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
Params: params,
|
||||
From: maddr,
|
||||
To: builtin.StorageMarketActorAddr,
|
||||
Method: builtin.MethodsMarket.VerifyDealsForActivation,
|
||||
Params: params,
|
||||
}, ts)
|
||||
if err != nil {
|
||||
return types.EmptyInt, err
|
||||
|
@ -103,13 +103,11 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a
|
||||
require.NoError(t, err)
|
||||
|
||||
msg := &types.Message{
|
||||
To: act,
|
||||
From: waddr,
|
||||
Method: builtin.MethodsMiner.ChangePeerID,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
GasPrice: types.NewInt(0),
|
||||
GasLimit: 0,
|
||||
To: act,
|
||||
From: waddr,
|
||||
Method: builtin.MethodsMiner.ChangePeerID,
|
||||
Params: enc,
|
||||
Value: types.NewInt(0),
|
||||
}
|
||||
|
||||
_, err = tnd.MpoolPushMessage(ctx, msg)
|
||||
|
@ -241,13 +241,11 @@ func (ca *channelAccessor) createPaych(ctx context.Context, from, to address.Add
|
||||
}
|
||||
|
||||
msg := &types.Message{
|
||||
To: builtin.InitActorAddr,
|
||||
From: from,
|
||||
Value: amt,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
To: builtin.InitActorAddr,
|
||||
From: from,
|
||||
Value: amt,
|
||||
Method: builtin.MethodsInit.Exec,
|
||||
Params: enc,
|
||||
}
|
||||
|
||||
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
|
||||
func (ca *channelAccessor) addFunds(ctx context.Context, channelInfo *ChannelInfo, amt types.BigInt, cb onCompleteFn) (*cid.Cid, error) {
|
||||
msg := &types.Message{
|
||||
To: *channelInfo.Channel,
|
||||
From: channelInfo.Control,
|
||||
Value: amt,
|
||||
Method: 0,
|
||||
GasLimit: 0,
|
||||
GasPrice: types.NewInt(0),
|
||||
To: *channelInfo.Channel,
|
||||
From: channelInfo.Control,
|
||||
Value: amt,
|
||||
Method: 0,
|
||||
}
|
||||
|
||||
smsg, err := ca.api.MpoolPushMessage(ctx, msg)
|
||||
|
@ -237,15 +237,16 @@ func (s SealingAPIAdapter) StateMarketStorageDeal(ctx context.Context, dealID ab
|
||||
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) {
|
||||
msg := types.Message{
|
||||
To: to,
|
||||
From: from,
|
||||
Value: value,
|
||||
GasPrice: gasPrice,
|
||||
GasLimit: gasLimit,
|
||||
Method: method,
|
||||
Params: params,
|
||||
To: to,
|
||||
From: from,
|
||||
Value: value,
|
||||
GasPremium: gasPrice,
|
||||
GasLimit: gasLimit,
|
||||
Method: method,
|
||||
Params: params,
|
||||
}
|
||||
|
||||
smsg, err := s.delegate.MpoolPushMessage(ctx, &msg)
|
||||
|
@ -281,7 +281,10 @@ func RecordTipsetMessagesPoints(ctx context.Context, api api.FullNode, pl *Point
|
||||
msgn := make(map[msgTag][]cid.Cid)
|
||||
|
||||
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)
|
||||
|
||||
bs, err := msg.Message.Serialize()
|
||||
|
Loading…
Reference in New Issue
Block a user