@nomicfoundation/edr 0.12.0-next.0 → 0.12.0-next.10
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 +217 -64
- package/index.js +4 -1
- package/package.json +26 -21
- package/src/account.rs +6 -5
- package/src/block.rs +1 -1
- package/src/call_override.rs +1 -1
- package/src/cast.rs +1 -1
- package/src/chains/generic.rs +27 -20
- package/src/chains/l1.rs +84 -78
- package/src/chains/op.rs +50 -51
- package/src/config.rs +166 -9
- package/src/context.rs +96 -89
- package/src/contract_decoder.rs +57 -0
- package/src/debug_trace.rs +2 -0
- package/src/gas_report.rs +92 -0
- package/src/lib.rs +4 -1
- package/src/log.rs +2 -2
- package/src/logger.rs +4 -2
- package/src/mock/time.rs +134 -0
- package/src/mock.rs +4 -1
- package/src/precompile.rs +1 -1
- package/src/provider/response.rs +4 -4
- package/src/provider.rs +51 -4
- package/src/result.rs +35 -80
- package/src/serde.rs +1 -1
- package/src/solidity_tests/config.rs +80 -12
- package/src/solidity_tests/l1.rs +7 -7
- package/src/solidity_tests/op.rs +5 -5
- package/src/solidity_tests/runner.rs +1 -1
- package/src/solidity_tests/test_results.rs +109 -41
- package/src/solidity_tests.rs +1 -1
- package/src/trace/debug.rs +29 -26
- package/src/trace/exit.rs +9 -8
- package/src/trace/return_data.rs +19 -7
- package/src/trace/solidity_stack_trace.rs +56 -28
- package/src/trace.rs +6 -5
- package/src/ts/solidity_tests.ts +46 -0
- package/src/withdrawal.rs +5 -5
- package/Cargo.toml +0 -92
- package/build.rs +0 -3
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 */
|
|
@@ -184,6 +198,16 @@ export interface CodeCoverageConfig {
|
|
|
184
198
|
*/
|
|
185
199
|
onCollectedCoverageCallback: (coverageHits: Uint8Array[]) => Promise<void>
|
|
186
200
|
}
|
|
201
|
+
export interface GasReportConfig {
|
|
202
|
+
/**
|
|
203
|
+
* Gas reports are collected after a block is mined or `eth_call` is
|
|
204
|
+
* executed.
|
|
205
|
+
*
|
|
206
|
+
* Exceptions thrown in the callback will be propagated to the original
|
|
207
|
+
* caller.
|
|
208
|
+
*/
|
|
209
|
+
onCollectedGasReportCallback: (gasReport: GasReport) => Promise<void>
|
|
210
|
+
}
|
|
187
211
|
/** Configuration for forking a blockchain */
|
|
188
212
|
export interface ForkConfig {
|
|
189
213
|
/**
|
|
@@ -244,6 +268,8 @@ export interface MiningConfig {
|
|
|
244
268
|
export interface ObservabilityConfig {
|
|
245
269
|
/** If present, configures runtime observability to collect code coverage. */
|
|
246
270
|
codeCoverage?: CodeCoverageConfig
|
|
271
|
+
/** If present, configures runtime observability to collect gas reports. */
|
|
272
|
+
gasReport?: GasReportConfig
|
|
247
273
|
}
|
|
248
274
|
/** Configuration for a provider */
|
|
249
275
|
export interface ProviderConfig {
|
|
@@ -255,6 +281,17 @@ export interface ProviderConfig {
|
|
|
255
281
|
bailOnCallFailure: boolean
|
|
256
282
|
/** Whether to return an `Err` when a `eth_sendTransaction` fails */
|
|
257
283
|
bailOnTransactionFailure: boolean
|
|
284
|
+
/**
|
|
285
|
+
* EIP-1559 base fee parameters activations to be used to calculate the
|
|
286
|
+
* block base fee.
|
|
287
|
+
*
|
|
288
|
+
* Provide an ordered list of `base_fee_params` to be
|
|
289
|
+
* used starting from the specified activation point (hardfork or block
|
|
290
|
+
* number).
|
|
291
|
+
* If not provided, the default values from the chain spec
|
|
292
|
+
* will be used.
|
|
293
|
+
*/
|
|
294
|
+
baseFeeConfig?: Array<BaseFeeParamActivation>
|
|
258
295
|
/** The gas limit of each block */
|
|
259
296
|
blockGasLimit: bigint
|
|
260
297
|
/** The chain ID of the blockchain */
|
|
@@ -347,6 +384,27 @@ export interface DebugTraceLogItem {
|
|
|
347
384
|
/** Map of all stored values with keys and values encoded as hex strings. */
|
|
348
385
|
storage?: Record<string, string>
|
|
349
386
|
}
|
|
387
|
+
export interface GasReport {
|
|
388
|
+
contracts: Record<string, ContractGasReport>
|
|
389
|
+
}
|
|
390
|
+
export interface ContractGasReport {
|
|
391
|
+
deployments: Array<DeploymentGasReport>
|
|
392
|
+
functions: Record<string, Array<FunctionGasReport>>
|
|
393
|
+
}
|
|
394
|
+
export enum GasReportExecutionStatus {
|
|
395
|
+
Success = 0,
|
|
396
|
+
Revert = 1,
|
|
397
|
+
Halt = 2
|
|
398
|
+
}
|
|
399
|
+
export interface DeploymentGasReport {
|
|
400
|
+
gas: bigint
|
|
401
|
+
size: bigint
|
|
402
|
+
status: GasReportExecutionStatus
|
|
403
|
+
}
|
|
404
|
+
export interface FunctionGasReport {
|
|
405
|
+
gas: bigint
|
|
406
|
+
status: GasReportExecutionStatus
|
|
407
|
+
}
|
|
350
408
|
export interface InstrumentationResult {
|
|
351
409
|
/** The generated source code with coverage instrumentation. */
|
|
352
410
|
readonly source: string
|
|
@@ -405,8 +463,7 @@ export enum SuccessReason {
|
|
|
405
463
|
/** The opcode `RETURN` was called */
|
|
406
464
|
Return = 1,
|
|
407
465
|
/** The opcode `SELFDESTRUCT` was called */
|
|
408
|
-
SelfDestruct = 2
|
|
409
|
-
EofReturnContract = 3
|
|
466
|
+
SelfDestruct = 2
|
|
410
467
|
}
|
|
411
468
|
export interface CallOutput {
|
|
412
469
|
/** Return value */
|
|
@@ -459,15 +516,7 @@ export enum ExceptionalHalt {
|
|
|
459
516
|
/** Error on created contract that begins with EF */
|
|
460
517
|
CreateContractStartingWithEF = 12,
|
|
461
518
|
/** EIP-3860: Limit and meter initcode. Initcode size limit exceeded. */
|
|
462
|
-
CreateInitCodeSizeLimit = 13
|
|
463
|
-
/** Aux data overflow, new aux data is larger tha u16 max size. */
|
|
464
|
-
EofAuxDataOverflow = 14,
|
|
465
|
-
/** Aud data is smaller then already present data size. */
|
|
466
|
-
EofAuxDataTooSmall = 15,
|
|
467
|
-
/** EOF Subroutine stack overflow */
|
|
468
|
-
SubRoutineStackOverflow = 16,
|
|
469
|
-
/** Check for target address validity is only done inside subcall. */
|
|
470
|
-
InvalidEXTCALLTarget = 17
|
|
519
|
+
CreateInitCodeSizeLimit = 13
|
|
471
520
|
}
|
|
472
521
|
/** The result when the EVM terminates due to an exceptional halt. */
|
|
473
522
|
export interface HaltResult {
|
|
@@ -628,7 +677,7 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
628
677
|
disableBlockGasLimit?: boolean
|
|
629
678
|
/**
|
|
630
679
|
* The memory limit of the EVM in bytes.
|
|
631
|
-
* Defaults to 33_554_432 (2^25 = 32MiB).
|
|
680
|
+
* Defaults to `33_554_432` (2^25 = 32MiB).
|
|
632
681
|
*/
|
|
633
682
|
memoryLimit?: bigint
|
|
634
683
|
/**
|
|
@@ -673,6 +722,8 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
673
722
|
* config value is set, then the fuzz config value will be used.
|
|
674
723
|
*/
|
|
675
724
|
invariant?: InvariantConfigArgs
|
|
725
|
+
/** Whether to collect stack traces. */
|
|
726
|
+
collectStackTraces?: CollectStackTraces
|
|
676
727
|
/**
|
|
677
728
|
* Controls which test results should include execution traces. Defaults to
|
|
678
729
|
* None.
|
|
@@ -685,6 +736,13 @@ export interface SolidityTestRunnerConfigArgs {
|
|
|
685
736
|
* match the pattern will be executed and reported as a test result.
|
|
686
737
|
*/
|
|
687
738
|
testPattern?: string
|
|
739
|
+
/**
|
|
740
|
+
* Controls whether to generate a gas report after running the tests.
|
|
741
|
+
* Enabling this also enables collection of all traces and EVM isolation
|
|
742
|
+
* mode.
|
|
743
|
+
* Defaults to false.
|
|
744
|
+
*/
|
|
745
|
+
generateGasReport?: boolean
|
|
688
746
|
}
|
|
689
747
|
/** Fuzz testing configuration */
|
|
690
748
|
export interface FuzzConfigArgs {
|
|
@@ -812,14 +870,36 @@ export interface PathPermission {
|
|
|
812
870
|
/** The targeted path guarded by the permission */
|
|
813
871
|
path: string
|
|
814
872
|
}
|
|
815
|
-
/**
|
|
873
|
+
/**
|
|
874
|
+
* Determines the level of file system access for the given path.
|
|
875
|
+
*
|
|
876
|
+
* Exact path matching is used for file permissions. Prefix matching is used
|
|
877
|
+
* for directory permissions.
|
|
878
|
+
*
|
|
879
|
+
* Giving write access to configuration files, source files or executables
|
|
880
|
+
* in a project is considered dangerous, because it can be used by malicious
|
|
881
|
+
* Solidity dependencies to escape the EVM sandbox. It is therefore
|
|
882
|
+
* recommended to give write access to specific safe files only. If write
|
|
883
|
+
* access to a directory is needed, please make sure that it doesn't contain
|
|
884
|
+
* configuration files, source files or executables neither in the top level
|
|
885
|
+
* directory, nor in any subdirectories.
|
|
886
|
+
*/
|
|
816
887
|
export enum FsAccessPermission {
|
|
817
|
-
/**
|
|
818
|
-
|
|
819
|
-
/** Only reading
|
|
820
|
-
|
|
821
|
-
/** Only writing
|
|
822
|
-
|
|
888
|
+
/** Allows reading and writing the file */
|
|
889
|
+
ReadWriteFile = 0,
|
|
890
|
+
/** Only allows reading the file */
|
|
891
|
+
ReadFile = 1,
|
|
892
|
+
/** Only allows writing the file */
|
|
893
|
+
WriteFile = 2,
|
|
894
|
+
/**
|
|
895
|
+
* Allows reading and writing all files in the directory and its
|
|
896
|
+
* subdirectories
|
|
897
|
+
*/
|
|
898
|
+
DangerouslyReadWriteDirectory = 3,
|
|
899
|
+
/** Allows reading all files in the directory and its subdirectories */
|
|
900
|
+
ReadDirectory = 4,
|
|
901
|
+
/** Allows writing all files in the directory and its subdirectories */
|
|
902
|
+
DangerouslyWriteDirectory = 5
|
|
823
903
|
}
|
|
824
904
|
export interface AddressLabel {
|
|
825
905
|
/** The address to label */
|
|
@@ -827,6 +907,19 @@ export interface AddressLabel {
|
|
|
827
907
|
/** The label to assign to the address */
|
|
828
908
|
label: string
|
|
829
909
|
}
|
|
910
|
+
/** A type that controls when stack traces are collected. */
|
|
911
|
+
export enum CollectStackTraces {
|
|
912
|
+
/** Always collects stack traces, adding performance overhead. */
|
|
913
|
+
Always = 0,
|
|
914
|
+
/**
|
|
915
|
+
* Only collects stack traces upon failure, re-executing the test. This
|
|
916
|
+
* minimizes performance overhead.
|
|
917
|
+
*
|
|
918
|
+
* Not all tests can be re-executed since certain cheatcodes contain
|
|
919
|
+
* non-deterministic side-effects.
|
|
920
|
+
*/
|
|
921
|
+
OnFailure = 1
|
|
922
|
+
}
|
|
830
923
|
/**
|
|
831
924
|
* Configuration for [`SolidityTestRunnerConfigArgs::include_traces`] that
|
|
832
925
|
* controls execution trace decoding and inclusion in test results.
|
|
@@ -841,6 +934,20 @@ export enum IncludeTraces {
|
|
|
841
934
|
}
|
|
842
935
|
export declare function l1SolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
843
936
|
export declare function opSolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
937
|
+
/** A grouping of value snapshot entries for a test. */
|
|
938
|
+
export interface ValueSnapshotGroup {
|
|
939
|
+
/** The group name. */
|
|
940
|
+
name: string
|
|
941
|
+
/** The entries in the group. */
|
|
942
|
+
entries: Array<ValueSnapshotEntry>
|
|
943
|
+
}
|
|
944
|
+
/** An entry in a value snapshot group. */
|
|
945
|
+
export interface ValueSnapshotEntry {
|
|
946
|
+
/** The name of the entry. */
|
|
947
|
+
name: string
|
|
948
|
+
/** The value of the entry. */
|
|
949
|
+
value: string
|
|
950
|
+
}
|
|
844
951
|
/** The stack trace result */
|
|
845
952
|
export interface StackTrace {
|
|
846
953
|
/** Enum tag for JS. */
|
|
@@ -896,21 +1003,21 @@ export enum TestStatus {
|
|
|
896
1003
|
/**Test skipped */
|
|
897
1004
|
Skipped = 'Skipped'
|
|
898
1005
|
}
|
|
899
|
-
/** See [edr_solidity_tests::result::TestKind::Standard] */
|
|
1006
|
+
/** See [`edr_solidity_tests::result::TestKind::Standard`] */
|
|
900
1007
|
export interface StandardTestKind {
|
|
901
1008
|
/** The gas consumed by the test. */
|
|
902
1009
|
readonly consumedGas: bigint
|
|
903
1010
|
}
|
|
904
|
-
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
1011
|
+
/** See [`edr_solidity_tests::result::TestKind::Fuzz`] */
|
|
905
1012
|
export interface FuzzTestKind {
|
|
906
|
-
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
1013
|
+
/** See [`edr_solidity_tests::result::TestKind::Fuzz`] */
|
|
907
1014
|
readonly runs: bigint
|
|
908
|
-
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
1015
|
+
/** See [`edr_solidity_tests::result::TestKind::Fuzz`] */
|
|
909
1016
|
readonly meanGas: bigint
|
|
910
|
-
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
1017
|
+
/** See [`edr_solidity_tests::result::TestKind::Fuzz`] */
|
|
911
1018
|
readonly medianGas: bigint
|
|
912
1019
|
}
|
|
913
|
-
/** See [edr_solidity_tests::fuzz::FuzzCase] */
|
|
1020
|
+
/** See [`edr_solidity_tests::fuzz::FuzzCase`] */
|
|
914
1021
|
export interface FuzzCase {
|
|
915
1022
|
/** The calldata used for this fuzz test */
|
|
916
1023
|
readonly calldata: Uint8Array
|
|
@@ -919,13 +1026,13 @@ export interface FuzzCase {
|
|
|
919
1026
|
/** The initial gas stipend for the transaction */
|
|
920
1027
|
readonly stipend: bigint
|
|
921
1028
|
}
|
|
922
|
-
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
1029
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
923
1030
|
export interface InvariantTestKind {
|
|
924
|
-
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
1031
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
925
1032
|
readonly runs: bigint
|
|
926
|
-
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
1033
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
927
1034
|
readonly calls: bigint
|
|
928
|
-
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
1035
|
+
/** See [`edr_solidity_tests::result::TestKind::Invariant`] */
|
|
929
1036
|
readonly reverts: bigint
|
|
930
1037
|
}
|
|
931
1038
|
/**
|
|
@@ -938,19 +1045,19 @@ export interface CounterExampleSequence {
|
|
|
938
1045
|
/** The shrunk counterexample sequence. */
|
|
939
1046
|
sequence: Array<BaseCounterExample>
|
|
940
1047
|
}
|
|
941
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample] */
|
|
1048
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample`] */
|
|
942
1049
|
export interface BaseCounterExample {
|
|
943
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::sender] */
|
|
1050
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::sender`] */
|
|
944
1051
|
readonly sender?: Uint8Array
|
|
945
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::addr] */
|
|
1052
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::addr`] */
|
|
946
1053
|
readonly address?: Uint8Array
|
|
947
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::calldata] */
|
|
1054
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::calldata`] */
|
|
948
1055
|
readonly calldata: Uint8Array
|
|
949
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::contract_name] */
|
|
1056
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::contract_name`] */
|
|
950
1057
|
readonly contractName?: string
|
|
951
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::signature] */
|
|
1058
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::signature`] */
|
|
952
1059
|
readonly signature?: string
|
|
953
|
-
/** See [edr_solidity_tests::fuzz::BaseCounterExample::args] */
|
|
1060
|
+
/** See [`edr_solidity_tests::fuzz::BaseCounterExample::args`] */
|
|
954
1061
|
readonly args?: string
|
|
955
1062
|
}
|
|
956
1063
|
/**
|
|
@@ -968,11 +1075,10 @@ export interface CallTrace {
|
|
|
968
1075
|
gasUsed: bigint
|
|
969
1076
|
/** The amount of native token that was included with the call. */
|
|
970
1077
|
value: bigint
|
|
971
|
-
/**
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
contract: string
|
|
1078
|
+
/** The target address of the call. */
|
|
1079
|
+
address: string
|
|
1080
|
+
/** The name of the contract that is the target of the call, if known. */
|
|
1081
|
+
contract?: string
|
|
976
1082
|
/**
|
|
977
1083
|
* The input (calldata) to the call. If it encodes a known function call,
|
|
978
1084
|
* it will be decoded into the function name and a list of arguments.
|
|
@@ -1037,6 +1143,11 @@ export interface DecodedTraceParameters {
|
|
|
1037
1143
|
*/
|
|
1038
1144
|
arguments: Array<string>
|
|
1039
1145
|
}
|
|
1146
|
+
/** The result of a Solidity test run. */
|
|
1147
|
+
export interface SolidityTestResult {
|
|
1148
|
+
/** Gas report, if it was generated. */
|
|
1149
|
+
readonly gasReport?: GasReport
|
|
1150
|
+
}
|
|
1040
1151
|
/** Configuration for subscriptions. */
|
|
1041
1152
|
export interface SubscriptionConfig {
|
|
1042
1153
|
/** Callback to be called when a new event is received. */
|
|
@@ -1102,7 +1213,8 @@ export enum StackTraceEntryType {
|
|
|
1102
1213
|
UNMAPPED_SOLC_0_6_3_REVERT_ERROR = 20,
|
|
1103
1214
|
CONTRACT_TOO_LARGE_ERROR = 21,
|
|
1104
1215
|
INTERNAL_FUNCTION_CALLSTACK_ENTRY = 22,
|
|
1105
|
-
CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR = 23
|
|
1216
|
+
CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR = 23,
|
|
1217
|
+
CHEATCODE_ERROR = 24
|
|
1106
1218
|
}
|
|
1107
1219
|
export declare function stackTraceEntryTypeToString(val: StackTraceEntryType): string
|
|
1108
1220
|
export const FALLBACK_FUNCTION_NAME: string
|
|
@@ -1232,6 +1344,11 @@ export interface ContractCallRunOutOfGasError {
|
|
|
1232
1344
|
type: StackTraceEntryType.CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR
|
|
1233
1345
|
sourceReference?: SourceReference
|
|
1234
1346
|
}
|
|
1347
|
+
export interface CheatcodeErrorStackTraceEntry {
|
|
1348
|
+
type: StackTraceEntryType.CHEATCODE_ERROR
|
|
1349
|
+
message: string
|
|
1350
|
+
sourceReference: SourceReference
|
|
1351
|
+
}
|
|
1235
1352
|
export interface TracingMessage {
|
|
1236
1353
|
/** Sender address */
|
|
1237
1354
|
readonly caller: Uint8Array
|
|
@@ -1291,22 +1408,43 @@ export interface Withdrawal {
|
|
|
1291
1408
|
amount: bigint
|
|
1292
1409
|
}
|
|
1293
1410
|
export declare class EdrContext {
|
|
1294
|
-
/**Creates a new [`EdrContext`] instance. Should only be called once! */
|
|
1411
|
+
/** Creates a new [`EdrContext`] instance. Should only be called once! */
|
|
1295
1412
|
constructor()
|
|
1296
|
-
/**Constructs a new provider with the provided configuration. */
|
|
1297
|
-
createProvider(chainType: string, providerConfig: ProviderConfig, loggerConfig: LoggerConfig, subscriptionConfig: SubscriptionConfig,
|
|
1298
|
-
/**Registers a new provider factory for the provided chain type. */
|
|
1413
|
+
/** Constructs a new provider with the provided configuration. */
|
|
1414
|
+
createProvider(chainType: string, providerConfig: ProviderConfig, loggerConfig: LoggerConfig, subscriptionConfig: SubscriptionConfig, contractDecoder: ContractDecoder): Promise<Provider>
|
|
1415
|
+
/** Registers a new provider factory for the provided chain type. */
|
|
1299
1416
|
registerProviderFactory(chainType: string, factory: ProviderFactory): Promise<void>
|
|
1300
1417
|
registerSolidityTestRunnerFactory(chainType: string, factory: SolidityTestRunnerFactory): Promise<void>
|
|
1301
1418
|
/**
|
|
1302
|
-
*Executes Solidity tests
|
|
1419
|
+
* Executes Solidity tests
|
|
1303
1420
|
*
|
|
1304
|
-
*The function will return
|
|
1305
|
-
*
|
|
1306
|
-
*
|
|
1307
|
-
*
|
|
1308
|
-
|
|
1309
|
-
|
|
1421
|
+
* The function will return a promise that resolves to a
|
|
1422
|
+
* [`SolidityTestResult`].
|
|
1423
|
+
*
|
|
1424
|
+
* Arguments:
|
|
1425
|
+
* - `chainType`: the same chain type that was passed to
|
|
1426
|
+
* `registerProviderFactory`.
|
|
1427
|
+
* - `artifacts`: the project's compilation output artifacts. It's
|
|
1428
|
+
* important to include include all artifacts here, otherwise cheatcodes
|
|
1429
|
+
* that access artifacts and other functionality (e.g. auto-linking, gas
|
|
1430
|
+
* reports) can break.
|
|
1431
|
+
* - `testSuites`: the test suite ids that specify which test suites to
|
|
1432
|
+
* execute. The test suite artifacts must be present in `artifacts`.
|
|
1433
|
+
* - `configArgs`: solidity test runner configuration. See the struct docs
|
|
1434
|
+
* for details.
|
|
1435
|
+
* - `tracingConfig`: the build infos used for stack trace generation.
|
|
1436
|
+
* These are lazily parsed and it's important that they're passed as
|
|
1437
|
+
* Uint8 arrays for performance.
|
|
1438
|
+
* - `onTestSuiteCompletedCallback`: The progress callback will be called
|
|
1439
|
+
* with the results of each test suite as soon as it finished executing.
|
|
1440
|
+
*/
|
|
1441
|
+
runSolidityTests(chainType: string, artifacts: Array<Artifact>, testSuites: Array<ArtifactId>, configArgs: SolidityTestRunnerConfigArgs, tracingConfig: TracingConfigWithBuffers, onTestSuiteCompletedCallback: (result: SuiteResult) => void): Promise<SolidityTestResult>
|
|
1442
|
+
}
|
|
1443
|
+
export declare class ContractDecoder {
|
|
1444
|
+
/**Creates an empty instance. */
|
|
1445
|
+
constructor()
|
|
1446
|
+
/**Creates a new instance with the provided configuration. */
|
|
1447
|
+
static withContracts(config: TracingConfigWithBuffers): ContractDecoder
|
|
1310
1448
|
}
|
|
1311
1449
|
export declare class Precompile {
|
|
1312
1450
|
/** Returns the address of the precompile. */
|
|
@@ -1323,6 +1461,14 @@ export declare class Response {
|
|
|
1323
1461
|
}
|
|
1324
1462
|
/** A JSON-RPC provider for Ethereum. */
|
|
1325
1463
|
export declare class Provider {
|
|
1464
|
+
/**
|
|
1465
|
+
*Adds a compilation result to the instance.
|
|
1466
|
+
*
|
|
1467
|
+
*For internal use only. Support for this method may be removed in the future.
|
|
1468
|
+
*/
|
|
1469
|
+
addCompilationResult(solcVersion: string, compilerInput: any, compilerOutput: any): Promise<void>
|
|
1470
|
+
/**Retrieves the instance's contract decoder. */
|
|
1471
|
+
contractDecoder(): ContractDecoder
|
|
1326
1472
|
/**Handles a JSON-RPC request and returns a JSON-RPC response. */
|
|
1327
1473
|
handleRequest(request: string): Promise<Response>
|
|
1328
1474
|
setCallOverrideCallback(callOverrideCallback: (contract_address: ArrayBuffer, data: ArrayBuffer) => Promise<CallOverrideResult | undefined>): Promise<void>
|
|
@@ -1335,36 +1481,43 @@ export declare class Provider {
|
|
|
1335
1481
|
setVerboseTracing(verboseTracing: boolean): Promise<void>
|
|
1336
1482
|
}
|
|
1337
1483
|
export declare class SolidityTestRunnerFactory { }
|
|
1338
|
-
/** See [edr_solidity_tests::result::SuiteResult] */
|
|
1484
|
+
/** See [`edr_solidity_tests::result::SuiteResult`] */
|
|
1339
1485
|
export declare class SuiteResult {
|
|
1340
1486
|
/**
|
|
1341
1487
|
* The artifact id can be used to match input to result in the progress
|
|
1342
1488
|
* callback
|
|
1343
1489
|
*/
|
|
1344
1490
|
readonly id: ArtifactId
|
|
1345
|
-
/** See [edr_solidity_tests::result::SuiteResult::duration] */
|
|
1491
|
+
/** See [`edr_solidity_tests::result::SuiteResult::duration`] */
|
|
1346
1492
|
readonly durationNs: bigint
|
|
1347
|
-
/** See [edr_solidity_tests::result::SuiteResult::test_results] */
|
|
1493
|
+
/** See [`edr_solidity_tests::result::SuiteResult::test_results`] */
|
|
1348
1494
|
readonly testResults: Array<TestResult>
|
|
1349
|
-
/** See [edr_solidity_tests::result::SuiteResult::warnings] */
|
|
1495
|
+
/** See [`edr_solidity_tests::result::SuiteResult::warnings`] */
|
|
1350
1496
|
readonly warnings: Array<string>
|
|
1351
1497
|
}
|
|
1352
|
-
/** See [edr_solidity_tests::result::TestResult] */
|
|
1498
|
+
/** See [`edr_solidity_tests::result::TestResult`] */
|
|
1353
1499
|
export declare class TestResult {
|
|
1354
1500
|
/** The name of the test. */
|
|
1355
1501
|
readonly name: string
|
|
1356
|
-
/** See [edr_solidity_tests::result::TestResult::status] */
|
|
1502
|
+
/** See [`edr_solidity_tests::result::TestResult::status`] */
|
|
1357
1503
|
readonly status: TestStatus
|
|
1358
|
-
/** See [edr_solidity_tests::result::TestResult::reason] */
|
|
1504
|
+
/** See [`edr_solidity_tests::result::TestResult::reason`] */
|
|
1359
1505
|
readonly reason?: string
|
|
1360
|
-
/** See [edr_solidity_tests::result::TestResult::counterexample] */
|
|
1506
|
+
/** See [`edr_solidity_tests::result::TestResult::counterexample`] */
|
|
1361
1507
|
readonly counterexample?: BaseCounterExample | CounterExampleSequence
|
|
1362
|
-
/** See [edr_solidity_tests::result::TestResult::decoded_logs] */
|
|
1508
|
+
/** See [`edr_solidity_tests::result::TestResult::decoded_logs`] */
|
|
1363
1509
|
readonly decodedLogs: Array<string>
|
|
1364
|
-
/** See [edr_solidity_tests::result::TestResult::kind] */
|
|
1510
|
+
/** See [`edr_solidity_tests::result::TestResult::kind`] */
|
|
1365
1511
|
readonly kind: StandardTestKind | FuzzTestKind | InvariantTestKind
|
|
1366
|
-
/** See [edr_solidity_tests::result::TestResult::duration] */
|
|
1512
|
+
/** See [`edr_solidity_tests::result::TestResult::duration`] */
|
|
1367
1513
|
readonly durationNs: bigint
|
|
1514
|
+
/**
|
|
1515
|
+
* Groups of value snapshot entries (incl. gas).
|
|
1516
|
+
*
|
|
1517
|
+
* Only present if the test runner collected scoped snapshots. Currently,
|
|
1518
|
+
* this is always the case.
|
|
1519
|
+
*/
|
|
1520
|
+
readonly valueSnapshotGroups?: Array<ValueSnapshotGroup>
|
|
1368
1521
|
/**
|
|
1369
1522
|
* Compute the error stack trace.
|
|
1370
1523
|
* The result is either the stack trace or the reason why we couldn't
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
|
|
313
|
+
const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
|
|
316
316
|
module.exports.genericChainProviderFactory = genericChainProviderFactory
|
|
@@ -357,6 +357,8 @@ module.exports.HOLOCENE = HOLOCENE
|
|
|
357
357
|
module.exports.ISTHMUS = ISTHMUS
|
|
358
358
|
module.exports.MineOrdering = MineOrdering
|
|
359
359
|
module.exports.EdrContext = EdrContext
|
|
360
|
+
module.exports.ContractDecoder = ContractDecoder
|
|
361
|
+
module.exports.GasReportExecutionStatus = GasReportExecutionStatus
|
|
360
362
|
module.exports.addStatementCoverageInstrumentation = addStatementCoverageInstrumentation
|
|
361
363
|
module.exports.Precompile = Precompile
|
|
362
364
|
module.exports.precompileP256Verify = precompileP256Verify
|
|
@@ -368,6 +370,7 @@ module.exports.ExceptionalHalt = ExceptionalHalt
|
|
|
368
370
|
module.exports.CachedChains = CachedChains
|
|
369
371
|
module.exports.CachedEndpoints = CachedEndpoints
|
|
370
372
|
module.exports.FsAccessPermission = FsAccessPermission
|
|
373
|
+
module.exports.CollectStackTraces = CollectStackTraces
|
|
371
374
|
module.exports.IncludeTraces = IncludeTraces
|
|
372
375
|
module.exports.SolidityTestRunnerFactory = SolidityTestRunnerFactory
|
|
373
376
|
module.exports.l1SolidityTestRunnerFactory = l1SolidityTestRunnerFactory
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomicfoundation/edr",
|
|
3
|
-
"version": "0.12.0-next.
|
|
3
|
+
"version": "0.12.0-next.10",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"@napi-rs/cli": "^2.18.4",
|
|
6
6
|
"@nomicfoundation/ethereumjs-util": "^9.0.4",
|
|
7
|
+
"@tsconfig/node20": "^20.1.6",
|
|
7
8
|
"@types/chai": "^4.2.0",
|
|
8
9
|
"@types/chai-as-promised": "^7.1.8",
|
|
9
10
|
"@types/mocha": ">=9.1.0",
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
"@typescript-eslint/parser": "5.61.0",
|
|
13
14
|
"chai": "^4.3.6",
|
|
14
15
|
"chai-as-promised": "^7.1.1",
|
|
16
|
+
"chalk": "^2.4.2",
|
|
15
17
|
"eslint": "^8.44.0",
|
|
16
18
|
"eslint-config-prettier": "9.1.0",
|
|
17
19
|
"eslint-plugin-import": "2.27.5",
|
|
@@ -25,14 +27,17 @@
|
|
|
25
27
|
"typescript": "~5.8.2"
|
|
26
28
|
},
|
|
27
29
|
"engines": {
|
|
28
|
-
"node": ">=
|
|
30
|
+
"node": ">= 20"
|
|
31
|
+
},
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./index.js",
|
|
34
|
+
"./solidity-tests": "./dist/src/ts/solidity_tests.js"
|
|
29
35
|
},
|
|
30
36
|
"files": [
|
|
31
37
|
"index.js",
|
|
32
38
|
"index.d.ts",
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"src/"
|
|
39
|
+
"src/",
|
|
40
|
+
"dist/src/"
|
|
36
41
|
],
|
|
37
42
|
"license": "MIT",
|
|
38
43
|
"main": "index.js",
|
|
@@ -53,32 +58,32 @@
|
|
|
53
58
|
},
|
|
54
59
|
"repository": "NomicFoundation/edr.git",
|
|
55
60
|
"types": "index.d.ts",
|
|
56
|
-
"
|
|
57
|
-
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.
|
|
58
|
-
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.
|
|
59
|
-
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.
|
|
60
|
-
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.
|
|
61
|
-
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.
|
|
62
|
-
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.
|
|
63
|
-
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"@nomicfoundation/edr-darwin-arm64": "0.12.0-next.10",
|
|
63
|
+
"@nomicfoundation/edr-darwin-x64": "0.12.0-next.10",
|
|
64
|
+
"@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.10",
|
|
65
|
+
"@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.10",
|
|
66
|
+
"@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.10",
|
|
67
|
+
"@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.10",
|
|
68
|
+
"@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.10"
|
|
64
69
|
},
|
|
65
70
|
"scripts": {
|
|
66
71
|
"artifacts": "napi artifacts",
|
|
67
72
|
"build": "pnpm run build:publish",
|
|
68
|
-
"build:debug": "
|
|
69
|
-
"build:dev": "
|
|
70
|
-
"build:publish": "
|
|
71
|
-
"build:scenarios": "
|
|
72
|
-
"build:tracing": "
|
|
73
|
-
"build:typingFile": "
|
|
73
|
+
"build:debug": "bash ../../scripts/build_edr_napi.sh --features op",
|
|
74
|
+
"build:dev": "bash ../../scripts/build_edr_napi.sh --release --features op,test-mock",
|
|
75
|
+
"build:publish": "bash ../../scripts/build_edr_napi.sh --profile napi-publish --features op",
|
|
76
|
+
"build:scenarios": "bash ../../scripts/build_edr_napi.sh --release --features op,scenarios",
|
|
77
|
+
"build:tracing": "bash ../../scripts/build_edr_napi.sh --release --features op,tracing",
|
|
78
|
+
"build:typingFile": "bash ../../scripts/build_edr_napi.sh --features op",
|
|
74
79
|
"clean": "rm -rf @nomicfoundation/edr.node",
|
|
75
80
|
"eslint": "eslint 'test/**/*.ts'",
|
|
76
81
|
"lint": "pnpm run prettier && pnpm run eslint",
|
|
77
82
|
"lint:fix": "pnpm run prettier --write",
|
|
78
83
|
"pretest": "pnpm build:dev",
|
|
79
84
|
"prettier": "prettier --check \"test/**.ts\"",
|
|
80
|
-
"test": "
|
|
81
|
-
"testNoBuild": "
|
|
85
|
+
"test": "node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
|
|
86
|
+
"testNoBuild": "node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/{,!(logs|mock)}.ts\"",
|
|
82
87
|
"universal": "napi universal",
|
|
83
88
|
"version": "napi version"
|
|
84
89
|
}
|
package/src/account.rs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use derive_more::Debug;
|
|
2
|
-
use
|
|
2
|
+
use edr_primitives::{hex, Address, HashMap, U256};
|
|
3
3
|
use edr_solidity_tests::{backend::Predeploy, revm::state::AccountInfo};
|
|
4
|
+
use edr_state_api::EvmStorageSlot;
|
|
4
5
|
use napi::bindgen_prelude::{BigInt, Uint8Array};
|
|
5
6
|
use napi_derive::napi;
|
|
6
7
|
|
|
@@ -36,7 +37,7 @@ pub struct AccountOverride {
|
|
|
36
37
|
pub storage: Option<Vec<StorageSlot>>,
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
impl TryFrom<AccountOverride> for (
|
|
40
|
+
impl TryFrom<AccountOverride> for (Address, edr_provider::AccountOverride) {
|
|
40
41
|
type Error = napi::Error;
|
|
41
42
|
|
|
42
43
|
fn try_from(value: AccountOverride) -> Result<Self, Self::Error> {
|
|
@@ -53,9 +54,9 @@ impl TryFrom<AccountOverride> for (edr_eth::Address, edr_provider::AccountOverri
|
|
|
53
54
|
.into_iter()
|
|
54
55
|
.map(|StorageSlot { index, value }| {
|
|
55
56
|
let value = value.try_cast()?;
|
|
56
|
-
let slot =
|
|
57
|
+
let slot = EvmStorageSlot::new(value, 0);
|
|
57
58
|
|
|
58
|
-
let index:
|
|
59
|
+
let index: U256 = index.try_cast()?;
|
|
59
60
|
Ok((index, slot))
|
|
60
61
|
})
|
|
61
62
|
.collect::<napi::Result<_>>()
|
|
@@ -69,7 +70,7 @@ impl TryFrom<AccountOverride> for (edr_eth::Address, edr_provider::AccountOverri
|
|
|
69
70
|
storage,
|
|
70
71
|
};
|
|
71
72
|
|
|
72
|
-
let address:
|
|
73
|
+
let address: Address = address.try_cast()?;
|
|
73
74
|
|
|
74
75
|
Ok((address, account_override))
|
|
75
76
|
}
|
package/src/block.rs
CHANGED
|
@@ -16,7 +16,7 @@ pub struct BlobGas {
|
|
|
16
16
|
pub excess_gas: BigInt,
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
impl TryFrom<BlobGas> for
|
|
19
|
+
impl TryFrom<BlobGas> for edr_block_header::BlobGas {
|
|
20
20
|
type Error = napi::Error;
|
|
21
21
|
|
|
22
22
|
fn try_from(value: BlobGas) -> Result<Self, Self::Error> {
|
package/src/call_override.rs
CHANGED
package/src/cast.rs
CHANGED