Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • May 03 18:42
    Yogasree-Segar commented #178
  • Mar 05 2020 04:39
    halfalicious added as member
  • Nov 12 2019 08:30
    hydai commented #187
  • Nov 11 2019 12:50
    chfast commented #187
  • Nov 04 2019 14:31
    taquangtrung closed #189
  • Oct 17 2019 09:31
    hydai opened #190
  • Oct 07 2019 15:20
    taquangtrung commented #189
  • Oct 02 2019 07:46
    taquangtrung opened #189
  • Aug 18 2019 06:16
    hydai commented #187
  • Aug 17 2019 06:46
    axic edited #181
  • Aug 17 2019 06:46
    axic edited #183
  • Aug 17 2019 06:45
    axic edited #188
  • Aug 17 2019 06:45
    axic labeled #188
  • Aug 17 2019 06:45
    axic opened #188
  • Aug 17 2019 06:37
    axic edited #181
  • Aug 17 2019 06:36
    axic commented #187
  • Aug 17 2019 05:09
    hydai commented #187
  • Aug 08 2019 09:16
    chfast commented #187
  • Aug 05 2019 11:43
    chfast commented #186
  • Jul 16 2019 22:27
    chfast commented #184
Paweł Bylica
@chfast
@computereasy there is not DELEGATECALL in the code.
computereasy
@computereasy

@chfast But if I use etherscan.io and "decoding" this contract, there do exist a "DELEGATE_CALL" in the contract. Am I missed anything here...?

https://etherscan.io/address/0x380d4a6701c5fe16ec203780cfb6914c76da0de8#code

Paweł Bylica
@chfast
Do you have disassembly of this?
Maybe DELEGATECALL is not reachable. You have to analyze the bytecode first.
computereasy
@computereasy
That's possible. I can see the delegatecall in the disassembled output, and also in the decompiled solidity code by JEB decompiler.
maybe it is because unreachable.
thanks for your help @chfast
d1m0
@d1m0
I am confused by the translation of revert. It seems to be translated as just a jump to the Exit label. However at the Exit label nothing is done with the return data offset/length that are on stack, instead the stack is just freed:
...
Exit:                                             ; preds = %Abort, %Stop, %.200, %.155, %.106, %.94, %.16, %.12
  %ret = phi i32 [ -1, %.12 ], [ 1, %.16 ], [ -1, %.94 ], [ -1, %.106 ], [ 1, %.155 ], [ -1, %.200 ], [ 0, %Stop ], [ -1, %Abort ]
  call void @free(i256* %stack.base)
  %msg.gas.ptr = getelementptr inbounds %RuntimeData, %RuntimeData* %dataPtr, i32 0, i32 0
  %gas = load i64, i64* %gas.ptr
  store i64 %gas, i64* %msg.gas.ptr
  ret i32 %ret
}
is this part just not completed yet or am I missing something?
Paweł Bylica
@chfast
@d1m0 the return data is kept in the memory, not on the stack. This is handled outside of the jitted code. I believe here we just record the offsets of the return data in memory, and then EVMJIT driver will do the proper handling.
d1m0
@d1m0
@chfast I don't see anywhere in the code where the offsets are saved from the stack before the @free call to %stack.base. This is the revert bb that jumps to exit:
.12:                                              ; preds = %.0
  %sp.12 = call i256* @stack.prepare(i256* %stack.base, i64* %stack.size, i64 0, i64 2, i64 2, i8* %jmpBuf)
  call void @gas.check(i64* %gas.ptr, i64 6, i8* %jmpBuf)
  %7 = getelementptr i256, i256* %sp.12, i64 0
  store i256 0, i256* %7, align 16
  %8 = getelementptr i256, i256* %sp.12, i64 1
  store i256 0, i256* %8, align 16
  br label %Exit
