-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EIP-1559 support release #510
EIP-1559 support release #510
Conversation
- Add `decodeHex<T: DecodableFromHex>(to type: T.Type, key: KeyedDecodingContainer<K>.Key) throws -> T` to initialize `Block` it's fields. - Temporary rename `_decodeHexToData<T>(_ container: KeyedDecodingContainer<T>, key: KeyedDecodingContainer<T>.Key, allowOptional:Bool = false) throws -> Data?` method which used in other Structures initialization. - Refactor Block `init(from decoder: Decoder) throws`.
- Refactor `EthereumTransaction` to make it more swifty.
- Add required constants to Web3 - Add public Web3 extension with `verifyEip1559Block` and `calcBaseFee` methods - Add draft ChainVersion enum to differ Blockchain versions
- Add additional Web3 constants. - Implement draft `verifyGasLimit(parentGasLimit: BigUInt, currentGasLimit: BigUInt) throws -> Bool` method. - Implement draft `verifyEip1559Block(chain version: ChainVersion, parent: Block, current: Block) throws -> Bool` method. - Add some comments to Block structure describing EIP-1559 specification. - Add draft EIP1559 tests.
- Fix bug in verifyEip1559Block method - Add testBlockGasLimits test (works only London to London part yet)
Checked: It builds
- Change verifyGasLimit method API - Change verifyEip1559Block method API - Change calcBaseFee method API - Implement ChainVersion enum for mainnet and made it Comparable - Implement getChainVersion(of:) method - Add chainVersion for Block struct
- Add methods documentation - Refactor calcBaseFee method - refactor ChainVersion mainNetFisrtBlockNumber for clarity - Delete useless ChainVersion Comparable method - Refactor EIP1559Tests class - Add testCalcBaseFee test All tests are green.
/// Block number: 13_773_000 | ||
case ArrowGlacier | ||
|
||
var mainNetFisrtBlockNumber: BigUInt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps this should be encapsulated in a dictionary with the key being the chainId? This way adding support for other networks would be eaiser
static let BaseFeeChangeDenominator: BigUInt = 8 // Bounds the amount the base fee can change between blocks. | ||
static let ElasticityMultiplier: BigUInt = 2 // Bounds the maximum gas limit an EIP-1559 block may have. | ||
static let InitialBaseFee: BigUInt = 1000000000 // Initial base fee for EIP-1559 blocks. | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file is missing a newline at the end
And object that predicts required transactions gas fee and tip amounts to proceed success. - Change all Block side gas methods to static since they don't need any Web3 scope values.
- `Oracle(_ provider: web3, blocksNumber: BigUInt = 20, transactionsNumber: BigUInt = 50)` to init object instance. - `predictBaseFee(_ statistic: Statistic) -> BigUInt?` to predict base fee according to given statistic. - `predictTip(_ statistic: Statistic) -> BigUInt?` to predict tip fee according to given statistic. - `predictBothFees(baseFee: Statistic, tip: Statistic) -> (BigUInt, BigUInt)?` to predict both fees according to given statistic All of the methods above returns nil if fails to predict. There's follow modes (statistics) are available yet: - `Statistic.minimum` — comes with minimum valid values - `Statistic.mean` — comes with mean valid values - `Statistic.median` — comes with median valid values - `Statistic.maximum` - comes with maximum valid values
84393e6
to
56e7eec
Compare
2346310
to
517eaaf
Compare
This reverts commit 03f55e2. Delete Web3+Oracle.swift
This PR adds follow API methods:
Web3().isEip1559Block(parent: Block, current: Block) -> Bool
for verifying is current block valid post EIP-1559 block.calcBaseFee(_ parent: Block) -> BigUInt
for baseFee amount calculating for the currently processing block based on already processed given block.Web3.ChainVersion
enum which stores some of the last of the mainNet Ethereum forks.Web3.ChainVersion.mainNetFisrtBlockNumber
— numbers of the each MainNet fork block.Web3.getChainVersion(of block: BigUInt) -> ChainVersion
static method that returns ChainVersion of the given block on the MainNet.Block
structure now have computedvar chainVersion: Web3.ChainVersion