-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Close #444: Add evm debugger #452
base: master
Are you sure you want to change the base?
Conversation
Close expload#418: cli evm
Vovapolu evm
build.sbt
Outdated
@@ -152,7 +152,7 @@ lazy val `vm-asm` = (project in file("vm-asm")) | |||
|
|||
lazy val evm = (project in file("evm")). | |||
dependsOn(`vm-asm`). | |||
dependsOn(vm % "test->test"). | |||
dependsOn(vm % "compile->compile;test->test"). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dependsOn(vm % "compile->compile;test->test"). | |
dependsOn(vm % "compile->compile;test->test"). |
memory: Memory, | ||
wattCounter: WattCounter, | ||
pcallAllowed: Boolean): Unit = | ||
throw new Exception("It's debug vm. You can't use pcall, lcall opcodes") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's bad, it's necessary feature
import pravda.vm.impl.MemoryImpl | ||
import pravda.vm.sandbox.VmSandbox.StorageSandbox | ||
|
||
trait Debugger[State] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trait Debugger[State] { | |
trait Debugger[S] { |
import pravda.vm.sandbox.VmSandbox.StorageSandbox | ||
|
||
//'extends Vm' is required for using 'this' in SystemOperation constructor | ||
trait DebugVm extends Vm { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use aggregation, not inheritance here
new SystemOperations(program, mem, maybeStorage, counter, env, maybePA, StandardLibrary.Index, this) | ||
val dataOperations = new DataOperations(mem, counter) | ||
|
||
val Some(storage) = maybeStorage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
} | ||
|
||
def showDebugLogContainer(implicit showDebugLog: Show[DebugLog]): cats.Show[List[DebugLog]] = | ||
l => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.map(...).mkString
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't flexible. Better to use type class and configure output in it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean you can rewrite your code to more readable version
`watts-limit` = 100000L, | ||
stack = Seq(Data.Primitive.Utf8("get")), | ||
storage = Map(evmWord(Array(0)) -> evmWord(Array(1))) | ||
//stack = Seq(Data.Primitive.Int64(10), Data.Primitive.Utf8("set")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//stack = Seq(Data.Primitive.Int64(10), Data.Primitive.Utf8("set")), |
|
||
val Right(output) = EvmSandboxDebug.debugAddressedCode(preconditions, ops, abi) | ||
|
||
println(output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
import pravda.evm.parse.Parser | ||
import pravda.evm.{readSolidityABI, readSolidityBinFile} | ||
import pravda.evm.translate.Translator | ||
//import pravda.evm.abi.parse.AbiParser |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
@@ -33,13 +34,15 @@ object TranslateTests extends TestSuite { | |||
} | |||
} | |||
|
|||
'Contracts - { | |||
/* 'Contracts - { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We often change our translator. Change these test very exhausting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why we should rewrite them to plaintest
, leave it for now, but it's an important thing we should implement before expanding our tests
Rebase on the current version of the master |
@@ -0,0 +1,15 @@ | |||
<!-- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these files, they are outdated
import pravda.vm.impl.MemoryImpl | ||
import pravda.vm.sandbox.VmSandbox.StorageSandbox | ||
|
||
//'extends Vm' is required for using 'this' in SystemOperation constructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//'extends Vm' is required for using 'this' in SystemOperation constructor |
import pravda.vm | ||
import pravda.vm._ | ||
import pravda.vm.impl.{MemoryImpl, WattCounterImpl} | ||
import pravda.vm.sandbox.VmSandbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import pravda.vm.sandbox.VmSandbox |
|
||
val effects = mutable.Buffer[vm.Effect]() | ||
val environmentS: Environment = environment(input, effects, pExecutor) | ||
val storage = new VmSandbox.StorageSandbox(Address.Void, effects, input.storage.toSeq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val storage = new VmSandbox.StorageSandbox(Address.Void, effects, input.storage.toSeq) | |
val storage = new StorageSandbox(Address.Void, effects, input.storage.toSeq) |
} | ||
} | ||
|
||
private def t(count: Int)(s: String) = "\t" * count + s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it inside debugLogShow
@@ -33,13 +34,15 @@ object TranslateTests extends TestSuite { | |||
} | |||
} | |||
|
|||
'Contracts - { | |||
/* 'Contracts - { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's why we should rewrite them to plaintest
, leave it for now, but it's an important thing we should implement before expanding our tests
|
||
'SimpleStorage - { | ||
val Right(ops) = Parser.parseWithIndices(readSolidityBinFile("SimpleStorage/SimpleStorage.bin")) | ||
val Right(abi) = AbiParser.parseAbi(readSolidityABI("SimpleStorage/SimpleStorage.abi")) | ||
val Right(asm) = Translator.translateActualContract(ops, abi) | ||
|
||
println() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
???
No description provided.