It corresponds to
```
push 0; push 0; revert
but it seems that the offset and length are only stored on the stack (relative to %sp.12). However, the stack gets freed first thing in the Exit bb
so how does the runtime know where the offset/length are?
Paweł Bylica
@chfast
This is done by inspecting results of the call: https://github.com/ethereum/evmjit/blob/master/libevmjit/JIT.cpp#L210-L212
d1m0
@d1m0
My confusion is that in the LLVM code I don't see where the return offset/length are stored in the result/runtime datastructures. This is the full file:https://gist.github.com/d1m0/efcda8ca8129661ef6f1bb177eadc3ee#file-test-ll-L69
If I understood the code correctly, the code starting on line 69 corresponds to a revert
this is the original evm file
the BB on line 69 in the ll file should correspond to the revert on line 15 in the evm file
the code on line 69 just stores offset/length (both 0s) on the stack, not anywhere else, and then jumps to exit, where the stack is freed
so I don't see how those two 0s make it outside of the JIT to be returned?
Paweł Bylica
@chfast
This is handled outside of the jitted code, see the link I send you. It is possible because EVMJIT sees the call result before it is passed to the jitted code.
d1m0
@d1m0
ok. will spend some time reading that code.
computereasy
@computereasy
@chfast Hello, I encountered a number of cases where "ethvm" takes quite a lot of time (over 24 hours) but couldn't terminate. Do you happen to have similar experiences?
Paweł Bylica
@chfast
@computereasy not really. Does it run EVMJIT as a backend?
computereasy
@computereasy

@chfast. Trapped by some other stuff for quite a while but just had more time to hack on this. Is there any chance that you could shed some lights on the parameters of the external call, in particular, which one represents the tranferred fund?

Call:                                             ; preds = %CheckBalance, %CheckTransfer
%25 = call i64 @evm.call(%Env* %0, i32 %1, i64 %2, i160* %3, i256* %4, i8* %5, i64 %6, i8* %7, i64 %8, i8** %9, i64* %10)

Thanks a lot.

Is it %4?
Paweł Bylica
@chfast
Based on type, yes
computereasy
@computereasy
perfect, thanks!
computereasy
@computereasy
would scall be subsumed as another instance of the @call wrapper? Thanks.
@chfast
Paweł Bylica
@chfast
@computereasy I don't remember any scall. Might be static call?
computereasy
@computereasy
@chfast A, you are right! Sorry, what I mean is staticcall (https://ethervm.io/).
computereasy
@computereasy
So would the @call wrapper includes "staticcall" as well?
@chfast
Paweł Bylica
@chfast
@computereasy I believe it should.
computereasy
@computereasy
@chfast That's awesome. Thank you very much.
Harrison Hicks
@hhicks13
@chfast Would it make sense to feed the EVM IR to libfuzzer or some testing tool that is supported by LLVM? Im wondering since EVM is not a register machine per se, would the fuzzer handle this in a meaningful way?
Paweł Bylica
@chfast
@hhicks13 it won't do anything useful with it maybe except finding integer overflows. It will not know what to look for.
Nick Geoca
@nickgeoca
hi, how does one access a mapping w/ assembly?
Paweł Bylica
@chfast
A mapping of what?
Nick Geoca
@nickgeoca
mapping (address => MyStruct) public tmp;
Paweł Bylica
@chfast
@nickgeoca This is not solidity help center
Darmon
@KunPengRen
Hi there, may I ask for which previous released version of aleth could use evmjit transfer EVM bytecode to LLVM IR?
Paweł Bylica
@chfast

@KunPengRen you mean translate to LLVM IR?

I'm not sure what the status of it is, but in theory EVMJIT can be used independently of Aleth.

You can also browse discussion history here, because some people were using it for this purpose.

Yogasree-Segar
@Yogasree-Segar
Hello all, I am new to Ethereum. I wanted to convert my own Solidity code to llvm ir. I dont find a documentation about how to proceed. Can someone guide me through this. Thank you!