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

Fix block data cleaning from pools #2259

Merged
merged 33 commits into from
Sep 3, 2020

Conversation

SebastianMarian
Copy link
Contributor

  • Canceled the removal of block data at the commit time as this approach was forgotten here and its scope was to test an old issue which was proven later to be from somewhere else. As now, there are situations when block data (miniblocks and transactions) are intentionally broadcast with delay, the call of the removeBlockDataFromPool method at commit time, could remove from pool only partial data. Because of this, when the cleanupPools method is called for the headers behind final, the already removed block data at the commit time for earlier blocks, broke some links between all the components from these blocks and they could not be removed anymore completely from pools.

…ach was forgotten here and its scope was to test an old issue which was proven later to be from somewhere else. As now, there are situations when block data (miniblocks and transactions) are intentionally broadcast with delay, the call of the removeBlockDataFromPool method at commit time, could remove from pool only partial data. Because of this, when the cleanupPools method is called for the headers behind final, the already removed block data at the commit time for earlier blocks, broke some links between all the components from these blocks and they could not be removed anymore completely from pools.
@SebastianMarian SebastianMarian added the type:feature New feature or request label Aug 30, 2020
@SebastianMarian SebastianMarian self-assigned this Aug 30, 2020
@iulianpascalau iulianpascalau self-requested a review August 31, 2020 07:25
iulianpascalau
iulianpascalau previously approved these changes Aug 31, 2020
AdoAdoAdo
AdoAdoAdo previously approved these changes Aug 31, 2020
sasurobert
sasurobert previously approved these changes Aug 31, 2020
Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests failed

iulianpascalau
iulianpascalau previously approved these changes Aug 31, 2020
@@ -541,7 +541,7 @@

[BlockSizeThrottleConfig]
MinSizeInBytes = 104857 # 104857 is 10% from 1MB
MaxSizeInBytes = 943718 # 943718 is 90% from 1MB
MaxSizeInBytes = 891289 # 943718 is 85% from 1MB
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

sasurobert
sasurobert previously approved these changes Aug 31, 2020
AdoAdoAdo
AdoAdoAdo previously approved these changes Aug 31, 2020
…uted transaction is of type smart contract call/deploy

- made p2p `buffer too large` error message carry more info
- reverted throttling config changes
@iulianpascalau iulianpascalau dismissed stale reviews from AdoAdoAdo, sasurobert, and themself via 9e0cbba August 31, 2020 15:13
@@ -961,7 +961,12 @@ func (txs *transactions) createAndProcessMiniBlocksFromMe(
}

