Polygon Bhilai Fork Updates#15261
Conversation
yperbasis
left a comment
There was a problem hiding this comment.
Need to update (evm *EVM) precompile(addr common.Address) for Bhilai
yperbasis
left a comment
There was a problem hiding this comment.
isEoaCodeAllowed in filterBadTransactions should be extended to Bhilai
|
If maticnetwork/bor includes Bhilai into fork ID, then we need to do that in |
Fixed by: 9581c31 |
Fixed by: 9581c31 |
Fixed by: 9581c31 |
| } | ||
| if bhilaiBlock != nil { | ||
| if !bhilaiBlock.IsUint64() { | ||
| return nil, errors.New("agraBlock overflow") |
There was a problem hiding this comment.
small nit: it should be bhilaiBlock overflow
| // from non-primary producer. Such blocks will be rejected later when we know the succession | ||
| // number of the signer in the current sprint. | ||
| if header.Time-config.CalculatePeriod(header.Number.Uint64()) > uint64(time.Now().Unix()) { | ||
| return fmt.Errorf("%w: expected: %s(%s), got: %s", consensus.ErrFutureBlock, time.Unix(now.Unix(), 0), now, time.Unix(int64(header.Time), 0)) |
There was a problem hiding this comment.
Just a suggestion from previous experience -- we have found errors with unix based timestamps much easy to debug and understand instead of printing full time stamps.
Reference: 0xPolygon/bor@f735312
There was a problem hiding this comment.
You will notice that it actually prints both. This is because we have discovered an issue - particularly on amoy where we are receiving 'early packets', however these are actually withing a few milliseconds of the clock time.
time.Unix just truncates the nanosecond part of the timestamp meaning that you need to receive at a second's granularity if your clock is slow. The information is included in the error so it is clear what is going on.
I have not changed what is being checked as we're about to allow early headers which will make this go away.
Its part of a bigger occasional problem we see in erigon where we occasionally see gaps in processing headers. We have traced it down to these missing headers getting dropped and then on certain occasions not being recovered - we're still trying work out what is happening.
There was a problem hiding this comment.
I see that for Ethereum we have a very generous tolerance of 15 sec - see allowedFutureBlockTimeSeconds
| cfg.GasLimit, err = flags.GetUint64(MinerGasLimitFlag.Name) | ||
| if err != nil { | ||
| gasLimit, err := flags.GetUint64(MinerGasLimitFlag.Name) | ||
| if _, ok := err.(*strconv.NumError); ok || err == nil { |
There was a problem hiding this comment.
When can strconv.NumError happen?
There was a problem hiding this comment.
If the flag is not set then it will return a parse error, Because the value is "".
Ideally we should make this an optional flag and check for optionality - but I couldn't see an obvious way of doing that.
There was a problem hiding this comment.
Actually re-reviewing the doe I can just use is set. I'll change it.
|
|
||
| var delay time.Duration | ||
| // Sweet, the protocol permits us to sign the block, wait for our time | ||
| delay := time.Until(time.Unix(int64(header.Time), 0)) |
There was a problem hiding this comment.
[nitpicking] To avoid duplication we could keep this line, but override it if IsBhilai && successionNumber == 0
| // early block announcements. Note that this is a loose check and would allow early blocks | ||
| // from non-primary producer. Such blocks will be rejected later when we know the succession | ||
| // number of the signer in the current sprint. | ||
| if header.Time-config.CalculatePeriod(header.Number.Uint64()) > uint64(time.Now().Unix()) { |
There was a problem hiding this comment.
ValidateHeaderTime should use its now argument instead of time.Now()
This is a fix to PR #15261. Before this PR [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623) and [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) were not counted as activated in `(p *TxPool) validateTx` when [Bhilai](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-63.md) was activated.
Perhaps it doesn't matter much in practice, but this PR hardens the [implementation](#15261) of [PIP-66](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-66.md) to avoid potential `uint64` overflows.
Perhaps it doesn't matter much in practice, but this PR hardens the [implementation](#15261) of [PIP-66](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-66.md) to avoid potential `uint64` overflows. (cherry picked from commit bc4cb61)
This is a fix to PR #15261. Before this PR [EIP-7623](https://eips.ethereum.org/EIPS/eip-7623) and [EIP-7702](https://eips.ethereum.org/EIPS/eip-7702) were not counted as activated in `(p *TxPool) validateTx` when [Bhilai](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-63.md) was activated. (cherry picked from commit fc4f264)
This is a cherry pick from main of the #15261: Which implements the Bhilai fork changes as specified in: [PIP-63](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-63.md) and also the feature to allow early block announcements specified in: [PIP-66](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-66.md) The individual changes included here are: [PIP-60: Increase gas limit to 45M](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-60.md) [PIP-58: Increase BaseFeeChangeDenominator to 64](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-58.md) [EIP-2537: Precompile for BLS12-381 curve operations](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2537.md) [EIP-2935: Save historical block hashes in state](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2935.md) [EIP-7623: Increase calldata cost](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7623.md) [EIP-7702: Set EOA account code](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md) [(PIP-51)](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-51.md) [PIP-66: Allow early block announcements](https://github.com/maticnetwork/Polygon-Improvement-Proposals/blob/main/PIPs/PIP-66.md)
This PR implements the Bhilai fork changes as specified in:
PIP-63
and also the feature to allow early block announcements specified in:
PIP-66
The individual changes included here are:
PIP-60: Increase gas limit to 45M
PIP-58: Increase BaseFeeChangeDenominator to 64
EIP-2537: Precompile for BLS12-381 curve operations
EIP-2935: Save historical block hashes in state
EIP-7623: Increase calldata cost
EIP-7702: Set EOA account code (PIP-51)
PIP-66: Allow early block announcements