Go implementation of the Ethereum protocol
Find a file
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
.github accounts, build, mobile: remove Android and iOS support (#26599) 2024-11-15 15:46:25 +08:00
accounts crypto: add SignatureLength constant and use it everywhere (#19996) 2024-12-09 17:48:59 +08:00
assets/images update README and include a logo photo 2022-07-24 21:44:58 +10:00
bmt crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
build PDF-01 (#397) 2024-01-19 15:05:03 +04:00
cicd fix typo and local script 2024-12-03 02:29:40 +04:00
cmd metrics, cmd/geth: informational metrics (prometheus, influxdb, opentsb) (#24877) 2024-12-13 14:00:13 +08:00
common crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
compression/rle compression/rle: fix staticcheck warning SA9004: constant has no explicit type 2024-10-30 21:12:32 +08:00
consensus metrics: refactor metrics (#28035) 2024-12-13 14:00:13 +08:00
console node, p2p/simulations: fix node.Node AccountsManager leak (#19004) 2024-11-25 16:33:26 +08:00
containers/docker containers: drop vagrant support, noone's maintaining it 2018-03-14 13:23:40 +02:00
contracts all: replace log15 with slog (#28187) 2024-11-15 10:02:42 +08:00
core metrics, cmd/geth: informational metrics (prometheus, influxdb, opentsb) (#24877) 2024-12-13 14:00:13 +08:00
crypto crypto: fix typos in comments (#29186) 2024-12-09 17:49:00 +08:00
docker all: normalize flag's name 2024-11-25 16:39:29 +08:00
eth crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
ethclient ethclient: apply accessList field in toCallArg (#28832) 2024-11-01 11:36:53 +08:00
ethdb new EVM Upgrade 2021-09-21 16:53:46 +05:30
ethstats all: replace strings.Replace with string.ReplaceAll (#24835) 2024-12-08 11:51:14 +08:00
event all: fix staticcheck warning ST1006: don't use generic name self 2024-10-25 21:30:54 +08:00
genesis xin-203 fix wrong config hash and update v2 params on mainnet (#109) 2022-07-12 16:56:55 +02:00
internal metrics/exp: allow configuring metrics HTTP server on separate endpoint (#21290) 2024-12-13 14:00:12 +08:00
les eth/gasprice: remove default from config (#30080) 2024-11-13 09:30:55 +08:00
light log: remove lazy, remove unused interfaces, unexport methods (#28622) 2024-11-15 10:02:42 +08:00
log log: fix issues with benchmarks (#30667) 2024-11-15 10:02:43 +08:00
metrics metrics: refactor metrics (#28035) 2024-12-13 14:00:13 +08:00
miner metrics: fix some typos (#25551) 2024-12-13 14:00:12 +08:00
node all: ensure resp.body closed (#26969) 2024-12-13 14:00:13 +08:00
p2p all: ensure resp.body closed (#26969) 2024-12-13 14:00:13 +08:00
params recover devnet by increasing timeout (#760) 2024-12-12 20:28:46 -08:00
rlp all: change format 0x%x to %#x (#25221) 2024-09-27 15:24:31 +08:00
rpc all: ensure resp.body closed (#26969) 2024-12-13 14:00:13 +08:00
swarm all: use errrors.New instead of empty fmt.Errorf 2024-06-14 19:19:21 +08:00
tests crypto, tests: update fuzzers to native go fuzzing (#28352) 2024-12-09 17:49:00 +08:00
trie fix tautological condition: nil == nil 2024-10-31 09:01:12 +08:00
XDCx crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
XDCxDAO XDCxDAO: fix staticcheck warning SA5007: infinite recursive call 2024-10-30 21:16:02 +08:00
XDCxlending crypto: switch over to upstream sha3 package (#18390) 2024-12-09 17:48:59 +08:00
.dockerignore dockerignore, internal/build: forward correct git folder 2017-11-12 22:52:41 +02:00
.gitattributes FIx Bad block error. 2021-09-17 17:59:06 +05:30
.gitignore add testnet and mainnet node for latest code testing (#467) 2024-03-04 17:13:50 +11:00
.travis.yml.bak remove all CI warning by upgrade to nodejs 20 image (#461) 2024-03-03 16:20:38 +11:00
COPYING all: update license information 2015-07-07 14:12:44 +02:00
COPYING.LESSER all: update license information 2015-07-07 14:12:44 +02:00
Dockerfile bump go to 1.21 in Dockerfiles 2023-10-23 00:08:43 +08:00
Dockerfile.bootnode bump go to 1.21 in Dockerfiles 2023-10-23 00:08:43 +08:00
Dockerfile.node bump go to 1.21 in Dockerfiles 2023-10-23 00:08:43 +08:00
go.mod metrics: use slices package for sorting (#27493 #27909) 2024-12-13 14:00:13 +08:00
go.sum metrics: use slices package for sorting (#27493 #27909) 2024-12-13 14:00:13 +08:00
interfaces.go ethclient: add FeeHistory support (#25403) 2024-11-01 11:36:53 +08:00
Makefile upgrade the websocket in xdpos (#349) 2023-11-06 15:37:14 +11:00
README.md merge from master 2023-07-30 16:50:45 +10:00

XDPoSChain

XinFin XDPoSchain
Enterprise ready hybrid blockchain for global trade and finance


XinFin Hybrid Blockchain

XinFin Hybrid Blockchain is an Enterprise ready Blockchain for global trade and finance

Visit: XinFin.org Contribute: Developer Docs

XinFin Network XDPoS is community driven project to achieve the following

  • XinFin DPOS (XDPoS) consensus that selects 108 set of Masternodes to achieve a high throughput Energy efficient consensus with instant block finality

  • KYC Enforcement on Masternodes for Enterprise Adoption and compliance

  • Ability to port/relay limited set of data and transactions from privacy channels to public channel

  • Interoperability between applications hosted on Private Blockchains like Corda, Hyperledger, Quorum(JP Morgan) using relayers to XinFin Network

  • Customer Centric and consortium driven Governance to equally benefit the validators as well as providing comfort for large scale enterprise applications to be hosted on the Network. This achieves

    • Rapid Upgradability

    • DApps Standardisation for rapid commercialisation

    • Compliance with major global jurisdictions.

KYC for masternodes

OVERVIEW

To add a layer of KYC for masternodes in the current system and a sense of ownership amongst the masternodes hence tying such a cluster of masternodes to physical entity which can held accountable for its actions.

Design

We established a bidirectional connection between a candidate and its owner inorder to retrieve a candidate belonging to a specific owner & vice versa.

All the masternodes are recognized by the KYC of their owners and hence are considered as a single verified entity ( for eg. while voting for invalid KYC, only one vote is considered per such cluster )

The contract is very strict in handing out penalty for invalid KYC, it results loss of all funds invested in all of its candidates.

For eg. say A proposes condidates B,C,D by paying for its proposal cost. If at a later stage if some predecided amount of owners ( investors ) vote that a KYC for a A is invalid then A & all of its candidates (B,C,D) will lose their position & all their funds will be lost ( will remain with contract wallet ).

For developers

Continues integration & delivery

See https://github.com/XinFinOrg/XDPoSChain/tree/dev-upgrade/cicd

To contribute

Simple create a pull request along with proper reasoning, we'll get back to you.

Our Channels : Telegram Developer Group or XDC.Dev