diff --git a/emulator/blockchain.go b/emulator/blockchain.go index c4f24f7a..4214603b 100644 --- a/emulator/blockchain.go +++ b/emulator/blockchain.go @@ -467,7 +467,10 @@ func (b *Blockchain) ReloadBlockchain() error { } 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 } @@ -808,7 +811,7 @@ func configureBootstrapProcedure(conf config, flowAccountKey flowgo.AccountPubli ) } -func configureTransactionValidator(conf config, blocks *blocks) *access.TransactionValidator { +func configureTransactionValidator(conf config, blocks *blocks) (*access.TransactionValidator, error) { return access.NewTransactionValidator( blocks, conf.GetChainID().Chain(), @@ -821,7 +824,9 @@ func configureTransactionValidator(conf config, blocks *blocks) *access.Transact CheckScriptsParse: true, MaxTransactionByteSize: flowgo.DefaultMaxTransactionByteSize, MaxCollectionByteSize: flowgo.DefaultMaxCollectionByteSize, + CheckPayerBalance: false, }, + nil, ) } @@ -1208,7 +1213,7 @@ func (b *Blockchain) addTransaction(tx flowgo.TransactionBody) error { return fmt.Errorf("failed to check storage for transaction %w", err) } - err = b.transactionValidator.Validate(&tx) + err = b.transactionValidator.Validate(context.Background(), &tx) if err != nil { return types.ConvertAccessError(err) } diff --git a/emulator/blocks.go b/emulator/blocks.go index 2570dba3..ea00951d 100644 --- a/emulator/blocks.go +++ b/emulator/blocks.go @@ -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 { diff --git a/go.mod b/go.mod index 8261683f..bb5976ae 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/logrusorgru/aurora v2.0.3+incompatible github.com/onflow/cadence v1.0.0-preview.38 github.com/onflow/crypto v0.25.1 - github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 + github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7 github.com/onflow/flow-go-sdk v1.0.0-preview.41 github.com/onflow/flow-nft/lib/go/contracts v1.2.1 @@ -153,7 +153,7 @@ require ( github.com/multiformats/go-varint v0.0.7 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/onflow/atree v0.7.0-rc.2 // indirect - github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect + github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.0 // indirect @@ -236,3 +236,5 @@ require ( nhooyr.io/websocket v1.8.7 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +replace github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7 => github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240718153829-58850e2c4673 diff --git a/go.sum b/go.sum index 1c8b8e23..6e071bee 100644 --- a/go.sum +++ b/go.sum @@ -979,6 +979,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-go v0.35.14-crescendo-preview.27.0.20240718153829-58850e2c4673 h1:1MSQFa16D9E2Cnqpc870iNLB080OuhAP0TDeJyJgMzo= +github.com/The-K-R-O-K/flow-go v0.35.14-crescendo-preview.27.0.20240718153829-58850e2c4673/go.mod h1:NKttW0i0DlJYxddJoyR+E4sukr8MeCiNvtSadnZrXjY= github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= @@ -2050,16 +2052,14 @@ github.com/onflow/cadence v1.0.0-preview.38/go.mod h1:jOwvPSSLTr9TvaKMs7KKiBYMmp github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= 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-core-contracts/lib/go/contracts v1.3.1 h1:q9tXLIALwQ76bO4bmSrhtTkyc2cZF4/gH11ix9E3F5k= +github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1/go.mod h1:u/mkP/B+PbV33tEG3qfkhhBlydSvAKxfLZSfB4lsJHg= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 h1:FfhMBAb78p6VAWkJ+iqdKLErGQVQgxk5w6DP5ZruWX8= +github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1/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= github.com/onflow/flow-ft/lib/go/templates v1.0.0/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE= -github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7 h1:ZlqdL88tBWCGqooqaFPgspwuwCPb+e2xE5imLEEYfTA= -github.com/onflow/flow-go v0.36.2-0.20240717214129-9ea6faeee3e7/go.mod h1:6M6tijXZLxQkzsF3IVIIuRk2lzHvMg2mVnirtLaMW18= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= github.com/onflow/flow-go-sdk v1.0.0-preview.41 h1:pOUAIQdlWuc90tQzYixCXkqmnoorDgsFxTu2J1wlhHA= github.com/onflow/flow-go-sdk v1.0.0-preview.41/go.mod h1:FyJiLluqK+sNo+ky9VU6HSwVkvhv5/fKH1sIKI1yrrI=