Skip to content

Commit

Permalink
add enropy provider to fvm cotext
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarak Ben Youssef committed Aug 4, 2023
1 parent 32011e9 commit a4b7dbe
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions emulator/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,19 @@ func (h CadenceHook) Run(_ *zerolog.Event, level zerolog.Level, msg string) {
}
}

// `dummyEntropyProvider“ implements `environment.EntropyProvider`
// which provides a source of entropy to fvm context (required for Cadence's randomness).
type dummyEntropyProvider struct{}

var dummySource = make([]byte, 32)

func (gen *dummyEntropyProvider) RandomSource() ([]byte, error) {
return dummySource, nil
}

// make sure `dummyEntropyProvider“ implements `environment.EntropyProvider`
var _ environment.EntropyProvider = (*dummyEntropyProvider)(nil)

Check failure on line 544 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: environment.EntropyProvider

Check failure on line 544 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: environment.EntropyProvider

Check failure on line 544 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: environment.EntropyProvider

Check failure on line 544 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

undefined: environment.EntropyProvider

func configureFVM(blockchain *Blockchain, conf config, blocks *blocks) (*fvm.VirtualMachine, fvm.Context, error) {
vm := fvm.NewVirtualMachine()

Expand Down Expand Up @@ -566,6 +579,7 @@ func configureFVM(blockchain *Blockchain, conf config, blocks *blocks) (*fvm.Vir
fvm.WithAccountStorageLimit(conf.StorageLimitEnabled),
fvm.WithTransactionFeesEnabled(conf.TransactionFeesEnabled),
fvm.WithReusableCadenceRuntimePool(customRuntimePool),
fvm.WithEntropyProvider(&dummyEntropyProvider{}),

Check failure on line 582 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: fvm.WithEntropyProvider (typecheck)

Check failure on line 582 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: fvm.WithEntropyProvider) (typecheck)

Check failure on line 582 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

undefined: fvm.WithEntropyProvider) (typecheck)

Check failure on line 582 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

undefined: fvm.WithEntropyProvider
}

if !conf.TransactionValidationEnabled {
Expand Down

0 comments on commit a4b7dbe

Please sign in to comment.