From ddf1beac6c95cf68bfffb821955f8258b6ed6ebc Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 18 Mar 2020 13:45:37 -0700 Subject: [PATCH] change gas limit to be a normal int64 --- chain/gen/gen.go | 2 +- chain/gen/genesis/util.go | 2 +- chain/market/fundmgr.go | 2 +- chain/stmgr/call.go | 6 +-- chain/stmgr/forks_test.go | 4 +- chain/stmgr/stmgr.go | 4 +- chain/store/weight.go | 4 +- chain/types/cbor_gen.go | 72 ++++++++++++++++++++++++------ chain/types/message.go | 4 +- chain/types/message_receipt.go | 4 +- chain/types/mock/chain.go | 2 +- chain/types/types_test.go | 2 +- chain/types_test.go | 2 +- chain/validation/applier.go | 7 +-- chain/vm/runtime.go | 15 +++---- chain/vm/vm.go | 33 +++++++------- cli/chain.go | 2 +- cli/multisig.go | 6 +-- cli/send.go | 2 +- cli/state.go | 6 +-- cmd/chain-noise/main.go | 5 ++- cmd/lotus-chainwatch/storage.go | 4 +- cmd/lotus-chainwatch/templates.go | 4 +- cmd/lotus-fountain/main.go | 6 +-- cmd/lotus-shed/nonce-fix.go | 2 +- cmd/lotus-storage-miner/init.go | 4 +- cmd/lotus-storage-miner/rewards.go | 2 +- markets/storageadapter/client.go | 2 +- markets/storageadapter/provider.go | 4 +- miner/miner_test.go | 10 ++--- node/impl/paych/paych.go | 4 +- node/node_test.go | 2 +- paychmgr/simple.go | 4 +- storage/fpost_run.go | 6 +-- storage/sealing/checks.go | 2 +- storage/sealing/states.go | 6 +-- 36 files changed, 148 insertions(+), 100 deletions(-) diff --git a/chain/gen/gen.go b/chain/gen/gen.go index aab6db675..1a0ae8ca0 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -416,7 +416,7 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) { Method: 0, - GasLimit: types.NewInt(10000), + GasLimit: 10000, GasPrice: types.NewInt(0), } diff --git a/chain/gen/genesis/util.go b/chain/gen/genesis/util.go index 22cb7c33d..e080eb90b 100644 --- a/chain/gen/genesis/util.go +++ b/chain/gen/genesis/util.go @@ -36,7 +36,7 @@ func doExecValue(ctx context.Context, vm *vm.VM, to, from address.Address, value From: from, Method: method, Params: params, - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, GasPrice: types.NewInt(0), Value: value, Nonce: act.Nonce, diff --git a/chain/market/fundmgr.go b/chain/market/fundmgr.go index 76f0c795c..73989bf98 100644 --- a/chain/market/fundmgr.go +++ b/chain/market/fundmgr.go @@ -70,7 +70,7 @@ func (fm *FundMgr) EnsureAvailable(ctx context.Context, addr, wallet address.Add From: wallet, Value: toAdd, GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, Method: builtin.MethodsMarket.AddBalance, Params: params, }) diff --git a/chain/stmgr/call.go b/chain/stmgr/call.go index 88373620a..cef9dc449 100644 --- a/chain/stmgr/call.go +++ b/chain/stmgr/call.go @@ -26,8 +26,8 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate return nil, xerrors.Errorf("failed to set up vm: %w", err) } - if msg.GasLimit == types.EmptyInt { - msg.GasLimit = types.NewInt(10000000000) + if msg.GasLimit == 0 { + msg.GasLimit = 10000000000 } if msg.GasPrice == types.EmptyInt { msg.GasPrice = types.NewInt(0) @@ -38,7 +38,7 @@ func (sm *StateManager) CallRaw(ctx context.Context, msg *types.Message, bstate if span.IsRecordingEvents() { span.AddAttributes( - trace.Int64Attribute("gas_limit", int64(msg.GasLimit.Uint64())), + trace.Int64Attribute("gas_limit", msg.GasLimit), trace.Int64Attribute("gas_price", int64(msg.GasPrice.Uint64())), trace.StringAttribute("value", msg.Value.String()), ) diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index f70bd106b..1265ee69f 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -181,7 +181,7 @@ func TestForkHeightTriggers(t *testing.T) { To: builtin.InitActorAddr, Method: builtin.MethodsInit.Exec, Params: enc, - GasLimit: types.NewInt(10000), + GasLimit: 10000, GasPrice: types.NewInt(0), } sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes()) @@ -208,7 +208,7 @@ func TestForkHeightTriggers(t *testing.T) { Method: 2, Params: nil, Nonce: nonce, - GasLimit: types.NewInt(10000), + GasLimit: 10000, GasPrice: types.NewInt(0), } nonce++ diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index dff0d9fe3..71e0c4caf 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -228,7 +228,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B Nonce: sysAct.Nonce, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1 << 30), + GasLimit: 1 << 30, Method: builtin.MethodsReward.AwardBlockReward, Params: params, } @@ -260,7 +260,7 @@ func (sm *StateManager) ApplyBlocks(ctx context.Context, pstate cid.Cid, bms []B Nonce: ca.Nonce, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1 << 30), // Make super sure this is never too little + GasLimit: 1 << 30, // Make super sure this is never too little Method: builtin.MethodsCron.EpochTick, Params: nil, } diff --git a/chain/store/weight.go b/chain/store/weight.go index d4005bb3d..3c9826b77 100644 --- a/chain/store/weight.go +++ b/chain/store/weight.go @@ -77,8 +77,8 @@ func (cs *ChainStore) call(ctx context.Context, msg *types.Message, ts *types.Ti return nil, xerrors.Errorf("failed to set up vm: %w", err) } - if msg.GasLimit == types.EmptyInt { - msg.GasLimit = types.NewInt(10000000000) + if msg.GasLimit == 0 { + msg.GasLimit = 10000000000 } if msg.GasPrice == types.EmptyInt { msg.GasPrice = types.NewInt(0) diff --git a/chain/types/cbor_gen.go b/chain/types/cbor_gen.go index 64f055026..0adccccbb 100644 --- a/chain/types/cbor_gen.go +++ b/chain/types/cbor_gen.go @@ -656,9 +656,15 @@ func (t *Message) MarshalCBOR(w io.Writer) error { return err } - // t.GasLimit (big.Int) (struct) - if err := t.GasLimit.MarshalCBOR(w); err != nil { - return err + // t.GasLimit (int64) (int64) + if t.GasLimit >= 0 { + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.GasLimit))); err != nil { + return err + } + } else { + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajNegativeInt, uint64(-t.GasLimit)-1)); err != nil { + return err + } } // t.Method (abi.MethodNum) (uint64) @@ -746,14 +752,30 @@ func (t *Message) UnmarshalCBOR(r io.Reader) error { } } - // t.GasLimit (big.Int) (struct) - + // t.GasLimit (int64) (int64) { - - if err := t.GasLimit.UnmarshalCBOR(br); err != nil { + maj, extra, err := cbg.CborReadHeader(br) + var extraI int64 + if err != nil { return err } + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative oveflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + t.GasLimit = int64(extraI) } // t.Method (abi.MethodNum) (uint64) @@ -1043,9 +1065,15 @@ func (t *MessageReceipt) MarshalCBOR(w io.Writer) error { return err } - // t.GasUsed (big.Int) (struct) - if err := t.GasUsed.MarshalCBOR(w); err != nil { - return err + // t.GasUsed (int64) (int64) + if t.GasUsed >= 0 { + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajUnsignedInt, uint64(t.GasUsed))); err != nil { + return err + } + } else { + if _, err := w.Write(cbg.CborEncodeMajorType(cbg.MajNegativeInt, uint64(-t.GasUsed)-1)); err != nil { + return err + } } return nil } @@ -1107,14 +1135,30 @@ func (t *MessageReceipt) UnmarshalCBOR(r io.Reader) error { if _, err := io.ReadFull(br, t.Return); err != nil { return err } - // t.GasUsed (big.Int) (struct) - + // t.GasUsed (int64) (int64) { - - if err := t.GasUsed.UnmarshalCBOR(br); err != nil { + maj, extra, err := cbg.CborReadHeader(br) + var extraI int64 + if err != nil { return err } + switch maj { + case cbg.MajUnsignedInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 positive overflow") + } + case cbg.MajNegativeInt: + extraI = int64(extra) + if extraI < 0 { + return fmt.Errorf("int64 negative oveflow") + } + extraI = -1 - extraI + default: + return fmt.Errorf("wrong type for int64 field: %d", maj) + } + t.GasUsed = int64(extraI) } return nil } diff --git a/chain/types/message.go b/chain/types/message.go index 7d41c8379..c3006d418 100644 --- a/chain/types/message.go +++ b/chain/types/message.go @@ -21,7 +21,7 @@ type Message struct { Value BigInt GasPrice BigInt - GasLimit BigInt + GasLimit int64 Method abi.MethodNum Params []byte @@ -87,7 +87,7 @@ func (m *Message) Cid() cid.Cid { func (m *Message) RequiredFunds() BigInt { return BigAdd( m.Value, - BigMul(m.GasPrice, m.GasLimit), + BigMul(m.GasPrice, NewInt(uint64(m.GasLimit))), ) } diff --git a/chain/types/message_receipt.go b/chain/types/message_receipt.go index bcb20443e..6671595ff 100644 --- a/chain/types/message_receipt.go +++ b/chain/types/message_receipt.go @@ -9,9 +9,9 @@ import ( type MessageReceipt struct { ExitCode exitcode.ExitCode Return []byte - GasUsed BigInt + GasUsed int64 } func (mr *MessageReceipt) Equals(o *MessageReceipt) bool { - return mr.ExitCode == o.ExitCode && bytes.Equal(mr.Return, o.Return) && BigCmp(mr.GasUsed, o.GasUsed) == 0 + return mr.ExitCode == o.ExitCode && bytes.Equal(mr.Return, o.Return) && mr.GasUsed == o.GasUsed } diff --git a/chain/types/mock/chain.go b/chain/types/mock/chain.go index c9687fa72..b10ebe728 100644 --- a/chain/types/mock/chain.go +++ b/chain/types/mock/chain.go @@ -27,7 +27,7 @@ func MkMessage(from, to address.Address, nonce uint64, w *wallet.Wallet) *types. From: from, Value: types.NewInt(1), Nonce: nonce, - GasLimit: types.NewInt(1), + GasLimit: 1, GasPrice: types.NewInt(0), } diff --git a/chain/types/types_test.go b/chain/types/types_test.go index d912c20e3..a2b47ad51 100644 --- a/chain/types/types_test.go +++ b/chain/types/types_test.go @@ -27,7 +27,7 @@ func BenchmarkSerializeMessage(b *testing.B) { Nonce: 197, Method: 1231254, Params: []byte("some bytes, idk. probably at least ten of them"), - GasLimit: NewInt(126723), + GasLimit: 126723, GasPrice: NewInt(1776234), } diff --git a/chain/types_test.go b/chain/types_test.go index 17b6c9cdd..55baf4a28 100644 --- a/chain/types_test.go +++ b/chain/types_test.go @@ -19,7 +19,7 @@ func TestSignedMessageJsonRoundtrip(t *testing.T) { Method: 1235126, Value: types.NewInt(123123), GasPrice: types.NewInt(1234), - GasLimit: types.NewInt(9992969384), + GasLimit: 9992969384, Nonce: 123123, }, } diff --git a/chain/validation/applier.go b/chain/validation/applier.go index 78b15ec60..b13ac68f8 100644 --- a/chain/validation/applier.go +++ b/chain/validation/applier.go @@ -4,6 +4,7 @@ import ( "context" "github.com/filecoin-project/specs-actors/actors/abi" + "github.com/filecoin-project/specs-actors/actors/abi/big" "github.com/filecoin-project/specs-actors/actors/builtin" "github.com/filecoin-project/specs-actors/actors/crypto" "github.com/filecoin-project/specs-actors/actors/runtime/exitcode" @@ -53,7 +54,7 @@ func (a *Applier) ApplyMessage(eCtx *vtypes.ExecutionContext, state vstate.VMWra mr := vtypes.MessageReceipt{ ExitCode: exitcode.ExitCode(ret.ExitCode), ReturnValue: ret.Return, - GasUsed: ret.GasUsed, + GasUsed: big.NewInt(ret.GasUsed), } return mr, nil @@ -91,7 +92,7 @@ func (a *Applier) ApplyTipSetMessages(state vstate.VMWrapper, blocks []vtypes.Bl ExitCode: exitcode.ExitCode(ret.ExitCode), ReturnValue: ret.Return, - GasUsed: ret.GasUsed, + GasUsed: big.NewInt(ret.GasUsed), }) return nil }) @@ -130,7 +131,7 @@ func toLotusMsg(msg *vtypes.Message) *types.Message { Value: types.BigInt{Int: msg.Value.Int}, GasPrice: types.BigInt{Int: msg.GasPrice.Int}, - GasLimit: types.NewInt(uint64(msg.GasLimit)), + GasLimit: msg.GasLimit, Params: msg.Params, } diff --git a/chain/vm/runtime.go b/chain/vm/runtime.go index ba23172e2..4740c44d5 100644 --- a/chain/vm/runtime.go +++ b/chain/vm/runtime.go @@ -34,8 +34,8 @@ type Runtime struct { height abi.ChainEpoch cst cbor.IpldStore - gasAvailable types.BigInt - gasUsed types.BigInt + gasAvailable int64 + gasUsed int64 sys runtime.Syscalls @@ -325,7 +325,7 @@ func (rt *Runtime) internalSend(to address.Address, method abi.MethodNum, value mr := types.MessageReceipt{ ExitCode: exitcode.ExitCode(aerrors.RetCode(errSend)), Return: ret, - GasUsed: types.EmptyInt, + GasUsed: 0, } er := ExecutionResult{ @@ -421,10 +421,9 @@ func (rt *Runtime) stateCommit(oldh, newh cid.Cid) aerrors.ActorError { return nil } -func (rt *Runtime) ChargeGas(amount uint64) { - toUse := types.NewInt(amount) - rt.gasUsed = types.BigAdd(rt.gasUsed, toUse) - if rt.gasUsed.GreaterThan(rt.gasAvailable) { - rt.Abortf(exitcode.SysErrOutOfGas, "not enough gas: used=%s, available=%s", rt.gasUsed, rt.gasAvailable) +func (rt *Runtime) ChargeGas(toUse int64) { + rt.gasUsed = rt.gasUsed + toUse + if rt.gasUsed > rt.gasAvailable { + rt.Abortf(exitcode.SysErrOutOfGas, "not enough gas: used=%d, available=%d", rt.gasUsed, rt.gasAvailable) } } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index 6b147e573..29d0afc00 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -91,7 +91,7 @@ func ResolveToKeyAddr(state types.StateTree, cst cbor.IpldStore, addr address.Ad var _ cbor.IpldBlockstore = (*gasChargingBlocks)(nil) type gasChargingBlocks struct { - chargeGas func(uint64) + chargeGas func(int64) under cbor.IpldBlockstore } @@ -101,13 +101,13 @@ func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) { if err != nil { return nil, aerrors.Escalate(err, "failed to get block from blockstore") } - bs.chargeGas(uint64(len(blk.RawData())) * gasGetPerByte) + bs.chargeGas(int64(len(blk.RawData())) * gasGetPerByte) return blk, nil } func (bs *gasChargingBlocks) Put(blk block.Block) error { - bs.chargeGas(gasPutObj + uint64(len(blk.RawData()))*gasPutPerByte) + bs.chargeGas(gasPutObj + int64(len(blk.RawData()))*gasPutPerByte) if err := bs.under.Put(blk); err != nil { return aerrors.Escalate(err, "failed to write data to disk") @@ -115,7 +115,7 @@ func (bs *gasChargingBlocks) Put(blk block.Block) error { return nil } -func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas types.BigInt, icc int64) *Runtime { +func (vm *VM) makeRuntime(ctx context.Context, msg *types.Message, origin address.Address, originNonce uint64, usedGas int64, icc int64) *Runtime { rt := &Runtime{ ctx: ctx, vm: vm, @@ -184,7 +184,7 @@ type ApplyRet struct { } func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, - gasCharge uint64) ([]byte, aerrors.ActorError, *Runtime) { + gasCharge int64) ([]byte, aerrors.ActorError, *Runtime) { st := vm.cstate @@ -206,12 +206,12 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, } } - gasUsed := types.NewInt(gasCharge) + gasUsed := gasCharge origin := msg.From on := msg.Nonce var icc int64 = 0 if parent != nil { - gasUsed = types.BigAdd(parent.gasUsed, gasUsed) + gasUsed = parent.gasUsed + gasUsed origin = parent.origin on = parent.originNonce icc = parent.internalCallCounter + 1 @@ -240,8 +240,11 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, } func checkMessage(msg *types.Message) error { - if msg.GasLimit == types.EmptyInt { - return xerrors.Errorf("message gas no gas limit set") + if msg.GasLimit == 0 { + return xerrors.Errorf("message has no gas limit set") + } + if msg.GasLimit < 0 { + return xerrors.Errorf("message has negative gas limit") } if msg.GasPrice == types.EmptyInt { @@ -274,8 +277,8 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, if err != nil { return nil, xerrors.Errorf("could not serialize message: %w", err) } - msgGasCost := uint64(len(serMsg)) * gasPerMessageByte - if msgGasCost > msg.GasLimit.Uint64() { + msgGasCost := int64(len(serMsg)) * gasPerMessageByte + if msgGasCost > msg.GasLimit { return &ApplyRet{ MessageReceipt: types.MessageReceipt{ ExitCode: exitcode.SysErrOutOfGas, @@ -312,7 +315,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, }, nil } - gascost := types.BigMul(msg.GasLimit, msg.GasPrice) + gascost := types.BigMul(types.NewInt(uint64(msg.GasLimit)), msg.GasPrice) totalCost := types.BigAdd(gascost, msg.Value) if fromActor.Balance.LessThan(totalCost) { return &ApplyRet{ @@ -340,7 +343,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, } var errcode uint8 - var gasUsed types.BigInt + var gasUsed int64 if errcode = aerrors.RetCode(actorErr); errcode != 0 { gasUsed = msg.GasLimit @@ -351,7 +354,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, } else { gasUsed = rt.gasUsed // refund unused gas - refund := types.BigMul(types.BigSub(msg.GasLimit, gasUsed), msg.GasPrice) + refund := types.BigMul(types.NewInt(uint64(msg.GasLimit-gasUsed)), msg.GasPrice) if err := Transfer(gasHolder, fromActor, refund); err != nil { return nil, xerrors.Errorf("failed to refund gas") } @@ -362,7 +365,7 @@ func (vm *VM) ApplyMessage(ctx context.Context, msg *types.Message) (*ApplyRet, return nil, xerrors.Errorf("getting burnt funds actor failed: %w", err) } - gasReward := types.BigMul(msg.GasPrice, gasUsed) + gasReward := types.BigMul(msg.GasPrice, types.NewInt(uint64(gasUsed))) if err := Transfer(gasHolder, rwAct, gasReward); err != nil { return nil, xerrors.Errorf("failed to give miner gas reward: %w", err) } diff --git a/cli/chain.go b/cli/chain.go index 6d091ce81..84fe75c0e 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -796,7 +796,7 @@ var slashConsensusFault = &cli.Command{ From: def, Value: types.NewInt(0), GasPrice: types.NewInt(1), - GasLimit: types.NewInt(10000000), + GasLimit: 10000000, Method: builtin.MethodsPower.ReportConsensusFault, Params: params, } diff --git a/cli/multisig.go b/cli/multisig.go index 9d1123f6e..cf9579664 100644 --- a/cli/multisig.go +++ b/cli/multisig.go @@ -123,7 +123,7 @@ var msigCreateCmd = &cli.Command{ Method: builtin.MethodsInit.Exec, Params: enc, GasPrice: types.NewInt(1), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, Value: types.BigInt(filval), } @@ -353,7 +353,7 @@ var msigProposeCmd = &cli.Command{ Value: types.NewInt(0), Method: builtin.MethodsMultisig.Propose, Params: enc, - GasLimit: types.NewInt(100000), + GasLimit: 100000, GasPrice: types.NewInt(1), } @@ -439,7 +439,7 @@ var msigApproveCmd = &cli.Command{ Value: types.NewInt(0), Method: builtin.MethodsMultisig.Approve, Params: enc, - GasLimit: types.NewInt(100000), + GasLimit: 100000, GasPrice: types.NewInt(1), } diff --git a/cli/send.go b/cli/send.go index 1a329ddad..46efadf8b 100644 --- a/cli/send.go +++ b/cli/send.go @@ -62,7 +62,7 @@ var sendCmd = &cli.Command{ From: fromAddr, To: toAddr, Value: types.BigInt(val), - GasLimit: types.NewInt(1000), + GasLimit: 1000, GasPrice: types.NewInt(0), } diff --git a/cli/state.go b/cli/state.go index 0809d0240..47a6b87d6 100644 --- a/cli/state.go +++ b/cli/state.go @@ -349,7 +349,7 @@ var stateReplaySetCmd = &cli.Command{ fmt.Println("Replay receipt:") fmt.Printf("Exit code: %d\n", res.MsgRct.ExitCode) fmt.Printf("Return: %x\n", res.MsgRct.Return) - fmt.Printf("Gas Used: %s\n", res.MsgRct.GasUsed) + fmt.Printf("Gas Used: %d\n", res.MsgRct.GasUsed) if res.MsgRct.ExitCode != 0 { fmt.Printf("Error message: %q\n", res.Error) } @@ -849,7 +849,7 @@ var stateWaitMsgCmd = &cli.Command{ fmt.Printf("message was executed in tipset: %s", mw.TipSet.Cids()) fmt.Printf("Exit Code: %d", mw.Receipt.ExitCode) - fmt.Printf("Gas Used: %s", mw.Receipt.GasUsed) + fmt.Printf("Gas Used: %d", mw.Receipt.GasUsed) fmt.Printf("Return: %x", mw.Receipt.Return) return nil }, @@ -928,7 +928,7 @@ var stateCallCmd = &cli.Command{ From: froma, To: toa, Value: types.BigInt(value), - GasLimit: types.NewInt(10000000000), + GasLimit: 10000000000, GasPrice: types.NewInt(0), Method: abi.MethodNum(method), Params: params, diff --git a/cmd/chain-noise/main.go b/cmd/chain-noise/main.go index 23440335c..dc64b70ed 100644 --- a/cmd/chain-noise/main.go +++ b/cmd/chain-noise/main.go @@ -3,11 +3,12 @@ package main import ( "context" "fmt" - "github.com/filecoin-project/specs-actors/actors/crypto" "math/rand" "os" "time" + "github.com/filecoin-project/specs-actors/actors/crypto" + "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/types" @@ -76,7 +77,7 @@ func sendSmallFundsTxs(ctx context.Context, api api.FullNode, from address.Addre From: from, To: sendSet[rand.Intn(20)], Value: types.NewInt(1), - GasLimit: types.NewInt(100000), + GasLimit: 100000, GasPrice: types.NewInt(0), } diff --git a/cmd/lotus-chainwatch/storage.go b/cmd/lotus-chainwatch/storage.go index 9e657ae71..25c676951 100644 --- a/cmd/lotus-chainwatch/storage.go +++ b/cmd/lotus-chainwatch/storage.go @@ -662,7 +662,7 @@ create temp table msgs (like messages excluding constraints) on commit drop; m.Nonce, m.Value.String(), m.GasPrice.String(), - m.GasLimit.String(), + m.GasLimit, m.Method, m.Params, ); err != nil { @@ -706,7 +706,7 @@ create temp table recs (like receipts excluding constraints) on commit drop; c.state.String(), c.idx, m.ExitCode, - m.GasUsed.String(), + m.GasUsed, m.Return, ); err != nil { return err diff --git a/cmd/lotus-chainwatch/templates.go b/cmd/lotus-chainwatch/templates.go index d1ad6984d..67534f1e9 100644 --- a/cmd/lotus-chainwatch/templates.go +++ b/cmd/lotus-chainwatch/templates.go @@ -279,7 +279,7 @@ type Message struct { Value sbig GasPrice sbig - GasLimit sbig + GasLimit int64 Method abi.MethodNum Params []byte @@ -324,7 +324,7 @@ func (h *handler) messages(filter string, args ...interface{}) (out []types.Mess Nonce: r.Nonce, Value: types.BigInt(r.Value), GasPrice: types.BigInt(r.GasPrice), - GasLimit: types.BigInt(r.GasLimit), + GasLimit: r.GasLimit, Method: r.Method, Params: r.Params, } diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index 382e55d59..a09748522 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -190,7 +190,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) { To: to, GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000), + GasLimit: 1000, }) if err != nil { w.WriteHeader(400) @@ -256,7 +256,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { To: owner, GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000), + GasLimit: 1000, }) if err != nil { w.WriteHeader(400) @@ -285,7 +285,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { Method: builtin.MethodsPower.CreateMiner, Params: params, - GasLimit: types.NewInt(10000000), + GasLimit: 10000000, GasPrice: types.NewInt(0), } diff --git a/cmd/lotus-shed/nonce-fix.go b/cmd/lotus-shed/nonce-fix.go index 827fd4921..8b12e4795 100644 --- a/cmd/lotus-shed/nonce-fix.go +++ b/cmd/lotus-shed/nonce-fix.go @@ -89,7 +89,7 @@ var noncefix = &cli.Command{ From: addr, To: addr, Value: types.NewInt(1), - GasLimit: types.NewInt(1000), + GasLimit: 1000, GasPrice: types.NewInt(1), Nonce: i, } diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index bf552cd68..f6be19e20 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -500,7 +500,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address. Params: enc, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(100000000), + GasLimit: 100000000, } smsg, err := api.MpoolPushMessage(ctx, msg) @@ -571,7 +571,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, Method: builtin.MethodsPower.CreateMiner, Params: params, - GasLimit: types.NewInt(10000000), + GasLimit: 10000000, GasPrice: types.NewInt(0), } diff --git a/cmd/lotus-storage-miner/rewards.go b/cmd/lotus-storage-miner/rewards.go index c7525325a..ce8b0291c 100644 --- a/cmd/lotus-storage-miner/rewards.go +++ b/cmd/lotus-storage-miner/rewards.go @@ -100,7 +100,7 @@ var rewardsRedeemCmd = &cli.Command{ Nonce: workerNonce, Value: types.NewInt(0), GasPrice: types.NewInt(1), - GasLimit: types.NewInt(100000), + GasLimit: 100000, Method: builtin.MethodsReward.WithdrawReward, Params: params, }) diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 0c0c0fa18..565c8cb39 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -127,7 +127,7 @@ func (n *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 0a03d3094..3d1ef5e57 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -73,7 +73,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark From: worker, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, Method: builtin.MethodsMarket.PublishStorageDeals, Params: params, }) @@ -161,7 +161,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/miner/miner_test.go b/miner/miner_test.go index 2a896dc4c..328562bb8 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -43,7 +43,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 3, Value: types.NewInt(500), - GasLimit: types.NewInt(50), + GasLimit: 50, GasPrice: types.NewInt(1), }, types.Message{ @@ -51,7 +51,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 4, Value: types.NewInt(500), - GasLimit: types.NewInt(50), + GasLimit: 50, GasPrice: types.NewInt(1), }, types.Message{ @@ -59,7 +59,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 1, Value: types.NewInt(800), - GasLimit: types.NewInt(100), + GasLimit: 100, GasPrice: types.NewInt(1), }, types.Message{ @@ -67,7 +67,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 0, Value: types.NewInt(800), - GasLimit: types.NewInt(100), + GasLimit: 100, GasPrice: types.NewInt(1), }, types.Message{ @@ -75,7 +75,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 2, Value: types.NewInt(150), - GasLimit: types.NewInt(100), + GasLimit: (100), GasPrice: types.NewInt(1), }, } diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index a9b0d9d54..8676cbfd3 100644 --- a/node/impl/paych/paych.go +++ b/node/impl/paych/paych.go @@ -125,7 +125,7 @@ func (a *PaychAPI) PaychClose(ctx context.Context, addr address.Address) (cid.Ci Method: builtin.MethodsPaych.Settle, Nonce: nonce, - GasLimit: types.NewInt(500), + GasLimit: 500, GasPrice: types.NewInt(0), } @@ -240,7 +240,7 @@ func (a *PaychAPI) PaychVoucherSubmit(ctx context.Context, ch address.Address, s Nonce: nonce, Method: builtin.MethodsPaych.UpdateChannelState, Params: enc, - GasLimit: types.NewInt(100000), + GasLimit: 100000, GasPrice: types.NewInt(0), } diff --git a/node/node_test.go b/node/node_test.go index c915c9328..3984e6aea 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -97,7 +97,7 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a Params: enc, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, } _, err = tnd.MpoolPushMessage(ctx, msg) diff --git a/paychmgr/simple.go b/paychmgr/simple.go index 92e0601db..653f58491 100644 --- a/paychmgr/simple.go +++ b/paychmgr/simple.go @@ -37,7 +37,7 @@ func (pm *Manager) createPaych(ctx context.Context, from, to address.Address, am Value: amt, Method: builtin.MethodsInit.Exec, Params: enc, - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, GasPrice: types.NewInt(0), } @@ -84,7 +84,7 @@ func (pm *Manager) addFunds(ctx context.Context, ch address.Address, from addres From: from, Value: amt, Method: 0, - GasLimit: types.NewInt(1000000), + GasLimit: 1000000, GasPrice: types.NewInt(0), } diff --git a/storage/fpost_run.go b/storage/fpost_run.go index dc38d7f4b..c3835764e 100644 --- a/storage/fpost_run.go +++ b/storage/fpost_run.go @@ -67,7 +67,7 @@ func (s *FPoStScheduler) declareFaults(ctx context.Context, fc uint64, params *m Method: builtin.MethodsMiner.DeclareTemporaryFaults, Params: enc, Value: types.NewInt(0), - GasLimit: types.NewInt(10000000), // i dont know help + GasLimit: 10000000, // i dont know help GasPrice: types.NewInt(1), } @@ -258,8 +258,8 @@ func (s *FPoStScheduler) submitPost(ctx context.Context, proof *abi.OnChainPoStV From: s.worker, Method: builtin.MethodsMiner.SubmitWindowedPoSt, Params: enc, - Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late - GasLimit: types.NewInt(10000000), // i dont know help + Value: types.NewInt(1000), // currently hard-coded late fee in actor, returned if not late + GasLimit: 10000000, // i dont know help GasPrice: types.NewInt(1), } diff --git a/storage/sealing/checks.go b/storage/sealing/checks.go index c7bec0228..ce0f5c385 100644 --- a/storage/sealing/checks.go +++ b/storage/sealing/checks.go @@ -90,7 +90,7 @@ func checkSeal(ctx context.Context, maddr address.Address, si SectorInfo, api se From: maddr, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: types.NewInt(9999999999), + GasLimit: 9999999999, Method: builtin.MethodsMarket.ComputeDataCommitment, Params: ccparams, } diff --git a/storage/sealing/states.go b/storage/sealing/states.go index e12860447..f66c97905 100644 --- a/storage/sealing/states.go +++ b/storage/sealing/states.go @@ -121,7 +121,7 @@ func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInf Method: builtin.MethodsMiner.PreCommitSector, Params: enc, Value: types.NewInt(0), // TODO: need to ensure sufficient collateral - GasLimit: types.NewInt(1000000 /* i dont know help */), + GasLimit: 1000000, /* i dont know help */ GasPrice: types.NewInt(1), } @@ -212,7 +212,7 @@ func (m *Sealing) handleCommitting(ctx statemachine.Context, sector SectorInfo) Method: builtin.MethodsMiner.ProveCommitSector, Params: enc, Value: types.NewInt(0), // TODO: need to ensure sufficient collateral - GasLimit: types.NewInt(1000000 /* i dont know help */), + GasLimit: 1000000, /* i dont know help */ GasPrice: types.NewInt(1), } @@ -278,7 +278,7 @@ func (m *Sealing) handleFaulty(ctx statemachine.Context, sector SectorInfo) erro Method: builtin.MethodsMiner.DeclareTemporaryFaults, Params: enc, Value: types.NewInt(0), // TODO: need to ensure sufficient collateral - GasLimit: types.NewInt(1000000 /* i dont know help */), + GasLimit: 1000000, /* i dont know help */ GasPrice: types.NewInt(1), }