Skip to content

Commit

Permalink
Merge pull request #978 from maticnetwork/arpit/merge-latest-branch
Browse files Browse the repository at this point in the history
Arpit/merge latest branch
  • Loading branch information
temaniarpit27 authored Aug 29, 2023
2 parents b48b89f + b32521d commit 40f329f
Show file tree
Hide file tree
Showing 23 changed files with 48 additions and 31 deletions.
5 changes: 0 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ nfpms:
scripts:
postinstall: builder/files/bor-post-install.sh

overrides:
rpm:
replacements:
amd64: x86_64

snapshot:
name_template: "{{ .Tag }}.next"

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ release-dry-run:
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate --skip-publish
--clean --skip-validate --skip-publish

.PHONY: release
release:
Expand All @@ -230,4 +230,4 @@ release:
-v `pwd`:/go/src/$(PACKAGE_NAME) \
-w /go/src/$(PACKAGE_NAME) \
goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
--rm-dist --skip-validate
--clean --skip-validate
6 changes: 5 additions & 1 deletion cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2170,11 +2170,15 @@ func RegisterFilterAPI(stack *node.Node, backend ethapi.Backend, ethcfg *ethconf
LogCacheSize: ethcfg.FilterLogCacheSize,
})

filterAPI := filters.NewFilterAPI(filterSystem, isLightClient, ethconfig.Defaults.BorLogs)
stack.RegisterAPIs([]rpc.API{{
Namespace: "eth",
Service: filters.NewFilterAPI(filterSystem, isLightClient, ethconfig.Defaults.BorLogs),
Service: filterAPI,
}})

// avoiding constructor changed by introducing new method to set genesis
filterAPI.SetChainConfig(ethcfg.Genesis.Config)

return filterSystem
}

Expand Down
Empty file added core/triecache/data.0.bin
Empty file.
Binary file added core/triecache/data.1.bin
Binary file not shown.
Empty file added core/triecache/data.2.bin
Empty file.
Binary file added core/triecache/data.3.bin
Binary file not shown.
Binary file added core/triecache/data.4.bin
Binary file not shown.
Binary file added core/triecache/data.5.bin
Binary file not shown.
Empty file added core/triecache/data.6.bin
Empty file.
Binary file added core/triecache/data.7.bin
Binary file not shown.
Binary file added core/triecache/metadata.bin
Binary file not shown.
19 changes: 16 additions & 3 deletions core/txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,10 @@ type TxPool struct {
eip1559 atomic.Bool // Fork indicator whether we are using EIP-1559 type transactions.
shanghai atomic.Bool // Fork indicator whether we are in the Shanghai stage.

currentState *state.StateDB // Current state in the blockchain head
pendingNonces *noncer // Pending state tracking virtual nonces
currentMaxGas atomic.Uint64 // Current gas limit for transaction caps
currentState *state.StateDB // Current state in the blockchain head
currentStateMutex sync.Mutex // Mutex to protect currentState
pendingNonces *noncer // Pending state tracking virtual nonces
currentMaxGas atomic.Uint64 // Current gas limit for transaction caps

locals *accountSet // Set of local transaction to exempt from eviction rules
journal *journal // Journal of local transaction to back up to disk
Expand Down Expand Up @@ -745,6 +746,9 @@ func (pool *TxPool) local() map[common.Address]types.Transactions {
// and does not require the pool mutex to be held.
// nolint:gocognit
func (pool *TxPool) validateTxBasics(tx *types.Transaction, local bool) error {
pool.currentStateMutex.Lock()
defer pool.currentStateMutex.Unlock()

// Accept only legacy transactions until EIP-2718/2930 activates.
if !pool.eip2718.Load() && tx.Type() != types.LegacyTxType {
return core.ErrTxTypeNotSupported
Expand Down Expand Up @@ -850,6 +854,9 @@ func (pool *TxPool) validateTxBasics(tx *types.Transaction, local bool) error {
// validateTx checks whether a transaction is valid according to the consensus
// rules and adheres to some heuristic limits of the local node (price and size).
func (pool *TxPool) validateTx(tx *types.Transaction, _ bool) error {
pool.currentStateMutex.Lock()
defer pool.currentStateMutex.Unlock()

// Signature has been checked already, this cannot error.
from, _ := types.Sender(pool.signer, tx)
// Ensure the transaction adheres to nonce ordering
Expand Down Expand Up @@ -1915,6 +1922,9 @@ func (pool *TxPool) promoteExecutables(accounts []common.Address) []*types.Trans

balance := uint256.NewInt(0)

pool.currentStateMutex.Lock()
defer pool.currentStateMutex.Unlock()

// Iterate over all accounts and promote any executable transactions
for _, addr := range accounts {
list = pool.queue[addr]
Expand Down Expand Up @@ -2252,6 +2262,9 @@ func (pool *TxPool) demoteUnexecutables() {
// Iterate over all accounts and demote any non-executable transactions
pool.pendingMu.RLock()

pool.currentStateMutex.Lock()
defer pool.currentStateMutex.Unlock()

for addr, list := range pool.pending {
nonce := pool.currentState.GetNonce(addr)

Expand Down
3 changes: 3 additions & 0 deletions eth/filters/filter_system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,8 @@ func TestInvalidGetLogsRequest(t *testing.T) {
blockHash = common.HexToHash("0x1111111111111111111111111111111111111111111111111111111111111111")
)

api.SetChainConfig(params.BorUnittestChainConfig)

// Reason: Cannot specify both BlockHash and FromBlock/ToBlock)
testCases := []FilterCriteria{
0: {BlockHash: &blockHash, FromBlock: big.NewInt(100)},
Expand Down Expand Up @@ -808,6 +810,7 @@ func TestPendingLogsSubscription(t *testing.T) {
<-testCases[i].sub.Err()
}
}

// nolint:gocognit
func TestLightFilterLogs(t *testing.T) {
t.Parallel()
Expand Down
4 changes: 2 additions & 2 deletions metrics/prometheus/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *collector) addHistogram(name string, m metrics.Histogram) {
}

c.writeSummarySum(name, fmt.Sprintf("%f", sum))
c.writeSummaryCounter(name, len(ps))
c.writeSummaryCounter(name, m.Count())
c.buff.WriteRune('\n')
}

Expand All @@ -97,7 +97,7 @@ func (c *collector) addTimer(name string, m metrics.Timer) {
}

c.writeSummarySum(name, fmt.Sprintf("%f", sum))
c.writeSummaryCounter(name, len(ps))
c.writeSummaryCounter(name, m.Count())
c.buff.WriteRune('\n')
}

Expand Down
18 changes: 10 additions & 8 deletions metrics/prometheus/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func TestCollector(t *testing.T) {
timer.Update(120 * time.Millisecond)
timer.Update(23 * time.Millisecond)
timer.Update(24 * time.Millisecond)
timer.Update(30 * time.Millisecond)
c.addTimer("test/timer", timer)

resettingTimer := metrics.NewResettingTimer()
Expand All @@ -58,6 +59,7 @@ func TestCollector(t *testing.T) {
resettingTimer.Update(120 * time.Millisecond)
resettingTimer.Update(13 * time.Millisecond)
resettingTimer.Update(14 * time.Millisecond)
resettingTimer.Update(30 * time.Millisecond)
c.addResettingTimer("test/resetting_timer", resettingTimer.Snapshot())

emptyResettingTimer := metrics.NewResettingTimer().Snapshot()
Expand All @@ -83,27 +85,27 @@ test_histogram {quantile="0.99"} 0
test_histogram {quantile="0.999"} 0
test_histogram {quantile="0.9999"} 0
test_histogram_sum 0.000000
test_histogram_count 6
test_histogram_count 0
# TYPE test_meter gauge
test_meter 9999999
# TYPE test_timer summary
test_timer {quantile="0.5"} 2.25e+07
test_timer {quantile="0.75"} 4.8e+07
test_timer {quantile="0.5"} 2.3e+07
test_timer {quantile="0.75"} 3e+07
test_timer {quantile="0.95"} 1.2e+08
test_timer {quantile="0.99"} 1.2e+08
test_timer {quantile="0.999"} 1.2e+08
test_timer {quantile="0.9999"} 1.2e+08
test_timer_sum 550500000.000000
test_timer_count 6
test_timer_sum 533000000.000000
test_timer_count 7
# TYPE test_resetting_timer summary
test_resetting_timer {quantile="0.50"} 12000000
test_resetting_timer {quantile="0.50"} 13000000
test_resetting_timer {quantile="0.95"} 120000000
test_resetting_timer {quantile="0.99"} 120000000
test_resetting_timer_sum 180000000
test_resetting_timer_count 6
test_resetting_timer_sum 210000000
test_resetting_timer_count 7
`

Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.validator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.4.0
Version: 1.0.0-beta
Section: develop
Priority: standard
Maintainer: Polygon <[email protected]>
Expand Down
8 changes: 4 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
)

const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 4 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "" // Version metadata to append to the version string
VersionMajor = 1 // Major version component of the current release
VersionMinor = 0 // Minor version component of the current release
VersionPatch = 0 // Patch version component of the current release
VersionMeta = "beta" // Version metadata to append to the version string
)

var GitCommit string
Expand Down

0 comments on commit 40f329f

Please sign in to comment.