miniBlock.TxHashes = append(miniBlock.TxHashes, txHash)
txs.blockSizeComputation.AddNumTxs(1)
numTxs := 1
if core.IsSmartContractAddress(tx.RcvAddr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not the correct way to resolve it. Add blockSizeComputation component to smart contract result post processor and call AddNumTxs there when new cross shard SCRs are generated. It is not ensured that one tx = one scr

Copy link
Contributor

Choose a reason for hiding this comment

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

When we reach the postprocessor it is already too late as the transactions are already executed and we need to include the scr(s) as well. Indeed, it is not ensured that one tx = one scr but at least it will estimate better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually you will have nothing in post processor when you create a miniblock from me to meta with 27k stake SC calls. But at destination, in this case in meta, could result 54k txs (from which 27k are SCR). Because you need to process at least one mb completely this could result in a stuck situation. So, you also need to multiply at source, with 2 or more (in terms of size, depending of how many SCR could exist), all the SC calls when you create mbs from me. I think that this situation on normal cases should be solved by gas limit and in case of an invalid SC call, adding only one additional tx which simulates the scr created at destination, should be enough as in this case would be only one SCR for each invalid SC call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added block size computation taking in consideration also the post process mbs and txs when creating mbs dest me

iulianpascalau and others added 4 commits August 31, 2020 22:27
…ls' into Fix-block-data-cleaning-from-pools

# Conflicts:
#	process/block/preprocess/transactions.go
Copy link
Contributor

@sasurobert sasurobert left a comment

Choose a reason for hiding this comment

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

add unit test

txs.blockSizeComputation.AddNumTxs(1)
txs.blockSizeComputation.AddNumTxs(numScCalls)
Copy link
Contributor

Choose a reason for hiding this comment

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

numScCalls here is always 1. call txs.blockSizeComputation.AddNumTxs(1) instead of numSCCalls++. Although this protection should be only for cross shard and per shard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


mbs := interimProc.CreateAllInterMiniBlocks()
for _, mb := range mbs {
numTxs += len(mb.TxHashes)
Copy link
Contributor

Choose a reason for hiding this comment

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

do not add intra shard miniblocks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored

process/block/preprocess/transactions.go Outdated Show resolved Hide resolved
process/coordinator/process.go Show resolved Hide resolved
process/coordinator/process.go Outdated Show resolved Hide resolved
numTxs := 0
numCrossShardScCalls := 0

allTxs := make(map[string]data.TransactionHandler)
Copy link
Contributor

Choose a reason for hiding this comment

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

some unit tests would have been great

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would be added of course. Just waiting for the system test results

@@ -505,3 +505,7 @@ const MaxWaitingTimeToReceiveRequestedItem = 5 * time.Second
// DefaultLogProfileIdentifier represents the default log profile used when the logviewer/termui applications do not
// need to change the current logging profile
const DefaultLogProfileIdentifier = "[default log profile]"

// MultiplyFactorForScCall specifies the multiply factor, in terms of number, which should be used for how many sc calls
// could be included in one block (normal txs -> aprox. 27000, sc calls -> aprox. 2700 with value of 9 set below)
Copy link
Contributor

Choose a reason for hiding this comment

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

comment or value need to be adjusted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

{numNewMiniBlocks: 1, numNewTxs: 27757, expected: true, name: "with miniblocks 1 and txs 20078"},
{numNewMiniBlocks: 2, numNewTxs: 27756, expected: true, name: "with miniblocks 2 and txs 20077"},
{numNewMiniBlocks: 1, numNewTxs: 27756, expected: false, name: "with miniblocks 1 and txs 27756"},
{numNewMiniBlocks: 1, numNewTxs: 27757, expected: true, name: "with miniblocks 1 and txs 27757"},
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@@ -476,6 +477,43 @@ func (scr *smartContractResults) ProcessMiniBlock(miniBlock *block.MiniBlock, ha
&totalGasConsumedInSelfShard)

if err != nil {
//TODO: Remove this after testing
Copy link
Contributor

Choose a reason for hiding this comment

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

can't remove this as it is used for the debug print L499

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added to serves the prints and also the prints would been removed now

iulianpascalau
iulianpascalau previously approved these changes Sep 3, 2020
@@ -145,6 +151,13 @@ func (vip *validatorInfoPreprocessor) ProcessMiniBlock(miniBlock *block.MiniBloc
return nil, process.ErrValidatorInfoMiniBlockNotFromMeta
}

if vip.blockSizeComputation.IsMaxBlockSizeWithoutThrottleReached(1, len(miniBlock.TxHashes)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need another function in the blocksize estimator that will better handle the peer changes as those are not hashes. cc @sasurobert

Copy link
Contributor

Choose a reason for hiding this comment

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

Those are taken as it is. It is hard to estimate what is the actual value

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a TODO to fix the estimator. It is not complicated to do so in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The good part is that until then we can reduce if needed the MaxSizeInBytes from [BlockSizeThrottleConfig] in config.toml to 85% from 90% and in this way we should avoid any kind of "message too large" from p2p

sasurobert
sasurobert previously approved these changes Sep 3, 2020
Copy link
Contributor

@sasurobert sasurobert left a comment

Choose a reason for hiding this comment

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

CreateSCRIfError is wrongly constructed right now. It is an old code, which is not up to date. Will fix it in separate PR.

@@ -145,6 +151,13 @@ func (vip *validatorInfoPreprocessor) ProcessMiniBlock(miniBlock *block.MiniBloc
return nil, process.ErrValidatorInfoMiniBlockNotFromMeta
}

if vip.blockSizeComputation.IsMaxBlockSizeWithoutThrottleReached(1, len(miniBlock.TxHashes)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Those are taken as it is. It is hard to estimate what is the actual value

sasurobert
sasurobert previously approved these changes Sep 3, 2020
iulianpascalau
iulianpascalau previously approved these changes Sep 3, 2020
if !firstCrossShardScCallFound {
numNewMiniBlocks++
}
numNewTxs += 1 * core.MultiplyFactorForScCall
Copy link
Contributor

Choose a reason for hiding this comment

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

1*core.MultiplyFactorForScCall
why 1*x instead of simply x ?

Is it supposed to be changed later to a different value? then use a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just kept an old pattern when 1 was a variable named numTxs. I will change.

txs.blockSizeComputation.AddNumMiniBlocks(1)
}
//we need to increment this as to account for the corresponding SCR hash
txs.blockSizeComputation.AddNumTxs(1 * core.MultiplyFactorForScCall)
Copy link
Contributor

Choose a reason for hiding this comment

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

1*core.MultiplyFactorForScCall ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just kept an old pattern when 1 was a variable named numTxs. I will change.

@SebastianMarian SebastianMarian added the type:bug Something isn't working label Sep 3, 2020
Copy link
Contributor

@LucianMincu LucianMincu left a comment

Choose a reason for hiding this comment

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

System tests passed.

@LucianMincu LucianMincu merged commit a2c2833 into development Sep 3, 2020
@LucianMincu LucianMincu deleted the Fix-block-data-cleaning-from-pools branch September 3, 2020 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Something isn't working type:feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants