diff --git a/app/submodule/chain/chain_api.go b/app/submodule/chain/chain_api.go index 61aadda010..297d67611c 100644 --- a/app/submodule/chain/chain_api.go +++ b/app/submodule/chain/chain_api.go @@ -9,6 +9,7 @@ type chainAPI struct { // nolint: golint v1api.IActor v1api.IMinerState v1api.IChainInfo + v1api.IBeacon } var _ v1api.IChain = &chainAPI{} diff --git a/app/submodule/chain/chaininfo_api.go b/app/submodule/chain/chaininfo_api.go index ad8795c2a3..d129ba78d9 100644 --- a/app/submodule/chain/chaininfo_api.go +++ b/app/submodule/chain/chaininfo_api.go @@ -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) @@ -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) } diff --git a/fixtures/assets/asset.go b/fixtures/assets/asset.go index abba06c4f2..14ebc8d6e1 100644 --- a/fixtures/assets/asset.go +++ b/fixtures/assets/asset.go @@ -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) { @@ -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 diff --git a/fixtures/assets/car/butterflynet.car b/fixtures/assets/genesis-car/butterflynet.car similarity index 100% rename from fixtures/assets/car/butterflynet.car rename to fixtures/assets/genesis-car/butterflynet.car diff --git a/fixtures/assets/car/calibnet.car b/fixtures/assets/genesis-car/calibnet.car similarity index 100% rename from fixtures/assets/car/calibnet.car rename to fixtures/assets/genesis-car/calibnet.car diff --git a/fixtures/assets/car/forcenet.car b/fixtures/assets/genesis-car/forcenet.car similarity index 100% rename from fixtures/assets/car/forcenet.car rename to fixtures/assets/genesis-car/forcenet.car diff --git a/fixtures/assets/car/interopnet.car b/fixtures/assets/genesis-car/interopnet.car similarity index 100% rename from fixtures/assets/car/interopnet.car rename to fixtures/assets/genesis-car/interopnet.car diff --git a/fixtures/assets/car/mainnet.car b/fixtures/assets/genesis-car/mainnet.car similarity index 100% rename from fixtures/assets/car/mainnet.car rename to fixtures/assets/genesis-car/mainnet.car diff --git a/fixtures/assets/car/nerpanet.car b/fixtures/assets/genesis-car/nerpanet.car similarity index 100% rename from fixtures/assets/car/nerpanet.car rename to fixtures/assets/genesis-car/nerpanet.car diff --git a/pkg/consensus/block_validator.go b/pkg/consensus/block_validator.go index 7d8b4ab500..5d767c9011 100644 --- a/pkg/consensus/block_validator.go +++ b/pkg/consensus/block_validator.go @@ -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 { @@ -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) } diff --git a/pkg/messagepool/gas.go b/pkg/messagepool/gas.go index 738f0add84..4b5a5f1c4b 100644 --- a/pkg/messagepool/gas.go +++ b/pkg/messagepool/gas.go @@ -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 @@ -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) } @@ -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) diff --git a/tools/conformance/rand_record.go b/tools/conformance/rand_record.go index 59c798d2c1..4f46e3ab47 100644 --- a/tools/conformance/rand_record.go +++ b/tools/conformance/rand_record.go @@ -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 } @@ -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 } diff --git a/venus-shared/api/chain/v1/chain.go b/venus-shared/api/chain/v1/chain.go index 495be9f523..20b5e0ad66 100644 --- a/venus-shared/api/chain/v1/chain.go +++ b/venus-shared/api/chain/v1/chain.go @@ -21,6 +21,7 @@ import ( type IChain interface { IAccount IActor + IBeacon IMinerState IChainInfo } @@ -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 diff --git a/venus-shared/api/chain/v1/method.md b/venus-shared/api/chain/v1/method.md index 00d2fd32ad..e1264868a2 100644 --- a/venus-shared/api/chain/v1/method.md +++ b/venus-shared/api/chain/v1/method.md @@ -5,6 +5,8 @@ * [Actor](#Actor) * [ListActor](#ListActor) * [StateGetActor](#StateGetActor) +* [Beacon](#Beacon) + * [BeaconGetEntry](#BeaconGetEntry) * [BlockStore](#BlockStore) * [ChainDeleteObj](#ChainDeleteObj) * [ChainHasObj](#ChainHasObj) @@ -251,6 +253,29 @@ Response: } ``` +## Beacon + +### BeaconGetEntry +Deprecated: Use StateGetBeaconEntry instead. + + +Perms: read + +Inputs: +```json +[ + 10101 +] +``` + +Response: +```json +{ + "Round": 42, + "Data": "Ynl0ZSBhcnJheQ==" +} +``` + ## BlockStore ### ChainDeleteObj @@ -680,6 +705,7 @@ Response: ``` ### ChainGetRandomnessFromBeacon +Deprecated: Use StateGetRandomnessFromBeacon instead. Perms: read @@ -704,6 +730,7 @@ Inputs: Response: `"Bw=="` ### ChainGetRandomnessFromTickets +Deprecated: Use StateGetRandomnessFromTickets instead. Perms: read diff --git a/venus-shared/api/chain/v1/mock/mock_fullnode.go b/venus-shared/api/chain/v1/mock/mock_fullnode.go index e95040c48d..6b665a6dff 100644 --- a/venus-shared/api/chain/v1/mock/mock_fullnode.go +++ b/venus-shared/api/chain/v1/mock/mock_fullnode.go @@ -51,6 +51,21 @@ func (m *MockFullNode) EXPECT() *MockFullNodeMockRecorder { return m.recorder } +// BeaconGetEntry mocks base method. +func (m *MockFullNode) BeaconGetEntry(arg0 context.Context, arg1 abi.ChainEpoch) (*types.BeaconEntry, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "BeaconGetEntry", arg0, arg1) + ret0, _ := ret[0].(*types.BeaconEntry) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// BeaconGetEntry indicates an expected call of BeaconGetEntry. +func (mr *MockFullNodeMockRecorder) BeaconGetEntry(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BeaconGetEntry", reflect.TypeOf((*MockFullNode)(nil).BeaconGetEntry), arg0, arg1) +} + // BlockTime mocks base method. func (m *MockFullNode) BlockTime(arg0 context.Context) time.Duration { m.ctrl.T.Helper() diff --git a/venus-shared/api/chain/v1/proxy_gen.go b/venus-shared/api/chain/v1/proxy_gen.go index d637923bbc..92bb08c60c 100644 --- a/venus-shared/api/chain/v1/proxy_gen.go +++ b/venus-shared/api/chain/v1/proxy_gen.go @@ -68,6 +68,16 @@ func (s *IActorStruct) StateGetActor(p0 context.Context, p1 address.Address, p2 return s.Internal.StateGetActor(p0, p1, p2) } +type IBeaconStruct struct { + Internal struct { + BeaconGetEntry func(ctx context.Context, epoch abi.ChainEpoch) (*types.BeaconEntry, error) `perm:"read"` + } +} + +func (s *IBeaconStruct) BeaconGetEntry(p0 context.Context, p1 abi.ChainEpoch) (*types.BeaconEntry, error) { + return s.Internal.BeaconGetEntry(p0, p1) +} + type IMinerStateStruct struct { Internal struct { StateCirculatingSupply func(ctx context.Context, tsk types.TipSetKey) (abi.TokenAmount, error) `perm:"read"` @@ -355,6 +365,7 @@ func (s *IChainInfoStruct) VerifyEntry(p0, p1 *types.BeaconEntry, p2 abi.ChainEp type IChainStruct struct { IAccountStruct IActorStruct + IBeaconStruct IMinerStateStruct IChainInfoStruct } diff --git a/venus-shared/compatible-checks/api-diff.txt b/venus-shared/compatible-checks/api-diff.txt index 4558462fc4..db7f03492e 100644 --- a/venus-shared/compatible-checks/api-diff.txt +++ b/venus-shared/compatible-checks/api-diff.txt @@ -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 diff --git a/venus-shared/compatible-checks/api-perm.txt b/venus-shared/compatible-checks/api-perm.txt index cfe4ddae1a..05209f02df 100644 --- a/venus-shared/compatible-checks/api-perm.txt +++ b/venus-shared/compatible-checks/api-perm.txt @@ -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