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

Implement EIP-1559 feature #1120

Merged
merged 179 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
1922339
Move PolyBFT to Edge (#774)
Nemanja0x Oct 13, 2022
d5ff74c
Build block with Txs in PolyBFT (#789)
igorcrevar Oct 17, 2022
069a063
EVM-48: Add RootChain helper (#773)
begmaroman Oct 18, 2022
2260c0b
EVM-57 PolyBft state transactions introduction (#809)
igorcrevar Oct 18, 2022
d862307
Migrate polybft e2e framework to edge (#797)
vcastellm Oct 21, 2022
417b250
v3 smart contracts integration (#796)
Stefan-Ethernal Oct 24, 2022
4609779
EVM-129 Implement bridge workflow (#828)
Stefan-Ethernal Oct 25, 2022
c9b71a1
Transfer unit tests from v3 to Edge (#825)
Stefan-Ethernal Oct 25, 2022
ac2f523
[Checkpointing] `ExitEvent` storage and proof generation (#838)
goran-ethernal Oct 31, 2022
dec0e88
Checkpoint data signing (#840)
Stefan-Ethernal Oct 31, 2022
d53d549
[Checkpoints] Parse receipt logs and insert new exit events (#852)
goran-ethernal Nov 2, 2022
ebbc058
Consolidate BLS verification ABI type (#867)
Stefan-Ethernal Nov 2, 2022
8f7fc4a
Checkpoint submission (#861)
Stefan-Ethernal Nov 8, 2022
4afe707
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 8, 2022
8db3965
Mock Host implementation in native transfer test (#887)
Stefan-Ethernal Nov 9, 2022
2f06ecd
Implement the logic for quorum check (#837)
vcastellm Nov 10, 2022
234eacb
Integrate go-ibft consensus engine to polybft consensus protocol (#891)
Stefan-Ethernal Nov 10, 2022
da337f6
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 10, 2022
19de4c6
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 10, 2022
455f185
Remove Polybft dummy smart contracts (#909)
Stefan-Ethernal Nov 15, 2022
0ab9ae7
Change ValidatorMetadata methods to pointer receivers (#911)
Stefan-Ethernal Nov 16, 2022
d67d898
EVM-152 Fix Unit Tests (#910)
igorcrevar Nov 16, 2022
3335564
adding devnet-v3 workflow for parity testing. Adding needed secrets f…
epikichi Nov 16, 2022
8627f12
Introduce local development cluster script (#912)
vcastellm Nov 16, 2022
4a3f562
Fix assigned boot nodes port number in genesis (#930)
Stefan-Ethernal Nov 18, 2022
a191a54
Local cluster - adapt port for ibft to polybft (#931)
vcastellm Nov 18, 2022
edf9d96
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 18, 2022
2968d5f
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 21, 2022
db63825
Fix unit test for event tracker (#935)
Stefan-Ethernal Nov 21, 2022
26663db
EVM-232 Keep polybft bls and ecdsa keys in separate secrets manager n…
igorcrevar Nov 23, 2022
64f728a
Track updates for validators (#939)
Stefan-Ethernal Nov 23, 2022
3ed0370
Epikichi/edge 973 change v3 parity workflow to devnet (#957)
epikichi Nov 25, 2022
e7ff3f3
EVM-220 TestClusterBlockSync/BLS fails in voting power branch (#926)
igorcrevar Nov 28, 2022
b8d35ac
Fix data race to polybft unit test (#965)
0xSasaPrsic Nov 28, 2022
b8ecb2b
Polybft voting power (#944)
Stefan-Ethernal Nov 28, 2022
1e4a66a
Align `v3-parity` with `develop` branch (#971)
Stefan-Ethernal Nov 28, 2022
b544aa3
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Nov 28, 2022
0ee71ed
Fix e2e tests
Stefan-Ethernal Nov 28, 2022
e5688ba
Set address to the result instance on applyCreate
Stefan-Ethernal Nov 29, 2022
07ce7e6
Remove State Sync execution step (#964)
vcastellm Nov 29, 2022
e96eeda
Replace BLS library with github.com/kilic/bn254 (#978)
igorcrevar Nov 30, 2022
a219437
Integrate with CheckpointManager.sol (#952)
goran-ethernal Nov 30, 2022
82fd78d
Merge remote-tracking branch 'origin/develop' into feature/v3-parity
goran-ethernal Nov 30, 2022
f33af57
Change genesis premine logic (#981)
Stefan-Ethernal Dec 1, 2022
4828279
Fix data race in fsm (#982)
0xSasaPrsic Dec 1, 2022
d239096
Removing `GenesisTarget` and adding the `NodeID` field to `Validator`…
vcastellm Dec 1, 2022
16463dd
Provide rootchain IP address from CLI (#989)
Stefan-Ethernal Dec 5, 2022
13b8885
Added london hardfork to the chain config (#999)
begmaroman Dec 6, 2022
49ae19d
Fix pending checkpoints submission (#992)
Stefan-Ethernal Dec 6, 2022
7a34b52
Update core-contracts (#1007)
Stefan-Ethernal Dec 7, 2022
1b8e7a5
Bundle build fix (#1014)
goran-ethernal Dec 8, 2022
12a0227
Check for nil proposal (#1009)
goran-ethernal Dec 8, 2022
dc17eaf
Remove gasLimit and gas fields from txrelayer call (#1020)
ferranbt Dec 8, 2022
aa1365d
Add default gas and gasPrice to local transactions (#1021)
ferranbt Dec 8, 2022
9e4ec91
Use geth console fork as default with flag to disable (#1022)
ferranbt Dec 8, 2022
74cbed3
Checkpoint submission e2e test (#990)
Stefan-Ethernal Dec 9, 2022
47f134e
Merge branch 'develop' into feature/v3-parity
Dec 9, 2022
9ad22d9
git modules: shallow and fix branch (#987)
JekaMas Dec 12, 2022
b0a8f1e
Remove bool return value from deliverMessage signature (#1027)
Stefan-Ethernal Dec 12, 2022
ffc8967
Fix/immutable trie race (#1017)
0xSasaPrsic Dec 12, 2022
1c7416d
Use total stake for voting power (#1038)
Stefan-Ethernal Dec 13, 2022
06aee78
RLP Marshal/Unmarshal update field in `ValidatorSetDelta` (#1026)
Stefan-Ethernal Dec 13, 2022
93ad4a0
Remove unused fields (#1039)
Stefan-Ethernal Dec 13, 2022
d0074e6
Introduce metrics for BoltDB for the state (#1045)
begmaroman Dec 13, 2022
c75d2ec
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Dec 13, 2022
84ef530
Expose `PolyBFT` metrics to Prometheus API (#1040)
Stefan-Ethernal Dec 14, 2022
b3543ca
EVM-308 Add commands we are missing (#1050)
goran-ethernal Dec 15, 2022
185e85a
Fix loop closure violations in unit tests (#1053)
Stefan-Ethernal Dec 16, 2022
05fb856
Integrate L2 exit workflow (#1024)
b00ris Dec 16, 2022
a8ff39c
Add pending checkpoints assertions to checkpoint submission e2e test …
Stefan-Ethernal Dec 16, 2022
e993b3b
Decouple rootchain contracts deployment from development environment …
Stefan-Ethernal Dec 16, 2022
e3e38c2
EVM-302 Save proposer priorities after each block (#1018)
igorcrevar Dec 19, 2022
c302a6c
Remove GossipMessage (#1057)
Stefan-Ethernal Dec 19, 2022
5f5bcf8
Consolidate `ExtendByteSlice` implementations (#1058)
Stefan-Ethernal Dec 19, 2022
b51b12b
Remove readContractBytecode (#1061)
Stefan-Ethernal Dec 20, 2022
722ef64
Evm 303: Fix race conditions after a block is inserted (#1047)
Nemanja0x Dec 20, 2022
cafd3ac
Feature/validator set changes (#1048)
0xSasaPrsic Dec 20, 2022
0c09cbc
Remove code related to bundles for state syncs (#1013)
vcastellm Dec 21, 2022
e6f620f
Create a full block object during polybft (#1063)
ferranbt Dec 21, 2022
a62ff6f
Fix segmentation fault panic on `ValidateSender` (#1054)
Stefan-Ethernal Dec 22, 2022
a86be75
RFC173 Checkpoint consensus issue (#1064)
goran-ethernal Dec 22, 2022
b321b43
Fix uptime total blocks calculation (#1069)
Stefan-Ethernal Dec 23, 2022
7ed9cea
Implement the relayer (#1044)
vcastellm Dec 23, 2022
a9646bf
Immutable trie simplification (#1068)
0xSasaPrsic Dec 23, 2022
32bc71a
Remove voting power scaling (#1060)
Stefan-Ethernal Dec 23, 2022
ad329a9
Epikichi/edge 988 add polybft consensus support to edge (#1051)
epikichi Dec 26, 2022
125489e
Implement `TestE2E_Bridge_ChangeVotingPower` (#1075)
Stefan-Ethernal Dec 28, 2022
b29ef26
Remove unnecessary panics from polybft (#1077)
Stefan-Ethernal Dec 29, 2022
a65d2d0
Dynamic epoch size (#897)
goran-ethernal Dec 30, 2022
4c5d0d9
Feature - State Sync manager (#1067)
ferranbt Jan 3, 2023
474978c
Core contracts to dev-audit (#1095)
vcastellm Jan 5, 2023
ff46c5f
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Jan 9, 2023
036644a
Implement `Stringer` interface in `AccountSet` (#1103)
Stefan-Ethernal Jan 9, 2023
7efa69f
Add disclaimer message when running polybft consensus protocol (#1107)
Stefan-Ethernal Jan 10, 2023
8aaae66
Register validator e2e test (#1084)
Stefan-Ethernal Jan 10, 2023
b099147
Handled go routines in event tracker (#1080)
Stefan-Ethernal Jan 10, 2023
9e9bd63
Multiple state sync commitments per epoch (#1083)
goran-ethernal Jan 11, 2023
6e8478a
Merge branch 'develop' into feature/v3-parity
Jan 12, 2023
217beb4
Return FullBlock from syncer (#1110)
goran-ethernal Jan 12, 2023
3006cb3
EVM-356 Update checkpoint out of fsm (#1113)
goran-ethernal Jan 13, 2023
ccc2897
Move BuildEventRoot to checkpointManager (#1115)
goran-ethernal Jan 13, 2023
bfbbce0
Initialize `closeCh` in `stateSyncManager` (#1116)
Stefan-Ethernal Jan 13, 2023
93555ea
Introduce dynamic fee tx type (#1111)
begmaroman Jan 13, 2023
186aeaa
Move GenerateExitProof to checkpointManager (#1118)
goran-ethernal Jan 16, 2023
a3cabc4
Merge remote-tracking branch 'origin/feature/v3-parity' into feature/…
begmaroman Jan 16, 2023
3c6e048
Invert logical condition in `WaitUntil` functions (#1123)
Stefan-Ethernal Jan 16, 2023
3f29527
Fix flaky register validator e2e test (#1122)
Stefan-Ethernal Jan 16, 2023
030cd76
TestE2E_Bridge_L2toL1Exit to work with multiple users (#1132)
Nemanja0x Jan 17, 2023
ce86fab
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Jan 18, 2023
923b9a5
Use PostBlock handler in ProposerCalculator (#1139)
goran-ethernal Jan 18, 2023
86052c2
Add missing cluster stop invocations in e2e tests (#1138)
Stefan-Ethernal Jan 18, 2023
e2025a8
Optimized docker build in docker-compose (#1135)
ZeljkoBenovic Jan 19, 2023
b37baab
Merge branch 'develop' into feature/v3-parity
Jan 19, 2023
2ed340b
Validator unstake e2e test (#1112)
Stefan-Ethernal Jan 19, 2023
9244f36
E2E Relayer (#1131)
vcastellm Jan 20, 2023
ccea1bd
BuildProofs for missed commitments (#1141)
goran-ethernal Jan 20, 2023
c2e3e6e
EVM-360 Invalid state root error on v0.7.1-alpha2 (#1133)
igorcrevar Jan 20, 2023
afac193
Rely on contracts api package when dealing with ABI abstractions (#1144)
Stefan-Ethernal Jan 20, 2023
36821be
Merge remote-tracking branch 'origin/feature/v3-parity' into feature/…
begmaroman Jan 23, 2023
3032df9
Align RLP marshaling logic according to eip-2718 (#1114)
begmaroman Jan 23, 2023
0e73b56
Merge remote-tracking branch 'origin/feature/v3-parity' into feature/…
begmaroman Jan 24, 2023
adda543
Synced with marent
begmaroman Jan 24, 2023
8048390
Synced with marent
begmaroman Jan 24, 2023
60c5600
EVM-360 e2e test (#1158)
igorcrevar Jan 24, 2023
8c63fe6
Merge branch 'develop' into feature/v3-parity
Stefan-Ethernal Jan 25, 2023
bf5ac4d
EVM-353 Different voting power property based test (#1149)
igorcrevar Jan 25, 2023
28f106a
Remove GetNonce function (#1165)
Stefan-Ethernal Jan 26, 2023
f0275ea
Expose ValidatorInfo struct (#1162)
Stefan-Ethernal Jan 26, 2023
c46ed37
Feature contractsapi gen (#1062)
ferranbt Jan 26, 2023
2d5863a
TestCommitEpoch unit test (#1167)
Nemanja0x Jan 27, 2023
b3a0773
EVM-395 Implement RFC-175 BLS integration (#1161)
igorcrevar Jan 27, 2023
5b3b614
Merge branch 'feature/v3-parity' into feature/EVM-262-EIP-1559
begmaroman Jan 27, 2023
ccae4e4
Introduce base fee (#1176)
begmaroman Feb 2, 2023
2e0b527
Introduce burn contract address (#1192)
begmaroman Feb 6, 2023
866c3cf
Update state transition logic according to EIP-1559 (#1204)
begmaroman Feb 8, 2023
208a9ee
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Feb 8, 2023
8005846
Update RLP marshaling for dynamic fee tx (#1237)
begmaroman Feb 20, 2023
319fecb
Added dynamic fees to jsonrpc of the transaction (#1239)
begmaroman Feb 20, 2023
af24049
Added base fee to the genesis head object #1240
begmaroman Feb 20, 2023
6595d58
Added dynamic fees validation to tx pool and state executor (#1241)
begmaroman Feb 20, 2023
652f0ad
Pass base fee to tx pool (#1243)
begmaroman Feb 21, 2023
6d0c5cc
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Feb 24, 2023
fc95144
Implement EIP-1559 tx signer (#1230)
begmaroman Feb 24, 2023
516029d
Added a function to calculate gas price if not provided (#1210)
begmaroman Feb 27, 2023
b55db80
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Feb 28, 2023
1d65258
Merge remote-tracking branch 'origin/feature/EVM-262-EIP-1559' into f…
begmaroman Feb 28, 2023
0a06379
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Mar 9, 2023
4f75ed5
Add burn contract to tests (#1281)
begmaroman Mar 14, 2023
d5f891d
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Mar 15, 2023
dcdcf46
Merge branch 'feature/EVM-262-EIP-1559' of ssh://github.com/0xPolygon…
begmaroman Mar 15, 2023
8152ca2
Fixed linter
begmaroman Mar 15, 2023
b71bbbb
Update tx pool ordering logic according to EIP-1559 (#1249)
begmaroman Mar 15, 2023
e1a2b8e
Add EIP-1559 tests to e2e framework (#1297)
begmaroman Mar 16, 2023
eec4344
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Mar 21, 2023
17e2ba8
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Mar 23, 2023
91122bc
Fixed linter
begmaroman Mar 23, 2023
a2217ec
Updated polybft e2e tests to include dynamic fees tx (#1308)
begmaroman Mar 23, 2023
68089ac
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Mar 28, 2023
9af1b7d
Fixed nit
begmaroman Mar 28, 2023
68ecd37
Fixed test
begmaroman Mar 28, 2023
7bd4262
Fixed linter
begmaroman Mar 28, 2023
279313f
Fixed linter
begmaroman Mar 28, 2023
a4c85d9
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Apr 5, 2023
f247ea9
Synced with develop
begmaroman Apr 5, 2023
6a0761b
Move base fee elasticity multiplier to genesis file (#1362)
begmaroman Apr 7, 2023
c9368f5
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Apr 11, 2023
384504a
Removed eip1559 burn contract from contracts gen
begmaroman Apr 11, 2023
05f9ac8
Added more tests
begmaroman Apr 11, 2023
91f63ce
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Apr 21, 2023
bf06740
Synced with develop
begmaroman Apr 21, 2023
685c574
Addressing comments
begmaroman Apr 24, 2023
c214861
Merge remote-tracking branch 'origin/develop' into feature/EVM-262-EI…
begmaroman Apr 24, 2023
66ec804
Fixed linter
begmaroman Apr 24, 2023
31ef286
Use block number as uin64 in burn contract addresses map
begmaroman Apr 24, 2023
947fd62
Minor updates
begmaroman Apr 24, 2023
79bd35f
Minor update
begmaroman Apr 24, 2023
970dc07
Minor update
begmaroman Apr 24, 2023
a4f78fd
Minor update
begmaroman Apr 24, 2023
132e04e
Added tx type check if in pool
begmaroman Apr 24, 2023
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
Prev Previous commit
Next Next commit
Return FullBlock from syncer (#1110)
* Return FullBlock from syncer

* Comments fix

* Comments fix

* Extract common parts of WriteBlock and WriteFullBlock

* Revert "Extract common parts of WriteBlock and WriteFullBlock"

This reverts commit 62166e6.

Co-authored-by: Stefan Negovanović <[email protected]>
  • Loading branch information
goran-ethernal and Stefan-Ethernal committed Jan 12, 2023
commit 217beb4802413ed030fff6eb235c1d8483542545
4 changes: 2 additions & 2 deletions archive/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type blockchainInterface interface {
GetBlockByNumber(uint64, bool) (*types.Block, bool)
GetHashByNumber(uint64) types.Hash
WriteBlock(*types.Block, string) error
VerifyFinalizedBlock(*types.Block) error
VerifyFinalizedBlock(*types.Block) (*types.FullBlock, error)
}

// RestoreChain reads blocks from the archive and write to the chain
Expand Down Expand Up @@ -78,7 +78,7 @@ func importBlocks(chain blockchainInterface, blockStream *blockStream, progressi
nextBlock := firstBlock

for {
if err := chain.VerifyFinalizedBlock(nextBlock); err != nil {
if _, err := chain.VerifyFinalizedBlock(nextBlock); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions archive/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (m *mockChain) WriteBlock(block *types.Block, _ string) error {
return nil
}

func (m *mockChain) VerifyFinalizedBlock(block *types.Block) error {
return nil
func (m *mockChain) VerifyFinalizedBlock(block *types.Block) (*types.FullBlock, error) {
return &types.FullBlock{Block: block}, nil
}

func (m *mockChain) SubscribeEvents() blockchain.Subscription {
Expand Down
40 changes: 22 additions & 18 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,44 +679,48 @@ func (b *Blockchain) WriteHeadersWithBodies(headers []*types.Header) error {
// outside the method call
func (b *Blockchain) VerifyPotentialBlock(block *types.Block) error {
// Do just the initial block verification
return b.verifyBlock(block)
_, err := b.verifyBlock(block)

return err
}

// VerifyFinalizedBlock verifies that the block is valid by performing a series of checks.
// It is assumed that the block status is sealed (committed)
func (b *Blockchain) VerifyFinalizedBlock(block *types.Block) error {
func (b *Blockchain) VerifyFinalizedBlock(block *types.Block) (*types.FullBlock, error) {
// Make sure the consensus layer verifies this block header
if err := b.consensus.VerifyHeader(block.Header); err != nil {
return fmt.Errorf("failed to verify the header: %w", err)
return nil, fmt.Errorf("failed to verify the header: %w", err)
}

// Do the initial block verification
if err := b.verifyBlock(block); err != nil {
return err
receipts, err := b.verifyBlock(block)
if err != nil {
return nil, err
}

return nil
return &types.FullBlock{Block: block, Receipts: receipts}, nil
}

// verifyBlock does the base (common) block verification steps by
// verifying the block body as well as the parent information
func (b *Blockchain) verifyBlock(block *types.Block) error {
func (b *Blockchain) verifyBlock(block *types.Block) ([]*types.Receipt, error) {
// Make sure the block is present
if block == nil {
return ErrNoBlock
return nil, ErrNoBlock
}

// Make sure the block is in line with the parent block
if err := b.verifyBlockParent(block); err != nil {
return err
return nil, err
}

// Make sure the block body data is valid
if err := b.verifyBlockBody(block); err != nil {
return err
receipts, err := b.verifyBlockBody(block)
if err != nil {
return nil, err
}

return nil
return receipts, nil
}

// verifyBlockParent makes sure that the child block is in line
Expand Down Expand Up @@ -774,7 +778,7 @@ func (b *Blockchain) verifyBlockParent(childBlock *types.Block) error {
// - The trie roots match up (state, transactions, receipts, uncles)
// - The receipts match up
// - The execution result matches up
func (b *Blockchain) verifyBlockBody(block *types.Block) error {
func (b *Blockchain) verifyBlockBody(block *types.Block) ([]*types.Receipt, error) {
// Make sure the Uncles root matches up
if hash := buildroot.CalculateUncleRoot(block.Uncles); hash != block.Header.Sha3Uncles {
b.logger.Error(fmt.Sprintf(
Expand All @@ -783,7 +787,7 @@ func (b *Blockchain) verifyBlockBody(block *types.Block) error {
block.Header.Sha3Uncles,
))

return ErrInvalidSha3Uncles
return nil, ErrInvalidSha3Uncles
}

// Make sure the transactions root matches up
Expand All @@ -794,21 +798,21 @@ func (b *Blockchain) verifyBlockBody(block *types.Block) error {
block.Header.TxRoot,
))

return ErrInvalidTxRoot
return nil, ErrInvalidTxRoot
}

// Execute the transactions in the block and grab the result
blockResult, executeErr := b.executeBlockTransactions(block)
if executeErr != nil {
return fmt.Errorf("unable to execute block transactions, %w", executeErr)
return nil, fmt.Errorf("unable to execute block transactions, %w", executeErr)
}

// Verify the local execution result with the proposed block data
if err := blockResult.verifyBlockResult(block); err != nil {
return fmt.Errorf("unable to verify block execution result, %w", err)
return nil, fmt.Errorf("unable to verify block execution result, %w", err)
}

return nil
return blockResult.Receipts, nil
}

// verifyBlockResult verifies that the block transaction execution result
Expand Down
15 changes: 10 additions & 5 deletions blockchain/blockchain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,8 @@ func TestBlockchain_VerifyBlockBody(t *testing.T) {
},
}

assert.ErrorIs(t, blockchain.verifyBlockBody(block), ErrInvalidSha3Uncles)
_, err = blockchain.verifyBlockBody(block)
assert.ErrorIs(t, err, ErrInvalidSha3Uncles)
})

t.Run("Invalid Transactions root", func(t *testing.T) {
Expand All @@ -1219,7 +1220,8 @@ func TestBlockchain_VerifyBlockBody(t *testing.T) {
},
}

assert.ErrorIs(t, blockchain.verifyBlockBody(block), ErrInvalidTxRoot)
_, err = blockchain.verifyBlockBody(block)
assert.ErrorIs(t, err, ErrInvalidTxRoot)
})

t.Run("Invalid execution result - missing parent", func(t *testing.T) {
Expand All @@ -1246,7 +1248,8 @@ func TestBlockchain_VerifyBlockBody(t *testing.T) {
},
}

assert.ErrorIs(t, blockchain.verifyBlockBody(block), ErrParentNotFound)
_, err = blockchain.verifyBlockBody(block)
assert.ErrorIs(t, err, ErrParentNotFound)
})

t.Run("Invalid execution result - unable to fetch block creator", func(t *testing.T) {
Expand Down Expand Up @@ -1285,7 +1288,8 @@ func TestBlockchain_VerifyBlockBody(t *testing.T) {
},
}

assert.ErrorIs(t, blockchain.verifyBlockBody(block), errBlockCreatorNotFound)
_, err = blockchain.verifyBlockBody(block)
assert.ErrorIs(t, err, errBlockCreatorNotFound)
})

t.Run("Invalid execution result - unable to execute transactions", func(t *testing.T) {
Expand Down Expand Up @@ -1327,6 +1331,7 @@ func TestBlockchain_VerifyBlockBody(t *testing.T) {
},
}

assert.ErrorIs(t, blockchain.verifyBlockBody(block), errUnableToExecute)
_, err = blockchain.verifyBlockBody(block)
assert.ErrorIs(t, err, errUnableToExecute)
})
}
2 changes: 1 addition & 1 deletion consensus/dev/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (d *Dev) writeNewBlock(parent *types.Header) error {
Receipts: transition.Receipts(),
})

if err := d.blockchain.VerifyFinalizedBlock(block); err != nil {
if _, err := d.blockchain.VerifyFinalizedBlock(block); err != nil {
return err
}

Expand Down
12 changes: 6 additions & 6 deletions consensus/ibft/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ func (i *backendIBFT) Initialize() error {

// sync runs the syncer in the background to receive blocks from advanced peers
func (i *backendIBFT) startSyncing() {
callInsertBlockHook := func(block *types.Block) bool {
if err := i.currentHooks.PostInsertBlock(block); err != nil {
i.logger.Error("failed to call PostInsertBlock", "height", block.Header.Number, "error", err)
callInsertBlockHook := func(fullBlock *types.FullBlock) bool {
if err := i.currentHooks.PostInsertBlock(fullBlock.Block); err != nil {
i.logger.Error("failed to call PostInsertBlock", "height", fullBlock.Block.Header.Number, "error", err)
}

if err := i.updateCurrentModules(block.Number() + 1); err != nil {
i.logger.Error("failed to update sub modules", "height", block.Number()+1, "err", err)
if err := i.updateCurrentModules(fullBlock.Block.Number() + 1); err != nil {
i.logger.Error("failed to update sub modules", "height", fullBlock.Block.Number()+1, "err", err)
}

i.txpool.ResetWithHeaders(block.Header)
i.txpool.ResetWithHeaders(fullBlock.Block.Header)

return false
}
Expand Down
32 changes: 16 additions & 16 deletions consensus/polybft/consensus_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,52 +225,52 @@ func (c *consensusRuntime) IsBridgeEnabled() bool {
}

// OnBlockInserted is called whenever fsm or syncer inserts new block
func (c *consensusRuntime) OnBlockInserted(block *types.Block) {
func (c *consensusRuntime) OnBlockInserted(fullBlock *types.FullBlock) {
c.lock.Lock()
defer c.lock.Unlock()

if c.lastBuiltBlock != nil && c.lastBuiltBlock.Number >= block.Number() {
if c.lastBuiltBlock != nil && c.lastBuiltBlock.Number >= fullBlock.Block.Number() {
c.logger.Debug("on block inserted already handled",
"current", c.lastBuiltBlock.Number, "block", block.Number())
"current", c.lastBuiltBlock.Number, "block", fullBlock.Block.Number())

return
}

if err := updateBlockMetrics(block, c.lastBuiltBlock); err != nil {
if err := updateBlockMetrics(fullBlock.Block, c.lastBuiltBlock); err != nil {
c.logger.Error("failed to update block metrics", "error", err)
}

// after the block has been written we reset the txpool so that the old transactions are removed
c.config.txPool.ResetWithHeaders(block.Header)
c.config.txPool.ResetWithHeaders(fullBlock.Block.Header)

var (
epoch = c.epoch
err error
)

// handle commitment and proofs creation
if err := c.stateSyncManager.PostBlock(&PostBlockRequest{Block: block}); err != nil {
if err := c.stateSyncManager.PostBlock(&PostBlockRequest{Block: fullBlock.Block}); err != nil {
c.logger.Error("failed to post block state sync", "err", err)
}

// TODO - this condition will need to be changed to recognize that either slashing happened
// or epoch reached its fixed size
if c.isFixedSizeOfEpochMet(block.Header.Number, epoch) {
if epoch, err = c.restartEpoch(block.Header); err != nil {
if c.isFixedSizeOfEpochMet(fullBlock.Block.Header.Number, epoch) {
if epoch, err = c.restartEpoch(fullBlock.Block.Header); err != nil {
c.logger.Error("failed to restart epoch after block inserted", "error", err)

return
}
}

if err := c.proposerCalculator.Update(block.Number()); err != nil {
if err := c.proposerCalculator.Update(fullBlock.Block.Number()); err != nil {
// do not return if proposer snapshot hasn't been inserted, next call of OnBlockInserted will catch-up
c.logger.Warn("Could not update proposer calculator", "err", err)
}

// finally update runtime state (lastBuiltBlock, epoch, proposerSnapshot)
c.epoch = epoch
c.lastBuiltBlock = block.Header
c.lastBuiltBlock = fullBlock.Block.Header
}

// FSM creates a new instance of fsm
Expand Down Expand Up @@ -731,30 +731,30 @@ func (c *consensusRuntime) BuildProposal(view *proto.View) []byte {
func (c *consensusRuntime) InsertBlock(proposal []byte, committedSeals []*messages.CommittedSeal) {
fsm := c.fsm

block, err := fsm.Insert(proposal, committedSeals)
fullBlock, err := fsm.Insert(proposal, committedSeals)
if err != nil {
c.logger.Error("cannot insert proposal", "error", err)

return
}

if c.IsBridgeEnabled() {
if (fsm.isEndOfEpoch || c.checkpointManager.isCheckpointBlock(block.Header.Number)) &&
bytes.Equal(c.config.Key.Address().Bytes(), block.Header.Miner) {
if (fsm.isEndOfEpoch || c.checkpointManager.isCheckpointBlock(fullBlock.Block.Header.Number)) &&
bytes.Equal(c.config.Key.Address().Bytes(), fullBlock.Block.Header.Miner) {
go func(header types.Header, epochNumber uint64) {
if err := c.checkpointManager.submitCheckpoint(header, fsm.isEndOfEpoch); err != nil {
c.logger.Warn("failed to submit checkpoint",
"checkpoint block", header.Number,
"epoch number", epochNumber,
"error", err)
}
}(*block.Header, fsm.epochNumber)
}(*fullBlock.Block.Header, fsm.epochNumber)

c.checkpointManager.latestCheckpointID = block.Number()
c.checkpointManager.latestCheckpointID = fullBlock.Block.Number()
}
}

c.OnBlockInserted(block)
c.OnBlockInserted(fullBlock)
}

// ID return ID (address actually) of the current node
Expand Down
4 changes: 2 additions & 2 deletions consensus/polybft/consensus_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func TestConsensusRuntime_OnBlockInserted_EndOfEpoch(t *testing.T) {
lastBuiltBlock: &types.Header{Number: header.Number - 1},
stateSyncManager: &dummyStateSyncManager{},
}
runtime.OnBlockInserted(builtBlock)
runtime.OnBlockInserted(&types.FullBlock{Block: builtBlock})

require.True(t, runtime.state.isEpochInserted(currentEpochNumber+1))
require.Equal(t, newEpochNumber, runtime.epoch.Number)
Expand Down Expand Up @@ -281,7 +281,7 @@ func TestConsensusRuntime_OnBlockInserted_MiddleOfEpoch(t *testing.T) {
logger: hclog.NewNullLogger(),
proposerCalculator: NewProposerCalculatorFromSnapshot(snapshot, config, hclog.NewNullLogger()),
}
runtime.OnBlockInserted(builtBlock)
runtime.OnBlockInserted(&types.FullBlock{Block: builtBlock})

require.Equal(t, header.Number, runtime.lastBuiltBlock.Number)
}
Expand Down
13 changes: 6 additions & 7 deletions consensus/polybft/fsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,13 @@ func (f *fsm) VerifyStateTransactions(transactions []*types.Transaction) error {
}

// Insert inserts the sealed proposal
func (f *fsm) Insert(proposal []byte, committedSeals []*messages.CommittedSeal) (*types.Block, error) {
newBlock := f.target.Block
receipts := f.target.Receipts
func (f *fsm) Insert(proposal []byte, committedSeals []*messages.CommittedSeal) (*types.FullBlock, error) {
newBlock := f.target

// In this function we should try to return little to no errors since
// at this point everything we have to do is just commit something that
// we should have already computed beforehand.
extra, _ := GetIbftExtra(newBlock.Header.ExtraData)
extra, _ := GetIbftExtra(newBlock.Block.Header.ExtraData)

// create map for faster access to indexes
nodeIDIndexMap := make(map[types.Address]int, f.validators.Len())
Expand Down Expand Up @@ -457,9 +456,9 @@ func (f *fsm) Insert(proposal []byte, committedSeals []*messages.CommittedSeal)
}

// Write extar data to header
newBlock.Header.ExtraData = append(make([]byte, ExtraVanity), extra.MarshalRLPTo(nil)...)
newBlock.Block.Header.ExtraData = append(make([]byte, ExtraVanity), extra.MarshalRLPTo(nil)...)

if err := f.backend.CommitBlock(&types.FullBlock{Block: newBlock, Receipts: receipts}); err != nil {
if err := f.backend.CommitBlock(newBlock); err != nil {
return nil, err
}

Expand All @@ -471,7 +470,7 @@ func (f *fsm) Insert(proposal []byte, committedSeals []*messages.CommittedSeal)
}

// commit exit events only when we finalize a block
events, err := getExitEventsFromReceipts(epoch, newBlock.Number(), receipts)
events, err := getExitEventsFromReceipts(epoch, newBlock.Block.Number(), newBlock.Receipts)
if err != nil {
return newBlock, err
}
Expand Down
Loading