Skip to content

Commit 569eb7b

Browse files
authored
Merge pull request #1383 from maticnetwork/v1.5.3-beta-candidate
v1.5.3 candidate
2 parents 16268f6 + 6c75359 commit 569eb7b

File tree

21 files changed

+300
-42
lines changed

21 files changed

+300
-42
lines changed

.github/workflows/packager_deb.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
- name: Building bor for arm64
8383
run: GOARCH=arm64 GOOS=linux CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ CGO_ENABLED=1 go build -o build/bin/bor ./cmd/cli/main.go
8484

85+
- name: Copying necessary binary post arm64 build
86+
run: cp -rp build/bin/bor packaging/deb/bor/usr/bin/
87+
8588
# Control file for arm64 creation
8689
- name: create control file
8790
run: |

consensus/bor/heimdall/client.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ var (
3131
)
3232

3333
const (
34-
stateFetchLimit = 50
35-
apiHeimdallTimeout = 5 * time.Second
36-
retryCall = 5 * time.Second
34+
heimdallAPIBodyLimit = 128 * 1024 * 1024 // 128 MB
35+
stateFetchLimit = 50
36+
apiHeimdallTimeout = 5 * time.Second
37+
retryCall = 5 * time.Second
3738
)
3839

3940
type StateSyncEventsResponse struct {
@@ -455,8 +456,11 @@ func internalFetch(ctx context.Context, client http.Client, u *url.URL) ([]byte,
455456
return nil, nil
456457
}
457458

459+
// Limit the number of bytes read from the response body
460+
limitedBody := http.MaxBytesReader(nil, res.Body, heimdallAPIBodyLimit)
461+
458462
// get response
459-
body, err := io.ReadAll(res.Body)
463+
body, err := io.ReadAll(limitedBody)
460464
if err != nil {
461465
return nil, err
462466
}

core/blockchain.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,20 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
23742374
status WriteStatus
23752375
)
23762376

2377+
// Before the actual db insertion happens, verify the block against the whitelisted
2378+
// milestone and checkpoint. This is to prevent a race condition where a milestone
2379+
// or checkpoint was whitelisted while the block execution happened (and wasn't
2380+
// available sometime before) and the block turns out to be inavlid (i.e. not
2381+
// honouring the milestone or checkpoint). Use the block itself as current block
2382+
// so that it's considered as a `past` chain and the validation doesn't get bypassed.
2383+
isValid, err = bc.forker.ValidateReorg(block.Header(), []*types.Header{block.Header()})
2384+
if err != nil {
2385+
return it.index, err
2386+
}
2387+
if !isValid {
2388+
return it.index, whitelist.ErrMismatch
2389+
}
2390+
23772391
if !setHead {
23782392
// Don't set the head, only insert the block
23792393
_, err = bc.writeBlockWithState(block, receipts, logs, statedb)

core/chain_makers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ func makeBlockChainWithGenesis(genesis *Genesis, n int, engine consensus.Engine,
618618
return db, blocks
619619
}
620620

621-
// makeBlockChain creates a deterministic chain of blocks rooted at parent with fake invalid transactions.
621+
// makeFakeNonEmptyBlockChain creates a deterministic chain of blocks rooted at parent with fake invalid transactions.
622622
func makeFakeNonEmptyBlockChain(parent *types.Block, n int, engine consensus.Engine, db ethdb.Database, seed int, numTx int) []*types.Block {
623623
blocks, _ := GenerateChain(params.TestChainConfig, parent, engine, db, n, func(i int, b *BlockGen) {
624624
addr := common.Address{0: byte(seed), 19: byte(i)}

core/state/statedb.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ func (s *StateDB) ApplyMVWriteSet(writes []blockstm.WriteDescriptor) {
418418

419419
switch path.GetSubpath() {
420420
case BalancePath:
421-
// todo: @anshalshukla || @cffls - check balance change reason
422421
s.SetBalance(addr, sr.GetBalance(addr), tracing.BalanceChangeUnspecified)
423422
case NoncePath:
424423
s.SetNonce(addr, sr.GetNonce(addr))
@@ -1095,9 +1094,6 @@ func (s *StateDB) createObject(addr common.Address) *stateObject {
10951094
// consensus bug eventually.
10961095
func (s *StateDB) CreateAccount(addr common.Address) {
10971096
s.createObject(addr)
1098-
// todo: @anshalshukla || @cffls
1099-
// Check the below MV Write, balance path change have been removed
1100-
MVWrite(s, blockstm.NewAddressKey(addr))
11011097
}
11021098

11031099
// CreateContract is used whenever a contract is created. This may be preceded
@@ -1107,13 +1103,14 @@ func (s *StateDB) CreateAccount(addr common.Address) {
11071103
// correctly handle EIP-6780 'delete-in-same-transaction' logic.
11081104
func (s *StateDB) CreateContract(addr common.Address) {
11091105
obj := s.getStateObject(addr)
1106+
if obj != nil {
1107+
obj = s.mvRecordWritten(obj)
1108+
}
11101109
if !obj.newContract {
11111110
obj.newContract = true
11121111
s.journal.append(createContractChange{account: addr})
11131112
}
11141113

1115-
// todo: @anshalshukla || @cffls
1116-
// Check the below MV Write, balance path change have been removed
11171114
MVWrite(s, blockstm.NewAddressKey(addr))
11181115
}
11191116

core/state/statedb_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,33 @@ func TestMVHashMapReadWriteDelete(t *testing.T) {
813813
assert.Equal(t, uint256.NewInt(0), b)
814814
}
815815

816+
func TestMVHashMapCreateContract(t *testing.T) {
817+
t.Parallel()
818+
819+
db := NewDatabase(rawdb.NewMemoryDatabase())
820+
mvhm := blockstm.MakeMVHashMap()
821+
s, _ := NewWithMVHashmap(common.Hash{}, db, nil, mvhm)
822+
823+
states := []*StateDB{s}
824+
825+
// Create copies of the original state for each transition
826+
for i := 1; i <= 4; i++ {
827+
sCopy := s.Copy()
828+
sCopy.txIndex = i
829+
states = append(states, sCopy)
830+
}
831+
832+
addr := common.HexToAddress("0x01")
833+
states[0].SetBalance(addr, uint256.NewInt(100), tracing.BalanceChangeTransfer)
834+
states[0].FlushMVWriteSet()
835+
836+
states[1].CreateContract(addr)
837+
states[1].FlushMVWriteSet()
838+
839+
b := states[1].GetBalance(addr)
840+
assert.Equal(t, uint256.NewInt(100), b)
841+
}
842+
816843
func TestMVHashMapRevert(t *testing.T) {
817844
t.Parallel()
818845

eth/bor_api_backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (b *EthAPIBackend) GetRootHash(ctx context.Context, starBlockNr uint64, end
3939
return root, nil
4040
}
4141

42-
// GetRootHash returns root hash for given start and end block
42+
// GetVoteOnHash returns the vote on hash
4343
func (b *EthAPIBackend) GetVoteOnHash(ctx context.Context, starBlockNr uint64, endBlockNr uint64, hash string, milestoneId string) (bool, error) {
4444
var api *bor.API
4545

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
github.com/fsnotify/fsnotify v1.7.0
3737
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08
3838
github.com/gofrs/flock v0.8.1
39-
github.com/golang-jwt/jwt/v4 v4.5.0
39+
github.com/golang-jwt/jwt/v4 v4.5.1
4040
github.com/golang/mock v1.6.0
4141
github.com/golang/protobuf v1.5.4
4242
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
@@ -65,7 +65,7 @@ require (
6565
github.com/kylelemons/godebug v1.1.0
6666
github.com/maticnetwork/crand v1.0.2
6767
github.com/maticnetwork/heimdall v1.0.7
68-
github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53
68+
github.com/maticnetwork/polyproto v0.0.4
6969
github.com/mattn/go-colorable v0.1.13
7070
github.com/mattn/go-isatty v0.0.20
7171
github.com/mitchellh/cli v1.1.5

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,9 @@ github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw
12921292
github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg=
12931293
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
12941294
github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
1295-
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
12961295
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
1296+
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
1297+
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
12971298
github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
12981299
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
12991300
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
@@ -1706,8 +1707,9 @@ github.com/maticnetwork/crand v1.0.2/go.mod h1:/NRNL3bj2eYdqpWmoIP5puxndTpi0XRxp
17061707
github.com/maticnetwork/heimdall v1.0.4/go.mod h1:Xh7KFvtbs/SVNjOI8IgYmk6JdzYx89eU/XUwH0AgHLs=
17071708
github.com/maticnetwork/heimdall v1.0.7 h1:QStn+hbZKxfE+PqecaorA/uATDPuQoi+U9Z7IIonb60=
17081709
github.com/maticnetwork/heimdall v1.0.7/go.mod h1:+ANI5+VV28ahwfdl7oMzrcNwaTEs1Fn6z39BqBGcvaA=
1709-
github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53 h1:PjYV+lghs106JKkrYgOnrsfDLoTc11BxZd4rUa4Rus4=
17101710
github.com/maticnetwork/polyproto v0.0.3-0.20230216113155-340ea926ca53/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o=
1711+
github.com/maticnetwork/polyproto v0.0.4 h1:qQ/qwcO6UNGS4mJlzlLJn1AUMfJK9Rqmf1v+KJgnPsk=
1712+
github.com/maticnetwork/polyproto v0.0.4/go.mod h1:e1mU2EXSwEpn5jM7GfNwu3AupsV6WAGoPFFfswXOF0o=
17111713
github.com/maticnetwork/tendermint v0.33.0 h1:f+vORM02BoUOlCvnu3Zjw5rv6l6JSNVchWjH03rUuR8=
17121714
github.com/maticnetwork/tendermint v0.33.0/go.mod h1:D2fcnxGk6bje+LoPwImuKSSYLiK7/G06IynGNDSEcJk=
17131715
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=

integration-tests/bor_health.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ do
1111
fi
1212
done
1313

14-
echo $peers
15-
echo $block
14+
echo "$peers"
15+
echo "$block"

0 commit comments

Comments
 (0)