@nomicfoundation/edr 0.12.0-next.5 → 0.12.0-next.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +25 -0
- package/package.json +8 -8
- package/src/chains/generic.rs +1 -2
- package/src/chains/l1.rs +62 -62
- package/src/chains/op.rs +15 -14
- package/src/config.rs +62 -5
- package/src/log.rs +2 -2
- package/src/mock/time.rs +3 -2
- package/src/mock.rs +2 -1
- package/src/provider/response.rs +4 -4
- package/src/result.rs +24 -48
- package/src/solidity_tests/l1.rs +6 -6
- package/src/solidity_tests/op.rs +4 -4
- package/src/solidity_tests/runner.rs +1 -1
- package/src/trace/exit.rs +9 -8
- package/src/trace.rs +5 -4
package/index.d.ts
CHANGED
|
@@ -162,6 +162,20 @@ export const FJORD: string
|
|
|
162
162
|
export const GRANITE: string
|
|
163
163
|
export const HOLOCENE: string
|
|
164
164
|
export const ISTHMUS: string
|
|
165
|
+
/** Configuration for EIP-1559 parameters */
|
|
166
|
+
export interface BaseFeeParamActivation {
|
|
167
|
+
activation: BaseFeeActivationByBlockNumber | BaseFeeActivationByHardfork
|
|
168
|
+
maxChangeDenominator: bigint
|
|
169
|
+
elasticityMultiplier: bigint
|
|
170
|
+
}
|
|
171
|
+
export interface BaseFeeActivationByBlockNumber {
|
|
172
|
+
/** The block number at which the base_fee_params is activated */
|
|
173
|
+
blockNumber: bigint
|
|
174
|
+
}
|
|
175
|
+
export interface BaseFeeActivationByHardfork {
|
|
176
|
+
/** The hardfork at which the base_fee_params is activated */
|
|
177
|
+
hardfork: string
|
|
178
|
+
}
|
|
165
179
|
/** Specification of a chain with possible overrides. */
|
|
166
180
|
export interface ChainOverride {
|
|
167
181
|
/** The chain ID */
|
|
@@ -255,6 +269,17 @@ export interface ProviderConfig {
|
|
|
255
269
|
bailOnCallFailure: boolean
|
|
256
270
|
/** Whether to return an `Err` when a `eth_sendTransaction` fails */
|
|
257
271
|
bailOnTransactionFailure: boolean
|
|
272
|
+
/**
|
|
273
|
+
* EIP-1559 base fee parameters activations to be used to calculate the
|
|
274
|
+
* block base fee.
|
|
275
|
+
*
|
|
276
|
+
* Provide an ordered list of base_fee_params to be
|
|
277
|
+
* used starting from the specified activation point (hardfork or block
|
|
278
|
+
* number).
|
|
279
|
+
* If not provided, the default values from the chain spec
|
|
280
|
+
* will be used.
|
|
281
|
+
*/
|
|
282
|
+
baseFeeConfig?: Array<BaseFeeParamActivation>
|
|
258
283
|
/** The gas limit of each block */
|
|
259
284
|
blockGasLimit: bigint
|
|
260
285
|
/** The chain ID of the blockchain */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/edr",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.6",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@napi-rs/cli": "^2.18.4",
|
|
6
6
|
"@nomicfoundation/ethereumjs-util": "^9.0.4",
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"repository": "NomicFoundation/edr.git",
|
|
60
60
|
"types": "index.d.ts",
|
|
61
61
|
"optionalDependencies": {
|
|
62
|
-
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.
|
|
63
|
-
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.
|
|
64
|
-
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.
|
|
65
|
-
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.
|
|
66
|
-
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.
|
|
67
|
-
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.
|
|
68
|
-
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.
|
|
62
|
+
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.6",
|
|
63
|
+
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.6",
|
|
64
|
+
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.6",
|
|
65
|
+
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.6",
|
|
66
|
+
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.6",
|
|
67
|
+
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.6",
|
|
68
|
+
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.6"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"artifacts": "napi artifacts",
|
package/src/chains/generic.rs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
use std::sync::Arc;
|
|
2
2
|
|
|
3
|
-
use edr_eth::l1;
|
|
4
3
|
use edr_generic::GenericChainSpec;
|
|
5
4
|
use edr_napi_core::{
|
|
6
5
|
logger::Logger,
|
|
@@ -31,7 +30,7 @@ impl SyncProviderFactory for GenericChainProviderFactory {
|
|
|
31
30
|
)?;
|
|
32
31
|
|
|
33
32
|
let provider_config =
|
|
34
|
-
edr_provider::ProviderConfig::<
|
|
33
|
+
edr_provider::ProviderConfig::<edr_chain_l1::Hardfork>::try_from(provider_config)?;
|
|
35
34
|
|
|
36
35
|
let provider = edr_provider::Provider::<GenericChainSpec>::new(
|
|
37
36
|
runtime.clone(),
|
package/src/chains/l1.rs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
use std::{str::FromStr, sync::Arc};
|
|
2
2
|
|
|
3
|
-
use
|
|
3
|
+
use edr_chain_l1::L1ChainSpec;
|
|
4
4
|
use edr_evm::eips::{
|
|
5
5
|
eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_UNSUPPORTED_BYTECODE},
|
|
6
6
|
eip4788::{BEACON_ROOTS_ADDRESS, BEACON_ROOTS_BYTECODE},
|
|
@@ -35,7 +35,7 @@ impl SyncProviderFactory for L1ProviderFactory {
|
|
|
35
35
|
Logger::<L1ChainSpec, CurrentTime>::new(logger_config, Arc::clone(&contract_decoder))?;
|
|
36
36
|
|
|
37
37
|
let provider_config =
|
|
38
|
-
edr_provider::ProviderConfig::<
|
|
38
|
+
edr_provider::ProviderConfig::<edr_chain_l1::Hardfork>::try_from(provider_config)?;
|
|
39
39
|
|
|
40
40
|
let provider = edr_provider::Provider::<L1ChainSpec>::new(
|
|
41
41
|
runtime.clone(),
|
|
@@ -52,7 +52,7 @@ impl SyncProviderFactory for L1ProviderFactory {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
#[napi]
|
|
55
|
-
pub const L1_CHAIN_TYPE: &str =
|
|
55
|
+
pub const L1_CHAIN_TYPE: &str = edr_chain_l1::CHAIN_TYPE;
|
|
56
56
|
|
|
57
57
|
#[napi(catch_unwind)]
|
|
58
58
|
pub fn l1_genesis_state(hardfork: SpecId) -> Vec<AccountOverride> {
|
|
@@ -142,25 +142,25 @@ impl FromStr for SpecId {
|
|
|
142
142
|
|
|
143
143
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
144
144
|
match s {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
145
|
+
edr_chain_l1::hardfork::name::FRONTIER => Ok(SpecId::Frontier),
|
|
146
|
+
edr_chain_l1::hardfork::name::FRONTIER_THAWING => Ok(SpecId::FrontierThawing),
|
|
147
|
+
edr_chain_l1::hardfork::name::HOMESTEAD => Ok(SpecId::Homestead),
|
|
148
|
+
edr_chain_l1::hardfork::name::DAO_FORK => Ok(SpecId::DaoFork),
|
|
149
|
+
edr_chain_l1::hardfork::name::TANGERINE => Ok(SpecId::Tangerine),
|
|
150
|
+
edr_chain_l1::hardfork::name::SPURIOUS_DRAGON => Ok(SpecId::SpuriousDragon),
|
|
151
|
+
edr_chain_l1::hardfork::name::BYZANTIUM => Ok(SpecId::Byzantium),
|
|
152
|
+
edr_chain_l1::hardfork::name::CONSTANTINOPLE => Ok(SpecId::Constantinople),
|
|
153
|
+
edr_chain_l1::hardfork::name::PETERSBURG => Ok(SpecId::Petersburg),
|
|
154
|
+
edr_chain_l1::hardfork::name::ISTANBUL => Ok(SpecId::Istanbul),
|
|
155
|
+
edr_chain_l1::hardfork::name::MUIR_GLACIER => Ok(SpecId::MuirGlacier),
|
|
156
|
+
edr_chain_l1::hardfork::name::BERLIN => Ok(SpecId::Berlin),
|
|
157
|
+
edr_chain_l1::hardfork::name::LONDON => Ok(SpecId::London),
|
|
158
|
+
edr_chain_l1::hardfork::name::ARROW_GLACIER => Ok(SpecId::ArrowGlacier),
|
|
159
|
+
edr_chain_l1::hardfork::name::GRAY_GLACIER => Ok(SpecId::GrayGlacier),
|
|
160
|
+
edr_chain_l1::hardfork::name::MERGE => Ok(SpecId::Merge),
|
|
161
|
+
edr_chain_l1::hardfork::name::SHANGHAI => Ok(SpecId::Shanghai),
|
|
162
|
+
edr_chain_l1::hardfork::name::CANCUN => Ok(SpecId::Cancun),
|
|
163
|
+
edr_chain_l1::hardfork::name::PRAGUE => Ok(SpecId::Prague),
|
|
164
164
|
_ => Err(napi::Error::new(
|
|
165
165
|
napi::Status::InvalidArg,
|
|
166
166
|
format!("The provided hardfork `{s}` is not supported."),
|
|
@@ -169,28 +169,28 @@ impl FromStr for SpecId {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
impl From<SpecId> for
|
|
172
|
+
impl From<SpecId> for edr_chain_l1::Hardfork {
|
|
173
173
|
fn from(value: SpecId) -> Self {
|
|
174
174
|
match value {
|
|
175
|
-
SpecId::Frontier =>
|
|
176
|
-
SpecId::FrontierThawing =>
|
|
177
|
-
SpecId::Homestead =>
|
|
178
|
-
SpecId::DaoFork =>
|
|
179
|
-
SpecId::Tangerine =>
|
|
180
|
-
SpecId::SpuriousDragon =>
|
|
181
|
-
SpecId::Byzantium =>
|
|
182
|
-
SpecId::Constantinople =>
|
|
183
|
-
SpecId::Petersburg =>
|
|
184
|
-
SpecId::Istanbul =>
|
|
185
|
-
SpecId::MuirGlacier =>
|
|
186
|
-
SpecId::Berlin =>
|
|
187
|
-
SpecId::London =>
|
|
188
|
-
SpecId::ArrowGlacier =>
|
|
189
|
-
SpecId::GrayGlacier =>
|
|
190
|
-
SpecId::Merge =>
|
|
191
|
-
SpecId::Shanghai =>
|
|
192
|
-
SpecId::Cancun =>
|
|
193
|
-
SpecId::Prague =>
|
|
175
|
+
SpecId::Frontier => edr_chain_l1::Hardfork::FRONTIER,
|
|
176
|
+
SpecId::FrontierThawing => edr_chain_l1::Hardfork::FRONTIER_THAWING,
|
|
177
|
+
SpecId::Homestead => edr_chain_l1::Hardfork::HOMESTEAD,
|
|
178
|
+
SpecId::DaoFork => edr_chain_l1::Hardfork::DAO_FORK,
|
|
179
|
+
SpecId::Tangerine => edr_chain_l1::Hardfork::TANGERINE,
|
|
180
|
+
SpecId::SpuriousDragon => edr_chain_l1::Hardfork::SPURIOUS_DRAGON,
|
|
181
|
+
SpecId::Byzantium => edr_chain_l1::Hardfork::BYZANTIUM,
|
|
182
|
+
SpecId::Constantinople => edr_chain_l1::Hardfork::CONSTANTINOPLE,
|
|
183
|
+
SpecId::Petersburg => edr_chain_l1::Hardfork::PETERSBURG,
|
|
184
|
+
SpecId::Istanbul => edr_chain_l1::Hardfork::ISTANBUL,
|
|
185
|
+
SpecId::MuirGlacier => edr_chain_l1::Hardfork::MUIR_GLACIER,
|
|
186
|
+
SpecId::Berlin => edr_chain_l1::Hardfork::BERLIN,
|
|
187
|
+
SpecId::London => edr_chain_l1::Hardfork::LONDON,
|
|
188
|
+
SpecId::ArrowGlacier => edr_chain_l1::Hardfork::ARROW_GLACIER,
|
|
189
|
+
SpecId::GrayGlacier => edr_chain_l1::Hardfork::GRAY_GLACIER,
|
|
190
|
+
SpecId::Merge => edr_chain_l1::Hardfork::MERGE,
|
|
191
|
+
SpecId::Shanghai => edr_chain_l1::Hardfork::SHANGHAI,
|
|
192
|
+
SpecId::Cancun => edr_chain_l1::Hardfork::CANCUN,
|
|
193
|
+
SpecId::Prague => edr_chain_l1::Hardfork::PRAGUE,
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -206,25 +206,25 @@ pub fn l1_hardfork_from_string(hardfork: String) -> napi::Result<SpecId> {
|
|
|
206
206
|
#[napi(catch_unwind)]
|
|
207
207
|
pub fn l1_hardfork_to_string(harfork: SpecId) -> &'static str {
|
|
208
208
|
match harfork {
|
|
209
|
-
SpecId::Frontier =>
|
|
210
|
-
SpecId::FrontierThawing =>
|
|
211
|
-
SpecId::Homestead =>
|
|
212
|
-
SpecId::DaoFork =>
|
|
213
|
-
SpecId::Tangerine =>
|
|
214
|
-
SpecId::SpuriousDragon =>
|
|
215
|
-
SpecId::Byzantium =>
|
|
216
|
-
SpecId::Constantinople =>
|
|
217
|
-
SpecId::Petersburg =>
|
|
218
|
-
SpecId::Istanbul =>
|
|
219
|
-
SpecId::MuirGlacier =>
|
|
220
|
-
SpecId::Berlin =>
|
|
221
|
-
SpecId::London =>
|
|
222
|
-
SpecId::ArrowGlacier =>
|
|
223
|
-
SpecId::GrayGlacier =>
|
|
224
|
-
SpecId::Merge =>
|
|
225
|
-
SpecId::Shanghai =>
|
|
226
|
-
SpecId::Cancun =>
|
|
227
|
-
SpecId::Prague =>
|
|
209
|
+
SpecId::Frontier => edr_chain_l1::hardfork::name::FRONTIER,
|
|
210
|
+
SpecId::FrontierThawing => edr_chain_l1::hardfork::name::FRONTIER_THAWING,
|
|
211
|
+
SpecId::Homestead => edr_chain_l1::hardfork::name::HOMESTEAD,
|
|
212
|
+
SpecId::DaoFork => edr_chain_l1::hardfork::name::DAO_FORK,
|
|
213
|
+
SpecId::Tangerine => edr_chain_l1::hardfork::name::TANGERINE,
|
|
214
|
+
SpecId::SpuriousDragon => edr_chain_l1::hardfork::name::SPURIOUS_DRAGON,
|
|
215
|
+
SpecId::Byzantium => edr_chain_l1::hardfork::name::BYZANTIUM,
|
|
216
|
+
SpecId::Constantinople => edr_chain_l1::hardfork::name::CONSTANTINOPLE,
|
|
217
|
+
SpecId::Petersburg => edr_chain_l1::hardfork::name::PETERSBURG,
|
|
218
|
+
SpecId::Istanbul => edr_chain_l1::hardfork::name::ISTANBUL,
|
|
219
|
+
SpecId::MuirGlacier => edr_chain_l1::hardfork::name::MUIR_GLACIER,
|
|
220
|
+
SpecId::Berlin => edr_chain_l1::hardfork::name::BERLIN,
|
|
221
|
+
SpecId::London => edr_chain_l1::hardfork::name::LONDON,
|
|
222
|
+
SpecId::ArrowGlacier => edr_chain_l1::hardfork::name::ARROW_GLACIER,
|
|
223
|
+
SpecId::GrayGlacier => edr_chain_l1::hardfork::name::GRAY_GLACIER,
|
|
224
|
+
SpecId::Merge => edr_chain_l1::hardfork::name::MERGE,
|
|
225
|
+
SpecId::Shanghai => edr_chain_l1::hardfork::name::SHANGHAI,
|
|
226
|
+
SpecId::Cancun => edr_chain_l1::hardfork::name::CANCUN,
|
|
227
|
+
SpecId::Prague => edr_chain_l1::hardfork::name::PRAGUE,
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
|
|
@@ -240,7 +240,7 @@ macro_rules! export_spec_id {
|
|
|
240
240
|
($($variant:ident),*) => {
|
|
241
241
|
$(
|
|
242
242
|
#[napi]
|
|
243
|
-
pub const $variant: &str =
|
|
243
|
+
pub const $variant: &str = edr_chain_l1::hardfork::name::$variant;
|
|
244
244
|
)*
|
|
245
245
|
};
|
|
246
246
|
}
|
package/src/chains/op.rs
CHANGED
|
@@ -6,7 +6,7 @@ use edr_napi_core::{
|
|
|
6
6
|
provider::{SyncProvider, SyncProviderFactory},
|
|
7
7
|
subscription::subscriber_callback_for_chain_spec,
|
|
8
8
|
};
|
|
9
|
-
use edr_op::{predeploys::GAS_PRICE_ORACLE_ADDRESS, OpChainSpec
|
|
9
|
+
use edr_op::{predeploys::GAS_PRICE_ORACLE_ADDRESS, OpChainSpec};
|
|
10
10
|
use edr_provider::time::CurrentTime;
|
|
11
11
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
12
12
|
use napi::{
|
|
@@ -34,7 +34,8 @@ impl SyncProviderFactory for OpProviderFactory {
|
|
|
34
34
|
let logger =
|
|
35
35
|
Logger::<OpChainSpec, CurrentTime>::new(logger_config, Arc::clone(&contract_decoder))?;
|
|
36
36
|
|
|
37
|
-
let provider_config =
|
|
37
|
+
let provider_config =
|
|
38
|
+
edr_provider::ProviderConfig::<edr_op::Hardfork>::try_from(provider_config)?;
|
|
38
39
|
|
|
39
40
|
let provider = edr_provider::Provider::<OpChainSpec>::new(
|
|
40
41
|
runtime.clone(),
|
|
@@ -63,17 +64,17 @@ pub enum OpHardfork {
|
|
|
63
64
|
Isthmus = 107,
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
impl From<OpHardfork> for
|
|
67
|
+
impl From<OpHardfork> for edr_op::Hardfork {
|
|
67
68
|
fn from(hardfork: OpHardfork) -> Self {
|
|
68
69
|
match hardfork {
|
|
69
|
-
OpHardfork::Bedrock =>
|
|
70
|
-
OpHardfork::Regolith =>
|
|
71
|
-
OpHardfork::Canyon =>
|
|
72
|
-
OpHardfork::Ecotone =>
|
|
73
|
-
OpHardfork::Fjord =>
|
|
74
|
-
OpHardfork::Granite =>
|
|
75
|
-
OpHardfork::Holocene =>
|
|
76
|
-
OpHardfork::Isthmus =>
|
|
70
|
+
OpHardfork::Bedrock => edr_op::Hardfork::BEDROCK,
|
|
71
|
+
OpHardfork::Regolith => edr_op::Hardfork::REGOLITH,
|
|
72
|
+
OpHardfork::Canyon => edr_op::Hardfork::CANYON,
|
|
73
|
+
OpHardfork::Ecotone => edr_op::Hardfork::ECOTONE,
|
|
74
|
+
OpHardfork::Fjord => edr_op::Hardfork::FJORD,
|
|
75
|
+
OpHardfork::Granite => edr_op::Hardfork::GRANITE,
|
|
76
|
+
OpHardfork::Holocene => edr_op::Hardfork::HOLOCENE,
|
|
77
|
+
OpHardfork::Isthmus => edr_op::Hardfork::ISTHMUS,
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
80
|
}
|
|
@@ -335,10 +336,10 @@ pub fn op_provider_factory() -> ProviderFactory {
|
|
|
335
336
|
factory.into()
|
|
336
337
|
}
|
|
337
338
|
|
|
338
|
-
fn gas_price_oracle_override(hardfork:
|
|
339
|
-
if hardfork >=
|
|
339
|
+
fn gas_price_oracle_override(hardfork: edr_op::Hardfork) -> AccountOverride {
|
|
340
|
+
if hardfork >= edr_op::Hardfork::ISTHMUS {
|
|
340
341
|
gas_price_oracle_isthmus()
|
|
341
|
-
} else if hardfork >=
|
|
342
|
+
} else if hardfork >= edr_op::Hardfork::FJORD {
|
|
342
343
|
gas_price_oracle_fjord()
|
|
343
344
|
} else {
|
|
344
345
|
gas_price_oracle_ecotone()
|
package/src/config.rs
CHANGED
|
@@ -7,10 +7,9 @@ use std::{
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
use edr_coverage::reporter::SyncOnCollectedCoverageCallback;
|
|
10
|
-
use
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
10
|
+
use edr_eip1559::{BaseFeeActivation, ConstantBaseFeeParams};
|
|
11
|
+
use edr_eth::{Bytes, HashMap, HashSet};
|
|
12
|
+
use edr_signer::{secret_key_from_str, SecretKey};
|
|
14
13
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
15
14
|
use napi::{
|
|
16
15
|
bindgen_prelude::{BigInt, Promise, Reference, Uint8Array},
|
|
@@ -27,6 +26,49 @@ use crate::{
|
|
|
27
26
|
precompile::Precompile, subscription::SubscriptionConfig,
|
|
28
27
|
};
|
|
29
28
|
|
|
29
|
+
/// Configuration for EIP-1559 parameters
|
|
30
|
+
#[napi(object)]
|
|
31
|
+
pub struct BaseFeeParamActivation {
|
|
32
|
+
pub activation: Either<BaseFeeActivationByBlockNumber, BaseFeeActivationByHardfork>,
|
|
33
|
+
pub max_change_denominator: BigInt,
|
|
34
|
+
pub elasticity_multiplier: BigInt,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#[napi(object)]
|
|
38
|
+
pub struct BaseFeeActivationByBlockNumber {
|
|
39
|
+
/// The block number at which the base_fee_params is activated
|
|
40
|
+
pub block_number: BigInt,
|
|
41
|
+
}
|
|
42
|
+
#[napi(object)]
|
|
43
|
+
pub struct BaseFeeActivationByHardfork {
|
|
44
|
+
/// The hardfork at which the base_fee_params is activated
|
|
45
|
+
pub hardfork: String,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
impl TryFrom<BaseFeeParamActivation> for (BaseFeeActivation<String>, ConstantBaseFeeParams) {
|
|
49
|
+
type Error = napi::Error;
|
|
50
|
+
|
|
51
|
+
fn try_from(value: BaseFeeParamActivation) -> Result<Self, Self::Error> {
|
|
52
|
+
let base_fee_params = ConstantBaseFeeParams {
|
|
53
|
+
max_change_denominator: value.max_change_denominator.try_cast()?,
|
|
54
|
+
elasticity_multiplier: value.elasticity_multiplier.try_cast()?,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
match value.activation {
|
|
58
|
+
Either::A(BaseFeeActivationByBlockNumber { block_number }) => {
|
|
59
|
+
let activation_block_number: u64 = block_number.try_cast()?;
|
|
60
|
+
Ok((
|
|
61
|
+
BaseFeeActivation::BlockNumber(activation_block_number),
|
|
62
|
+
base_fee_params,
|
|
63
|
+
))
|
|
64
|
+
}
|
|
65
|
+
Either::B(BaseFeeActivationByHardfork { hardfork }) => {
|
|
66
|
+
Ok((BaseFeeActivation::Hardfork(hardfork), base_fee_params))
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
30
72
|
/// Specification of a chain with possible overrides.
|
|
31
73
|
#[napi(object)]
|
|
32
74
|
pub struct ChainOverride {
|
|
@@ -142,6 +184,15 @@ pub struct ProviderConfig {
|
|
|
142
184
|
pub bail_on_call_failure: bool,
|
|
143
185
|
/// Whether to return an `Err` when a `eth_sendTransaction` fails
|
|
144
186
|
pub bail_on_transaction_failure: bool,
|
|
187
|
+
/// EIP-1559 base fee parameters activations to be used to calculate the
|
|
188
|
+
/// block base fee.
|
|
189
|
+
///
|
|
190
|
+
/// Provide an ordered list of base_fee_params to be
|
|
191
|
+
/// used starting from the specified activation point (hardfork or block
|
|
192
|
+
/// number).
|
|
193
|
+
/// If not provided, the default values from the chain spec
|
|
194
|
+
/// will be used.
|
|
195
|
+
pub base_fee_config: Option<Vec<BaseFeeParamActivation>>,
|
|
145
196
|
/// The gas limit of each block
|
|
146
197
|
pub block_gas_limit: BigInt,
|
|
147
198
|
/// The chain ID of the blockchain
|
|
@@ -423,7 +474,7 @@ impl ProviderConfig {
|
|
|
423
474
|
// This is the only place in production code where it's allowed to use
|
|
424
475
|
// `DangerousSecretKeyStr`.
|
|
425
476
|
#[allow(deprecated)]
|
|
426
|
-
use
|
|
477
|
+
use edr_signer::DangerousSecretKeyStr;
|
|
427
478
|
|
|
428
479
|
static_assertions::assert_not_impl_all!(JsString: Debug, Display, serde::Serialize);
|
|
429
480
|
static_assertions::assert_not_impl_all!(JsStringUtf8: Debug, Display, serde::Serialize);
|
|
@@ -443,6 +494,11 @@ impl ProviderConfig {
|
|
|
443
494
|
})
|
|
444
495
|
.collect::<napi::Result<Vec<_>>>()?;
|
|
445
496
|
|
|
497
|
+
let base_fee_params: Option<Vec<(BaseFeeActivation<String>, ConstantBaseFeeParams)>> = self
|
|
498
|
+
.base_fee_config
|
|
499
|
+
.map(|vec| vec.into_iter().map(TryInto::try_into).collect())
|
|
500
|
+
.transpose()?;
|
|
501
|
+
|
|
446
502
|
let block_gas_limit =
|
|
447
503
|
NonZeroU64::new(self.block_gas_limit.try_cast()?).ok_or_else(|| {
|
|
448
504
|
napi::Error::new(
|
|
@@ -468,6 +524,7 @@ impl ProviderConfig {
|
|
|
468
524
|
allow_unlimited_contract_size: self.allow_unlimited_contract_size,
|
|
469
525
|
bail_on_call_failure: self.bail_on_call_failure,
|
|
470
526
|
bail_on_transaction_failure: self.bail_on_transaction_failure,
|
|
527
|
+
base_fee_params,
|
|
471
528
|
block_gas_limit,
|
|
472
529
|
chain_id: self.chain_id.try_cast()?,
|
|
473
530
|
coinbase: self.coinbase.try_cast()?,
|
package/src/log.rs
CHANGED
|
@@ -9,8 +9,8 @@ pub struct ExecutionLog {
|
|
|
9
9
|
pub data: Uint8Array,
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
impl From<&
|
|
13
|
-
fn from(value: &
|
|
12
|
+
impl From<&edr_receipt::log::ExecutionLog> for ExecutionLog {
|
|
13
|
+
fn from(value: &edr_receipt::log::ExecutionLog) -> Self {
|
|
14
14
|
let topics = value
|
|
15
15
|
.topics()
|
|
16
16
|
.iter()
|
package/src/mock/time.rs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
use std::sync::Arc;
|
|
2
2
|
|
|
3
|
-
use edr_eth::
|
|
3
|
+
use edr_eth::B256;
|
|
4
4
|
use edr_evm::spec::RuntimeSpec;
|
|
5
|
+
use edr_evm_spec::ChainSpec;
|
|
5
6
|
use edr_generic::GenericChainSpec;
|
|
6
7
|
use edr_napi_core::logger::Logger;
|
|
7
8
|
use edr_rpc_eth::RpcSpec;
|
|
@@ -95,7 +96,7 @@ pub fn create_provider_with_mock_timer(
|
|
|
95
96
|
)?;
|
|
96
97
|
|
|
97
98
|
let provider_config =
|
|
98
|
-
edr_provider::ProviderConfig::<
|
|
99
|
+
edr_provider::ProviderConfig::<edr_chain_l1::Hardfork>::try_from(provider_config)?;
|
|
99
100
|
|
|
100
101
|
let provider =
|
|
101
102
|
edr_provider::Provider::<GenericChainSpec, Arc<edr_provider::time::MockTime>>::new(
|
package/src/mock.rs
CHANGED
|
@@ -2,6 +2,7 @@ pub mod time;
|
|
|
2
2
|
|
|
3
3
|
use std::sync::Arc;
|
|
4
4
|
|
|
5
|
+
use edr_evm_spec::EvmHaltReason;
|
|
5
6
|
use edr_napi_core::provider::SyncProvider;
|
|
6
7
|
use edr_rpc_client::jsonrpc;
|
|
7
8
|
use edr_solidity::contract_decoder::ContractDecoder;
|
|
@@ -35,7 +36,7 @@ impl SyncProvider for MockProvider {
|
|
|
35
36
|
&self,
|
|
36
37
|
_request: String,
|
|
37
38
|
_contract_decoder: Arc<ContractDecoder>,
|
|
38
|
-
) -> napi::Result<edr_napi_core::spec::Response<
|
|
39
|
+
) -> napi::Result<edr_napi_core::spec::Response<EvmHaltReason>> {
|
|
39
40
|
let response = jsonrpc::ResponseData::Success {
|
|
40
41
|
result: self.mocked_response.clone(),
|
|
41
42
|
};
|
package/src/provider/response.rs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use
|
|
1
|
+
use edr_evm_spec::EvmHaltReason;
|
|
2
2
|
use edr_napi_core::spec::SolidityTraceData;
|
|
3
3
|
use edr_solidity::contract_decoder::NestedTraceDecoder as _;
|
|
4
4
|
use napi::Either;
|
|
@@ -11,11 +11,11 @@ use crate::{
|
|
|
11
11
|
|
|
12
12
|
#[napi]
|
|
13
13
|
pub struct Response {
|
|
14
|
-
inner: edr_napi_core::spec::Response<
|
|
14
|
+
inner: edr_napi_core::spec::Response<EvmHaltReason>,
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
impl From<edr_napi_core::spec::Response<
|
|
18
|
-
fn from(value: edr_napi_core::spec::Response<
|
|
17
|
+
impl From<edr_napi_core::spec::Response<EvmHaltReason>> for Response {
|
|
18
|
+
fn from(value: edr_napi_core::spec::Response<EvmHaltReason>) -> Self {
|
|
19
19
|
Self { inner: value }
|
|
20
20
|
}
|
|
21
21
|
}
|
package/src/result.rs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
use edr_evm::trace::AfterMessage;
|
|
2
|
+
use edr_evm_spec::EvmHaltReason;
|
|
2
3
|
use napi::{
|
|
3
4
|
bindgen_prelude::{BigInt, Either3, Uint8Array},
|
|
4
5
|
Either,
|
|
@@ -99,61 +100,36 @@ pub enum ExceptionalHalt {
|
|
|
99
100
|
CreateInitCodeSizeLimit,
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
impl From<
|
|
103
|
-
fn from(halt:
|
|
103
|
+
impl From<EvmHaltReason> for ExceptionalHalt {
|
|
104
|
+
fn from(halt: EvmHaltReason) -> Self {
|
|
104
105
|
match halt {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
edr_eth::l1::HaltReason::CreateContractStartingWithEF => {
|
|
106
|
+
EvmHaltReason::OutOfGas(..) => ExceptionalHalt::OutOfGas,
|
|
107
|
+
EvmHaltReason::OpcodeNotFound => ExceptionalHalt::OpcodeNotFound,
|
|
108
|
+
EvmHaltReason::InvalidFEOpcode => ExceptionalHalt::InvalidFEOpcode,
|
|
109
|
+
EvmHaltReason::InvalidJump => ExceptionalHalt::InvalidJump,
|
|
110
|
+
EvmHaltReason::NotActivated => ExceptionalHalt::NotActivated,
|
|
111
|
+
EvmHaltReason::StackUnderflow => ExceptionalHalt::StackUnderflow,
|
|
112
|
+
EvmHaltReason::StackOverflow => ExceptionalHalt::StackOverflow,
|
|
113
|
+
EvmHaltReason::OutOfOffset => ExceptionalHalt::OutOfOffset,
|
|
114
|
+
EvmHaltReason::CreateCollision => ExceptionalHalt::CreateCollision,
|
|
115
|
+
EvmHaltReason::PrecompileError => ExceptionalHalt::PrecompileError,
|
|
116
|
+
EvmHaltReason::NonceOverflow => ExceptionalHalt::NonceOverflow,
|
|
117
|
+
EvmHaltReason::CreateContractSizeLimit => ExceptionalHalt::CreateContractSizeLimit,
|
|
118
|
+
EvmHaltReason::CreateContractStartingWithEF => {
|
|
120
119
|
ExceptionalHalt::CreateContractStartingWithEF
|
|
121
120
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
| edr_eth::l1::HaltReason::OutOfFunds
|
|
129
|
-
| edr_eth::l1::HaltReason::CallTooDeep => {
|
|
121
|
+
EvmHaltReason::CreateInitCodeSizeLimit => ExceptionalHalt::CreateInitCodeSizeLimit,
|
|
122
|
+
EvmHaltReason::OverflowPayment
|
|
123
|
+
| EvmHaltReason::StateChangeDuringStaticCall
|
|
124
|
+
| EvmHaltReason::CallNotAllowedInsideStatic
|
|
125
|
+
| EvmHaltReason::OutOfFunds
|
|
126
|
+
| EvmHaltReason::CallTooDeep => {
|
|
130
127
|
unreachable!("Internal halts that can be only found inside Inspector: {halt:?}")
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
130
|
}
|
|
134
131
|
}
|
|
135
132
|
|
|
136
|
-
impl From<ExceptionalHalt> for edr_eth::l1::HaltReason {
|
|
137
|
-
fn from(value: ExceptionalHalt) -> Self {
|
|
138
|
-
match value {
|
|
139
|
-
ExceptionalHalt::OutOfGas => Self::OutOfGas(edr_eth::l1::OutOfGasError::Basic),
|
|
140
|
-
ExceptionalHalt::OpcodeNotFound => Self::OpcodeNotFound,
|
|
141
|
-
ExceptionalHalt::InvalidFEOpcode => Self::InvalidFEOpcode,
|
|
142
|
-
ExceptionalHalt::InvalidJump => Self::InvalidJump,
|
|
143
|
-
ExceptionalHalt::NotActivated => Self::NotActivated,
|
|
144
|
-
ExceptionalHalt::StackUnderflow => Self::StackUnderflow,
|
|
145
|
-
ExceptionalHalt::StackOverflow => Self::StackOverflow,
|
|
146
|
-
ExceptionalHalt::OutOfOffset => Self::OutOfOffset,
|
|
147
|
-
ExceptionalHalt::CreateCollision => Self::CreateCollision,
|
|
148
|
-
ExceptionalHalt::PrecompileError => Self::PrecompileError,
|
|
149
|
-
ExceptionalHalt::NonceOverflow => Self::NonceOverflow,
|
|
150
|
-
ExceptionalHalt::CreateContractSizeLimit => Self::CreateContractSizeLimit,
|
|
151
|
-
ExceptionalHalt::CreateContractStartingWithEF => Self::CreateContractStartingWithEF,
|
|
152
|
-
ExceptionalHalt::CreateInitCodeSizeLimit => Self::CreateInitCodeSizeLimit,
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
133
|
/// The result when the EVM terminates due to an exceptional halt.
|
|
158
134
|
#[napi(object)]
|
|
159
135
|
pub struct HaltResult {
|
|
@@ -173,8 +149,8 @@ pub struct ExecutionResult {
|
|
|
173
149
|
pub contract_address: Option<Uint8Array>,
|
|
174
150
|
}
|
|
175
151
|
|
|
176
|
-
impl From<&AfterMessage<
|
|
177
|
-
fn from(value: &AfterMessage<
|
|
152
|
+
impl From<&AfterMessage<EvmHaltReason>> for ExecutionResult {
|
|
153
|
+
fn from(value: &AfterMessage<EvmHaltReason>) -> Self {
|
|
178
154
|
let AfterMessage {
|
|
179
155
|
execution_result,
|
|
180
156
|
contract_address,
|
package/src/solidity_tests/l1.rs
CHANGED
|
@@ -8,7 +8,7 @@ use edr_napi_core::solidity::{
|
|
|
8
8
|
use edr_solidity::artifacts::ArtifactId;
|
|
9
9
|
use edr_solidity_tests::{
|
|
10
10
|
contracts::ContractsByArtifact, decode::RevertDecoder, evm_context::L1EvmBuilder,
|
|
11
|
-
multi_runner::TestContract,
|
|
11
|
+
multi_runner::TestContract, MultiContractRunner,
|
|
12
12
|
};
|
|
13
13
|
use napi::tokio;
|
|
14
14
|
use napi_derive::napi;
|
|
@@ -33,14 +33,14 @@ impl SyncTestRunnerFactory for L1TestRunnerFactory {
|
|
|
33
33
|
let runner = tokio::task::block_in_place(|| {
|
|
34
34
|
runtime
|
|
35
35
|
.block_on(MultiContractRunner::<
|
|
36
|
-
|
|
36
|
+
edr_chain_l1::BlockEnv,
|
|
37
37
|
(),
|
|
38
38
|
L1EvmBuilder,
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
edr_chain_l1::HaltReason,
|
|
40
|
+
edr_chain_l1::Hardfork,
|
|
41
41
|
_,
|
|
42
|
-
|
|
43
|
-
TxEnv,
|
|
42
|
+
edr_chain_l1::InvalidTransaction,
|
|
43
|
+
edr_chain_l1::TxEnv,
|
|
44
44
|
>::new(
|
|
45
45
|
config.try_into()?,
|
|
46
46
|
contracts,
|
package/src/solidity_tests/op.rs
CHANGED
|
@@ -34,14 +34,14 @@ impl SyncTestRunnerFactory for OpTestRunnerFactory {
|
|
|
34
34
|
let runner = tokio::task::block_in_place(|| {
|
|
35
35
|
runtime
|
|
36
36
|
.block_on(MultiContractRunner::<
|
|
37
|
-
|
|
37
|
+
edr_op::BlockEnv,
|
|
38
38
|
_,
|
|
39
39
|
OpEvmBuilder,
|
|
40
|
-
edr_op::
|
|
41
|
-
edr_op::
|
|
40
|
+
edr_op::HaltReason,
|
|
41
|
+
edr_op::Hardfork,
|
|
42
42
|
_,
|
|
43
43
|
edr_op::transaction::InvalidTransaction,
|
|
44
|
-
edr_op::transaction::OpTxEnv<
|
|
44
|
+
edr_op::transaction::OpTxEnv<edr_chain_l1::TxEnv>,
|
|
45
45
|
>::new(
|
|
46
46
|
config.try_into()?,
|
|
47
47
|
contracts,
|
package/src/trace/exit.rs
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
use std::fmt;
|
|
5
5
|
|
|
6
|
+
use edr_evm_spec::EvmHaltReason;
|
|
6
7
|
use napi_derive::napi;
|
|
7
8
|
|
|
8
9
|
#[napi]
|
|
@@ -50,20 +51,20 @@ impl fmt::Display for ExitCode {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
#[allow(clippy::fallible_impl_from)] // naively ported for now
|
|
53
|
-
impl From<edr_solidity::exit_code::ExitCode<
|
|
54
|
-
fn from(code: edr_solidity::exit_code::ExitCode<
|
|
54
|
+
impl From<edr_solidity::exit_code::ExitCode<EvmHaltReason>> for ExitCode {
|
|
55
|
+
fn from(code: edr_solidity::exit_code::ExitCode<EvmHaltReason>) -> Self {
|
|
55
56
|
use edr_solidity::exit_code::ExitCode;
|
|
56
57
|
|
|
57
58
|
match code {
|
|
58
59
|
ExitCode::Success => Self::SUCCESS,
|
|
59
60
|
ExitCode::Revert => Self::REVERT,
|
|
60
|
-
ExitCode::Halt(
|
|
61
|
-
ExitCode::Halt(
|
|
61
|
+
ExitCode::Halt(EvmHaltReason::OutOfGas(_)) => Self::OUT_OF_GAS,
|
|
62
|
+
ExitCode::Halt(EvmHaltReason::OpcodeNotFound | EvmHaltReason::InvalidFEOpcode
|
|
62
63
|
// Returned when an opcode is not implemented for the hardfork
|
|
63
|
-
|
|
|
64
|
-
ExitCode::Halt(
|
|
65
|
-
ExitCode::Halt(
|
|
66
|
-
ExitCode::Halt(
|
|
64
|
+
| EvmHaltReason::NotActivated) => Self::INVALID_OPCODE,
|
|
65
|
+
ExitCode::Halt(EvmHaltReason::StackUnderflow) => Self::STACK_UNDERFLOW,
|
|
66
|
+
ExitCode::Halt(EvmHaltReason::CreateContractSizeLimit) => Self::CODESIZE_EXCEEDS_MAXIMUM,
|
|
67
|
+
ExitCode::Halt(EvmHaltReason::CreateCollision) => Self::CREATE_COLLISION,
|
|
67
68
|
_ => Self::UNKNOWN_HALT_REASON,
|
|
68
69
|
}
|
|
69
70
|
}
|
package/src/trace.rs
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
use std::sync::Arc;
|
|
9
9
|
|
|
10
|
-
use edr_eth::
|
|
10
|
+
use edr_eth::bytecode::opcode::OpCode;
|
|
11
11
|
use edr_evm::trace::BeforeMessage;
|
|
12
|
+
use edr_evm_spec::EvmHaltReason;
|
|
12
13
|
use napi::bindgen_prelude::{BigInt, Either3, Uint8Array};
|
|
13
14
|
use napi_derive::napi;
|
|
14
15
|
|
|
@@ -161,11 +162,11 @@ pub struct TracingMessageResult {
|
|
|
161
162
|
#[napi]
|
|
162
163
|
#[derive(Clone)]
|
|
163
164
|
pub struct RawTrace {
|
|
164
|
-
inner: Arc<edr_evm::trace::Trace<
|
|
165
|
+
inner: Arc<edr_evm::trace::Trace<EvmHaltReason>>,
|
|
165
166
|
}
|
|
166
167
|
|
|
167
|
-
impl From<Arc<edr_evm::trace::Trace<
|
|
168
|
-
fn from(value: Arc<edr_evm::trace::Trace<
|
|
168
|
+
impl From<Arc<edr_evm::trace::Trace<EvmHaltReason>>> for RawTrace {
|
|
169
|
+
fn from(value: Arc<edr_evm::trace::Trace<EvmHaltReason>>) -> Self {
|
|
169
170
|
Self { inner: value }
|
|
170
171
|
}
|
|
171
172
|
}
|