Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix some issues #4962

Merged
merged 5 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/submodule/chain/chain_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type chainAPI struct { // nolint: golint
v1api.IActor
v1api.IMinerState
v1api.IChainInfo
v1api.IBeacon
}

var _ v1api.IChain = &chainAPI{}
10 changes: 10 additions & 0 deletions app/submodule/chain/chaininfo_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,14 @@ func (cia *chainInfoAPI) VerifyEntry(parent, child *types.BeaconEntry, height ab
// BeaconGetEntry returns the beacon entry for the given filecoin epoch. If
// the entry has not yet been produced, the call will block until the entry
// becomes available
// Deprecated: Use StateGetBeaconEntry instead.
func (cia *chainInfoAPI) BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
return cia.StateGetBeaconEntry(ctx, epoch)
}

// StateGetBeaconEntry returns the beacon entry for the given filecoin epoch. If
// the entry has not yet been produced, the call will block until the entry
// becomes available
func (cia *chainInfoAPI) StateGetBeaconEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) {
b := cia.chain.Drand.BeaconForEpoch(epoch)
nv := cia.chain.Fork.GetNetworkVersion(ctx, epoch)
Expand Down Expand Up @@ -378,11 +386,13 @@ func (cia *chainInfoAPI) getNetworkName(ctx context.Context) (string, error) {
}

// ChainGetRandomnessFromBeacon is used to sample the beacon for randomness.
// Deprecated: Use StateGetRandomnessFromBeacon instead.
func (cia *chainInfoAPI) ChainGetRandomnessFromBeacon(ctx context.Context, key types.TipSetKey, personalization acrypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
return cia.StateGetRandomnessFromBeacon(ctx, personalization, randEpoch, entropy, key)
}

// ChainGetRandomnessFromTickets is used to sample the chain for randomness.
// Deprecated: Use StateGetRandomnessFromTickets instead.
func (cia *chainInfoAPI) ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization acrypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) {
return cia.StateGetRandomnessFromTickets(ctx, personalization, randEpoch, entropy, tsk)
}
Expand Down
4 changes: 2 additions & 2 deletions fixtures/assets/asset.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/filecoin-project/venus/venus-shared/types"
)

//go:embed car
//go:embed genesis-car
var carFS embed.FS

func GetGenesis(networkType types.NetworkType) ([]byte, error) {
Expand All @@ -27,7 +27,7 @@ func GetGenesis(networkType types.NetworkType) ([]byte, error) {
fileName = "mainnet.car"
}

return carFS.ReadFile(filepath.Join("car", fileName))
return carFS.ReadFile(filepath.Join("genesis-car", fileName))
}

//go:embed proof-params
Expand Down
5 changes: 3 additions & 2 deletions pkg/consensus/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (bv *BlockValidator) validateBlock(ctx context.Context, blk *types.BlockHea

beaconValuesCheck := async.Err(func() error {
parentHeight := parent.Height()
return bv.ValidateBlockBeacon(blk, parentHeight, prevBeacon, bv.fork.GetNetworkVersion(ctx, blk.Height))
return bv.ValidateBlockBeacon(blk, parentHeight, prevBeacon)
})

tktsCheck := async.Err(func() error {
Expand Down Expand Up @@ -493,10 +493,11 @@ func (bv *BlockValidator) minerIsValid(ctx context.Context, maddr address.Addres
return nil
}

func (bv *BlockValidator) ValidateBlockBeacon(blk *types.BlockHeader, parentEpoch abi.ChainEpoch, prevEntry *types.BeaconEntry, nv network.Version) error {
func (bv *BlockValidator) ValidateBlockBeacon(blk *types.BlockHeader, parentEpoch abi.ChainEpoch, prevEntry *types.BeaconEntry) error {
if os.Getenv("VENUS_IGNORE_DRAND") == "_yes_" {
return nil
}
nv := bv.fork.GetNetworkVersion(context.TODO(), blk.Height)
return beacon.ValidateBlockValues(bv.drand, nv, blk, parentEpoch, prevEntry)
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/messagepool/gas.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ func (mp *MessagePool) evalMessageGasLimit(ctx context.Context, msgIn *types.Mes

// skip storage market, 80th percentie for everything ~1.9, leave it at 2.0
}()
log.Infof("overestimate gas around the upgrade msg: %v, transitional multi: %v", msg, transitionalMulti)
}
ret = (ret * int64(transitionalMulti*1024)) >> 10

Expand Down Expand Up @@ -320,6 +321,7 @@ func (mp *MessagePool) GasEstimateMessageGas(ctx context.Context, estimateMessag
if estimateMessage.Spec != nil && estimateMessage.Spec.GasOverEstimation > 0 {
gasLimitOverestimation = estimateMessage.Spec.GasOverEstimation
}
log.Debugf("call GasEstimateMessageGas %v, spec: %v, config gasLimitOverestimation: %v", estimateMessage.Msg, estimateMessage.Spec, mp.GetConfig().GasLimitOverestimation)
estimateMessage.Msg.GasLimit = int64(float64(gasLimit) * gasLimitOverestimation)
}

Expand Down Expand Up @@ -371,10 +373,7 @@ func (mp *MessagePool) GasBatchEstimateMessageGas(ctx context.Context, estimateM
estimateMsg := estimateMessage.Msg
estimateMsg.Nonce = fromNonce

if estimateMessage.Spec != nil {
log.Debugf("GasBatchEstimateMessageGas from %s, nonce %d, gas limit %d, gas fee cap %s, max fee %s",
estimateMsg.From, estimateMsg.Nonce, estimateMsg.GasLimit, estimateMsg.GasFeeCap, estimateMessage.Spec.MaxFee)
}
log.Debugf("call GasBatchEstimateMessageGas msg %v, spec %v", estimateMsg, estimateMessage.Spec)

if estimateMsg.GasLimit == 0 {
gasUsed, err := mp.evalMessageGasLimit(ctx, estimateMsg, priorMsgs, ts)
Expand Down
6 changes: 3 additions & 3 deletions tools/conformance/rand_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ func (r *RecordingRand) GetChainRandomnessV1(ctx context.Context, pers crypto.Do

func (r *RecordingRand) getChainRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) {
r.once.Do(r.loadHead)
// FullNode's ChainGetRandomnessFromTickets handles whether we should be looking forward or back
ret, err := r.api.ChainGetRandomnessFromTickets(ctx, r.head, pers, round, entropy)
// FullNode's StateGetRandomnessFromTickets handles whether we should be looking forward or back
ret, err := r.api.StateGetRandomnessFromTickets(ctx, pers, round, entropy, r.head)
if err != nil {
return ret, err
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func (r *RecordingRand) GetBeaconRandomnessV2(ctx context.Context, pers crypto.D

func (r *RecordingRand) getBeaconRandomness(ctx context.Context, pers crypto.DomainSeparationTag, round abi.ChainEpoch, entropy []byte) ([]byte, error) {
r.once.Do(r.loadHead)
ret, err := r.api.ChainGetRandomnessFromBeacon(ctx, r.head, pers, round, entropy)
ret, err := r.api.StateGetRandomnessFromBeacon(ctx, pers, round, entropy, r.head)
if err != nil {
return ret, err
}
Expand Down
24 changes: 16 additions & 8 deletions venus-shared/api/chain/v1/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
type IChain interface {
IAccount
IActor
IBeacon
IMinerState
IChainInfo
}
Expand All @@ -34,15 +35,22 @@ type IActor interface {
ListActor(ctx context.Context) (map[address.Address]*types.Actor, error) //perm:read
}

type IBeacon interface {
// Deprecated: Use StateGetBeaconEntry instead.
BeaconGetEntry(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) //perm:read
}

type IChainInfo interface {
BlockTime(ctx context.Context) time.Duration //perm:read
ChainList(ctx context.Context, tsKey types.TipSetKey, count int) ([]types.TipSetKey, error) //perm:read
ChainHead(ctx context.Context) (*types.TipSet, error) //perm:read
ChainSetHead(ctx context.Context, key types.TipSetKey) error //perm:admin
ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) //perm:read
ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) //perm:read
ChainGetTipSetAfterHeight(ctx context.Context, height abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) //perm:read
ChainGetRandomnessFromBeacon(ctx context.Context, key types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read
BlockTime(ctx context.Context) time.Duration //perm:read
ChainList(ctx context.Context, tsKey types.TipSetKey, count int) ([]types.TipSetKey, error) //perm:read
ChainHead(ctx context.Context) (*types.TipSet, error) //perm:read
ChainSetHead(ctx context.Context, key types.TipSetKey) error //perm:admin
ChainGetTipSet(ctx context.Context, key types.TipSetKey) (*types.TipSet, error) //perm:read
ChainGetTipSetByHeight(ctx context.Context, height abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) //perm:read
ChainGetTipSetAfterHeight(ctx context.Context, height abi.ChainEpoch, tsk types.TipSetKey) (*types.TipSet, error) //perm:read
// Deprecated: Use StateGetRandomnessFromBeacon instead.
ChainGetRandomnessFromBeacon(ctx context.Context, key types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read
// Deprecated: Use StateGetRandomnessFromTickets instead.
ChainGetRandomnessFromTickets(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) //perm:read
StateGetRandomnessFromTickets(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
StateGetRandomnessFromBeacon(ctx context.Context, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte, tsk types.TipSetKey) (abi.Randomness, error) //perm:read
Expand Down
27 changes: 27 additions & 0 deletions venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* [Actor](#Actor)
* [ListActor](#ListActor)
* [StateGetActor](#StateGetActor)
* [Beacon](#Beacon)
* [BeaconGetEntry](#BeaconGetEntry)
* [BlockStore](#BlockStore)
* [ChainDeleteObj](#ChainDeleteObj)
* [ChainHasObj](#ChainHasObj)
Expand Down Expand Up @@ -251,6 +253,29 @@ Response:
}
```

## Beacon

### BeaconGetEntry
Deprecated: Use StateGetBeaconEntry instead.


Perms: read

Inputs:
```json
[
10101
]
```

Response:
```json
{
"Round": 42,
"Data": "Ynl0ZSBhcnJheQ=="
}
```

## BlockStore

### ChainDeleteObj
Expand Down Expand Up @@ -680,6 +705,7 @@ Response:
```

### ChainGetRandomnessFromBeacon
Deprecated: Use StateGetRandomnessFromBeacon instead.


Perms: read
Expand All @@ -704,6 +730,7 @@ Inputs:
Response: `"Bw=="`

### ChainGetRandomnessFromTickets
Deprecated: Use StateGetRandomnessFromTickets instead.


Perms: read
Expand Down
15 changes: 15 additions & 0 deletions venus-shared/api/chain/v1/mock/mock_fullnode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions venus-shared/api/chain/v1/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-diff.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ github.com/filecoin-project/venus/venus-shared/api/chain/v0.FullNode <> github.c
github.com/filecoin-project/venus/venus-shared/api/chain/v1.FullNode <> github.com/filecoin-project/lotus/api.FullNode:
- AuthNew
- AuthVerify
+ BeaconGetEntry
+ BlockTime
- ChainBlockstoreInfo
- ChainCheckBlockstore
Expand Down
1 change: 1 addition & 0 deletions venus-shared/compatible-checks/api-perm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ v0: github.com/filecoin-project/venus/venus-shared/api/chain/v0 <> github.com/fi

v1: github.com/filecoin-project/venus/venus-shared/api/chain/v1 <> github.com/filecoin-project/lotus/api
- IActor.ListActor
- IBeacon.BeaconGetEntry
- IChainInfo.BlockTime
- IChainInfo.ChainGetRandomnessFromBeacon
- IChainInfo.ChainGetRandomnessFromTickets
Expand Down