Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Secret Decoder Ring #1265

Merged
merged 136 commits into from
Dec 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
e80865e
initial readme for contract-decoder
mikeseese Aug 6, 2018
97852d3
rename truffle-contract-decoder folder
mikeseese Aug 6, 2018
4bd8a86
decoder package init
mikeseese Aug 7, 2018
52058bd
implement a lot of super draft decoder stuff
mikeseese Aug 24, 2018
e79f567
more updates to remove all typing errors
mikeseese Aug 28, 2018
0d4b235
initial interface implementation
mikeseese Aug 29, 2018
a2a76ef
temporarily skip truffle-decoder branch in travis builds
mikeseese Aug 29, 2018
fb73315
add support to generate types file
mikeseese Aug 29, 2018
82524ad
add initial file to pull apart ASTs
mikeseese Aug 29, 2018
2153dc0
remove truffle-contract typing that will come from schema updates
mikeseese Aug 29, 2018
ecfb52d
remove unneeded file as this logic will live in contract-decoder.ts
mikeseese Aug 29, 2018
392c56b
initial implemention to start pulling information out of the contracts
mikeseese Aug 29, 2018
5a24f45
move spec typings to spec folder and ignore TS typings
mikeseese Aug 30, 2018
405aa0e
more updates to decoder ring
mikeseese Sep 4, 2018
810b099
remove preceding hex '0x' if its there
mikeseese Sep 5, 2018
8bda991
add flag to hash only the offset value
mikeseese Sep 5, 2018
deb04b3
get initial responses from decoder library
mikeseese Sep 5, 2018
a8dfa58
format variables to output format
mikeseese Sep 5, 2018
5d698ec
implement struct support in decoder
mikeseese Sep 5, 2018
362cd9f
ignore development files in decoder
mikeseese Sep 5, 2018
22e370d
initial mapping support
mikeseese Sep 10, 2018
ac18fb5
fix array support
mikeseese Sep 10, 2018
0eb6746
Merge branch 'next' into truffle-decoder
gnidan Sep 11, 2018
2b5dc0c
implement initial event getter for block
mikeseese Sep 11, 2018
e7c934d
ignore vscode specific files
mikeseese Sep 11, 2018
9b54091
Merge branch 'truffle-decoder' of github.com:trufflesuite/truffle int…
mikeseese Sep 11, 2018
9dd3819
remove decoding logic from the debugger, use decoder
mikeseese Sep 11, 2018
834b919
ignore the bin folder (where contracts are built)
mikeseese Sep 12, 2018
8fe7fe1
add decoder build step to bootstrap, needs to be before debugger
mikeseese Sep 12, 2018
d3a318e
use module for decoder in the debugger
mikeseese Sep 12, 2018
8a6ae42
upgrade web3 types package
mikeseese Sep 12, 2018
0357b4f
use package.json module instead of direct file require for decoder
mikeseese Sep 12, 2018
87bd832
break out event decoding into a separate function to be reused
mikeseese Sep 12, 2018
bc36786
move decoder utils to new truffle-decode-utils package
mikeseese Sep 13, 2018
1ce316f
fix typescript module resolution for web3 types
mikeseese Sep 13, 2018
a679d36
fix typescript name resolution for decode-utils
mikeseese Sep 13, 2018
dd23400
move ast definition types to decode-utils
mikeseese Sep 13, 2018
3927be4
use decode-utils for astdefinition in decoder
mikeseese Sep 13, 2018
3ab5a69
add decode-utils build script. move bootstrap script to a shell file
mikeseese Sep 13, 2018
e9b43fe
Merge branch 'next' into truffle-decoder
gnidan Sep 13, 2018
3dcfd0b
use `set -ex` to stop the bootstrap script on failure
mikeseese Sep 14, 2018
7c3a687
use latest web3 types!
mikeseese Sep 14, 2018
a65944d
Merge branch 'truffle-decoder' of github.com:trufflesuite/truffle int…
mikeseese Sep 14, 2018
c6cb4a9
fix contract schema building on bootstrap
mikeseese Sep 14, 2018
10ffd59
add back debugger tests for data decoding
mikeseese Sep 14, 2018
7ca6757
move debugger data decoding tests to a folder up
mikeseese Sep 14, 2018
e1c7119
change decode tests in debugger to support decoder ring
mikeseese Sep 14, 2018
a8286db
publish modules to npm temporarily to be able to test
mikeseese Sep 14, 2018
fffb874
don't error because of lack of tests in decoder and decode-utils
mikeseese Sep 14, 2018
cb1bf9f
revert all this silly npm package stuff I did. lerna takes care of this
mikeseese Sep 14, 2018
4f8f65b
fix package references to decode-utils and decoder for debugger
mikeseese Sep 14, 2018
689d6c4
fix import error as decoder doesn't export a default
mikeseese Sep 14, 2018
bb95acd
check if pointers are undefined first
mikeseese Sep 27, 2018
7d55561
use async function for the evm state
mikeseese Sep 27, 2018
88fac8e
change decoder version
mikeseese Sep 27, 2018
635fe47
change version number for decode utils
mikeseese Sep 27, 2018
5f17698
update version for decode utils in decoder
mikeseese Sep 27, 2018
a0510ff
change contract schema dep version to official version
mikeseese Sep 27, 2018
cc0d1b9
change decodeEvent function to public
mikeseese Sep 27, 2018
8e0afcd
add event decoding using an abi decoder package
mikeseese Sep 27, 2018
baf35be
add transaction decoding
mikeseese Sep 28, 2018
076062e
fix the name of the decodeMethod function
mikeseese Sep 28, 2018
9e3888c
temporarily use local version of truffle-contract-schema
mikeseese Oct 5, 2018
290c02f
use toArrayLike(Buffer) instead of toBuffer()
mikeseese Oct 5, 2018
9fabed0
upgrade decode-utils
mikeseese Oct 5, 2018
42291d3
publish new version of decoder
mikeseese Oct 5, 2018
99b5ed6
fix slot allocation and address generation
mikeseese Oct 10, 2018
9527543
temporarily add some print statements for slot decoding
mikeseese Oct 10, 2018
d2fb284
push updated version of decoder
mikeseese Oct 11, 2018
b4edf03
add enum support to decoder
mikeseese Oct 11, 2018
87f5bff
fix issues with uint and bytes
mikeseese Oct 11, 2018
ea8ab2b
fix arrays and child structs in decoder
mikeseese Oct 12, 2018
b9c300b
initial fixing of decoding arrays of sub slot base definitions
mikeseese Oct 12, 2018
7ccf442
fix subslot array bases
mikeseese Oct 12, 2018
65f0ec4
fix fixed arrays for byte and enum
mikeseese Oct 12, 2018
a6cd284
make sure to wait for the decode function to finish
mikeseese Oct 15, 2018
9b6723f
upgrade typescript versions
mikeseese Oct 15, 2018
e54e037
use correct decoder/decode-utils versions
mikeseese Oct 15, 2018
e63c4d9
typescript doens't really like just passing Buffer
mikeseese Oct 15, 2018
2e27f2d
update yarn.lock file
mikeseese Oct 15, 2018
930bce5
publish new version of decode-utils
mikeseese Oct 15, 2018
9608750
publish decode-utils without experimental changes
mikeseese Oct 15, 2018
84e8540
use latest published version of decode-utils
mikeseese Oct 15, 2018
1b97612
update versions for decoder and decode-utils in debugger
mikeseese Oct 15, 2018
2c7e5b4
update bn.js typings to fix typescript compiler error
mikeseese Oct 16, 2018
f094a1b
use correct usage of buffer in toArrayLike
mikeseese Oct 16, 2018
12159fa
pushing to github, for remote dev, likely not working
mikeseese Oct 26, 2018
3a6fed8
Merge branch 'next' into truffle-decoder
mikeseese Nov 8, 2018
93dfff1
prettier/lint and port helper functions
mikeseese Nov 13, 2018
c436e1b
Merge branch 'truffle-box-cleanup' into truffle-decoder
mikeseese Nov 13, 2018
c6b19f7
implement initial fixes for debugger tests with decoder
mikeseese Nov 14, 2018
b3494cb
add support for mocha-webpack debugging
mikeseese Nov 14, 2018
6df98ee
Get mappings working with the decoder
mikeseese Nov 15, 2018
81fc775
Fix memory decoding tests
mikeseese Nov 15, 2018
18a1689
use debug module for print outs
mikeseese Nov 15, 2018
06b0c3b
use correct length for strings in memory
mikeseese Nov 15, 2018
4483fab
Fix remaining tests that had issues with decoder
mikeseese Nov 15, 2018
2833471
use correct package of truffle-contract-schema
mikeseese Nov 15, 2018
f604970
publish new versions for decode-utils and decoder
mikeseese Nov 15, 2018
55d3c99
address race condition when determining mapping keys left to decode
mikeseese Nov 15, 2018
45910fd
add tests for truffle decoder
mikeseese Nov 15, 2018
f82b61d
Merge remote-tracking branch 'origin/newvarids' into truffle-decoder
mikeseese Nov 16, 2018
2026922
Finsih integration of var-ids
mikeseese Nov 16, 2018
734ec62
Skip failing decoder tests
mikeseese Nov 20, 2018
ee1512a
update har-validator to 5.1.3 to help harry
mikeseese Nov 20, 2018
0f8bf6e
Update yarn.lock.
haltman-at Nov 21, 2018
79c53f9
Merge branch 'next' of github.com:trufflesuite/truffle into truffle-d…
gnidan Nov 26, 2018
d742b28
get decoder tests to pass by commenting out problem childs
mikeseese Nov 26, 2018
79164a2
Merge branch 'next' of github.com:trufflesuite/truffle into truffle-d…
gnidan Nov 28, 2018
eac8a92
Update yarn.lock
gnidan Nov 28, 2018
5fb3812
Make sure to pass files when starting debugger.
haltman-at Nov 28, 2018
2be55ec
Merge branch 'solc-0.5.0-tests' of github.com:trufflesuite/truffle in…
gnidan Nov 28, 2018
f18735c
Merge branch 'next' of github.com:trufflesuite/truffle into truffle-d…
gnidan Nov 28, 2018
4ef415a
Fix async interpreter not to use a callback
gnidan Nov 29, 2018
8a7977f
Add watch script to decoder
gnidan Nov 29, 2018
c5b7a3a
Move { literal } short-circuit to after ref. check
gnidan Nov 30, 2018
6684e2b
Add a missing debugModule
gnidan Nov 30, 2018
2f5b1b4
Add baseDefinition hack for erroneous typeIdentifiers
gnidan Nov 30, 2018
51784dc
Fix memory struct decoding so it doesn't explode
gnidan Nov 30, 2018
ec9fbad
Make DecodeUtils.Definition.isDynamicArray more forgiving
gnidan Nov 30, 2018
7b3c808
Add debugModule setup
gnidan Nov 30, 2018
5b9812b
Use more forgiving dynamicness checking
gnidan Nov 30, 2018
3adedef
Make storage struct decoding less explode-y
gnidan Nov 30, 2018
258f804
Add custom BN formatting in debug CLI
gnidan Nov 30, 2018
198fb6b
Fix repl.stop this binding
gnidan Nov 30, 2018
ec4e499
Allow Truffle REPLs to pass `ignoreUndefined`
gnidan Nov 30, 2018
c1ed864
Merge branch 'next' of github.com:trufflesuite/truffle into truffle-d…
gnidan Dec 4, 2018
c078bdb
Add `yarn start` for decode-utils
gnidan Dec 5, 2018
2c00684
Define conversion helper to clean decoder mappings
gnidan Dec 5, 2018
4e56c48
Omit decoder mapping metadata in d.c.i.decoded
gnidan Dec 5, 2018
d4e1020
update decoder tests to test fixed array allocation
mikeseese Dec 6, 2018
c4ee7ee
Merge branch 'truffle-decoder' of github.com:trufflesuite/truffle int…
gnidan Dec 6, 2018
6478239
Merge branch 'next' of github.com:trufflesuite/truffle into truffle-d…
gnidan Dec 6, 2018
a1e41c0
Add forgotten cleanMappings() recurse step
gnidan Dec 6, 2018
0e14c14
Remove toMap external func
gnidan Dec 7, 2018
e2c34f3
Merge pull request #1494 from trufflesuite/de-decoder
gnidan Dec 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ packages/truffle-debugger/.tmp
packages/truffle-contract/dist
node_modules
yarn-error.log
.vscode
bin
.DS_Store
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ notifications:
slack:
secure: cm12Kcc8YmtZ0TZ7T6t+kZqKNrpKG7D4MyaJLWf0llHeGTUqldIaSkLTasqCnBEUhg2/uqQ1dbG8nuqhnov9rHhRFUQmZPVUqiCE90wLDo2qIC9l98sXQRT/yrRgr1W7d3Jfauq53B2WBUpS5LBzcfYgzj13PBcmKtX2+wBZTLddmfcqZUwqzXRL9TPWUQrecAVSQZBVutZ6tQaxTAdBUbyobf6kXYHYRVOJQp7xtHUAIFULitpvCG6cH2F6L+G4gSqDykx74V8bScCvBe0TW8ue5zxbSoM5UmgSMIXzYMBCWa+/WzNjwvCAYScKkqoWt0mk5nzUOQZgndyyO/nA7Ylo7Za1b/LzChgYHB/TybxmF2Jul/MkHy614l/W4Z3dRRXMuPNmY3JIkuYej/9m/uqoLHqEyka8h6YJfZ7IPQ11Kg0r6XZiy+G2sZTg6BW5TIy1GvwDWhZ8hyLk/ka+4JMUK7/gOtAzUUiMIUFwXpgyLnTHzbCF547mx5yJbkeGzJ1Faiq50LcnI8SswP+VQrwgJr2pMfcCXyPyJmZZmRXxOP3qvaYBbfEtSHuIp00DSNITa9dDxZUKiBuzbCJuZ2ChYY12rV4/6EZsu1FhXKPfN735uVqz+HJD/YsvpfAoZ4jTGikMNrIRKfAYLCewkWpsDN51mgO4TBPcbrQ8FbI=
on_success: change
on_failure: always
on_failure: always
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
"private": true,
"scripts": {
"build:debugger": "cd packages/truffle-debugger && npm run build",
"build:decode-utils": "cd packages/truffle-decode-utils && npm run build",
"build:decoder": "cd packages/truffle-decoder && npm run build",
"build:truffle-contract-schema": "cd packages/truffle-contract-schema && npm run build",
"lerna:bootstrap": "lerna bootstrap",
"bootstrap": "npm run lerna:bootstrap && npm run build:debugger",
"bootstrap": "./scripts/bootstrap.sh",
"test": "lerna run test --stream --concurrency=1 -- --colors",
"ci": "./scripts/ci.sh",
"geth": "./scripts/geth.sh",
Expand Down
3 changes: 3 additions & 0 deletions packages/truffle-contract-schema/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
yarn.lock
package-lock.json
3 changes: 2 additions & 1 deletion packages/truffle-contract-schema/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "JSON schema for contract artifacts",
"main": "index.js",
"scripts": {
"prepare": "cd spec && json2ts -i contract-object.spec.json -o ./index.d.ts",
"prepare": "npm run build",
"build": "cd spec && json2ts -i contract-object.spec.json -o ./index.d.ts",
"test": "mocha"
},
"repository": {
Expand Down
62 changes: 35 additions & 27 deletions packages/truffle-core/lib/commands/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ var command = {
var debug = debugModule("lib:commands:debug");
var safeEval = require("safe-eval");
var util = require("util");
const BN = require("bn.js");

// add custom inspect options for BNs
BN.prototype[util.inspect.custom] = function(depth, options) {
return options.stylize(this.toString(), "number");
};

var compile = require("truffle-compile");
var Config = require("truffle-config");
Expand All @@ -33,7 +39,6 @@ var command = {
var selectors = require("truffle-debugger").selectors;

// Debugger Session properties
var data = selectors.data;
var trace = selectors.trace;
var solidity = selectors.solidity;
var controller = selectors.controller;
Expand Down Expand Up @@ -100,7 +105,7 @@ var command = {
.catch(done);

sessionPromise
.then(function(session) {
.then(async function(session) {
if (err) return done(err);

function splitLines(str) {
Expand Down Expand Up @@ -219,28 +224,31 @@ var command = {
});
}

function printWatchExpressionsResults() {
enabledExpressions.forEach(function(expression) {
config.logger.log(expression);
// Add some padding. Note: This won't work with all loggers,
// meaning it's not portable. But doing this now so we can get something
// pretty until we can build more architecture around this.
// Note: Selector results already have padding, so this isn't needed.
if (expression[0] == ":") {
process.stdout.write(" ");
}
printWatchExpressionResult(expression);
});
async function printWatchExpressionsResults() {
debug("enabledExpressions %o", enabledExpressions);
await Promise.all(
[...enabledExpressions].map(async expression => {
config.logger.log(expression);
// Add some padding. Note: This won't work with all loggers,
// meaning it's not portable. But doing this now so we can get something
// pretty until we can build more architecture around this.
// Note: Selector results already have padding, so this isn't needed.
if (expression[0] == ":") {
process.stdout.write(" ");
}
await printWatchExpressionResult(expression);
})
);
}

function printWatchExpressionResult(expression) {
async function printWatchExpressionResult(expression) {
var type = expression[0];
var exprArgs = expression.substring(1);

if (type == "!") {
printSelector(exprArgs);
} else {
evalAndPrintExpression(exprArgs, 2, true);
await evalAndPrintExpression(exprArgs, 2, true);
}
}

Expand All @@ -266,8 +274,9 @@ var command = {
.join(OS.EOL);
}

function printVariables() {
var variables = session.view(data.current.identifiers.native);
async function printVariables() {
var variables = await session.variables();
debug("variables %o", variables);

// Get the length of the longest name.
var longestNameLength = Math.max.apply(
Expand Down Expand Up @@ -512,7 +521,7 @@ var command = {
return;
}

function interpreter(cmd, replContext, filename, callback) {
async function interpreter(cmd) {
cmd = cmd.trim();
var cmdArgs, splitArgs;
debug("cmd %s", cmd);
Expand Down Expand Up @@ -540,7 +549,7 @@ var command = {

//quit if that's what we were given
if (cmd === "q") {
return repl.stop(callback);
return await util.promisify(repl.stop.bind(repl))();
}

let alreadyFinished = session.view(trace.finished);
Expand Down Expand Up @@ -607,7 +616,7 @@ var command = {
switch (cmd) {
case "+":
enabledExpressions.add(cmdArgs);
printWatchExpressionResult(cmdArgs);
await printWatchExpressionResult(cmdArgs);
break;
case "-":
enabledExpressions.delete(cmdArgs);
Expand All @@ -619,7 +628,7 @@ var command = {
printWatchExpressions();
break;
case "v":
printVariables();
await printVariables();
break;
case ":":
evalAndPrintExpression(cmdArgs);
Expand All @@ -635,7 +644,7 @@ var command = {
printFile();
printInstruction();
printState();
printWatchExpressionsResults();
await printWatchExpressionsResults();
break;
case "o":
case "i":
Expand All @@ -650,7 +659,7 @@ var command = {
printFile();
printState();
}
printWatchExpressionsResults();
await printWatchExpressionsResults();
break;
case "r":
printAddressesAffected();
Expand All @@ -677,8 +686,6 @@ var command = {
) {
lastCommand = cmd;
}

callback();
}

printAddressesAffected();
Expand All @@ -698,7 +705,8 @@ var command = {
":" +
txHash.substring(0, 10) +
"...)> ",
interpreter: interpreter,
interpreter: util.callbackify(interpreter),
ignoreUndefined: true,
done: done
});
})
Expand Down
29 changes: 19 additions & 10 deletions packages/truffle-core/lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ function ReplManager(options) {
this.repl = options.repl;

this.contexts = [];
};
}

ReplManager.prototype.start = function(options) {
var self = this;

this.contexts.push({
prompt: options.prompt,
interpreter: options.interpreter,
ignoreUndefined: options.ignoreUndefined || false,
done: options.done
});

Expand All @@ -41,19 +42,21 @@ ReplManager.prototype.start = function(options) {
if (!this.repl) {
this.repl = repl.start({
prompt: currentContext.prompt,
eval: this.interpret.bind(this),
eval: this.interpret.bind(this)
});

this.repl.on("exit", function() {
// If we exit for some reason, call done functions for good measure
// then ensure the process is completely killed. Once the repl exits,
// the process is in a bad state and can't be recovered (e.g., stdin is closed).
var doneFunctions = self.contexts.map(function(context) {
return context.done ?
function() { context.done(); } :
function() {};
return context.done
? function() {
context.done();
}
: function() {};
});
async.series(doneFunctions, function(err) {
async.series(doneFunctions, function() {
process.exit();
});
});
Expand All @@ -64,19 +67,25 @@ ReplManager.prototype.start = function(options) {
self.emit("exit");
});

this.repl.setPrompt(options.prompt);
this.setContextVars(options.context || {});
this.activate(options);
};

ReplManager.prototype.setContextVars = function(obj) {
var self = this;
if (this.repl) {
Object.keys(obj).forEach(function(key) {
Object.keys(obj || {}).forEach(function(key) {
self.repl.context[key] = obj[key];
});
}
};

ReplManager.prototype.activate = function(session) {
const { prompt, context, ignoreUndefined } = session;
this.repl.setPrompt(prompt);
this.repl.ignoreUndefined = ignoreUndefined;
this.setContextVars(context);
};

ReplManager.prototype.stop = function(callback) {
var oldContext = this.contexts.pop();

Expand All @@ -87,7 +96,7 @@ ReplManager.prototype.stop = function(callback) {
var currentContext = this.contexts[this.contexts.length - 1];

if (currentContext) {
this.repl.setPrompt(currentContext.prompt);
this.activate(currentContext);
} else {
// If there's no new context, stop the process altogether.
// Though this might seem like an out of place process.exit(),
Expand Down
1 change: 1 addition & 0 deletions packages/truffle-debugger/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ package-lock.json
docs
.DS_Store
dist
tmp-*
8 changes: 8 additions & 0 deletions packages/truffle-debugger/lib/data/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export function mapKey(id, key) {
};
}

export const MAP_KEY_DECODING = "MAP_KEY_DECODING";
export function mapKeyDecoding(started) {
return {
type: MAP_KEY_DECODING,
started
};
}

export const RESET = "DATA_RESET";
export function reset() {
return { type: RESET };
Expand Down
Loading