From c0eb4b39ac156f75b001220d50044203573959c7 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 3 Jul 2020 15:13:23 +0200 Subject: [PATCH 1/7] Reorg some gas charges Signed-off-by: Jakub Sztandera --- chain/vm/mkactor.go | 8 ++++---- chain/vm/vm.go | 17 +++++++++-------- cmd/lotus-bench/import.go | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/chain/vm/mkactor.go b/chain/vm/mkactor.go index 1a3fd97de8c..ef4382df169 100644 --- a/chain/vm/mkactor.go +++ b/chain/vm/mkactor.go @@ -30,6 +30,10 @@ var EmptyObjectCid cid.Cid // TryCreateAccountActor creates account actors from only BLS/SECP256K1 addresses. func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aerrors.ActorError) { + if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil { + return nil, err + } + addrID, err := rt.state.RegisterNewAddress(addr) if err != nil { return nil, aerrors.Escalate(err, "registering actor address") @@ -50,10 +54,6 @@ func TryCreateAccountActor(rt *Runtime, addr address.Address) (*types.Actor, aer } // call constructor on account - if err := rt.chargeGasSafe(PricelistByEpoch(rt.height).OnCreateActor()); err != nil { - return nil, err - } - _, aerr = rt.internalSend(builtin.SystemActorAddr, addrID, builtin.MethodsAccount.Constructor, big.Zero(), p) if aerr != nil { return nil, aerrors.Wrap(aerr, "failed to invoke account constructor") diff --git a/chain/vm/vm.go b/chain/vm/vm.go index a2b0db4664f..ce02f9ac898 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -211,7 +211,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, parent.lastGasCharge = rt.lastGasCharge }() } - if gasCharge != nil { if err := rt.chargeGasSafe(*gasCharge); err != nil { // this should never happen @@ -220,10 +219,7 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, } ret, err := func() ([]byte, aerrors.ActorError) { - if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil { - return nil, aerrors.Wrap(aerr, "not enough gas for method invocation") - } - + _ = rt.chargeGasSafe(newGasCharge("OnGetActor", 0, 0)) toActor, err := st.GetActor(msg.To) if err != nil { if xerrors.Is(err, init_.ErrAddressNotFound) { @@ -237,6 +233,11 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, } } + if aerr := rt.chargeGasSafe(rt.Pricelist().OnMethodInvocation(msg.Value, msg.Method)); aerr != nil { + return nil, aerrors.Wrap(aerr, "not enough gas for method invocation") + } + defer rt.chargeGasSafe(newGasCharge("OnMethodInvocationDone", 0, 0)) + if types.BigCmp(msg.Value, types.NewInt(0)) != 0 { if err := vm.transfer(msg.From, msg.To, msg.Value); err != nil { return nil, aerrors.Wrap(err, "failed to transfer funds") @@ -247,7 +248,6 @@ func (vm *VM) send(ctx context.Context, msg *types.Message, parent *Runtime, var ret []byte _ = rt.chargeGasSafe(gasOnActorExec) ret, err := vm.Invoke(toActor, rt, msg.Method, msg.Params) - _ = rt.chargeGasSafe(newGasCharge("OnActorExecDone", 0, 0)) return ret, err } return nil, nil @@ -441,6 +441,9 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, return nil, xerrors.Errorf("revert state failed: %w", err) } } + + rt.finilizeGasTracing() + gasUsed = rt.gasUsed if gasUsed < 0 { gasUsed = 0 @@ -460,8 +463,6 @@ func (vm *VM) ApplyMessage(ctx context.Context, cmsg types.ChainMsg) (*ApplyRet, return nil, xerrors.Errorf("gas handling math is wrong") } - rt.finilizeGasTracing() - return &ApplyRet{ MessageReceipt: types.MessageReceipt{ ExitCode: errcode, diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index 6d5f7f8ff44..ec1815ac00b 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -604,7 +604,7 @@ var importAnalyzeCmd = &cli.Command{ timeInActors := actorExec.timeTaken.Mean() * actorExec.timeTaken.n fmt.Printf("Avarage time per epoch in actors: %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100) } - if actorExecDone, ok := charges["OnActorExecDone"]; ok { + if actorExecDone, ok := charges["OnMethodInvocationDone"]; ok { timeInActors := actorExecDone.timeTaken.Mean() * actorExecDone.timeTaken.n fmt.Printf("Avarage time per epoch in OnActorExecDone %s (%.1f%%)\n", time.Duration(timeInActors)/time.Duration(totalTipsets), timeInActors/float64(totalTime)*100) } From 4dd6f6400c3de3eb6e9c39a28580505d912f7b71 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 10 Jul 2020 15:12:27 +0200 Subject: [PATCH 2/7] Make virtual gas real Signed-off-by: Jakub Sztandera --- chain/vm/gas.go | 59 +++++++++++++++++++---------------- chain/vm/gas_v0.go | 78 ++++++++++++++++++++-------------------------- 2 files changed, 65 insertions(+), 72 deletions(-) diff --git a/chain/vm/gas.go b/chain/vm/gas.go index bee65fd8f8f..449984ed132 100644 --- a/chain/vm/gas.go +++ b/chain/vm/gas.go @@ -84,30 +84,35 @@ type Pricelist interface { var prices = map[abi.ChainEpoch]Pricelist{ abi.ChainEpoch(0): &pricelistV0{ - onChainMessageBase: 0, - onChainMessagePerByte: 2, - onChainReturnValuePerByte: 8, - sendBase: 5, - sendTransferFunds: 5, - sendInvokeMethod: 10, - ipldGetBase: 10, - ipldGetPerByte: 1, - ipldPutBase: 20, - ipldPutPerByte: 2, - createActorBase: 40, // IPLD put + 20 - createActorExtra: 500, - deleteActor: -500, // -createActorExtra - // Dragons: this cost is not persistable, create a LinearCost{a,b} struct that has a `.Cost(x) -> ax + b` - verifySignature: map[crypto.SigType]func(int64) int64{ - crypto.SigTypeBLS: func(x int64) int64 { return 3*x + 2 }, - crypto.SigTypeSecp256k1: func(x int64) int64 { return 3*x + 2 }, + onChainMessageComputeBase: 137137, + onChainMessageStorageBase: 0, // TODO gas + onChainMessageStoragePerByte: 2, // TODO gas + + onChainReturnValuePerByte: 8, // TODO gas + + sendBase: 97236, + sendTransferFunds: 96812, + sendTransferOnlyPremium: 347806, + sendInvokeMethod: -3110, + + ipldGetBase: 417230, + ipldPutBase: 396100, + ipldPutPerByte: 2, // TODO gas + + createActorCompute: 750011, + createActorStorage: 500, // TODO gas + deleteActor: -500, // -createActorStorage + + verifySignature: map[crypto.SigType]int64{ + crypto.SigTypeBLS: 219946580, + crypto.SigTypeSecp256k1: 6726720, }, - hashingBase: 5, - hashingPerByte: 2, - computeUnsealedSectorCidBase: 100, - verifySealBase: 2000, - verifyPostBase: 700, - verifyConsensusFault: 10, + + hashingBase: 110685, + computeUnsealedSectorCidBase: 431890, + verifySealBase: 2000, // TODO gas , it VerifySeal syscall is not used + verifyPostBase: 2621447835, + verifyConsensusFault: 495422, }, } @@ -198,14 +203,14 @@ func (ps pricedSyscalls) VerifyConsensusFault(h1 []byte, h2 []byte, extra []byte } func (ps pricedSyscalls) BatchVerifySeals(inp map[address.Address][]abi.SealVerifyInfo) (map[address.Address][]bool, error) { - var gasChargeSum GasCharge - gasChargeSum.Name = "BatchVerifySeals" count := int64(0) for _, svis := range inp { count += int64(len(svis)) } - gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(129778623*count+716683250, 0) - ps.chargeGas(gasChargeSum) // TODO: this is only called by the cron actor. Should we even charge gas? + + gasChargeSum := newGasCharge("BatchVerifySeals", 0, 0) + gasChargeSum = gasChargeSum.WithExtra(count).WithVirtual(15075005*count+899741502, 0) + ps.chargeGas(gasChargeSum) // real gas charged by actors defer ps.chargeGas(gasOnActorExec) return ps.under.BatchVerifySeals(inp) diff --git a/chain/vm/gas_v0.go b/chain/vm/gas_v0.go index 5735d0b83b6..39e24d2cf27 100644 --- a/chain/vm/gas_v0.go +++ b/chain/vm/gas_v0.go @@ -20,8 +20,9 @@ type pricelistV0 struct { // Together, these account for the cost of message propagation and validation, // up to but excluding any actual processing by the VM. // This is the cost a block producer burns when including an invalid message. - onChainMessageBase int64 - onChainMessagePerByte int64 + onChainMessageComputeBase int64 + onChainMessageStorageBase int64 + onChainMessageStoragePerByte int64 // Gas cost charged to the originator of a non-nil return value produced // by an on-chain message is given by: @@ -41,15 +42,17 @@ type pricelistV0 struct { // already accounted for). sendTransferFunds int64 + // Gsa cost charged, in addition to SendBase, if message only transfers funds. + sendTransferOnlyPremium int64 + // Gas cost charged, in addition to SendBase, if a message invokes // a method on the receiver. // Accounts for the cost of loading receiver code and method dispatch. sendInvokeMethod int64 - // Gas cost (Base + len*PerByte) for any Get operation to the IPLD store + // Gas cost for any Get operation to the IPLD store // in the runtime VM context. - ipldGetBase int64 - ipldGetPerByte int64 + ipldGetBase int64 // Gas cost (Base + len*PerByte) for any Put operation to the IPLD store // in the runtime VM context. @@ -64,18 +67,17 @@ type pricelistV0 struct { // // Note: this costs assume that the extra will be partially or totally refunded while // the base is covering for the put. - createActorBase int64 - createActorExtra int64 + createActorCompute int64 + createActorStorage int64 // Gas cost for deleting an actor. // // Note: this partially refunds the create cost to incentivise the deletion of the actors. deleteActor int64 - verifySignature map[crypto.SigType]func(len int64) int64 + verifySignature map[crypto.SigType]int64 - hashingBase int64 - hashingPerByte int64 + hashingBase int64 computeUnsealedSectorCidBase int64 verifySealBase int64 @@ -87,57 +89,51 @@ var _ Pricelist = (*pricelistV0)(nil) // OnChainMessage returns the gas used for storing a message of a given size in the chain. func (pl *pricelistV0) OnChainMessage(msgSize int) GasCharge { - return newGasCharge("OnChainMessage", 0, pl.onChainMessageBase+pl.onChainMessagePerByte*int64(msgSize)).WithVirtual(77302, 0) + return newGasCharge("OnChainMessage", pl.onChainMessageComputeBase, + pl.onChainMessageStorageBase+pl.onChainMessageStoragePerByte*int64(msgSize)) } // OnChainReturnValue returns the gas used for storing the response of a message in the chain. func (pl *pricelistV0) OnChainReturnValue(dataSize int) GasCharge { - return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte).WithVirtual(107294, 0) + return newGasCharge("OnChainReturnValue", 0, int64(dataSize)*pl.onChainReturnValuePerByte) } // OnMethodInvocation returns the gas used when invoking a method. func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge { ret := pl.sendBase extra := "" - virtGas := int64(1072944) - if value != abi.NewTokenAmount(0) { - // TODO: fix this, it is comparing pointers instead of values - // see vv - ret += pl.sendTransferFunds - } if big.Cmp(value, abi.NewTokenAmount(0)) != 0 { - virtGas += 497495 + ret += pl.sendTransferFunds if methodNum == builtin.MethodSend { // transfer only - virtGas += 973940 + ret += pl.sendTransferOnlyPremium } extra += "t" } + if methodNum != builtin.MethodSend { - ret += pl.sendInvokeMethod extra += "i" // running actors is cheaper becase we hand over to actors - virtGas += -295779 + ret += pl.sendInvokeMethod } - return newGasCharge("OnMethodInvocation", ret, 0).WithVirtual(virtGas, 0).WithExtra(extra) + return newGasCharge("OnMethodInvocation", ret, 0).WithExtra(extra) } // OnIpldGet returns the gas used for storing an object func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge { - return newGasCharge("OnIpldGet", pl.ipldGetBase+int64(dataSize)*pl.ipldGetPerByte, 0). - WithExtra(dataSize).WithVirtual(433685, 0) + return newGasCharge("OnIpldGet", pl.ipldGetBase, 0) } // OnIpldPut returns the gas used for storing an object func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge { return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte). - WithExtra(dataSize).WithVirtual(88970, 0) + WithExtra(dataSize) } // OnCreateActor returns the gas used for creating an actor func (pl *pricelistV0) OnCreateActor() GasCharge { - return newGasCharge("OnCreateActor", pl.createActorBase, pl.createActorExtra).WithVirtual(65636, 0) + return newGasCharge("OnCreateActor", pl.createActorCompute, pl.createActorStorage) } // OnDeleteActor returns the gas used for deleting an actor @@ -148,50 +144,42 @@ func (pl *pricelistV0) OnDeleteActor() GasCharge { // OnVerifySignature func (pl *pricelistV0) OnVerifySignature(sigType crypto.SigType, planTextSize int) (GasCharge, error) { - costFn, ok := pl.verifySignature[sigType] + cost, ok := pl.verifySignature[sigType] if !ok { return GasCharge{}, fmt.Errorf("cost function for signature type %d not supported", sigType) } - sigName, _ := sigType.Name() - virtGas := int64(0) - switch sigType { - case crypto.SigTypeBLS: - virtGas = 220138570 - case crypto.SigTypeSecp256k1: - virtGas = 7053730 - } - return newGasCharge("OnVerifySignature", costFn(int64(planTextSize)), 0). + sigName, _ := sigType.Name() + return newGasCharge("OnVerifySignature", cost, 0). WithExtra(map[string]interface{}{ "type": sigName, "size": planTextSize, - }).WithVirtual(virtGas, 0), nil + }), nil } // OnHashing func (pl *pricelistV0) OnHashing(dataSize int) GasCharge { - return newGasCharge("OnHashing", pl.hashingBase+int64(dataSize)*pl.hashingPerByte, 0).WithExtra(dataSize).WithVirtual(77300, 0) + return newGasCharge("OnHashing", pl.hashingBase, 0).WithExtra(dataSize) } // OnComputeUnsealedSectorCid func (pl *pricelistV0) OnComputeUnsealedSectorCid(proofType abi.RegisteredSealProof, pieces []abi.PieceInfo) GasCharge { - // TODO: this needs more cost tunning, check with @lotus - return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0).WithVirtual(382370, 0) + return newGasCharge("OnComputeUnsealedSectorCid", pl.computeUnsealedSectorCidBase, 0) } // OnVerifySeal func (pl *pricelistV0) OnVerifySeal(info abi.SealVerifyInfo) GasCharge { // TODO: this needs more cost tunning, check with @lotus - return newGasCharge("OnVerifySeal", pl.verifySealBase, 0).WithVirtual(199954003, 0) + // this is not used + return newGasCharge("OnVerifySeal", pl.verifySealBase, 0) } // OnVerifyPost func (pl *pricelistV0) OnVerifyPost(info abi.WindowPoStVerifyInfo) GasCharge { - // TODO: this needs more cost tunning, check with @lotus - return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithVirtual(2629471704, 0).WithExtra(len(info.ChallengedSectors)) + return newGasCharge("OnVerifyPost", pl.verifyPostBase, 0).WithExtra(len(info.ChallengedSectors)) } // OnVerifyConsensusFault func (pl *pricelistV0) OnVerifyConsensusFault() GasCharge { - return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0).WithVirtual(551935, 0) + return newGasCharge("OnVerifyConsensusFault", pl.verifyConsensusFault, 0) } From 347c2ed4981d617d2a274f6b049fe2cf7734cca5 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Fri, 10 Jul 2020 16:59:27 +0200 Subject: [PATCH 3/7] Update chain-val to new gas values Signed-off-by: Jakub Sztandera --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 040b9d02e31..4715688cee1 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/drand/drand v1.0.3-0.20200714175734-29705eaf09d4 github.com/drand/kyber v1.1.1 github.com/fatih/color v1.8.0 - github.com/filecoin-project/chain-validation v0.0.6-0.20200713102302-1bc823b1e01d + github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2 diff --git a/go.sum b/go.sum index a44b5c2b6fa..31d82a0ebbe 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY= github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8= github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= -github.com/filecoin-project/chain-validation v0.0.6-0.20200713102302-1bc823b1e01d h1:6mOOHCn8iJfWPRELM7LPE4X9mBmCTvQORsgzsA/u0Wg= -github.com/filecoin-project/chain-validation v0.0.6-0.20200713102302-1bc823b1e01d/go.mod h1:293UFGwKduXCuIC2/5pIepH7lof+L9fNiPku/+arST4= +github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d h1:VQi/3o8Ocvp4Qj9SDbps2hPJv5mqQFpAUXBKI9F6I14= +github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d/go.mod h1:Tr0C0rl7WCPkkQOkrOLDR6k1ppFVgoIuj1s4KPs4bzo= github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U= From 61156afd90d7b5eaaec4aee5ff0260492a0f5dbd Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Mon, 13 Jul 2020 14:49:21 +0200 Subject: [PATCH 4/7] Update chain val Signed-off-by: Jakub Sztandera --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4715688cee1..288d1079be6 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/drand/drand v1.0.3-0.20200714175734-29705eaf09d4 github.com/drand/kyber v1.1.1 github.com/fatih/color v1.8.0 - github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d + github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e github.com/filecoin-project/filecoin-ffi v0.26.1-0.20200508175440-05b30afeb00d github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef github.com/filecoin-project/go-amt-ipld/v2 v2.0.1-0.20200424220931-6263827e49f2 diff --git a/go.sum b/go.sum index 31d82a0ebbe..35e47e46119 100644 --- a/go.sum +++ b/go.sum @@ -215,8 +215,8 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv github.com/fatih/color v1.8.0 h1:5bzFgL+oy7JITMTxUPJ00n7VxmYd/PdMp5mHFX40/RY= github.com/fatih/color v1.8.0/go.mod h1:3l45GVGkyrnYNl9HoIjnp2NnNWvh6hLAqD8yTfGjnw8= github.com/fd/go-nat v1.0.0/go.mod h1:BTBu/CKvMmOMUPkKVef1pngt2WFH/lg7E6yQnulfp6E= -github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d h1:VQi/3o8Ocvp4Qj9SDbps2hPJv5mqQFpAUXBKI9F6I14= -github.com/filecoin-project/chain-validation v0.0.6-0.20200710153924-b18f62a5c59d/go.mod h1:Tr0C0rl7WCPkkQOkrOLDR6k1ppFVgoIuj1s4KPs4bzo= +github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e h1:oCdk3QSDcHu3l6dWpZcHhaUVz5RQi1mXNyv8hgcK1zA= +github.com/filecoin-project/chain-validation v0.0.6-0.20200713115604-652494bba69e/go.mod h1:293UFGwKduXCuIC2/5pIepH7lof+L9fNiPku/+arST4= github.com/filecoin-project/go-address v0.0.0-20200107215422-da8eea2842b5/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200218010043-eb9bb40ed5be/go.mod h1:SAOwJoakQ8EPjwNIsiakIQKsoKdkcbx8U3IapgCg9R0= github.com/filecoin-project/go-address v0.0.2-0.20200504173055-8b6f2fb2b3ef h1:Wi5E+P1QfHP8IF27eUiTx5vYfqQZwfPxzq3oFEq8w8U= From 7b14d445b45d585c985b841072ddef2da375032f Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 15 Jul 2020 19:53:27 +0200 Subject: [PATCH 5/7] Update message gas limits Signed-off-by: Jakub Sztandera --- chain/gen/gen.go | 2 +- chain/market/fundmgr.go | 2 +- chain/stmgr/forks_test.go | 4 ++-- chain/types_test.go | 2 +- cli/chain.go | 2 +- cli/send.go | 2 +- cmd/chain-noise/main.go | 2 +- cmd/lotus-fountain/main.go | 6 +++--- cmd/lotus-shed/nonce-fix.go | 2 +- cmd/lotus-shed/verifreg.go | 4 ++-- cmd/lotus-storage-miner/init.go | 4 ++-- markets/storageadapter/client.go | 2 +- markets/storageadapter/provider.go | 4 ++-- miner/miner_test.go | 8 ++++---- node/impl/full/multisig.go | 6 +++--- node/impl/full/state.go | 2 +- node/impl/paych/paych.go | 4 ++-- node/node_test.go | 2 +- paychmgr/simple.go | 4 ++-- storage/adapter_storage_miner.go | 2 +- storage/wdpost_run.go | 4 ++-- 21 files changed, 35 insertions(+), 35 deletions(-) diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 3a0ac2187e2..990383ad630 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -468,7 +468,7 @@ func getRandomMessages(cg *ChainGen) ([]*types.SignedMessage, error) { Method: 0, - GasLimit: 10000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } diff --git a/chain/market/fundmgr.go b/chain/market/fundmgr.go index 42ad50b2b0a..1bafda3c9e9 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: 1000000, + GasLimit: 100_000_000, Method: builtin.MethodsMarket.AddBalance, Params: params, }) diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index 2fbcbbc99f5..c84b0b7b99b 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -179,7 +179,7 @@ func TestForkHeightTriggers(t *testing.T) { To: builtin.InitActorAddr, Method: builtin.MethodsInit.Exec, Params: enc, - GasLimit: 10000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } sig, err := cg.Wallet().Sign(ctx, cg.Banker(), m.Cid().Bytes()) @@ -206,7 +206,7 @@ func TestForkHeightTriggers(t *testing.T) { Method: 2, Params: nil, Nonce: nonce, - GasLimit: 10000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } nonce++ diff --git a/chain/types_test.go b/chain/types_test.go index 55baf4a2856..3b49a8d9443 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: 9992969384, + GasLimit: 100_000_000, Nonce: 123123, }, } diff --git a/cli/chain.go b/cli/chain.go index c2acee5e5e6..69f3d741399 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -935,7 +935,7 @@ var slashConsensusFault = &cli.Command{ From: def, Value: types.NewInt(0), GasPrice: types.NewInt(1), - GasLimit: 10000000, + GasLimit: 100_000_000, Method: builtin.MethodsMiner.ReportConsensusFault, Params: enc, } diff --git a/cli/send.go b/cli/send.go index 9f9c70dde41..4a9a39bfca4 100644 --- a/cli/send.go +++ b/cli/send.go @@ -77,7 +77,7 @@ var sendCmd = &cli.Command{ From: fromAddr, To: toAddr, Value: types.BigInt(val), - GasLimit: 10000, + GasLimit: 100_000_000, GasPrice: gp, } diff --git a/cmd/chain-noise/main.go b/cmd/chain-noise/main.go index 4a4a099d8a8..5a04fbf2121 100644 --- a/cmd/chain-noise/main.go +++ b/cmd/chain-noise/main.go @@ -77,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: 100000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index a86910cbeea..b9c0fe26ae1 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -281,7 +281,7 @@ func (h *handler) send(w http.ResponseWriter, r *http.Request) { To: to, GasPrice: types.NewInt(0), - GasLimit: 10000, + GasLimit: 100_000_000, }) if err != nil { w.WriteHeader(400) @@ -355,7 +355,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { To: owner, GasPrice: types.NewInt(0), - GasLimit: 10000, + GasLimit: 100_000_000, }) if err != nil { w.WriteHeader(400) @@ -391,7 +391,7 @@ func (h *handler) mkminer(w http.ResponseWriter, r *http.Request) { Method: builtin.MethodsPower.CreateMiner, Params: params, - GasLimit: 10000000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } diff --git a/cmd/lotus-shed/nonce-fix.go b/cmd/lotus-shed/nonce-fix.go index 4fb30300ab7..c85e9179742 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: 10000, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), Nonce: i, } diff --git a/cmd/lotus-shed/verifreg.go b/cmd/lotus-shed/verifreg.go index 747a233a557..3641ac2df1a 100644 --- a/cmd/lotus-shed/verifreg.go +++ b/cmd/lotus-shed/verifreg.go @@ -76,7 +76,7 @@ var verifRegAddVerifierCmd = &cli.Command{ From: fromk, Method: builtin.MethodsVerifiedRegistry.AddVerifier, GasPrice: types.NewInt(1), - GasLimit: 300000, + GasLimit: 100_000_000, Params: params, } @@ -152,7 +152,7 @@ var verifRegVerifyClientCmd = &cli.Command{ From: fromk, Method: builtin.MethodsVerifiedRegistry.AddVerifiedClient, GasPrice: types.NewInt(1), - GasLimit: 300000, + GasLimit: 100_000_000, Params: params, } diff --git a/cmd/lotus-storage-miner/init.go b/cmd/lotus-storage-miner/init.go index dc43b6c93f5..8468c7f9636 100644 --- a/cmd/lotus-storage-miner/init.go +++ b/cmd/lotus-storage-miner/init.go @@ -557,7 +557,7 @@ func configureStorageMiner(ctx context.Context, api lapi.FullNode, addr address. Params: enc, Value: types.NewInt(0), GasPrice: gasPrice, - GasLimit: 99999999, + GasLimit: 100_000_000, } smsg, err := api.MpoolPushMessage(ctx, msg) @@ -636,7 +636,7 @@ func createStorageMiner(ctx context.Context, api lapi.FullNode, peerid peer.ID, Method: builtin.MethodsPower.CreateMiner, Params: params, - GasLimit: 10000000, + GasLimit: 100_000_000, GasPrice: gasPrice, } diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 7ef6d07093b..4844ba514bd 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -138,7 +138,7 @@ func (c *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: 1000000, + GasLimit: 100_000_000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index 0b04757c560..b5ed247f4bf 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -78,7 +78,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark From: mi.Worker, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: 1000000, + GasLimit: 100_000_000, Method: builtin.MethodsMarket.PublishStorageDeals, Params: params, }) @@ -175,7 +175,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: 1000000, + GasLimit: 100_000_000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/miner/miner_test.go b/miner/miner_test.go index 32b1aef2409..7ae07644e26 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -44,7 +44,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 3, Value: types.NewInt(500), - GasLimit: 50, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, { @@ -52,7 +52,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 4, Value: types.NewInt(500), - GasLimit: 50, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, { @@ -60,7 +60,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 1, Value: types.NewInt(800), - GasLimit: 100, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, { @@ -68,7 +68,7 @@ func TestMessageFiltering(t *testing.T) { To: a1, Nonce: 0, Value: types.NewInt(800), - GasLimit: 100, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, { diff --git a/node/impl/full/multisig.go b/node/impl/full/multisig.go index 7d6d9e86c2b..7340ae0dad4 100644 --- a/node/impl/full/multisig.go +++ b/node/impl/full/multisig.go @@ -76,7 +76,7 @@ func (a *MsigAPI) MsigCreate(ctx context.Context, req uint64, addrs []address.Ad Method: builtin.MethodsInit.Exec, Params: enc, GasPrice: gp, - GasLimit: 1000000, + GasLimit: 100_000_000, Value: val, } @@ -123,7 +123,7 @@ func (a *MsigAPI) MsigPropose(ctx context.Context, msig address.Address, to addr Value: types.NewInt(0), Method: builtin.MethodsMultisig.Propose, Params: enc, - GasLimit: 100000, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), } @@ -212,7 +212,7 @@ func (a *MsigAPI) msigApproveOrCancel(ctx context.Context, operation api.MsigPro Value: types.NewInt(0), Method: msigResponseMethod, Params: enc, - GasLimit: 100000, + GasLimit: 100_000_000, GasPrice: types.NewInt(1), } diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 313665c606c..dc88aef48a9 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -779,7 +779,7 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr From: maddr, To: builtin.StorageMarketActorAddr, Method: builtin.MethodsMarket.VerifyDealsForActivation, - GasLimit: 100000000000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), Params: params, }, ts) diff --git a/node/impl/paych/paych.go b/node/impl/paych/paych.go index b08e07dbdf6..1ecd8250e4a 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: 10000, + GasLimit: 100_000_000, 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: 100000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } diff --git a/node/node_test.go b/node/node_test.go index 64d59fc50f7..e03d9ed4f94 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -107,7 +107,7 @@ func testStorageNode(ctx context.Context, t *testing.T, waddr address.Address, a Params: enc, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: 1000000, + GasLimit: 100_000_000, } _, err = tnd.MpoolPushMessage(ctx, msg) diff --git a/paychmgr/simple.go b/paychmgr/simple.go index 4d275a1a705..ddc49f864f6 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: 1000000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } @@ -92,7 +92,7 @@ func (pm *Manager) addFunds(ctx context.Context, ch address.Address, from addres From: from, Value: amt, Method: 0, - GasLimit: 1000000, + GasLimit: 100_000_000, GasPrice: types.NewInt(0), } diff --git a/storage/adapter_storage_miner.go b/storage/adapter_storage_miner.go index eaaa7a75c6b..1405adf3b3b 100644 --- a/storage/adapter_storage_miner.go +++ b/storage/adapter_storage_miner.go @@ -117,7 +117,7 @@ func (s SealingAPIAdapter) StateComputeDataCommitment(ctx context.Context, maddr From: maddr, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: 9999999999, + GasLimit: 100_000_000, Method: builtin.MethodsMarket.ComputeDataCommitment, Params: ccparams, } diff --git a/storage/wdpost_run.go b/storage/wdpost_run.go index 9f3919240c3..8e404610c16 100644 --- a/storage/wdpost_run.go +++ b/storage/wdpost_run.go @@ -177,7 +177,7 @@ func (s *WindowPoStScheduler) checkNextRecoveries(ctx context.Context, deadline Method: builtin.MethodsMiner.DeclareFaultsRecovered, Params: enc, Value: types.NewInt(0), - GasLimit: 10000000, // i dont know help + GasLimit: 100_000_000, // i dont know help GasPrice: types.NewInt(2), } @@ -256,7 +256,7 @@ func (s *WindowPoStScheduler) checkNextFaults(ctx context.Context, deadline uint Method: builtin.MethodsMiner.DeclareFaults, Params: enc, Value: types.NewInt(0), // TODO: Is there a fee? - GasLimit: 10000000, // i dont know help + GasLimit: 100_000_000, // i dont know help GasPrice: types.NewInt(2), } From 399c171f0356e2c2515d6f522248acf8d3831ae2 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 15 Jul 2020 21:21:53 +0200 Subject: [PATCH 6/7] Update gas limits, update storage-fsm Signed-off-by: Jakub Sztandera --- build/params_shared_vals.go | 2 +- go.mod | 2 +- go.sum | 6 ++---- markets/storageadapter/client.go | 2 +- markets/storageadapter/provider.go | 4 ++-- miner/miner_test.go | 19 +++++++++---------- node/impl/full/mpool.go | 6 ++++++ 7 files changed, 22 insertions(+), 19 deletions(-) diff --git a/build/params_shared_vals.go b/build/params_shared_vals.go index a0633987d14..e770f8c69ad 100644 --- a/build/params_shared_vals.go +++ b/build/params_shared_vals.go @@ -91,7 +91,7 @@ const VerifSigCacheSize = 32000 // TODO: If this is gonna stay, it should move to specs-actors const BlockMessageLimit = 512 -const BlockGasLimit = 100_000_000_000 +const BlockGasLimit = 7_500_000_000 var DrandConfig = dtypes.DrandConfig{ Servers: []string{ diff --git a/go.mod b/go.mod index 288d1079be6..8345a047c7c 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,7 @@ require ( github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15 github.com/filecoin-project/specs-actors v0.7.2 github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea - github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080 + github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41 github.com/gbrlsnchs/jwt/v3 v3.0.0-beta.1 github.com/go-kit/kit v0.10.0 github.com/go-ole/go-ole v1.2.4 // indirect diff --git a/go.sum b/go.sum index 35e47e46119..8d2bb74f0fc 100644 --- a/go.sum +++ b/go.sum @@ -258,8 +258,6 @@ github.com/filecoin-project/go-statestore v0.1.0/go.mod h1:LFc9hD+fRxPqiHiaqUEZO github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b h1:fkRZSPrYpk42PV3/lIXiL0LHetxde7vyYYvSsttQtfg= github.com/filecoin-project/go-storedcounter v0.0.0-20200421200003-1c99c62e8a5b/go.mod h1:Q0GQOBtKf1oE10eSXSlhN45kDBdGvEcVOqMiffqX+N8= github.com/filecoin-project/sector-storage v0.0.0-20200615154852-728a47ab99d6/go.mod h1:M59QnAeA/oV+Z8oHFLoNpGMv0LZ8Rll+vHVXX7GirPM= -github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246 h1:NfYQRmVRe0LzlNbK5Ket3vbBOwFD5TvtcNtfo/Sd8mg= -github.com/filecoin-project/sector-storage v0.0.0-20200625154333-98ef8e4ef246/go.mod h1:8f0hWDzzIi1hKs4IVKH9RnDsO4LEHVz8BNat0okDOuY= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15 h1:miw6hiusb/MkV1ryoqUKKWnvHhPW00AYtyeCj0L8pqo= github.com/filecoin-project/sector-storage v0.0.0-20200712023225-1d67dcfa3c15/go.mod h1:salgVdX7qeXFo/xaiEQE29J4pPkjn71T0kt0n+VDBzo= github.com/filecoin-project/specs-actors v0.0.0-20200210130641-2d1fbd8672cf/go.mod h1:xtDZUB6pe4Pksa/bAJbJ693OilaC5Wbot9jMhLm3cZA= @@ -274,8 +272,8 @@ github.com/filecoin-project/specs-storage v0.1.0 h1:PkDgTOT5W5Ao7752onjDl4QSv+sg github.com/filecoin-project/specs-storage v0.1.0/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea h1:iixjULRQFPn7Q9KlIqfwLJnlAXO10bbkI+xy5GKGdLY= github.com/filecoin-project/specs-storage v0.1.1-0.20200622113353-88a9704877ea/go.mod h1:Pr5ntAaxsh+sLG/LYiL4tKzvA83Vk5vLODYhfNwOg7k= -github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080 h1:WZonjI7/GFLi4NxziBCefS9x7bm8S405RWkmFuDfRLA= -github.com/filecoin-project/storage-fsm v0.0.0-20200712045002-6e92d6a6f080/go.mod h1:SXO4VnXG056B/lXHL8HZv54eMqlsyynm+v93BlLwlOY= +github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41 h1:K2DI5+IKuY0cOjX/r1Agy6rYcAhU89LVNOjutCUib4g= +github.com/filecoin-project/storage-fsm v0.0.0-20200715191202-7e92e888bf41/go.mod h1:TDNjb0HYG2fppxWH5EsiNCZu97iJZNuPYmivSK13Ao0= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6 h1:u/UEqS66A5ckRmS4yNpjmVH56sVtS/RfclBAYocb4as= github.com/flynn/noise v0.0.0-20180327030543-2492fe189ae6/go.mod h1:1i71OnUq3iUe1ma7Lr6yG6/rjvM3emb6yoL7xLFzcVQ= diff --git a/markets/storageadapter/client.go b/markets/storageadapter/client.go index 4844ba514bd..2bb762e2849 100644 --- a/markets/storageadapter/client.go +++ b/markets/storageadapter/client.go @@ -138,7 +138,7 @@ func (c *ClientNodeAdapter) AddFunds(ctx context.Context, addr address.Address, From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: 100_000_000, + GasLimit: 200_000_000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/markets/storageadapter/provider.go b/markets/storageadapter/provider.go index b5ed247f4bf..9e1a101cc9a 100644 --- a/markets/storageadapter/provider.go +++ b/markets/storageadapter/provider.go @@ -78,7 +78,7 @@ func (n *ProviderNodeAdapter) PublishDeals(ctx context.Context, deal storagemark From: mi.Worker, Value: types.NewInt(0), GasPrice: types.NewInt(0), - GasLimit: 100_000_000, + GasLimit: 600_000_000, Method: builtin.MethodsMarket.PublishStorageDeals, Params: params, }) @@ -175,7 +175,7 @@ func (n *ProviderNodeAdapter) AddFunds(ctx context.Context, addr address.Address From: addr, Value: amount, GasPrice: types.NewInt(0), - GasLimit: 100_000_000, + GasLimit: 200_000_000, Method: builtin.MethodsMarket.AddBalance, }) if err != nil { diff --git a/miner/miner_test.go b/miner/miner_test.go index 7ae07644e26..b600ff1367a 100644 --- a/miner/miner_test.go +++ b/miner/miner_test.go @@ -7,6 +7,7 @@ import ( "github.com/filecoin-project/go-address" "github.com/filecoin-project/lotus/chain/types" + "github.com/stretchr/testify/assert" ) func mustIDAddr(i uint64) address.Address { @@ -26,11 +27,11 @@ func TestMessageFiltering(t *testing.T) { actors := map[address.Address]*types.Actor{ a1: { Nonce: 3, - Balance: types.NewInt(1200), + Balance: types.FromFil(1200), }, a2: { Nonce: 1, - Balance: types.NewInt(1000), + Balance: types.FromFil(1000), }, } @@ -43,7 +44,7 @@ func TestMessageFiltering(t *testing.T) { From: a1, To: a1, Nonce: 3, - Value: types.NewInt(500), + Value: types.FromFil(500), GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, @@ -51,7 +52,7 @@ func TestMessageFiltering(t *testing.T) { From: a1, To: a1, Nonce: 4, - Value: types.NewInt(500), + Value: types.FromFil(500), GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, @@ -59,7 +60,7 @@ func TestMessageFiltering(t *testing.T) { From: a2, To: a1, Nonce: 1, - Value: types.NewInt(800), + Value: types.FromFil(800), GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, @@ -67,7 +68,7 @@ func TestMessageFiltering(t *testing.T) { From: a2, To: a1, Nonce: 0, - Value: types.NewInt(800), + Value: types.FromFil(800), GasLimit: 100_000_000, GasPrice: types.NewInt(1), }, @@ -75,7 +76,7 @@ func TestMessageFiltering(t *testing.T) { From: a2, To: a1, Nonce: 2, - Value: types.NewInt(150), + Value: types.FromFil(150), GasLimit: 100, GasPrice: types.NewInt(1), }, @@ -86,9 +87,7 @@ func TestMessageFiltering(t *testing.T) { t.Fatal(err) } - if len(outmsgs) != 3 { - t.Fatal("filtering didnt work as expected") - } + assert.Len(t, outmsgs, 3, "filtering didnt work as expected") was, expected := outmsgs[0].Message, msgs[2] if was.From != expected.From || was.Nonce != expected.Nonce { diff --git a/node/impl/full/mpool.go b/node/impl/full/mpool.go index 79e6d30bedc..d5b77b0bbef 100644 --- a/node/impl/full/mpool.go +++ b/node/impl/full/mpool.go @@ -90,6 +90,12 @@ func (a *MpoolAPI) MpoolPushMessage(ctx context.Context, msg *types.Message) (*t if msg.Nonce != 0 { return nil, xerrors.Errorf("MpoolPushMessage expects message nonce to be 0, was %d", msg.Nonce) } + if msg.GasLimit == 0 { + msg.GasLimit = 100_000_000 // TODO: gas limit estimation + } + if types.BigCmp(msg.GasPrice, types.NewInt(0)) == 0 { + msg.GasPrice = types.NewInt(1) // TODO: gas price estimation + } return a.Mpool.PushWithNonce(ctx, msg.From, func(from address.Address, nonce uint64) (*types.SignedMessage, error) { msg.Nonce = nonce From 610ed0dc13dfdb21b48d63fc1f3746053c4dea3e Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Wed, 15 Jul 2020 21:40:49 +0200 Subject: [PATCH 7/7] Change OnIpldGet Signed-off-by: Jakub Sztandera --- chain/vm/gas.go | 2 +- chain/vm/gas_v0.go | 2 +- chain/vm/vm.go | 4 ++-- cmd/lotus-bench/import.go | 13 ++++++++----- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/chain/vm/gas.go b/chain/vm/gas.go index 449984ed132..81a5fc8e360 100644 --- a/chain/vm/gas.go +++ b/chain/vm/gas.go @@ -65,7 +65,7 @@ type Pricelist interface { OnMethodInvocation(value abi.TokenAmount, methodNum abi.MethodNum) GasCharge // OnIpldGet returns the gas used for storing an object - OnIpldGet(dataSize int) GasCharge + OnIpldGet() GasCharge // OnIpldPut returns the gas used for storing an object OnIpldPut(dataSize int) GasCharge diff --git a/chain/vm/gas_v0.go b/chain/vm/gas_v0.go index 39e24d2cf27..068726d7404 100644 --- a/chain/vm/gas_v0.go +++ b/chain/vm/gas_v0.go @@ -121,7 +121,7 @@ func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.M } // OnIpldGet returns the gas used for storing an object -func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge { +func (pl *pricelistV0) OnIpldGet() GasCharge { return newGasCharge("OnIpldGet", pl.ipldGetBase, 0) } diff --git a/chain/vm/vm.go b/chain/vm/vm.go index ce02f9ac898..dd1d2351386 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -71,12 +71,12 @@ type gasChargingBlocks struct { } func (bs *gasChargingBlocks) Get(c cid.Cid) (block.Block, error) { - bs.chargeGas(newGasCharge("OnIpldGetStart", 0, 0)) + bs.chargeGas(bs.pricelist.OnIpldGet()) blk, err := bs.under.Get(c) if err != nil { return nil, aerrors.Escalate(err, "failed to get block from blockstore") } - bs.chargeGas(bs.pricelist.OnIpldGet(len(blk.RawData()))) + bs.chargeGas(newGasCharge("OnIpldGetEnd", 0, 0).WithExtra(len(blk.RawData()))) bs.chargeGas(gasOnActorExec) return blk, nil diff --git a/cmd/lotus-bench/import.go b/cmd/lotus-bench/import.go index ec1815ac00b..3c56a5707e1 100644 --- a/cmd/lotus-bench/import.go +++ b/cmd/lotus-bench/import.go @@ -405,16 +405,19 @@ func getExtras(ex interface{}) (*string, *float64) { func tallyGasCharges(charges map[string]*stats, et types.ExecutionTrace) { for i, gc := range et.GasCharges { name := gc.Name - if name == "OnIpldGetStart" { + if name == "OnIpldGetEnd" { continue } tt := float64(gc.TimeTaken.Nanoseconds()) if name == "OnIpldGet" { - prev := et.GasCharges[i-1] - if prev.Name != "OnIpldGetStart" { - log.Warn("OnIpldGet without OnIpldGetStart") + next := &types.GasTrace{} + if i+1 < len(et.GasCharges) { + next = et.GasCharges[i+1] } - tt += float64(prev.TimeTaken.Nanoseconds()) + if next.Name != "OnIpldGetEnd" { + log.Warn("OnIpldGet without OnIpldGetEnd") + } + tt += float64(next.TimeTaken.Nanoseconds()) } eType, eSize := getExtras(gc.Extra) if eType != nil {