sol-dbg 0.0.0
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/LICENSE +201 -0
- package/README.md +105 -0
- package/dist/artifacts/helpers.d.ts +14 -0
- package/dist/artifacts/helpers.d.ts.map +1 -0
- package/dist/artifacts/helpers.js +111 -0
- package/dist/artifacts/helpers.js.map +1 -0
- package/dist/artifacts/index.d.ts +3 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +19 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/artifacts/solc.d.ts +44 -0
- package/dist/artifacts/solc.d.ts.map +1 -0
- package/dist/artifacts/solc.js +3 -0
- package/dist/artifacts/solc.js.map +1 -0
- package/dist/debug/abi.d.ts +30 -0
- package/dist/debug/abi.d.ts.map +1 -0
- package/dist/debug/abi.js +183 -0
- package/dist/debug/abi.js.map +1 -0
- package/dist/debug/artifact_manager.d.ts +68 -0
- package/dist/debug/artifact_manager.d.ts.map +1 -0
- package/dist/debug/artifact_manager.js +182 -0
- package/dist/debug/artifact_manager.js.map +1 -0
- package/dist/debug/decoding/calldata.d.ts +6 -0
- package/dist/debug/decoding/calldata.d.ts.map +1 -0
- package/dist/debug/decoding/calldata.js +228 -0
- package/dist/debug/decoding/calldata.js.map +1 -0
- package/dist/debug/decoding/general.d.ts +9 -0
- package/dist/debug/decoding/general.d.ts.map +1 -0
- package/dist/debug/decoding/general.js +114 -0
- package/dist/debug/decoding/general.js.map +1 -0
- package/dist/debug/decoding/index.d.ts +6 -0
- package/dist/debug/decoding/index.d.ts.map +1 -0
- package/dist/debug/decoding/index.js +22 -0
- package/dist/debug/decoding/index.js.map +1 -0
- package/dist/debug/decoding/memory.d.ts +4 -0
- package/dist/debug/decoding/memory.d.ts.map +1 -0
- package/dist/debug/decoding/memory.js +216 -0
- package/dist/debug/decoding/memory.js.map +1 -0
- package/dist/debug/decoding/stack.d.ts +9 -0
- package/dist/debug/decoding/stack.d.ts.map +1 -0
- package/dist/debug/decoding/stack.js +85 -0
- package/dist/debug/decoding/stack.js.map +1 -0
- package/dist/debug/decoding/storage.d.ts +4 -0
- package/dist/debug/decoding/storage.d.ts.map +1 -0
- package/dist/debug/decoding/storage.js +333 -0
- package/dist/debug/decoding/storage.js.map +1 -0
- package/dist/debug/index.d.ts +7 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +23 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/opcodes.d.ts +302 -0
- package/dist/debug/opcodes.d.ts.map +1 -0
- package/dist/debug/opcodes.js +2909 -0
- package/dist/debug/opcodes.js.map +1 -0
- package/dist/debug/sol_debugger.d.ts +247 -0
- package/dist/debug/sol_debugger.d.ts.map +1 -0
- package/dist/debug/sol_debugger.js +443 -0
- package/dist/debug/sol_debugger.js.map +1 -0
- package/dist/debug/types.d.ts +33 -0
- package/dist/debug/types.d.ts.map +1 -0
- package/dist/debug/types.js +3 -0
- package/dist/debug/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/utils/immutable_map.d.ts +13 -0
- package/dist/utils/immutable_map.d.ts.map +1 -0
- package/dist/utils/immutable_map.js +56 -0
- package/dist/utils/immutable_map.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.d.ts +48 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +221 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/srcmap.d.ts +8 -0
- package/dist/utils/srcmap.d.ts.map +1 -0
- package/dist/utils/srcmap.js +28 -0
- package/dist/utils/srcmap.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toABIEncodedType = exports.decodeMsgData = exports.changeToLocation = void 0;
|
|
4
|
+
const solc_typed_ast_1 = require("solc-typed-ast");
|
|
5
|
+
const abi_1 = require("solc-typed-ast/dist/types/abi");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
function changeToLocation(typ, newLoc) {
|
|
8
|
+
if (typ instanceof solc_typed_ast_1.PointerType) {
|
|
9
|
+
return new solc_typed_ast_1.PointerType(changeToLocation(typ.to, newLoc), newLoc, typ.kind);
|
|
10
|
+
}
|
|
11
|
+
if (typ instanceof solc_typed_ast_1.ArrayType) {
|
|
12
|
+
return new solc_typed_ast_1.ArrayType(changeToLocation(typ.elementT, newLoc), typ.size);
|
|
13
|
+
}
|
|
14
|
+
if (typ instanceof solc_typed_ast_1.MappingType) {
|
|
15
|
+
(0, solc_typed_ast_1.assert)(newLoc === solc_typed_ast_1.DataLocation.Storage, `Cannot change type of mapping ${typ.pp()} to ${newLoc}`);
|
|
16
|
+
return typ;
|
|
17
|
+
}
|
|
18
|
+
if (typ instanceof solc_typed_ast_1.TupleType) {
|
|
19
|
+
return new solc_typed_ast_1.TupleType(typ.elements.map((elT) => changeToLocation(elT, newLoc)));
|
|
20
|
+
}
|
|
21
|
+
if (typ instanceof solc_typed_ast_1.IntType ||
|
|
22
|
+
typ instanceof solc_typed_ast_1.BoolType ||
|
|
23
|
+
typ instanceof solc_typed_ast_1.AddressType ||
|
|
24
|
+
typ instanceof solc_typed_ast_1.FixedBytesType ||
|
|
25
|
+
typ instanceof solc_typed_ast_1.StringType ||
|
|
26
|
+
typ instanceof solc_typed_ast_1.BytesType ||
|
|
27
|
+
typ instanceof solc_typed_ast_1.UserDefinedType) {
|
|
28
|
+
return typ;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Cannot change location of type ${typ.pp()}`);
|
|
31
|
+
}
|
|
32
|
+
exports.changeToLocation = changeToLocation;
|
|
33
|
+
/**
|
|
34
|
+
* Return the static size that the type `typ` will take in the standard ABI encoding of
|
|
35
|
+
* argumetns.
|
|
36
|
+
*/
|
|
37
|
+
function abiStaticTypeSize(typ) {
|
|
38
|
+
if (typ instanceof solc_typed_ast_1.IntType ||
|
|
39
|
+
typ instanceof solc_typed_ast_1.AddressType ||
|
|
40
|
+
typ instanceof solc_typed_ast_1.FixedBytesType ||
|
|
41
|
+
typ instanceof solc_typed_ast_1.BoolType ||
|
|
42
|
+
typ instanceof solc_typed_ast_1.PointerType) {
|
|
43
|
+
return 32;
|
|
44
|
+
}
|
|
45
|
+
if (typ instanceof solc_typed_ast_1.UserDefinedType) {
|
|
46
|
+
const def = typ.definition;
|
|
47
|
+
if (def instanceof solc_typed_ast_1.EnumDefinition ||
|
|
48
|
+
def instanceof solc_typed_ast_1.ContractDefinition ||
|
|
49
|
+
def instanceof solc_typed_ast_1.UserDefinedValueTypeDefinition) {
|
|
50
|
+
return 32;
|
|
51
|
+
}
|
|
52
|
+
throw new Error(`NYI decoding user-defined type ${typ.pp()}`);
|
|
53
|
+
}
|
|
54
|
+
if (typ instanceof solc_typed_ast_1.TupleType) {
|
|
55
|
+
let res = 0;
|
|
56
|
+
for (const elT of typ.elements) {
|
|
57
|
+
res += abiStaticTypeSize(elT);
|
|
58
|
+
}
|
|
59
|
+
return res;
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`NYI decoding type ${typ.pp()}`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* An ABI-decoder implementation that is resilient to failures in some arguments decoding.
|
|
65
|
+
* This function will return partial decoding results. This is needed since the fuzzer may not
|
|
66
|
+
* always produce inputs that decode in their entirety.
|
|
67
|
+
*
|
|
68
|
+
* TODO: (dimo): The name of this function is bad. Its not doing any decoding - just building 'DataView' elements
|
|
69
|
+
* into msg.data that match a specific function signature. Also this should be moved into sol_debugger, in the same place
|
|
70
|
+
* where `SolTxDebugger.decodeFunArgs` lives.
|
|
71
|
+
*/
|
|
72
|
+
function decodeMsgData(callee, data, kind, encoderVersion) {
|
|
73
|
+
const res = [];
|
|
74
|
+
const selector = callee instanceof solc_typed_ast_1.FunctionDefinition
|
|
75
|
+
? (0, utils_1.getFunctionSelector)(callee, encoderVersion)
|
|
76
|
+
: callee.getterCanonicalSignatureHash(encoderVersion);
|
|
77
|
+
(0, solc_typed_ast_1.assert)(selector === data.slice(0, 4).toString("hex"), `Expected selector ${selector} instead got ${data.slice(0, 4)}`);
|
|
78
|
+
const formals = callee instanceof solc_typed_ast_1.FunctionDefinition
|
|
79
|
+
? callee.vParameters.vParameters.map((argDef) => [
|
|
80
|
+
argDef.name,
|
|
81
|
+
(0, solc_typed_ast_1.variableDeclarationToTypeNode)(argDef)
|
|
82
|
+
])
|
|
83
|
+
: callee.getterArgsAndReturn()[0].map((typ, i) => [`ARG_${i}`, typ]);
|
|
84
|
+
let staticOff = 4;
|
|
85
|
+
const len = data.length;
|
|
86
|
+
for (const [name, originalType] of formals) {
|
|
87
|
+
const typ = toABIEncodedType(originalType, encoderVersion);
|
|
88
|
+
const staticSize = abiStaticTypeSize(typ);
|
|
89
|
+
const loc = staticOff + staticSize <= len ? { kind, address: BigInt(staticOff) } : undefined;
|
|
90
|
+
staticOff += staticSize;
|
|
91
|
+
const val = loc ? { type: originalType, loc } : undefined;
|
|
92
|
+
res.push([name, val]);
|
|
93
|
+
}
|
|
94
|
+
return res;
|
|
95
|
+
}
|
|
96
|
+
exports.decodeMsgData = decodeMsgData;
|
|
97
|
+
/**
|
|
98
|
+
* Determine if the specified type `typ` is dynamic or not. Dynamic means
|
|
99
|
+
* that if we are trying to read `typ` at location `loc`, in `loc` there should be just a
|
|
100
|
+
* uint256 offset into memory/storage/calldata, where the actual data lives. Otherwise
|
|
101
|
+
* (if the type is "static"), the direct encoding of the data will start at `loc`.
|
|
102
|
+
*
|
|
103
|
+
* Usually "static" types are just the value types - i.e. anything of statically
|
|
104
|
+
* known size that fits in a uint256. As per https://docs.soliditylang.org/en/latest/abi-spec.html#formal-specification-of-the-encoding
|
|
105
|
+
* there are several exceptions to the rule when encoding types in calldata:
|
|
106
|
+
*
|
|
107
|
+
* 1. Fixed size arrays with fixed-sized element types
|
|
108
|
+
* 2. Tuples where all the tuple elements are fixed-size
|
|
109
|
+
*
|
|
110
|
+
* TODO(dimo):
|
|
111
|
+
* 1. Check again that its not possible for tuples in internal calls to somehow get encoded on the stack
|
|
112
|
+
* 2. What happens with return tuples? Are they always in memory?
|
|
113
|
+
*/
|
|
114
|
+
function isTypeEncodingDynamic(typ) {
|
|
115
|
+
if (typ instanceof solc_typed_ast_1.PointerType ||
|
|
116
|
+
typ instanceof solc_typed_ast_1.ArrayType ||
|
|
117
|
+
typ instanceof solc_typed_ast_1.StringType ||
|
|
118
|
+
typ instanceof solc_typed_ast_1.BytesType) {
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
// Tuples in calldata with static elements
|
|
122
|
+
if (typ instanceof solc_typed_ast_1.TupleType) {
|
|
123
|
+
for (const elT of typ.elements) {
|
|
124
|
+
if (isTypeEncodingDynamic(elT)) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Convert an internal TypeNode to the external TypeNode that would correspond to it
|
|
134
|
+
* after ABI-encoding with encoder version `encoderVersion`. Follows the following rules:
|
|
135
|
+
*
|
|
136
|
+
* 1. Contract definitions turned to address.
|
|
137
|
+
* 2. Enum definitions turned to uint of minimal fitting size.
|
|
138
|
+
* 3. Any storage pointer types are converted to memory pointer types.
|
|
139
|
+
* 4. Throw an error on any nested mapping types.
|
|
140
|
+
* 5. Fixed-size arrays with fixed-sized element types are encoded as inlined tuples
|
|
141
|
+
* 6. Structs with fixed-sized elements are encoded as inlined tuples
|
|
142
|
+
*
|
|
143
|
+
* @see https://docs.soliditylang.org/en/latest/abi-spec.html
|
|
144
|
+
*/
|
|
145
|
+
function toABIEncodedType(type, encoderVersion) {
|
|
146
|
+
if (type instanceof solc_typed_ast_1.MappingType) {
|
|
147
|
+
throw new Error("Cannot abi-encode mapping types");
|
|
148
|
+
}
|
|
149
|
+
if (type instanceof solc_typed_ast_1.ArrayType) {
|
|
150
|
+
const encodedElementT = toABIEncodedType(type.elementT, encoderVersion);
|
|
151
|
+
if (type.size !== undefined) {
|
|
152
|
+
const elements = [];
|
|
153
|
+
for (let i = 0; i < type.size; i++) {
|
|
154
|
+
elements.push(encodedElementT);
|
|
155
|
+
}
|
|
156
|
+
return new solc_typed_ast_1.TupleType(elements);
|
|
157
|
+
}
|
|
158
|
+
return new solc_typed_ast_1.ArrayType(encodedElementT, type.size);
|
|
159
|
+
}
|
|
160
|
+
if (type instanceof solc_typed_ast_1.PointerType) {
|
|
161
|
+
const toT = toABIEncodedType(type.to, encoderVersion);
|
|
162
|
+
return isTypeEncodingDynamic(toT) ? new solc_typed_ast_1.PointerType(toT, type.location) : toT;
|
|
163
|
+
}
|
|
164
|
+
if (type instanceof solc_typed_ast_1.UserDefinedType) {
|
|
165
|
+
if (type.definition instanceof solc_typed_ast_1.UserDefinedValueTypeDefinition) {
|
|
166
|
+
return (0, solc_typed_ast_1.typeNameToTypeNode)(type.definition.underlyingType);
|
|
167
|
+
}
|
|
168
|
+
if (type.definition instanceof solc_typed_ast_1.ContractDefinition) {
|
|
169
|
+
return new solc_typed_ast_1.AddressType(false);
|
|
170
|
+
}
|
|
171
|
+
if (type.definition instanceof solc_typed_ast_1.EnumDefinition) {
|
|
172
|
+
return (0, solc_typed_ast_1.enumToIntType)(type.definition);
|
|
173
|
+
}
|
|
174
|
+
if (type.definition instanceof solc_typed_ast_1.StructDefinition) {
|
|
175
|
+
(0, solc_typed_ast_1.assert)(encoderVersion !== abi_1.ABIEncoderVersion.V1, "Getters of struct return type are not supported by ABI encoder v1");
|
|
176
|
+
const fieldTs = type.definition.vMembers.map((fieldT) => (0, solc_typed_ast_1.variableDeclarationToTypeNode)(fieldT));
|
|
177
|
+
return new solc_typed_ast_1.TupleType(fieldTs.map((fieldT) => toABIEncodedType(fieldT, encoderVersion)));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return type;
|
|
181
|
+
}
|
|
182
|
+
exports.toABIEncodedType = toABIEncodedType;
|
|
183
|
+
//# sourceMappingURL=abi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abi.js","sourceRoot":"","sources":["../../src/debug/abi.ts"],"names":[],"mappings":";;;AAAA,mDAwBwB;AACxB,uDAAkE;AAElE,oCAA+C;AAE/C,SAAgB,gBAAgB,CAAC,GAAa,EAAE,MAAuB;IACnE,IAAI,GAAG,YAAY,4BAAW,EAAE;QAC5B,OAAO,IAAI,4BAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;KAC9E;IAED,IAAI,GAAG,YAAY,0BAAS,EAAE;QAC1B,OAAO,IAAI,0BAAS,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;KAC1E;IAED,IAAI,GAAG,YAAY,4BAAW,EAAE;QAC5B,IAAA,uBAAM,EACF,MAAM,KAAK,6BAAe,CAAC,OAAO,EAClC,iCAAiC,GAAG,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE,CAC3D,CAAC;QAEF,OAAO,GAAG,CAAC;KACd;IAED,IAAI,GAAG,YAAY,0BAAS,EAAE;QAC1B,OAAO,IAAI,0BAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;KAClF;IAED,IACI,GAAG,YAAY,wBAAO;QACtB,GAAG,YAAY,yBAAQ;QACvB,GAAG,YAAY,4BAAW;QAC1B,GAAG,YAAY,+BAAc;QA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0,0 +1,68 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PrefixedHexString } from "ethereumjs-util";
|
|
3
|
+
import { ASTContext, ASTNode, ContractDefinition, SourceUnit } from "solc-typed-ast";
|
|
4
|
+
import { ABIEncoderVersion } from "solc-typed-ast/dist/types/abi";
|
|
5
|
+
import { DecodedBytecodeSourceMapEntry, PartialCompiledContract, PartialSolcOutput, RawAST } from "..";
|
|
6
|
+
import { HexString } from "../artifacts";
|
|
7
|
+
export interface IArtifactManager {
|
|
8
|
+
getContractFromDeployedBytecode(code: string | Buffer): ContractInfo | undefined;
|
|
9
|
+
getContractFromCreationBytecode(code: string | Buffer): ContractInfo | undefined;
|
|
10
|
+
getContractFromMDHash(hash: HexString): ContractInfo | undefined;
|
|
11
|
+
artifacts(): ArtifactInfo[];
|
|
12
|
+
contracts(): ContractInfo[];
|
|
13
|
+
getFileById(id: number, code: string | Buffer, isCreation: boolean): SourceFileInfo | undefined;
|
|
14
|
+
}
|
|
15
|
+
export interface BytecodeInfo {
|
|
16
|
+
generatedFileMap: Map<number, SourceFileInfo>;
|
|
17
|
+
srcMap: DecodedBytecodeSourceMapEntry[];
|
|
18
|
+
offsetToIndexMap: Map<number, number>;
|
|
19
|
+
}
|
|
20
|
+
export interface ContractInfo {
|
|
21
|
+
artifact: ArtifactInfo;
|
|
22
|
+
contractArtifact: PartialCompiledContract;
|
|
23
|
+
contractName: string;
|
|
24
|
+
fileName: string;
|
|
25
|
+
ast: ContractDefinition | undefined;
|
|
26
|
+
bytecode: BytecodeInfo;
|
|
27
|
+
deployedBytecode: BytecodeInfo;
|
|
28
|
+
mdHash: PrefixedHexString;
|
|
29
|
+
}
|
|
30
|
+
export interface ArtifactInfo {
|
|
31
|
+
artifact: PartialSolcOutput;
|
|
32
|
+
units: SourceUnit[];
|
|
33
|
+
ctx: ASTContext;
|
|
34
|
+
compilerVersion: string;
|
|
35
|
+
abiEncoderVersion: ABIEncoderVersion;
|
|
36
|
+
fileMap: Map<number, SourceFileInfo>;
|
|
37
|
+
srcMap: Map<string, ASTNode>;
|
|
38
|
+
}
|
|
39
|
+
export declare enum SourceFileType {
|
|
40
|
+
Solidity = "solidity",
|
|
41
|
+
InternalYul = "internal_yul"
|
|
42
|
+
}
|
|
43
|
+
export interface SourceFileInfo {
|
|
44
|
+
contents: string | undefined;
|
|
45
|
+
rawAst: RawAST;
|
|
46
|
+
ast: SourceUnit | undefined;
|
|
47
|
+
name: string;
|
|
48
|
+
fileIndex: number;
|
|
49
|
+
type: SourceFileType;
|
|
50
|
+
}
|
|
51
|
+
export declare function getOffsetSrc(off: number, bytecode: BytecodeInfo): DecodedBytecodeSourceMapEntry;
|
|
52
|
+
/**
|
|
53
|
+
* ArtifactManager contains a set of solc standard JSON compiler artifacts, and allows for quick
|
|
54
|
+
* lookup from creation or deployed bytecode to the actual compiler artifact.
|
|
55
|
+
*/
|
|
56
|
+
export declare class ArtifactManager implements IArtifactManager {
|
|
57
|
+
private _artifacts;
|
|
58
|
+
private _contracts;
|
|
59
|
+
private _mdHashToContractInfo;
|
|
60
|
+
constructor(artifacts: PartialSolcOutput[]);
|
|
61
|
+
artifacts(): ArtifactInfo[];
|
|
62
|
+
getContractFromMDHash(hash: HexString): ContractInfo | undefined;
|
|
63
|
+
getContractFromDeployedBytecode(bytecode: string | Buffer): ContractInfo | undefined;
|
|
64
|
+
getContractFromCreationBytecode(creationBytecode: string | Buffer): ContractInfo | undefined;
|
|
65
|
+
getFileById(id: number, arg: string | Buffer | ContractInfo, isCreation: boolean): SourceFileInfo | undefined;
|
|
66
|
+
contracts(): ContractInfo[];
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=artifact_manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact_manager.d.ts","sourceRoot":"","sources":["../../src/debug/artifact_manager.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,E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,OAAO,GACpB,cAAc,GAAG,SAAS;IA4B7B,SAAS,IAAI,YAAY,EAAE;CAG9B"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArtifactManager = exports.getOffsetSrc = exports.SourceFileType = void 0;
|
|
4
|
+
const solc_typed_ast_1 = require("solc-typed-ast");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const opcodes_1 = require("./opcodes");
|
|
7
|
+
var SourceFileType;
|
|
8
|
+
(function (SourceFileType) {
|
|
9
|
+
SourceFileType["Solidity"] = "solidity";
|
|
10
|
+
SourceFileType["InternalYul"] = "internal_yul";
|
|
11
|
+
})(SourceFileType = exports.SourceFileType || (exports.SourceFileType = {}));
|
|
12
|
+
/**
|
|
13
|
+
* Build an offset-to-instruction index map for the given bytecode. Note
|
|
14
|
+
* that since its not easy to tell exactly where the instruction section ends, we
|
|
15
|
+
* over-approximate by also mapping any potential data sections at the end of bytecode.
|
|
16
|
+
*
|
|
17
|
+
* The main assumption we make is that all non-instruction bytecode comes at the end of the
|
|
18
|
+
* bytecode.
|
|
19
|
+
*/
|
|
20
|
+
function buildOffsetToIndexMap(bytecode) {
|
|
21
|
+
if (typeof bytecode === "string") {
|
|
22
|
+
bytecode = Buffer.from(bytecode, "hex");
|
|
23
|
+
}
|
|
24
|
+
const res = new Map();
|
|
25
|
+
for (let i = 0, off = 0; off < bytecode.length; i++) {
|
|
26
|
+
const op = opcodes_1.OpcodeInfo[bytecode[off]];
|
|
27
|
+
res.set(off, i);
|
|
28
|
+
off += op.length;
|
|
29
|
+
}
|
|
30
|
+
return res;
|
|
31
|
+
}
|
|
32
|
+
function getOffsetSrc(off, bytecode) {
|
|
33
|
+
const idx = bytecode.offsetToIndexMap.get(off);
|
|
34
|
+
(0, solc_typed_ast_1.assert)(idx !== undefined, `No index for code offset ${off}`);
|
|
35
|
+
(0, solc_typed_ast_1.assert)(idx >= 0 && idx < bytecode.srcMap.length, `Instruction index ${idx} outside of source map (0-${bytecode.srcMap.length})`);
|
|
36
|
+
return bytecode.srcMap[idx];
|
|
37
|
+
}
|
|
38
|
+
exports.getOffsetSrc = getOffsetSrc;
|
|
39
|
+
/**
|
|
40
|
+
* ArtifactManager contains a set of solc standard JSON compiler artifacts, and allows for quick
|
|
41
|
+
* lookup from creation or deployed bytecode to the actual compiler artifact.
|
|
42
|
+
*/
|
|
43
|
+
class ArtifactManager {
|
|
44
|
+
constructor(artifacts) {
|
|
45
|
+
this._artifacts = [];
|
|
46
|
+
this._contracts = [];
|
|
47
|
+
this._mdHashToContractInfo = new Map();
|
|
48
|
+
for (const artifact of artifacts) {
|
|
49
|
+
const reader = new solc_typed_ast_1.ASTReader();
|
|
50
|
+
const compilerVersion = (0, __1.getArtifactCompilerVersion)(artifact);
|
|
51
|
+
(0, solc_typed_ast_1.assert)(compilerVersion !== undefined, `Couldn't find compiler version for artifact`);
|
|
52
|
+
const units = reader.read(artifact);
|
|
53
|
+
const abiEncoderVersion = (0, solc_typed_ast_1.getABIEncoderVersion)(units, compilerVersion);
|
|
54
|
+
const fileMap = new Map();
|
|
55
|
+
const unitMap = new Map(units.map((unit) => [unit.id, unit]));
|
|
56
|
+
for (const fileName in artifact.sources) {
|
|
57
|
+
const sourceInfo = artifact.sources[fileName];
|
|
58
|
+
// TODO: This is hacky. Figure out a cleaner aay to get the fileIndex
|
|
59
|
+
const fileIdx = sourceInfo.fileIndex !== undefined ? sourceInfo.fileIndex : sourceInfo.id;
|
|
60
|
+
fileMap.set(fileIdx, {
|
|
61
|
+
contents: sourceInfo.contents,
|
|
62
|
+
rawAst: sourceInfo.ast,
|
|
63
|
+
ast: unitMap.get(sourceInfo.ast.id),
|
|
64
|
+
name: fileName,
|
|
65
|
+
fileIndex: fileIdx,
|
|
66
|
+
type: SourceFileType.Solidity
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
const srcMap = new Map();
|
|
70
|
+
for (const unit of units) {
|
|
71
|
+
unit.walkChildren((child) => srcMap.set(child.src, child));
|
|
72
|
+
}
|
|
73
|
+
this._artifacts.push({
|
|
74
|
+
artifact,
|
|
75
|
+
units,
|
|
76
|
+
ctx: reader.context,
|
|
77
|
+
compilerVersion,
|
|
78
|
+
abiEncoderVersion,
|
|
79
|
+
fileMap,
|
|
80
|
+
srcMap
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
for (const artifactInfo of this._artifacts) {
|
|
84
|
+
const artifact = artifactInfo.artifact;
|
|
85
|
+
for (const fileName in artifact.contracts) {
|
|
86
|
+
for (const contractName in artifact.contracts[fileName]) {
|
|
87
|
+
const contractDef = (0, __1.findContractDef)(artifactInfo.units, fileName, contractName);
|
|
88
|
+
const contractArtifact = artifact.contracts[fileName][contractName];
|
|
89
|
+
const generatedFileMap = new Map();
|
|
90
|
+
const deployedGeneratedFileMap = new Map();
|
|
91
|
+
for (const [srcMap, bytecodeInfo] of [
|
|
92
|
+
[generatedFileMap, contractArtifact.evm.bytecode],
|
|
93
|
+
[deployedGeneratedFileMap, contractArtifact.evm.deployedBytecode]
|
|
94
|
+
]) {
|
|
95
|
+
if (!bytecodeInfo.generatedSources) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
for (const src of bytecodeInfo.generatedSources) {
|
|
99
|
+
srcMap.set(src.id, {
|
|
100
|
+
rawAst: src.ast,
|
|
101
|
+
ast: undefined,
|
|
102
|
+
name: src.name ? src.name : "",
|
|
103
|
+
contents: src.contents ? src.contents : undefined,
|
|
104
|
+
type: SourceFileType.InternalYul,
|
|
105
|
+
fileIndex: src.id
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
const hash = (0, __1.getCodeHash)(contractArtifact.evm.deployedBytecode.object);
|
|
110
|
+
(0, solc_typed_ast_1.assert)(hash !== undefined, `Couldn't find md in bytecode for ${contractName} from ${fileName}`);
|
|
111
|
+
const contractInfo = {
|
|
112
|
+
artifact: artifactInfo,
|
|
113
|
+
contractArtifact: contractArtifact,
|
|
114
|
+
fileName,
|
|
115
|
+
contractName,
|
|
116
|
+
ast: contractDef,
|
|
117
|
+
bytecode: {
|
|
118
|
+
generatedFileMap,
|
|
119
|
+
srcMap: (0, __1.parseBytecodeSourceMapping)(contractArtifact.evm.bytecode.sourceMap),
|
|
120
|
+
offsetToIndexMap: buildOffsetToIndexMap(contractArtifact.evm.bytecode.object)
|
|
121
|
+
},
|
|
122
|
+
deployedBytecode: {
|
|
123
|
+
generatedFileMap: deployedGeneratedFileMap,
|
|
124
|
+
srcMap: (0, __1.parseBytecodeSourceMapping)(contractArtifact.evm.deployedBytecode.sourceMap),
|
|
125
|
+
offsetToIndexMap: buildOffsetToIndexMap(contractArtifact.evm.deployedBytecode.object)
|
|
126
|
+
},
|
|
127
|
+
mdHash: hash
|
|
128
|
+
};
|
|
129
|
+
this._contracts.push(contractInfo);
|
|
130
|
+
this._mdHashToContractInfo.set(hash, contractInfo);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
artifacts() {
|
|
136
|
+
return this._artifacts;
|
|
137
|
+
}
|
|
138
|
+
getContractFromMDHash(hash) {
|
|
139
|
+
return this._mdHashToContractInfo.get(hash);
|
|
140
|
+
}
|
|
141
|
+
getContractFromDeployedBytecode(bytecode) {
|
|
142
|
+
const hash = (0, __1.getCodeHash)(bytecode);
|
|
143
|
+
if (hash) {
|
|
144
|
+
return this._mdHashToContractInfo.get(hash);
|
|
145
|
+
}
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
getContractFromCreationBytecode(creationBytecode) {
|
|
149
|
+
const hash = (0, __1.getCreationCodeHash)(creationBytecode);
|
|
150
|
+
if (hash) {
|
|
151
|
+
return this._mdHashToContractInfo.get(hash);
|
|
152
|
+
}
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
getFileById(id, arg, isCreation) {
|
|
156
|
+
let contractInfo;
|
|
157
|
+
if (typeof arg === "string" || arg instanceof Buffer) {
|
|
158
|
+
contractInfo = isCreation
|
|
159
|
+
? this.getContractFromCreationBytecode(arg)
|
|
160
|
+
: this.getContractFromDeployedBytecode(arg);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
contractInfo = arg;
|
|
164
|
+
}
|
|
165
|
+
if (contractInfo === undefined) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
const genFilesMap = isCreation
|
|
169
|
+
? contractInfo.bytecode.generatedFileMap
|
|
170
|
+
: contractInfo.deployedBytecode.generatedFileMap;
|
|
171
|
+
const res = genFilesMap.get(id);
|
|
172
|
+
if (res) {
|
|
173
|
+
return res;
|
|
174
|
+
}
|
|
175
|
+
return contractInfo.artifact.fileMap.get(id);
|
|
176
|
+
}
|
|
177
|
+
contracts() {
|
|
178
|
+
return this._contracts;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
exports.ArtifactManager = ArtifactManager;
|
|
182
|
+
//# sourceMappingURL=artifact_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact_manager.js","sourceRoot":"","sources":["../../src/debug/artifact_manager.ts"],"names":[],"mappings":";;;AACA,mDAQwB;AAExB,0BAYY;AAEZ,uCAAuC;AA2CvC,IAAY,cAGX;AAHD,WAAY,cAAc;IACtB,uCAAqB,CAAA;IACrB,8CAA4B,CAAA;AAChC,CAAC,EAHW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAGzB;AAWD;;;;;;;GAOG;AACH,SAAS,qBAAqB,CAAC,QAAsC;IACjE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;KAC3C;IAED,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,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D,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,UAAU,CAAC;IAC3B,CAAC;CACJ;AA7LD,0CA6LC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ArrayType, TypeNode } from "solc-typed-ast";
|
|
2
|
+
import { CalldataLocation } from "..";
|
|
3
|
+
import { Memory } from "../..";
|
|
4
|
+
export declare function cd_decodeArrayContents(abiType: ArrayType, origType: ArrayType | undefined, arrOffset: bigint, numLen: number, calldata: Memory): undefined | [any[], number];
|
|
5
|
+
export declare function cd_decodeValue(abiType: TypeNode, origType: TypeNode | undefined, loc: CalldataLocation, calldata: Memory, callDataBaseOff?: bigint): undefined | [any, number];
|
|
6
|
+
//# sourceMappingURL=calldata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calldata.d.ts","sourceRoot":"","sources":["../../../src/debug/decoding/calldata.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,SAAS,EAWT,QAAQ,EAGX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAoD,MAAM,IAAI,CAAC;AACxF,OAAO,EAKH,MAAM,EAET,MAAM,OAAO,CAAC;AAwHf,wBAAgB,sBAAsB,CAClC,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,SAAS,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACjB,SAAS,GAAG,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CA8B7B;AAsKD,wBAAgB,cAAc,CAC1B,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,QAAQ,GAAG,SAAS,EAC9B,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,MAAM,EAChB,eAAe,SAAY,GAC5B,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAwD3B"}
|