Add beacon chain / eth2.0 related NewType
See original GitHub issueWhat is wrong?
https://github.com/ethereum/py-evm/pull/1373#discussion_r224107745 To make the types more explict!
How can it be fixed
- Time unit -
Second
- and also can be used for PoW chain? - For beacon chain, some other
NewType
candidates:Slot
,ShardID
. And with the latest spec:ValidatorStatus
,SpecialRecordType
,ValidatorSetDeltaFlag
. - EDIT: Move to ethereum/eth-typing/
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
The Ethereum 2.0 Beacon Chain is here. Now what?
A massive new structure is being built alongside Ethereum. The core of this is the Beacon Chain, which changes the consensus model to...
Read more >Ethereum 2.0 FAQ
Ethereum 2.0, also called Eth2 or “The Beacon Chain”, is the next major change to the Ethereum blockchain, introducing a Proof-of-Stake consensus mechanism, ......
Read more >The Beacon Chain
The Beacon Chain introduced proof-of-stake to Ethereum. This keeps Ethereum secure and earns validators more ETH in the process. In practice, staking involves ......
Read more >K Semantic Model of Beacon Chain - Devcon Archive
Daejun Park gives an overview of the K-Semantic Model of the Beacon Chain. ... ETH2. 0 is evaluating libp2p gossipsub as a decentralized,...
Read more >ETHEREUM 2.0 AND CHAINLINK: The Story So Far And ...
Activation occurs after the beacon chain processes the deposit receipt from ETH 1.0. Shard Chains (2021) - Sharding is planned for 2021.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, that would be my preferred approach as well 👍
Ensuring that an API that expects
Gwei
isn’t called withEther
is exactly what NewTypes are for. The canonical example is usually this NASA bug where an API was called with miles that expected kilometers and caused the rocket to crash. This falls into the same category.I would just simplify the names to
No,
mypy
can not do these things. What it can do is to allow you different types for different intents and ensure to trace the flow of these to prevent the wrong one ending up at a wrong place.Consider this:
clearly we want to prevent the following situation:
Mypy can help you with this if you create a
NewType
.Now, if you’d try this again, mypy would yell at you because it knows that
x
is not of typeUnsignedInt
.