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

Reuse calculated tx id in executor #1248

Merged
merged 7 commits into from
Jul 12, 2023

Conversation

MitchTurner
Copy link
Member

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update places like this?
image

@MitchTurner
Copy link
Member Author

Yes. I had it originally and then removed it because I thought there was some ordering issues, but it was a simple fix in the end.

@MitchTurner
Copy link
Member Author

Actually. I was right. The compute_inputs needs to happen before the into_checked_basic because the tx is being mutated.

So we can't get the tx id from the checked_tx, and if we were to add a tx_id calculation before compute_inputs it would get called twice every time. I recommend keeping it as is since it only get's called once, either when it errors or when it does the tx_check.

@xgreenx
Copy link
Collaborator

xgreenx commented Jul 12, 2023

The into_checked_basic shouldn't modify tx_id, otherwise something is wrong in our logic=D

@MitchTurner
Copy link
Member Author

Sorry. That's not what I'm saying.

compute_inputs modifies the tx. And that's the method that you are suggesting passing tx_id into. As you can see, the tests are failing if I do into_check_basic before compute_inputs.

If tx_id is calculated during into_check_basic and compute_inputs needs to happen before into_check_basic I don't recommend calculating tx_id before compute_inputs and only calling tx.id() if an error occurs.

That is how the current code works. So, I'm suggesting we don't make this change.

@xgreenx
Copy link
Collaborator

xgreenx commented Jul 12, 2023

Modification from compute_inputs doesn't affect transaction id. You don't need to do into_check_basic before

@MitchTurner
Copy link
Member Author

MitchTurner commented Jul 12, 2023

Right. But it always calculates and caches the tx_id during into_check_basic. So adding an additional tx.id() would be redundant.

In other words, can you explain what benefits we get from passing tx_id into compute_inputs instead of calculating it on the error? The only placecompute_inputs uses tx_id is in the error cases--which we can assume won't get called very often. I might be missing something.

@xgreenx
Copy link
Collaborator

xgreenx commented Jul 12, 2023

After refactoring the TxPool, we don't need to call into_check_basic, so in the future, we will use a cached value each time=)

The idea is to minimize the number of .id(&self.config.transaction_parameters.chain_id) in the code. Because without this change, we already use cached value everywhere. We receive transactions from TxPool, and their id is calculated there.

…or' into reuse-calculated-tx-id-in-executor

# Conflicts:
#	crates/fuel-core/src/executor.rs
@MitchTurner
Copy link
Member Author

Okay. Cool, if original_tx has a cached id, then I take it back. I'm comfortable with that!

@MitchTurner MitchTurner enabled auto-merge (squash) July 12, 2023 21:13
@MitchTurner MitchTurner merged commit 3615a24 into master Jul 12, 2023
16 of 22 checks passed
@MitchTurner MitchTurner deleted the reuse-calculated-tx-id-in-executor branch July 12, 2023 21:57
This was referenced Jul 12, 2023
xgreenx added a commit that referenced this pull request Jul 17, 2023
## Release v0.20.0

The release brings a couple of new breaking changes from the [`fuel-vm
0.35.0`](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.35.0) with
bugfixes. Check the description of the VM release for more details.

The `fuel-core` release mostly improved the internal codebase but also
brought some breaking changes:
- Removed `Trigger::Hybrid` PoA block trigger mode. Only
`Trigger::Instante` and `Trigger::Interval` are available for block
production now. The main mode for testnets and mainnet will be
`Interval`.
- Removed support for `OpaqueReceipt` and the `Receipt` type doesn't
have the `raw_payload` field anymore.
- A `Receipt` type got two new variants: `Mint` and `Burn`. The
corresponding opcodes emit these new events.
- The `AssetId` is derived from `ContractId` and additional nonce. So
the `ContractId` and `AssetId` can't be the same anymore.

## What's Changed
* bump rocksdb to enable compiling with GCC 13 by @segfault-magnet in
#1219
* setting peer reputation params by @leviathanbeak in
#1202
* Take into account the actually used gas by the transactions and fetch
more transaction by @xgreenx in
#1223
* Use production configuration for `fuel-core` during benches by
@xgreenx in #1227
* Speedup and stabilize unit and integration tests by @xgreenx in
#1231
* test: State benchmarks by @bvrooman in
#1226
* Remove hybrid PoA block trigger mode by @Dentosal in
#1232
* test: Benchmark contract state insertions with DB vs. DB transactions
by @bvrooman in #1230
* multiplatform docker builds by @Voxelot in
#1233
* Fix typo in architecture.md by @eltociear in
#1241
* Expose gas cost in chain info by @MitchTurner in
#1244
* Reuse calculated tx id in executor by @MitchTurner in
#1248
* Fix multi-platform images by @Voxelot in
#1251
* Add logging of the long GraphQL queries for future debug by
@MitchTurner in #1250
* Reused `CheckedTransaction` from transaction pool in the executor by
@xgreenx in #1249
* Bump `fuel-vm` to `0.35.0` version by @xgreenx in
#1256

## New Contributors
* @segfault-magnet made their first contribution in
#1219
* @eltociear made their first contribution in
#1241
* @MitchTurner made their first contribution in
#1244

**Full Changelog**:
v0.19.1...v0.20.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants