Skip to content
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

Open
wants to merge 53 commits into
base: master
Choose a base branch
from

Conversation

nevgeny
Copy link
Contributor

@nevgeny nevgeny commented Jan 22, 2019

No description provided.

nevgeny and others added 30 commits December 11, 2018 15:09
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").
Copy link
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
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
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
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
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
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
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

Copy link
Contributor

@vovapolu vovapolu Jan 28, 2019

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

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 - {
Copy link
Contributor

Choose a reason for hiding this comment

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

???

Copy link
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
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
Contributor

Rebase on the current version of the master

@@ -0,0 +1,15 @@
<!--
Copy link
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
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
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
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
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

@@ -33,13 +34,15 @@ object TranslateTests extends TestSuite {
}
}

'Contracts - {
/* 'Contracts - {
Copy link
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


'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()
Copy link
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