Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions services/requester/batch_tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (t *BatchTxPool) batchSubmitTransactionsForSameAddress(
return err
}

script := replaceAddresses(batchRunTxScript, t.config.FlowNetworkID)
script := replaceAddresses(runTxScript, t.config.FlowNetworkID)
flowTx, err := t.buildTransaction(
latestBlock,
account,
Expand Down Expand Up @@ -259,7 +259,7 @@ func (t *BatchTxPool) submitSingleTransaction(
latestBlock,
account,
script,
hexEncodedTx,
cadence.NewArray([]cadence.Value{hexEncodedTx}),
coinbaseAddress,
)
if err != nil {
Expand Down
35 changes: 0 additions & 35 deletions services/requester/cadence/batch_run.cdc

This file was deleted.

49 changes: 42 additions & 7 deletions services/requester/cadence/run.cdc
Original file line number Diff line number Diff line change
@@ -1,14 +1,49 @@
import EVM

transaction(hexEncodedTx: String, coinbase: String) {
transaction(hexEncodedTxs: [String], coinbase: String) {
execute {
let txResult = EVM.run(
tx: hexEncodedTx.decodeHex(),
let txs: [[UInt8]] = []
for tx in hexEncodedTxs {
txs.append(tx.decodeHex())
}

// If there's only one tx, use `EVM.run`.
// If there are more, then use `EVM.batchRun`
if txs.length == 1 {
let txResult = EVM.run(
tx: txs[0],
coinbase: EVM.addressFromString(coinbase)
)
assert(
txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)
return
}

let txResults = EVM.batchRun(
txs: txs,
coinbase: EVM.addressFromString(coinbase)
)
assert(
txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)

// If at least one of the EVM transactions in the batch is either
// failed or successful, in other words not invalid, we let the
// Cadence transaction succeed.
for txResult in txResults {
if txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful {
return
}
}

// Otherwise, all EVM transactions are invalid txs and can't be
// executed (such as nonce too low).
// In this case, we fail the Cadence transaction with the error
// message from the first EVM transaction.
for txResult in txResults {
assert(
txResult.status == EVM.Status.failed || txResult.status == EVM.Status.successful,
message: "evm_error=\(txResult.errorMessage);evm_error_code=\(txResult.errorCode)"
)
}
}
}
3 changes: 0 additions & 3 deletions services/requester/requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ var (
//go:embed cadence/run.cdc
runTxScript []byte

//go:embed cadence/batch_run.cdc
batchRunTxScript []byte

//go:embed cadence/get_latest_evm_height.cdc
getLatestEVMHeight []byte
)
Expand Down
2 changes: 1 addition & 1 deletion services/requester/single_tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (t *SingleTxPool) Add(
latestBlock,
account,
script,
hexEncodedTx,
cadence.NewArray([]cadence.Value{hexEncodedTx}),
coinbaseAddress,
)
if err != nil {
Expand Down