disable bal for transaction selection when not activated#9189
disable bal for transaction selection when not activated#9189jframe merged 5 commits intobesu-eth:mainfrom
Conversation
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
| maybeBlockAccessListBuilder = | ||
| protocolSpec | ||
| .getBlockAccessListFactory() | ||
| .filter(BlockAccessListFactory::isEnabled) |
There was a problem hiding this comment.
This should be BlockAccessListFactory::isForkEnabled - including BALs built blocks without the fork being active might lead to building invalid blocks.
There was a problem hiding this comment.
I agree so I think we should add the same check here
There was a problem hiding this comment.
Well, currently newProtocolSpec.getBlockAccessListFactory.isPresent() is equivalent to BlockAccessListFactory::isForkEnabled, because if the factory is present it means that the BAL fork is enabled. But it is true that this may not be true in general so the check should be more specific.
There was a problem hiding this comment.
modified the code in order to have a isForkActivated for block creation ; transaction evaluation and simulation/ To be safe for fusaka
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
jflo
left a comment
There was a problem hiding this comment.
I think this might work to clear fusaka, but will likely break other stuff. I suggest revisiting the design and removing any knowledge of "why" it is active from the BlockAccessListFactory
...n/java/org/hyperledger/besu/ethereum/blockcreation/txselection/BlockTransactionSelector.java
Show resolved
Hide resolved
ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/BlockSimulator.java
Show resolved
Hide resolved
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
Signed-off-by: Karim Taam <karim.t2am@gmail.com>
fab-10
left a comment
There was a problem hiding this comment.
LGTM, just a question and a suggestion
| for (final var pendingAction : selectedTxPendingActions) { | ||
| pendingAction.run(); | ||
| } |
There was a problem hiding this comment.
From what I can see there is no pending action that rely on the state to be committed, so it is fine to running the pending actions before the state commits.
| if (txWorldStateUpdater | ||
| instanceof StackedUpdater<?, ?> stackedUpdater) { | ||
| blockAccessListBuilder.addTransactionLevelAccessList( | ||
| transactionAccessList, stackedUpdater); |
There was a problem hiding this comment.
Why this check about the type? and if the type does not match it is fine to just ignore?
There was a problem hiding this comment.
For now we are not yet compatible with Journaled updater. This is a work that will have to do. For now, no particular problem because it's just experimental.
| maybeBlockAccessListBuilder = | ||
| protocolSpec | ||
| .getBlockAccessListFactory() |
There was a problem hiding this comment.
Non blocking suggestion, to keep the clean of all the checks about the presence or not of the BAL builder, what if instead having the factory that just return a NoOp BAL builder when it is disabled?
There was a problem hiding this comment.
nit: Also prefer the NoopBal approach.
nit: Whether Noop or Optional, I prefer that the fork-dependent wiring happens in MainnetProtocolSpecs rather than in-line in this constructor, since that is our common convention.
e.g. similar approach to NoBlobSchedule https://github.com/hyperledger/besu/blob/3227dd647d1b52c06fd1cd624ae0ad1d5577c413/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java#L81
There was a problem hiding this comment.
Looking at the code a bit more I see it is indeed wired into the MainnetProtocolSpecs futureEipsDefinition, so I'm not sure why we need the extra isForkActivated filter, shouldn't the class just not exist for Osaka?
There was a problem hiding this comment.
No, because for testing reasons for the moment the option can be activated by flag and also by fork. The idea is to be able to test BAL on the current mainnet too
There was a problem hiding this comment.
@mirgee Do you remember exactly why re used this solution. I forgot the main reason. At first there was a noop but that was changed.
There was a problem hiding this comment.
@matkt I am not sure I understand the question - what aspect of the solution are we talking about? There never was a noop builder in the first iteration. I think that the code can be refactored to use a noop builder, but I wouldn't say it's the first priority right now.
| if (txWorldStateUpdater instanceof StackedUpdater<?, ?> stackedUpdater) { | ||
| balBuilder.addTransactionLevelAccessList(transactionAccessList, stackedUpdater); | ||
| } |
There was a problem hiding this comment.
just a question. why was the balBuilder.addTransactionLevelAccessList call moved from here to later to the handleTransactionSelected method?
There was a problem hiding this comment.
Because that way we are sure to add only the transactions that are selected in the bal and not those that are in timeout. The reason for the bug you had.
siladu
left a comment
There was a problem hiding this comment.
Approving for expediency but couple of things to revisit, esp test coverage.
| maybeBlockAccessListBuilder = | ||
| protocolSpec | ||
| .getBlockAccessListFactory() |
There was a problem hiding this comment.
nit: Also prefer the NoopBal approach.
nit: Whether Noop or Optional, I prefer that the fork-dependent wiring happens in MainnetProtocolSpecs rather than in-line in this constructor, since that is our common convention.
e.g. similar approach to NoBlobSchedule https://github.com/hyperledger/besu/blob/3227dd647d1b52c06fd1cd624ae0ad1d5577c413/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/ProtocolSpecBuilder.java#L81
| maybeBlockAccessListBuilder = | ||
| protocolSpec | ||
| .getBlockAccessListFactory() |
There was a problem hiding this comment.
Looking at the code a bit more I see it is indeed wired into the MainnetProtocolSpecs futureEipsDefinition, so I'm not sure why we need the extra isForkActivated filter, shouldn't the class just not exist for Osaka?
| } | ||
|
|
||
| @Test | ||
| public void blockAccessListShouldNotIncludesAccountWithoutBalSupport() { |
There was a problem hiding this comment.
nit: This test doesn't appear to exercise the code that was causing the exception: #9186
(in BlockTransactionSelector.buildTransactionListForBlock)
Ideally, we'd ensure blockAccessListBuilder.build() never gets called.
There is a references test but we can't merge it yet. |
* disable bal for transaction selection when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * disable bal for block creation and simulator when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * update bal only for selected transaction Signed-off-by: Karim Taam <karim.t2am@gmail.com> * move pending task during block creation before commit for BAL Signed-off-by: Karim Taam <karim.t2am@gmail.com> --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Ali <alijakparov.kz@gmail.com>
* disable bal for transaction selection when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * disable bal for block creation and simulator when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * update bal only for selected transaction Signed-off-by: Karim Taam <karim.t2am@gmail.com> * move pending task during block creation before commit for BAL Signed-off-by: Karim Taam <karim.t2am@gmail.com> --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: Ali <alijakparov.kz@gmail.com> Signed-off-by: Ali Zhagparov <alijakparov.kz@gmail.com>
* disable bal for transaction selection when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * disable bal for block creation and simulator when not activated Signed-off-by: Karim Taam <karim.t2am@gmail.com> * update bal only for selected transaction Signed-off-by: Karim Taam <karim.t2am@gmail.com> * move pending task during block creation before commit for BAL Signed-off-by: Karim Taam <karim.t2am@gmail.com> --------- Signed-off-by: Karim Taam <karim.t2am@gmail.com> Signed-off-by: jflo <justin+github@florentine.us>
PR description
Should disable bal for transaction selection when not activated
Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTests