ethereumjs / ethereumjs-lib

[DEPRECATED] A JavaScript library of core Ethereum functions
442 stars 102 forks source link

Can't determine number of topics of logN in VM #114

Closed asinyagin closed 9 years ago

asinyagin commented 9 years ago

Hey,

I'm trying to trace log messages in vm and as I see there's no way to get number of topics of logN(). In vm.onStep() opcode's LOG for all of the numbers and info doesn't contain opcode number.

Can you please add some method to get number of topics? Probably it could be opcode number in info argument of vm.onStep() or different labels (LOG0 .. LOG4) for each logN function.

wanderer commented 9 years ago

the logger now does something like this

 {
  "step": 14,
  "pc": "73",
  "depth": 1,
  "opcode": "LOG1",
  "gas": "3279",
  "memory": "aabbffffffffffffffffffffffffffffffffffffffffffffffffffffffffccdd",
  "storage": [],
  "address": "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
  "stack": ["ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "0000000000000000000000000000000000000000000000000000000000000020", "0000000000000000000000000000000000000000000000000000000000000000"]
}

let me know if that works for ya @asinyagin !

asinyagin commented 9 years ago

@wanderer maybe I'm doing something wrong but I'm getting this log object with ethereumjs-lib 0.5.0 and nodejs v0.10.39:

{"step":28,"pc":"69","depth":0,"opcode":"LOG","gas":"74628","memory":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000606865792100000000000000000000000000000000000000000000000000000000","storage":[],"address":"77045e71a7a2c50903d88e564cd72fab11e82051","stack":["0000000000000000000000000000000000000000000000000000000000000004","0000000000000000000000000000000000000000000000000000000000000003","0000000000000000000000000000000000000000000000000000000000000020","0000000000000000000000000000000000000000000000000000000000000060"]}

for log2('hey!', 3, 4)

asinyagin commented 9 years ago

I'm using ethereumjs-utils with that fix https://github.com/ethereum/ethereumjs-util/pull/3

wanderer commented 9 years ago

ok i merged that PR. But if you can you should upgrade to node version 11 or 12. I think there are other things that could be broken on 10. Also Have you pulled the latest code? I'm defiantly seeing the LOG numbers in my stack trace.

asinyagin commented 9 years ago

Hey, @wanderer!

I've just checked ethereumjs-lib from the repo with nodejs v0.12.0 and it gives me LOG opcode. Contract:

contract Contract {
    function Contract() {
        log0("asdf");
    }
}

Tracing (the full example is here https://github.com/asinyagin/ethereumjs-test/blob/opcode-check/app.js):

function watchLog(cb) {
  vm.logReadStream().on('data', function(data) {
    console.log(data);
  });
  cb(null, vm);
}

Output

{"step":24,"pc":"62","depth":0,"opcode":"LOG","gas":"999975120","memory":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000606173646600000000000000000000000000000000000000000000000000000000","storage":[],"address":"77045e71a7a2c50903d88e564cd72fab11e82051","stack":["0000000000000000000000000000000000000000000000000000000000000004","0000000000000000000000000000000000000000000000000000000000000060"]}
wanderer commented 9 years ago

oh yeah! I forget stuff won't work on anything less than node version 0.11 . I should make a note of that in the README

On Mon, Aug 10, 2015 at 9:02 AM, Alexander Sinyagin < notifications@github.com> wrote:

Hey, @wanderer https://github.com/wanderer!

I've just checked ethereumjs-lib from the repo with nodejs v0.12.0 and it gives me LOG opcode. Contract:

contract Contract { function Contract() { log0("asdf"); } }

Tracing (the full example is here https://github.com/asinyagin/ethereumjs-test/blob/opcode-check/app.js):

function watchLog(cb) { vm.logReadStream().on('data', function(data) { console.log(data); }); cb(null, vm); }

Output

{"step":24,"pc":"62","depth":0,"opcode":"LOG","gas":"999975120","memory":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000606173646600000000000000000000000000000000000000000000000000000000","storage":[],"address":"77045e71a7a2c50903d88e564cd72fab11e82051","stack":["0000000000000000000000000000000000000000000000000000000000000004","0000000000000000000000000000000000000000000000000000000000000060"]}

— Reply to this email directly or view it on GitHub https://github.com/ethereum/ethereumjs-lib/issues/114#issuecomment-129373221 .

asinyagin commented 9 years ago

There's a problem with LOG opcode. I want to get topics from the stack but I need to know number of them. I could get it from opcode label (LOG0, LOG1, etc), but info.opcode is always LOG without number (see https://github.com/ethereum/ethereumjs-lib/blob/master/lib/vm/opcodes.js#L138). Also, I could get number of topics if I have a hexadecimal opcode (0xa0, 0xa1, etc), but info doesn't have it.

romanman commented 9 years ago

@wanderer , any idea looks like more than version of the nodejs ?

kumavis commented 9 years ago

reopening this...

asinyagin commented 9 years ago

The problem is solved in https://github.com/ethereum/ethereumjs-vm

@wanderer @kumavis I can close the issue, right?

wanderer commented 9 years ago

Yep it should be solved

On Thu, Aug 13, 2015 at 2:09 PM, Alexander Sinyagin < notifications@github.com> wrote:

The problem is solved in https://github.com/ethereum/ethereumjs-vm

@wanderer https://github.com/wanderer @kumavis https://github.com/kumavis I can close the issue, right?

— Reply to this email directly or view it on GitHub https://github.com/ethereum/ethereumjs-lib/issues/114#issuecomment-130688006 .