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

Update usage of tx validator interface #699

11 changes: 8 additions & 3 deletions emulator/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@
}

b.pendingBlock = newPendingBlock(latestBlock, latestLedger, b.clock)
b.transactionValidator = configureTransactionValidator(b.conf, blocks)
b.transactionValidator, err = configureTransactionValidator(b.conf, blocks)
if err != nil {
return err
}

return nil
}
Expand Down Expand Up @@ -808,8 +811,8 @@
)
}

func configureTransactionValidator(conf config, blocks *blocks) *access.TransactionValidator {
func configureTransactionValidator(conf config, blocks *blocks) (*access.TransactionValidator, error) {
return access.NewTransactionValidator(

Check failure on line 815 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

not enough return values

Check failure on line 815 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

not enough return values

Check failure on line 815 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

not enough return values
blocks,
conf.GetChainID().Chain(),
access.TransactionValidationOptions{
Expand All @@ -821,7 +824,9 @@
CheckScriptsParse: true,
MaxTransactionByteSize: flowgo.DefaultMaxTransactionByteSize,
MaxCollectionByteSize: flowgo.DefaultMaxCollectionByteSize,
CheckPayerBalance: false,

Check failure on line 827 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

unknown field CheckPayerBalance in struct literal of type "github.com/onflow/flow-go/access".TransactionValidationOptions

Check failure on line 827 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field CheckPayerBalance in struct literal of type "github.com/onflow/flow-go/access".TransactionValidationOptions

Check failure on line 827 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

unknown field CheckPayerBalance in struct literal of type "github.com/onflow/flow-go/access".TransactionValidationOptions
},
nil,

Check failure on line 829 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

too many arguments in call to access.NewTransactionValidator

Check failure on line 829 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

too many arguments in call to access.NewTransactionValidator

Check failure on line 829 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

too many arguments in call to access.NewTransactionValidator
)
}

Expand Down Expand Up @@ -1208,7 +1213,7 @@
return fmt.Errorf("failed to check storage for transaction %w", err)
}

err = b.transactionValidator.Validate(&tx)
err = b.transactionValidator.Validate(context.Background(), &tx)

Check failure on line 1216 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Test

too many arguments in call to b.transactionValidator.Validate

Check failure on line 1216 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

too many arguments in call to b.transactionValidator.Validate

Check failure on line 1216 in emulator/blockchain.go

View workflow job for this annotation

GitHub Actions / Lint

too many arguments in call to b.transactionValidator.Validate
if err != nil {
return types.ConvertAccessError(err)
}
Expand Down
9 changes: 9 additions & 0 deletions emulator/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ func (b *blocks) FinalizedHeader() (*flowgo.Header, error) {
return block.Header, nil
}

func (b *blocks) SealedHeader() (*flowgo.Header, error) {
block, err := b.blockchain.storage.LatestBlock(context.Background())
if err != nil {
return nil, err
}

return block.Header, nil
}

// We don't have to do anything complex here, as emulator does not fork the chain
func (b *blocks) ByHeightFrom(height uint64, header *flowgo.Header) (*flowgo.Header, error) {
if height > header.Height {
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,7 @@ require (
nhooyr.io/websocket v1.8.7 // indirect
rsc.io/tmplfunc v0.0.3 // indirect
)

replace github.com/onflow/flow-go v0.35.14-crescendo-preview.27 => github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240705100918-3f0e13f6872c

replace github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 => github.com/The-K-R-O-K/flow-core-contracts/lib/go/templates v0.15.2-0.20240624091211-1812579d3242
illia-malachyn marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,8 @@ github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMx
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/The-K-R-O-K/flow-core-contracts/lib/go/templates v0.15.2-0.20240624091211-1812579d3242 h1:7vLo/AXTu0QdiRE04o1gctyB+u7NQz6K9GqENjW2O8Q=
github.com/The-K-R-O-K/flow-core-contracts/lib/go/templates v0.15.2-0.20240624091211-1812579d3242/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw=
github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40=
github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o=
Expand Down Expand Up @@ -2057,8 +2059,6 @@ github.com/onflow/crypto v0.25.1 h1:0txy2PKPMM873JbpxQNbJmuOJtD56bfs48RQfm0ts5A=
github.com/onflow/crypto v0.25.1/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 h1:cq3RfBr9TnTSnsGlUHMjMGZib24Horfb1XJqMpkN5ew=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 h1:aMFJdB2CW+Dzm+AJ5QN6J1yWh+a0l2RxHN2/TtLaXUo=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0/go.mod h1:NgbMOYnMh0GN48VsNKZuiwK7uyk38Wyo8jN9+C9QE30=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 h1:mToacZ5NWqtlWwk/7RgIl/jeKB/Sy/tIXdw90yKHcV0=
github.com/onflow/flow-ft/lib/go/contracts v1.0.0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
github.com/onflow/flow-ft/lib/go/templates v1.0.0 h1:6cMS/lUJJ17HjKBfMO/eh0GGvnpElPgBXx7h5aoWJhs=
Expand Down
Loading