Skip to content

Commit

Permalink
fix: adjust calculation of gas outputs for FIP-0009 (#356)
Browse files Browse the repository at this point in the history
* fix: adjust calculation of gas outputs for FIP-0009

* remove dev lines from go.mod

* Use exported ShouldBurn method from lotus vm

* Use exported ShouldBurn method from lotus vm

* Upgrade carbs version
  • Loading branch information
iand authored Jan 15, 2021
1 parent b7f1f6f commit 6bd1428
Show file tree
Hide file tree
Showing 10 changed files with 282 additions and 86 deletions.
15 changes: 7 additions & 8 deletions chain/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ func (p *MessageProcessor) processExecutedMessages(ctx context.Context, ts, pts
}
receiptResults = append(receiptResults, rcpt)

outputs := p.node.ComputeGasOutputs(m.Receipt.GasUsed, m.Message.GasLimit, m.BlockHeader.ParentBaseFee, m.Message.GasFeeCap, m.Message.GasPremium)
gasOutput := &derivedmodel.GasOutputs{
Height: msg.Height,
Cid: msg.Cid,
Expand All @@ -180,13 +179,13 @@ func (p *MessageProcessor) processExecutedMessages(ctx context.Context, ts, pts
GasUsed: rcpt.GasUsed,
ParentBaseFee: m.BlockHeader.ParentBaseFee.String(),
SizeBytes: msgSize,
BaseFeeBurn: outputs.BaseFeeBurn.String(),
OverEstimationBurn: outputs.OverEstimationBurn.String(),
MinerPenalty: outputs.MinerPenalty.String(),
MinerTip: outputs.MinerTip.String(),
Refund: outputs.Refund.String(),
GasRefund: outputs.GasRefund,
GasBurned: outputs.GasBurned,
BaseFeeBurn: m.GasOutputs.BaseFeeBurn.String(),
OverEstimationBurn: m.GasOutputs.OverEstimationBurn.String(),
MinerPenalty: m.GasOutputs.MinerPenalty.String(),
MinerTip: m.GasOutputs.MinerTip.String(),
Refund: m.GasOutputs.Refund.String(),
GasRefund: m.GasOutputs.GasRefund,
GasBurned: m.GasOutputs.GasBurned,
ActorName: actorstate.ActorNameByCode(m.ToActorCode),
}
gasOutputsResults = append(gasOutputsResults, gasOutput)
Expand Down
9 changes: 9 additions & 0 deletions extern/filecoin-ffi-stub/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/filecoin-project/sentinel-visor/extern/filecoin-ffi-stub

go 1.14

require (
github.com/filecoin-project/go-state-types v0.0.0-20200904021452-1883f36ca2f4
github.com/filecoin-project/specs-actors v0.9.4
github.com/ipfs/go-cid v0.0.7
)
102 changes: 102 additions & 0 deletions extern/filecoin-ffi-stub/iface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package ffi

import (
"io"
"os"

abi "github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/specs-actors/actors/runtime/proof"
"github.com/ipfs/go-cid"
)

func GetGPUDevices() ([]string, error) {
return nil, nil
}

func GenerateUnsealedCID(_ abi.RegisteredSealProof, _ []abi.PieceInfo) (cid.Cid, error) {
return cid.Undef, nil
}

func GeneratePieceCIDFromFile(_ abi.RegisteredSealProof, _ io.Reader, _ abi.UnpaddedPieceSize) (cid.Cid, error) {
return cid.Undef, nil
}

func UnsealRange(_ abi.RegisteredSealProof, _ string, _, _ *os.File, _ abi.SectorNumber, _ abi.ActorID, _ abi.SealRandomness, _ cid.Cid, _, _ uint64) error {
return nil
}

func SealPreCommitPhase1(_ abi.RegisteredSealProof, _, _, _ string, _ abi.SectorNumber, _ abi.ActorID, _ abi.SealRandomness, _ []abi.PieceInfo) ([]byte, error) {
return nil, nil
}

func SealPreCommitPhase2(_ []byte, _, _ string) (cid.Cid, cid.Cid, error) {
return cid.Undef, cid.Undef, nil
}

func SealCommitPhase1(abi.RegisteredSealProof, cid.Cid, cid.Cid, string, string, abi.SectorNumber, abi.ActorID, abi.SealRandomness, abi.InteractiveSealRandomness, []abi.PieceInfo) ([]byte, error) {
return nil, nil
}

func SealCommitPhase2([]byte, abi.SectorNumber, abi.ActorID) ([]byte, error) {
return nil, nil
}

func ClearCache(uint64, string) error {
return nil
}

func GenerateWinningPoSt(abi.ActorID, SortedPrivateSectorInfo, abi.PoStRandomness) ([]proof.PoStProof, error) {
return nil, nil
}

func GenerateWindowPoSt(abi.ActorID, SortedPrivateSectorInfo, abi.PoStRandomness) ([]proof.PoStProof, []abi.SectorNumber, error) {
return nil, nil, nil
}

type (
SortedPrivateSectorInfo struct{ abi.SectorNumber }
PrivateSectorInfo struct {
abi.SectorNumber
CacheDirPath string
PoStProofType abi.RegisteredPoStProof
SealedSectorPath string
SectorInfo proof.SectorInfo
}
)

func NewSortedPrivateSectorInfo(...PrivateSectorInfo) SortedPrivateSectorInfo {
return SortedPrivateSectorInfo{}
}

func VerifySeal(proof.SealVerifyInfo) (bool, error) {
return true, nil
}

func VerifyWinningPoSt(proof.WinningPoStVerifyInfo) (bool, error) {
return true, nil
}

func VerifyWindowPoSt(proof.WindowPoStVerifyInfo) (bool, error) {
return true, nil
}

func GenerateWinningPoStSectorChallenge(abi.RegisteredPoStProof, abi.ActorID, abi.PoStRandomness, uint64) ([]uint64, error) {
return nil, nil
}

func FauxRep(abi.RegisteredSealProof, string, string) (cid.Cid, error) {
return cid.Undef, nil
}

type FallbackChallenges struct {
Sectors []abi.SectorNumber
Challenges map[abi.SectorNumber][]uint64
}

func GeneratePoStFallbackSectorChallenges(proofType abi.RegisteredPoStProof, minerID abi.ActorID, randomness abi.PoStRandomness, sectorIds []abi.SectorNumber) (*FallbackChallenges, error) {
return nil, nil
}

func GenerateSingleVanillaProof(replica PrivateSectorInfo, challange []uint64) ([]byte, error) {
return nil, nil
}
25 changes: 12 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ require (
github.com/fatih/color v1.10.0 // indirect
github.com/filecoin-project/go-address v0.0.5-0.20201103152444-f2023ef3f5bb
github.com/filecoin-project/go-bitfield v0.2.3-0.20201110211213-fe2c1862e816
github.com/filecoin-project/go-fil-markets v1.0.4
github.com/filecoin-project/go-fil-markets v1.0.10
github.com/filecoin-project/go-multistore v0.0.3
github.com/filecoin-project/go-state-types v0.0.0-20201013222834-41ea465f274f
github.com/filecoin-project/lotus v1.1.4-0.20201116232018-a152d98af82b
github.com/filecoin-project/specs-actors v0.9.12
github.com/filecoin-project/specs-actors/v2 v2.2.0
github.com/filecoin-project/go-state-types v0.0.0-20201102161440-c8033295a1fc
github.com/filecoin-project/lotus v1.4.1-pre1.0.20210114132837-5453e70cabb9
github.com/filecoin-project/specs-actors v0.9.13
github.com/filecoin-project/specs-actors/v2 v2.3.3
github.com/filecoin-project/statediff v0.0.8-0.20201027195725-7eaa5391a639
github.com/go-pg/migrations/v8 v8.0.1
github.com/go-pg/pg/v10 v10.3.1
Expand All @@ -23,7 +23,6 @@ require (
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
github.com/ipfs/go-ipfs-blockstore v1.0.3 // indirect
github.com/ipfs/go-ipld-cbor v0.0.5
github.com/ipfs/go-log/v2 v2.1.2-0.20200626104915-0016c0b4b3e4
github.com/ipld/go-ipld-prime v0.5.1-0.20201021195245-109253e8a018
Expand All @@ -40,8 +39,8 @@ require (
github.com/stretchr/testify v1.6.1
github.com/urfave/cli/v2 v2.3.0
github.com/whyrusleeping/cbor-gen v0.0.0-20200826160007-0b9f6c5fb163
github.com/willscott/carbs v0.0.3
go.opencensus.io v0.22.4
github.com/willscott/carbs v0.0.4
go.opencensus.io v0.22.5
go.opentelemetry.io/otel v0.12.0
go.opentelemetry.io/otel/exporters/trace/jaeger v0.12.0
go.opentelemetry.io/otel/sdk v0.12.0
Expand All @@ -50,8 +49,8 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/filecoin-project/filecoin-ffi => github.com/filecoin-project/statediff/extern/filecoin-ffi v0.0.0-20201028183730-8e6631500d49

replace github.com/supranational/blst => ./extern/fil-blst/blst

replace github.com/filecoin-project/fil-blst => ./extern/fil-blst
replace (
github.com/filecoin-project/fil-blst => ./extern/fil-blst
github.com/filecoin-project/filecoin-ffi => ./extern/filecoin-ffi-stub
github.com/supranational/blst => ./extern/fil-blst/blst
)
Loading

0 comments on commit 6bd1428

Please sign in to comment.