Skip to content

Commit

Permalink
fix vm bug: network version check (#4482)
Browse files Browse the repository at this point in the history
Co-authored-by: 一页素书 <2931107265@qq.com>
Co-authored-by: Mike <41407352+hunjixin@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 1, 2021
1 parent 3d0675f commit d5ea97d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/consensus/call_invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *Expected) CallWithGas(ctx context.Context, msg *types.UnsignedMessage,
NtwkVersionGetter: c.fork.GetNtwkVersion,
Rnd: &rnd,
BaseFee: ts.At(0).ParentBaseFee,
Epoch: ts.Height() + 1,
Epoch: ts.Height(),
GasPriceSchedule: c.gasPirceSchedule,
PRoot: stateRoot,
Bsstore: c.bstore,
Expand Down
3 changes: 2 additions & 1 deletion pkg/vm/vmcontext/runtime_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func (a *runtimeAdapter) NetworkVersion() network.Version {
func (a *runtimeAdapter) GetRandomnessFromBeacon(personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) abi.Randomness {
var err error
var res []byte
if randEpoch > a.ctx.vm.vmOption.Fork.GetForkUpgrade().UpgradeHyperdriveHeight {

if a.ctx.vm.vmOption.NtwkVersionGetter(a.ctx.vm.context, randEpoch) >= network.Version13 {
res, err = a.ctx.randSource.GetBeaconRandomnessLookingForward(a.Context(), personalization, randEpoch, entropy)
} else {
res, err = a.ctx.randSource.GetBeaconRandomnessLookingBack(a.Context(), personalization, randEpoch, entropy)
Expand Down

0 comments on commit d5ea97d

Please # to comment.