Skip to content

Close #444: Add evm debugger - #452

Open
nevgeny wants to merge 53 commits into
expload:masterfrom
nevgeny:i444-evm-debugger
Open

Close #444: Add evm debugger#452
nevgeny wants to merge 53 commits into
expload:masterfrom
nevgeny:i444-evm-debugger

Conversation

@nevgeny

@nevgeny nevgeny commented Jan 22, 2019

Copy link
Copy Markdown
Contributor

No description provided.

nevgeny and others added 30 commits December 11, 2018 15:09
Comment thread build.sbt Outdated
lazy val evm = (project in file("evm")).
dependsOn(`vm-asm`).
dependsOn(vm % "test->test").
dependsOn(vm % "compile->compile;test->test").

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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")

Copy link
Copy Markdown
Contributor

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] {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 {

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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 =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.map(...).mkString?

Copy link
Copy Markdown
Contributor Author

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

@vovapolu vovapolu Jan 28, 2019

Copy link
Copy Markdown
Contributor

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")),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//stack = Seq(Data.Primitive.Int64(10), Data.Primitive.Utf8("set")),


val Right(output) = EvmSandboxDebug.debugAddressedCode(preconditions, ops, abi)

println(output)

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

}

'Contracts - {
/* 'Contracts - {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor

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

@vovapolu

Copy link
Copy Markdown
Contributor

Rebase on the current version of the master

Comment thread doc/standard-library/read-evm-word.md Outdated
@@ -0,0 +1,15 @@
<!--

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//'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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it inside debugLogShow

}

'Contracts - {
/* 'Contracts - {

Copy link
Copy Markdown
Contributor

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

val Right(abi) = AbiParser.parseAbi(readSolidityABI("SimpleStorage/SimpleStorage.abi"))
val Right(asm) = Translator.translateActualContract(ops, abi)

println()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants