Commit graph

383 commits

Author SHA1 Message Date
wgr523
6a38aa00aa
Reward float upgrade (#940)
* feat: use float type reward

* feat: add test of float reward
2025-04-16 02:03:41 -07:00
Wanwiset Peerapatanapokin
9a00e475b4
Merge pull request #930 from XinFinOrg/add-api-limit
consensus/XDPoS: add limit to high resource demand api
2025-04-08 15:31:50 +04:00
Daniel Liu
5b8c267122 trie: use trie.NewStackTrie instead of new(trie.Trie) (#22246) 2025-04-07 16:44:32 +08:00
Daniel Liu
a4c7d7f458 all: clean duplicate constants in package common 2025-04-07 16:43:01 +08:00
wanwiset25
f3a2577a76 simplify code 2025-04-04 09:56:41 +04:00
wanwiset25
229caf0125 add limit to high resource demand api 2025-03-31 06:00:27 +04:00
benjamin202410
b8a9a8bfb1
Merge pull request #924 from XinFinOrg/update-reward-percapita
Update reward percapita
2025-03-28 23:52:33 -07:00
Daniel Liu
c73a0aa929 core/state: fix state iterator (#19127) 2025-03-28 22:34:59 +08:00
Gerui Wang
6bac06b1e7 feat: fixed reward per node (per capita) 2025-03-25 22:33:49 +08:00
Gerui Wang
84ae914350 feat: add TIPEpochHalving, better style 2025-03-25 22:16:35 +08:00
Daniel Liu
a9b9f53701 core, eth, trie: add a prefix to contract code (21080) 2025-03-24 22:31:03 +08:00
wgr523
c36e4d54c0
Upgrade reward 2.0 (#865)
* refactor: reward hook gets prepared for upgrade

* feat: new reward hook, config change, unit tests

* add missing code

* feat: filter penalty in reward. add unit test

* update constant and config

---------

Co-authored-by: liam.lai <liam.lai@us>
2025-03-02 02:44:34 -08:00
JukLee0ira
51dac59e92 common: change type of variables for constants 2025-02-17 11:38:16 +08:00
Daniel Liu
cfc8cca674 common: refactor constants 2025-02-17 09:13:40 +08:00
JukLee0ira
d6b136ed7c
consensus, internal, contracts: remove extra hash and string conversions (#830)
* consensus, internal: remove extra hash conversions

* contracts: remove extra string conversions
2025-02-07 13:59:07 +08:00
Daniel Liu
4bbcd988b2 params: remove EIP150Hash from chainconfig (#27087) 2025-02-05 18:16:17 +08:00
Daniel Liu
b6f3007af1 core: move genesis alloc types to core/types (#29003) 2025-01-24 16:54:12 +08:00
Daniel Liu
4e951ed8fe all: use github.com/deckarep/golang-set/v2 (generic set) (#26159) 2025-01-24 16:54:11 +08:00
Daniel Liu
5b10b2441c all: use T.TempDir to create temporary test directories (#24633) 2025-01-24 16:54:08 +08:00
Daniel Liu
6d17a42edb all: replace t.Log(); t.FailNow() with t.Fatal() (#19849) 2025-01-24 16:18:29 +08:00
Daniel Liu
f542e463d3 accounts: implement simple checkpoint syncing (#19543) 2025-01-24 16:18:29 +08:00
Daniel Liu
97c50f97bb all: add read-only option to database 2025-01-24 14:24:39 +08:00
wgr523
537dc5e6fb
Exp timeout (#764)
* feat: write duration calculation in countdown as
interface. add more inputs as function argument

* feat: ExpTimeoutDuration

* fix: three dots usage

* feat: refine exp duration

* feat: add exp timeout config and use it in countdown

* feat: remove const countdown

* feat: remove use of interface in countdown, use error

* fix: countdown reset timer problem

* fix: add default ExpTimeoutConfig for config
2025-01-19 23:04:03 +08:00
wanwiset25
44ac46f676 add local xdpos function
add readme

changes to support xdpos2 protocol from block 0
2025-01-01 22:06:09 -05:00
benjamin202410
f8decab061
code refactor for performance (#782)
Co-authored-by: liam.lai <liam.lai@us>
2024-12-29 21:47:14 -08:00
benjamin202410
3e62a4c611
Merge pull request #778 from XinFinOrg/release-br-v2.4.6-beta1-dev-upgrade
Release br v2.4.6 beta1 merge back to dev upgrade
2024-12-27 20:07:41 -08:00
Daniel Liu
6e33633d28 common: drop BigMin and BigMax, they pollute our dep graph (#30645) 2024-12-28 09:06:31 +08:00
Péter Szilágyi
39e9d8f94d common/prque: generic priority queue (#26290) 2024-12-28 09:06:31 +08:00
Daniel Liu
28739d7863 common: remove usage of deprecated function (#21610) 2024-12-28 09:06:30 +08:00
liam.lai
77f9cc59ec merge from dev-upgrade 2024-12-27 10:03:54 -08:00
benjamin202410
c8aae5e537
Get right tc epoch (#773)
* get right tc epoch

* fix debug message

* merge test

* merge test

---------

Co-authored-by: liam.lai <liam.lai@us>
2024-12-24 01:53:40 -08:00
benjamin202410
332380c889
fix only timeout round exists in next epoch (#772)
* fix only timeout round exists in next epoch

* bump version

---------

Co-authored-by: liam.lai <liam.lai@us>
2024-12-23 23:09:45 -08:00
liam.lai
00785b096f fix tc cross epoch different masternode counts issue 2024-12-22 19:34:09 -08:00
Daniel Liu
82ff8c19a0 all: remove uses of untyped golang-lru 2024-12-21 14:39:26 +08:00
liam.lai
50f4013059 remove normal log 2024-12-20 14:11:32 -08:00
benjamin202410
21b05243b6
Merge from master mining time patch (#767)
* merge from master

* close channel

* close channel

---------

Co-authored-by: liam.lai <liam.lai@us>
2024-12-19 01:17:29 -08:00
benjamin202410
78331172f3 cherry pick vote test fix 2024-12-13 01:58:58 -08:00
liam.lai
383e2d5207 Merge branch 'master' into release-br-v2.4.3-beta1 2024-12-13 01:45:56 -08:00
Daniel Liu
6beee27886 metrics, cmd/XDC: change init-process of metrics (#30814)
This PR modifies how the metrics library handles `Enabled`: previously,
the package `init` decided whether to serve real metrics or just
dummy-types.

This has several drawbacks:
- During pkg init, we need to determine whether metrics are enabled or
not. So we first hacked in a check if certain geth-specific
commandline-flags were enabled. Then we added a similar check for
geth-env-vars. Then we almost added a very elaborate check for
toml-config-file, plus toml parsing.

- Using "real" types and dummy types interchangeably means that
everything is hidden behind interfaces. This has a performance penalty,
and also it just adds a lot of code.

This PR removes the interface stuff, uses concrete types, and allows for
the setting of Enabled to happen later. It is still assumed that
`metrics.Enable()` is invoked early on.

The somewhat 'heavy' operations, such as ticking meters and exp-decay,
now checks the enable-flag to prevent resource leak.

The change may be large, but it's mostly pretty trivial, and from the
last time I gutted the metrics, I ensured that we have fairly good test
coverage.

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2024-12-13 14:00:14 +08:00
Daniel Liu
cc4ea7a685 metrics: refactor metrics (#28035)
This change includes a lot of things, listed below.

The interfaces have been split up into one write-interface and one read-interface, with `Snapshot` being the gateway from write to read. This simplifies the semantics _a lot_.

Example of splitting up an interface into one readonly 'snapshot' part, and one updatable writeonly part:

```golang
type MeterSnapshot interface {
	Count() int64
	Rate1() float64
	Rate5() float64
	Rate15() float64
	RateMean() float64
}

// Meters count events to produce exponentially-weighted moving average rates
// at one-, five-, and fifteen-minutes and a mean rate.
type Meter interface {
	Mark(int64)
	Snapshot() MeterSnapshot
	Stop()
}
```

This PR makes the concurrency model clearer. We have actual meters and snapshot of meters. The `meter` is the thing which can be accessed from the registry, and updates can be made to it.

- For all `meters`, (`Gauge`, `Timer` etc), it is assumed that they are accessed by different threads, making updates. Therefore, all `meters` update-methods (`Inc`, `Add`, `Update`, `Clear` etc) need to be concurrency-safe.
- All `meters` have a `Snapshot()` method. This method is _usually_ called from one thread, a backend-exporter. But it's fully possible to have several exporters simultaneously: therefore this method should also be concurrency-safe.

TLDR: `meter`s are accessible via registry, all their methods must be concurrency-safe.

For all `Snapshot`s, it is assumed that an individual exporter-thread has obtained a `meter` from the registry, and called the `Snapshot` method to obtain a readonly snapshot. This snapshot is _not_ guaranteed to be concurrency-safe. There's no need for a snapshot to be concurrency-safe, since exporters should not share snapshots.

Note, though: that by happenstance a lot of the snapshots _are_ concurrency-safe, being unmutable minimal representations of a value. Only the more complex ones are _not_ threadsafe, those that lazily calculate things like `Variance()`, `Mean()`.

Example of how a background exporter typically works, obtaining the snapshot and sequentially accessing the non-threadsafe methods in it:
```golang
		ms := metric.Snapshot()
                ...
		fields := map[string]interface{}{
			"count":    ms.Count(),
			"max":      ms.Max(),
			"mean":     ms.Mean(),
			"min":      ms.Min(),
			"stddev":   ms.StdDev(),
			"variance": ms.Variance(),
```

TLDR: `snapshots` are not guaranteed to be concurrency-safe (but often are).

I also changed the `Sample` type: previously, it iterated the samples fully every time `Mean()`,`Sum()`, `Min()` or `Max()` was invoked. Since we now have readonly base data, we can just iterate it once, in the constructor, and set all four values at once.

The same thing has been done for runtimehistogram.

Back when ResettingTImer was implemented, as part of https://github.com/ethereum/go-ethereum/pull/15910, Anton implemented a `Percentiles` on the new type. However, the method did not conform to the other existing types which also had a `Percentiles`.

1. The existing ones, on input, took `0.5` to mean `50%`. Anton used `50` to mean `50%`.
2. The existing ones returned `float64` outputs, thus interpolating between values. A value-set of `0, 10`, at `50%` would return `5`, whereas Anton's would return either `0` or `10`.

This PR removes the 'new' version, and uses only the 'legacy' percentiles, also for the ResettingTimer type.

The resetting timer snapshot was also defined so that it would expose the internal values. This has been removed, and getters for `Max, Min, Mean` have been added instead.

A lot of types were exported, but do not need to be. This PR unexports quite a lot of them.

metrics: refactor metrics (28035)
2024-12-13 14:00:13 +08:00
Daniel Liu
ad5e7d6db3 crypto: add SignatureLength constant and use it everywhere (#19996) 2024-12-09 17:48:59 +08:00
Daniel Liu
92fc843683 crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
Wang Gerui
1b89654663 feat: add a new round chan between consensus and miner 2024-12-04 22:42:45 +08:00
benjamin202410
a8560300a4
fix vote test and optimize log (#750)
Co-authored-by: liam.lai <liam.lai@us>
2024-11-29 03:14:25 -08:00
liam.lai
809242223a bug fix use right block to count vote theshold 2024-11-22 00:04:39 -08:00
liam.lai
100ce5cbe5 bug fix for count vote threshold 2024-11-22 00:01:22 -08:00
Daniel Liu
ed242b4763 all: implement EIP-1153 transient storage (#26003) 2024-11-15 19:39:18 +08:00
Daniel Liu
9b20ac785e consensus/misc: move eip1559 into a package (#27828) 2024-11-01 11:36:53 +08:00
Daniel Liu
e18553b855 all: implement eip-1559 (#22837) 2024-11-01 11:36:52 +08:00
Daniel Liu
363d9784bf engines/engine_v2: fix staticcheck warning S1009: should omit nil check 2024-10-31 21:51:53 +08:00